- bootloader: read boot image offset from via board provided method

- bootloader_with_flash: fixed apperent bug with GPIO alignmentand masking



git-svn-id: http://moon:8086/svn/mips@134 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2017-01-28 09:56:43 +00:00
parent 6fbd1fbf38
commit 4dbc4695fb
4 changed files with 22 additions and 9 deletions
+5
View File
@@ -55,6 +55,11 @@ char dbg_getchar()
} }
#endif #endif
uint32_t getBootOffset(uint32_t sel)
{
return 0x100000 *(1+sel);
}
void board_init(void) void board_init(void)
{ {
+12 -3
View File
@@ -5,6 +5,8 @@
#define MAGIC_EB 0x4A464931 // "JFI1" in big-endian; #define MAGIC_EB 0x4A464931 // "JFI1" in big-endian;
#define MAGIC_EL 0x3149464A // "JFI1" in little-endian; #define MAGIC_EL 0x3149464A // "JFI1" in little-endian;
extern uint32_t getBootOffset(uint32_t sel);
typedef struct _sflash_img_hdr_t typedef struct _sflash_img_hdr_t
{ {
uint32_t magic; uint32_t magic;
@@ -74,16 +76,23 @@ int main(int argc, char *argv[])
uint8_t buf[256]; uint8_t buf[256];
srec_t srec; srec_t srec;
int result, srec_state, i; int result, srec_state, i;
uint32_t haddr; uint32_t haddr = 0;
volatile uint8_t *pMem; volatile uint8_t *pMem;
haddr = 0;
flash_img_hdr_t img_hdr; flash_img_hdr_t img_hdr;
volatile uint32_t *pFlashMem = (uint32_t*)(FLASH_BASE_MEM + 0x00100000); // Flash in cached area volatile uint32_t *pFlashMem = (uint32_t*)(FLASH_BASE_MEM); // Flash in cached area
volatile uint32_t *pSdram32 = (uint32_t*)SDRAM_BASE; volatile uint32_t *pSdram32 = (uint32_t*)SDRAM_BASE;
volatile uint32_t *pGPIO_DATA = (uint32_t*)SYS_GPIO_0_DATA;
volatile uint32_t *pGPIO_DIR = (uint32_t*)SYS_GPIO_0_DIR;
*pGPIO_DIR = GPIO_0_DFLT_DIR;
*pGPIO_DATA = GPIO_0_DFLT_DATA;
uint32_t block_sel = (uint32_t)((*pGPIO_DATA >> GPIO_0_ALIGN_DIP) & GPIO_0_MASK_DIP);
uint32_t flash_offset = getBootOffset(block_sel);
sputs("\nMIPS bootloader\n"); sputs("\nMIPS bootloader\n");
pFlashMem += flash_offset >> 2;
// ---------------------------------------------------------- // ----------------------------------------------------------
sputs("Loading image from flash at ");print_word((int)pFlashMem);sputs("\n"); sputs("Loading image from flash at ");print_word((int)pFlashMem);sputs("\n");
+2 -3
View File
@@ -115,7 +115,7 @@ int main(int argc, char *argv[])
uint8_t buf[1024]; uint8_t buf[1024];
srec_t srec; srec_t srec;
int srec_state, i; int srec_state, i;
uint32_t haddr, result; uint32_t haddr = 0, result;
flash_t flash; flash_t flash;
flash_img_hdr_t img_hdr = {0}; flash_img_hdr_t img_hdr = {0};
flash_img_hdr_t *pImg_hdr; flash_img_hdr_t *pImg_hdr;
@@ -131,8 +131,7 @@ int main(int argc, char *argv[])
*pGPIO_DIR = GPIO_0_DFLT_DIR; *pGPIO_DIR = GPIO_0_DFLT_DIR;
*pGPIO_DATA = GPIO_0_DFLT_DATA; *pGPIO_DATA = GPIO_0_DFLT_DATA;
haddr = 0; block_sel = 0x7F & (uint32_t)((*pGPIO_DATA >> GPIO_0_ALIGN_DIP) & GPIO_0_MASK_DIP);
block_sel = 0x7F & (uint32_t)((*pGPIO_DATA & GPIO_0_MASK_DIP) >> GPIO_0_ALIGN_DIP);
sputs("\nMIPS bootloader\n"); sputs("\nMIPS bootloader\n");
// ---------------------------------------------------------- // ----------------------------------------------------------
+2 -2
View File
@@ -59,8 +59,8 @@
#define GPIO_0_MASK_LED 0x000000FF #define GPIO_0_MASK_LED 0x000000FF
#define GPIO_0_ALIGN_LED 0 #define GPIO_0_ALIGN_LED 0
#define GPIO_0_MASK_DIP 0x000000FF #define GPIO_0_MASK_DIP 0x0000000F
#define GPIO_0_ALIGN_DIP 16 #define GPIO_0_ALIGN_DIP 8
#define GPIO_0_MASK_BTN 0x0000001F #define GPIO_0_MASK_BTN 0x0000001F
#define GPIO_0_ALIGN_BTN 24 #define GPIO_0_ALIGN_BTN 24