[Bootloader]

- cleaned up
- added srec_init()

git-svn-id: http://moon:8086/svn/mips@178 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
2021-11-22 11:12:23 +00:00
parent c76849d2cc
commit 0c06127499
3 changed files with 17 additions and 10 deletions
+11 -10
View File
@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
uint8_t srec_buf[SREC_BUFSIZE];
srec_t srec;
int srec_state;
uint32_t haddr = 0, result;
uint32_t haddr = 0;
flash_t flash;
flash_img_hdr_t img_hdr = {0};
flash_img_hdr_t *pImg_hdr;
@@ -126,14 +126,13 @@ int main(int argc, char *argv[])
volatile uint32_t *pGPIO_DATA = (uint32_t*)SYS_GPIO_0_DATA;
volatile uint32_t *pGPIO_DIR = (uint32_t*)SYS_GPIO_0_DIR;
volatile uint32_t *pFlashIO = (uint32_t*)FLASH_BASE_IO; // Flash in uncached area
uint32_t flash_offset;
*pGPIO_DIR = GPIO_0_DFLT_DIR;
*pGPIO_DATA = GPIO_0_DFLT_DATA;
block_sel = 0x7F & (uint32_t)((*pGPIO_DATA >> GPIO_0_ALIGN_DIP) & GPIO_0_MASK_DIP);
sputs("\n\nMIPS bootloader 2.01\n");
sputs("\n\nMIPS bootloader 2.02\n");
PrintCPUinfo();
// ----------------------------------------------------------
@@ -146,10 +145,9 @@ int main(int argc, char *argv[])
// Get flash offset by value of DIP-switch
flash_offset = flash_get_offset_by_blocknum(&flash, block_sel);
pFlashIO = (uint32_t*)(SYS_FLASH_IO + flash_offset);
if (!(((*pGPIO_DATA >> GPIO_0_ALIGN_BTN) & GPIO_0_MASK_BTN) & 2))
{
volatile uint32_t *pFlashIO = (uint32_t*)(SYS_FLASH_IO + flash_offset); // Flash in uncached area
pImg_hdr = (flash_img_hdr_t*)pFlashIO;
if ((pImg_hdr->magic != MAGIC_EL) && (pImg_hdr->magic != MAGIC_EB))
{
@@ -175,15 +173,16 @@ int main(int argc, char *argv[])
while(1)
{
srec_init();
sputs(".");
while(1)
{
result = srec_getline(srec_buf);
srec_state = srec_decode(&srec, srec_buf, result);
uint32_t size = srec_getline(srec_buf);
srec_state = srec_decode(&srec, srec_buf, size);
uint32_t result = -1;
switch (srec_state)
{
case srec_data:
result = -1;
if ((srec.addr + srec.size) > (SDRAM_BASE + MAX_IMG_SIZE))
{
sputs("O");
@@ -196,7 +195,6 @@ int main(int argc, char *argv[])
haddr = srec.addr + srec.size;
}
result = 0;
break;
case srec_eob:
@@ -246,11 +244,14 @@ int main(int argc, char *argv[])
// Jump to reset vector
Jump_to((void*)0xBFC00000);
result = 0;
break;
case srec_sob:
break;
default:
sputs("E");
result = -1;
break;
}
if (IS_ERROR(result))
+5
View File
@@ -23,6 +23,11 @@ uint8_t h2i(uint8_t *c)
return b;
}
void srec_init()
{
}
int srec_decode(srec_t *pRec, uint8_t *pBuf, int buflen)
{
uint8_t chksum, byte;
+1
View File
@@ -34,6 +34,7 @@ enum srec_type
extern "C" {
#endif
void srec_init();
int srec_decode(srec_t *pRec, uint8_t *pBuf, int buflen);
int srec_getline(uint8_t *pLine);