mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-26 10:09:20 +02:00
Implemented ingenic_query_nand
This commit is contained in:
parent
86ba12af12
commit
8488331cdf
32
ingenic.c
32
ingenic.c
@ -473,3 +473,35 @@ int ingenic_go(void *hndl, uint32_t address) {
|
|||||||
return ingenic_wordop(handle->usb, VR_PROGRAM_START2, address);
|
return ingenic_wordop(handle->usb, VR_PROGRAM_START2, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int ingenic_nandop(void *usb, uint8_t cs, uint8_t request, uint8_t param) {
|
||||||
|
return usbdev_vendor(usb, USBDEV_TODEV, VR_NAND_OPS, (param << 12) | (cs << 4) | (request & 0x0F), 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int ingenic_query_nand(void *hndl, int cs, nand_info_t *info) {
|
||||||
|
HANDLE;
|
||||||
|
|
||||||
|
if(ingenic_nandop(handle->usb, cs, NAND_QUERY, 0) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
uint32_t dummy[8];
|
||||||
|
|
||||||
|
int ret = usbdev_recvbulk(handle->usb, dummy, sizeof(dummy));
|
||||||
|
|
||||||
|
if(ret == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if(ret < sizeof(nand_info_t)) {
|
||||||
|
errno = EIO;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(info, dummy, sizeof(nand_info_t));
|
||||||
|
|
||||||
|
if(usbdev_recvbulk(handle->usb, dummy, sizeof(dummy)) == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
66
ingenic.h
66
ingenic.h
@ -17,29 +17,6 @@
|
|||||||
#define VR_CONFIGRATION 0x09
|
#define VR_CONFIGRATION 0x09
|
||||||
#define VR_GET_NUM 0x0a
|
#define VR_GET_NUM 0x0a
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void (*cmdset_change)(void *arg);
|
|
||||||
} ingenic_callbacks_t;
|
|
||||||
|
|
||||||
void *ingenic_open(void *usb_hndl);
|
|
||||||
void ingenic_close(void *hndl);
|
|
||||||
void ingenic_set_callbacks(void *hndl, const ingenic_callbacks_t *callbacks, void *arg);
|
|
||||||
|
|
||||||
int ingenic_redetect(void *hndl);
|
|
||||||
int ingenic_cmdset(void *hndl);
|
|
||||||
int ingenic_type(void *hndl);
|
|
||||||
uint32_t ingenic_sdram_size(void *hndl);
|
|
||||||
|
|
||||||
int ingenic_rebuild(void *hndl);
|
|
||||||
int ingenic_loadstage(void *hndl, int id, const char *filename);
|
|
||||||
int ingenic_stage1_debugop(void *device, const char *filename, uint32_t op, uint32_t pin, uint32_t base, uint32_t size);
|
|
||||||
int ingenic_memtest(void *hndl, const char *filename, uint32_t base, uint32_t size, uint32_t *fail);
|
|
||||||
|
|
||||||
int ingenic_configure_stage2(void *hndl);
|
|
||||||
int ingenic_load_sdram(void *hndl, void *data, uint32_t base, uint32_t size);
|
|
||||||
int ingenic_load_sdram_file(void *hndl, uint32_t base, const char *filename);
|
|
||||||
int ingenic_go(void *hndl, uint32_t address);
|
|
||||||
|
|
||||||
#define CMDSET_SPL 1
|
#define CMDSET_SPL 1
|
||||||
#define CMDSET_USBBOOT 2
|
#define CMDSET_USBBOOT 2
|
||||||
|
|
||||||
@ -60,6 +37,16 @@ int ingenic_go(void *hndl, uint32_t address);
|
|||||||
|
|
||||||
#define SDRAM_LOAD 0
|
#define SDRAM_LOAD 0
|
||||||
|
|
||||||
|
#define NAND_QUERY 0
|
||||||
|
#define NAND_INIT 1
|
||||||
|
#define NAND_MARK_BAD 2
|
||||||
|
#define NAND_READ_OOB 3
|
||||||
|
#define NAND_READ_RAW 4
|
||||||
|
#define NAND_ERASE 5
|
||||||
|
#define NAND_READ 6
|
||||||
|
#define NAND_PROGRAM 7
|
||||||
|
#define NAND_READ_TO_RAM 8
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* debug args */
|
/* debug args */
|
||||||
uint8_t debug_ops;
|
uint8_t debug_ops;
|
||||||
@ -109,4 +96,37 @@ typedef struct {
|
|||||||
uint32_t nand_bpc; /* block number per chip */
|
uint32_t nand_bpc; /* block number per chip */
|
||||||
} nand_config_t;
|
} nand_config_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint8_t vid;
|
||||||
|
uint8_t pid;
|
||||||
|
uint8_t chip;
|
||||||
|
uint8_t page;
|
||||||
|
uint8_t plane;
|
||||||
|
} nand_info_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
void (*cmdset_change)(void *arg);
|
||||||
|
} ingenic_callbacks_t;
|
||||||
|
|
||||||
|
void *ingenic_open(void *usb_hndl);
|
||||||
|
void ingenic_close(void *hndl);
|
||||||
|
void ingenic_set_callbacks(void *hndl, const ingenic_callbacks_t *callbacks, void *arg);
|
||||||
|
|
||||||
|
int ingenic_redetect(void *hndl);
|
||||||
|
int ingenic_cmdset(void *hndl);
|
||||||
|
int ingenic_type(void *hndl);
|
||||||
|
uint32_t ingenic_sdram_size(void *hndl);
|
||||||
|
|
||||||
|
int ingenic_rebuild(void *hndl);
|
||||||
|
int ingenic_loadstage(void *hndl, int id, const char *filename);
|
||||||
|
int ingenic_stage1_debugop(void *device, const char *filename, uint32_t op, uint32_t pin, uint32_t base, uint32_t size);
|
||||||
|
int ingenic_memtest(void *hndl, const char *filename, uint32_t base, uint32_t size, uint32_t *fail);
|
||||||
|
|
||||||
|
int ingenic_configure_stage2(void *hndl);
|
||||||
|
int ingenic_load_sdram(void *hndl, void *data, uint32_t base, uint32_t size);
|
||||||
|
int ingenic_load_sdram_file(void *hndl, uint32_t base, const char *filename);
|
||||||
|
int ingenic_go(void *hndl, uint32_t address);
|
||||||
|
|
||||||
|
int ingenic_query_nand(void *hndl, int cs, nand_info_t *info);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,12 +27,16 @@
|
|||||||
static int usbboot_boot(int argc, char *argv[]);
|
static int usbboot_boot(int argc, char *argv[]);
|
||||||
static int usbboot_load(int argc, char *argv[]);
|
static int usbboot_load(int argc, char *argv[]);
|
||||||
static int usbboot_go(int argc, char *argv[]);
|
static int usbboot_go(int argc, char *argv[]);
|
||||||
|
static int usbboot_nquery(int argc, char *argv[]);
|
||||||
|
|
||||||
const shell_command_t usbboot_cmdset[] = {
|
const shell_command_t usbboot_cmdset[] = {
|
||||||
|
|
||||||
{ "boot", "- Reconfigure stage2", usbboot_boot },
|
{ "boot", "- Reconfigure stage2", usbboot_boot },
|
||||||
{ "load", "<FILE> <BASE> - Load file to SDRAM", usbboot_load },
|
{ "load", "<FILE> <BASE> - Load file to SDRAM", usbboot_load },
|
||||||
{ "go", "<ADDRESS> - Jump to <ADDRESS>", usbboot_go },
|
{ "go", "<ADDRESS> - Jump to <ADDRESS>", usbboot_go },
|
||||||
|
|
||||||
|
{ "nquery", "<DEVICE> - Query NAND information", usbboot_nquery },
|
||||||
|
|
||||||
{ NULL, NULL, NULL }
|
{ NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,3 +79,32 @@ static int usbboot_go(int argc, char *argv[]) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int usbboot_nquery(int argc, char *argv[]) {
|
||||||
|
if(argc != 2) {
|
||||||
|
printf("Usage: %s <DEVICE>\n", argv[0]);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
nand_info_t info;
|
||||||
|
|
||||||
|
int ret = ingenic_query_nand(shell_device(), atoi(argv[1]), &info);
|
||||||
|
|
||||||
|
if(ret == -1) {
|
||||||
|
perror("ingenic_query_nand");
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf(
|
||||||
|
"VID: %02hhX\n"
|
||||||
|
"PID: %02hhX\n"
|
||||||
|
"Chip: %02hhX\n"
|
||||||
|
"Page: %02hhX\n"
|
||||||
|
"Plane: %02hhX\n",
|
||||||
|
info.vid, info.pid, info.chip, info.page, info.plane);
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user