mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2024-11-22 22:27:32 +02:00
Code cleanup
This commit is contained in:
parent
8c36acee57
commit
0bf753e06a
32
ingenic.c
32
ingenic.c
@ -180,7 +180,7 @@ void ingenic_close(void *hndl) {
|
|||||||
int ingenic_rebuild(void *hndl) {
|
int ingenic_rebuild(void *hndl) {
|
||||||
HANDLE;
|
HANDLE;
|
||||||
|
|
||||||
handle->cfg.cpu_id = 0x4750; //CPUID(handle->type);
|
handle->cfg.cpu_id = CPUID(handle->type);
|
||||||
|
|
||||||
CFGOPT("EXTCLK", ext_clk, v <= 27 && v >= 12);
|
CFGOPT("EXTCLK", ext_clk, v <= 27 && v >= 12);
|
||||||
CFGOPT("CPUSPEED", cpu_speed, (v % 12) == 0);
|
CFGOPT("CPUSPEED", cpu_speed, (v % 12) == 0);
|
||||||
@ -197,10 +197,8 @@ int ingenic_rebuild(void *hndl) {
|
|||||||
CFGOPT("SDRAM_COLADDR", col_addr, 1);
|
CFGOPT("SDRAM_COLADDR", col_addr, 1);
|
||||||
CFGOPT("SDRAM_ISMOBILE", is_mobile, v == 0 || v == 1);
|
CFGOPT("SDRAM_ISMOBILE", is_mobile, v == 0 || v == 1);
|
||||||
CFGOPT("SDRAM_ISBUSSHARE", is_busshare, v == 0 || v == 1);
|
CFGOPT("SDRAM_ISBUSSHARE", is_busshare, v == 0 || v == 1);
|
||||||
CFGOPT("DEBUGOPS", debug_ops, 1);
|
|
||||||
CFGOPT("PINNUM", pin_num, 1);
|
memset(&handle->cfg.debug, 0, sizeof(ingenic_stage1_debug_t));
|
||||||
CFGOPT("START", start, 1);
|
|
||||||
CFGOPT("SIZE", size, 1);
|
|
||||||
|
|
||||||
handle->total_sdram_size = (uint32_t)
|
handle->total_sdram_size = (uint32_t)
|
||||||
(2 << (handle->cfg.row_addr + handle->cfg.col_addr - 1)) * 2
|
(2 << (handle->cfg.row_addr + handle->cfg.col_addr - 1)) * 2
|
||||||
@ -220,6 +218,24 @@ static int ingenic_address(void *usb, uint32_t base) {
|
|||||||
return usbdev_vendor(usb, USBDEV_TODEV, VR_SET_DATA_ADDRESS, (base >> 16), base & 0xFFFF, 0, 0);
|
return usbdev_vendor(usb, USBDEV_TODEV, VR_SET_DATA_ADDRESS, (base >> 16), base & 0xFFFF, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ingenic_stage1_debugop(void *hndl, const char *filename, uint32_t op, uint32_t pin, uint32_t base, uint32_t size) {
|
||||||
|
HANDLE;
|
||||||
|
|
||||||
|
handle->cfg.debug.debug_ops = op;
|
||||||
|
handle->cfg.debug.pin_num = pin;
|
||||||
|
handle->cfg.debug.start = base;
|
||||||
|
handle->cfg.debug.size = size;
|
||||||
|
|
||||||
|
debug(LEVEL_DEBUG, "Debug configuration dump:\n");
|
||||||
|
hexdump(&handle->cfg, sizeof(firmware_config_t));
|
||||||
|
|
||||||
|
int ret = ingenic_loadstage(handle, INGENIC_STAGE1, filename);
|
||||||
|
|
||||||
|
memset(&handle->cfg.debug, 0, sizeof(ingenic_stage1_debug_t));
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int ingenic_loadstage(void *hndl, int id, const char *file) {
|
int ingenic_loadstage(void *hndl, int id, const char *file) {
|
||||||
HANDLE;
|
HANDLE;
|
||||||
|
|
||||||
@ -253,11 +269,8 @@ int ingenic_loadstage(void *hndl, int id, const char *file) {
|
|||||||
|
|
||||||
FILE *fd = fopen(file, "rb");
|
FILE *fd = fopen(file, "rb");
|
||||||
|
|
||||||
if(fd == NULL) {
|
if(fd == NULL)
|
||||||
debug(LEVEL_ERROR, "Ingenic: cannot load file `%s'\n", file);
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
fseek(fd, 0, SEEK_END);
|
fseek(fd, 0, SEEK_END);
|
||||||
int size = ftell(fd);
|
int size = ftell(fd);
|
||||||
@ -307,3 +320,4 @@ int ingenic_loadstage(void *hndl, int id, const char *file) {
|
|||||||
|
|
||||||
return ingenic_redetect(hndl);
|
return ingenic_redetect(hndl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
22
ingenic.h
22
ingenic.h
@ -31,6 +31,7 @@ int ingenic_type(void *hndl);
|
|||||||
|
|
||||||
int ingenic_rebuild(void *hndl);
|
int ingenic_rebuild(void *hndl);
|
||||||
int ingenic_loadstage(void *hndl, int id, const char *filename);
|
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);
|
||||||
|
|
||||||
#define CMDSET_SPL 1
|
#define CMDSET_SPL 1
|
||||||
#define CMDSET_USBBOOT 2
|
#define CMDSET_USBBOOT 2
|
||||||
@ -38,14 +39,23 @@ int ingenic_loadstage(void *hndl, int id, const char *filename);
|
|||||||
#define INGENIC_STAGE1 1
|
#define INGENIC_STAGE1 1
|
||||||
#define INGENIC_STAGE2 2
|
#define INGENIC_STAGE2 2
|
||||||
|
|
||||||
#define SPL_DEBUG_MEMTEST "1"
|
#define STAGE1_DEBUG_BOOT 0
|
||||||
#define SPL_DEBUG_GPIO_SET "2"
|
#define STAGE1_DEBUG_MEMTEST 1
|
||||||
#define SPL_DEBUG_GPIO_CLEAR "3"
|
#define STAGE1_DEBUG_GPIO_SET 2
|
||||||
|
#define STAGE1_DEBUG_GPIO_CLEAR 3
|
||||||
|
|
||||||
#define STAGE1_BASE 0x2000
|
#define STAGE1_BASE 0x2000
|
||||||
#define STAGE2_CODESIZE 0x400000
|
#define STAGE2_CODESIZE 0x400000
|
||||||
#define SDRAM_BASE 0x80000000
|
#define SDRAM_BASE 0x80000000
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
/* debug args */
|
||||||
|
uint8_t debug_ops;
|
||||||
|
uint8_t pin_num;
|
||||||
|
uint32_t start;
|
||||||
|
uint32_t size;
|
||||||
|
} ingenic_stage1_debug_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/* CPU ID */
|
/* CPU ID */
|
||||||
uint32_t cpu_id;
|
uint32_t cpu_id;
|
||||||
@ -65,11 +75,7 @@ typedef struct {
|
|||||||
uint8_t is_mobile;
|
uint8_t is_mobile;
|
||||||
uint8_t is_busshare;
|
uint8_t is_busshare;
|
||||||
|
|
||||||
/* debug args */
|
ingenic_stage1_debug_t debug;
|
||||||
uint8_t debug_ops;
|
|
||||||
uint8_t pin_num;
|
|
||||||
uint32_t start;
|
|
||||||
uint32_t size;
|
|
||||||
} __attribute__((packed)) firmware_config_t;
|
} __attribute__((packed)) firmware_config_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -31,11 +31,4 @@ set NAND_BCHBIT 8 # Specify the hardware BCH algorithm for 4750 (4|8)
|
|||||||
set NAND_WPPIN 0 # Specify the write protect pin number
|
set NAND_WPPIN 0 # Specify the write protect pin number
|
||||||
set NAND_BLOCKPERCHIP 4096 # Specify the block number per chip,0 means ignore
|
set NAND_BLOCKPERCHIP 4096 # Specify the block number per chip,0 means ignore
|
||||||
|
|
||||||
# DEBUG
|
|
||||||
set DEBUGOPS 0
|
|
||||||
set PINNUM 0
|
|
||||||
set START 0
|
|
||||||
set SIZE 0
|
|
||||||
|
|
||||||
|
|
||||||
rebuildcfg
|
rebuildcfg
|
||||||
|
11
shell.c
11
shell.c
@ -304,7 +304,7 @@ static int builtin_source(int argc, char *argv[]) {
|
|||||||
int ret = shell_source(argv[1]);
|
int ret = shell_source(argv[1]);
|
||||||
|
|
||||||
if(ret == -1) {
|
if(ret == -1) {
|
||||||
printf("Error while sourcing file %s\n", argv[1]);
|
fprintf(stderr, "Error while sourcing file %s: %s\n", argv[1], strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
shell_exit = 0;
|
shell_exit = 0;
|
||||||
@ -320,14 +320,9 @@ static int builtin_echo(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 1; i < argc; i++) {
|
for(int i = 1; i < argc; i++) {
|
||||||
printf("%s", argv[i]);
|
fputs(argv[i], stdout);
|
||||||
|
|
||||||
if(i < argc - 1) {
|
putchar((i < argc - 1) ? ' ' : '\n');
|
||||||
printf(" ");
|
|
||||||
|
|
||||||
} else {
|
|
||||||
printf("\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
48
spl_cmdset.c
48
spl_cmdset.c
@ -36,14 +36,19 @@ const shell_command_t spl_cmdset[] = {
|
|||||||
{ NULL, NULL, NULL }
|
{ NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static int spl_load_stage1() {
|
static int spl_stage1_op(uint32_t op, uint32_t pin, uint32_t base, uint32_t size) {
|
||||||
if(cfg_getenv("STAGE1_FILE") == NULL) {
|
if(cfg_getenv("STAGE1_FILE") == NULL) {
|
||||||
printf("Variable STAGE1_FILE is not set\n");
|
printf("Variable STAGE1_FILE is not set\n");
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ingenic_loadstage(shell_device(), INGENIC_STAGE1, cfg_getenv("STAGE1_FILE"));
|
int ret = ingenic_stage1_debugop(shell_device(), cfg_getenv("STAGE1_FILE"), op, pin, base, size);
|
||||||
|
|
||||||
|
if(ret == -1)
|
||||||
|
perror("ingenic_stage1_debugop");
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_memtest(int argc, char *argv[]) {
|
static int spl_memtest(int argc, char *argv[]) {
|
||||||
@ -51,7 +56,7 @@ static int spl_memtest(int argc, char *argv[]) {
|
|||||||
printf("Usage: %s [BASE <SIZE>]\n", argv[0]);
|
printf("Usage: %s [BASE <SIZE>]\n", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return spl_load_stage1(); // TODO
|
return spl_stage1_op(STAGE1_DEBUG_BOOT, 0, 0, 0); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_gpio(int argc, char *argv[]) {
|
static int spl_gpio(int argc, char *argv[]) {
|
||||||
@ -62,30 +67,7 @@ static int spl_gpio(int argc, char *argv[]) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *old_debugops = strdup(cfg_getenv("DEBUGOPS")),
|
return spl_stage1_op(!strcmp(argv[2], "1") ? STAGE1_DEBUG_GPIO_SET : STAGE1_DEBUG_GPIO_CLEAR, atoi(argv[1]), 0, 0);
|
||||||
*old_pinnum = strdup(cfg_getenv("PINNUM"));
|
|
||||||
|
|
||||||
cfg_setenv("DEBUGOPS", (!strcmp(argv[2], "1")) ?
|
|
||||||
SPL_DEBUG_GPIO_SET : SPL_DEBUG_GPIO_CLEAR);
|
|
||||||
cfg_setenv("PINNUM", argv[1]);
|
|
||||||
|
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
ret = shell_execute("rebuildcfg");
|
|
||||||
|
|
||||||
if(ret == -1)
|
|
||||||
goto finally;
|
|
||||||
|
|
||||||
ret = spl_load_stage1();
|
|
||||||
|
|
||||||
finally:
|
|
||||||
cfg_setenv("DEBUGOPS", old_debugops);
|
|
||||||
cfg_setenv("PINNUM", old_pinnum);
|
|
||||||
|
|
||||||
free(old_debugops);
|
|
||||||
free(old_pinnum);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int spl_boot(int argc, char *argv[]) {
|
static int spl_boot(int argc, char *argv[]) {
|
||||||
@ -93,9 +75,7 @@ static int spl_boot(int argc, char *argv[]) {
|
|||||||
printf("Usage: %s\n", argv[0]);
|
printf("Usage: %s\n", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ret;
|
int ret = spl_stage1_op(STAGE1_DEBUG_BOOT, 0, 0, 0);
|
||||||
|
|
||||||
ret = spl_load_stage1();
|
|
||||||
|
|
||||||
if(ret == -1)
|
if(ret == -1)
|
||||||
return -1;
|
return -1;
|
||||||
@ -106,5 +86,11 @@ static int spl_boot(int argc, char *argv[]) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ingenic_loadstage(shell_device(), INGENIC_STAGE2, cfg_getenv("STAGE2_FILE"));
|
ret = ingenic_loadstage(shell_device(), INGENIC_STAGE2, cfg_getenv("STAGE2_FILE"));
|
||||||
|
|
||||||
|
if(ret == -1)
|
||||||
|
perror("ingenic_loadstage");
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user