Firmware: uPD77c25 program download, reset
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
// #define DEBUG_IRQ
|
||||
// #define DEBUG_MSU1
|
||||
|
||||
// #define DEBUG_UART
|
||||
|
||||
#ifdef DEBUG_UART
|
||||
#define DBG_UART
|
||||
#else
|
||||
|
||||
@@ -151,6 +151,7 @@ FLASH_RES flash_file(uint8_t *filename) {
|
||||
|
||||
uint32_t res;
|
||||
|
||||
writeled(1);
|
||||
DBG_BL printf("erasing flash...\n");
|
||||
if((res = iap_prepare_for_write(FW_START / 0x1000, FLASH_SECTORS)) != CMD_SUCCESS) {
|
||||
DBG_BL printf("error %ld while preparing for erase\n", res);
|
||||
@@ -172,7 +173,6 @@ FLASH_RES flash_file(uint8_t *filename) {
|
||||
: (flash_addr >> 12);
|
||||
DBG_BL printf("current_sec=%d flash_addr=%08lx\n", current_sec, flash_addr);
|
||||
DBG_UART uart_putc('.');
|
||||
toggle_rdy_led();
|
||||
if(current_sec < (FW_START / 0x1000)) return ERR_FLASH;
|
||||
if((res = iap_prepare_for_write(current_sec, current_sec)) != CMD_SUCCESS) {
|
||||
DBG_BL printf("error %ld while preparing sector %d for write\n", res, current_sec);
|
||||
@@ -188,6 +188,7 @@ FLASH_RES flash_file(uint8_t *filename) {
|
||||
DBG_UART uart_putc('X');
|
||||
return ERR_FILECHK;
|
||||
}
|
||||
writeled(0);
|
||||
} else {
|
||||
DBG_UART uart_putc('n');
|
||||
DBG_BL printf("flash content is ok, no version mismatch, no forced upgrade. No need to flash\n");
|
||||
|
||||
@@ -45,7 +45,7 @@ int main(void) {
|
||||
DBG_UART uart_init();
|
||||
led_init();
|
||||
readled(0);
|
||||
rdyled(0);
|
||||
rdyled(1);
|
||||
writeled(0);
|
||||
/* do this last because the peripheral init()s change PCLK dividers */
|
||||
clock_init();
|
||||
@@ -63,9 +63,11 @@ DBG_BL printf("PCONP=%lx\n", LPC_SC->PCONP);
|
||||
|
||||
FLASH_RES res = flash_file((uint8_t*)"/sd2snes/firmware.img");
|
||||
if(res == ERR_FLASHPREP || res == ERR_FLASHERASE || res == ERR_FLASH) {
|
||||
rdyled(0);
|
||||
writeled(1);
|
||||
}
|
||||
if(res == ERR_FILEHD || res == ERR_FILECHK) {
|
||||
rdyled(0);
|
||||
readled(1);
|
||||
}
|
||||
DBG_BL printf("flash result = %d\n", res);
|
||||
|
||||
Reference in New Issue
Block a user