- pimped bootloader without flash to read flash images
git-svn-id: http://moon:8086/svn/mips@52 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -1,5 +1,20 @@
|
||||
#include "libsys_boot.h"
|
||||
|
||||
#define MAGIC_EB 0x4A464931 // "JFI1" in big-endian;
|
||||
#define MAGIC_EL 0x3149464A // "JFI1" in little-endian;
|
||||
|
||||
typedef struct _sflash_img_hdr_t
|
||||
{
|
||||
uint32_t magic;
|
||||
uint32_t target_base;
|
||||
uint32_t img_base;
|
||||
uint32_t img_size;
|
||||
uint32_t hdr_next;
|
||||
uint8_t img_name[128];
|
||||
uint8_t res[108];
|
||||
|
||||
} flash_img_hdr_t;
|
||||
|
||||
typedef struct _ssrec_t
|
||||
{
|
||||
uint32_t addr;
|
||||
@@ -198,6 +213,40 @@ int main(int argc, char *argv[])
|
||||
volatile uint8_t *pMem;
|
||||
haddr = 0;
|
||||
|
||||
flash_img_hdr_t *pImg_hdr;
|
||||
|
||||
volatile uint32_t *pFlashIO = (uint32_t*)(FLASH_BASE_IO + 0x00100000); // Flash in uncached area
|
||||
volatile uint32_t *pFlashMem = (uint32_t*)(FLASH_BASE_MEM + 0x00100000); // Flash in cached area
|
||||
volatile uint32_t *pSdram32 = (uint32_t*)SDRAM_BASE;
|
||||
|
||||
sputs("\nMIPS bootloader\n");
|
||||
|
||||
// ----------------------------------------------------------
|
||||
sputs("Loading image from flash at ");print_word((int)pFlashMem);sputs("\n");
|
||||
pImg_hdr = (flash_img_hdr_t*)pFlashIO;
|
||||
if ((pImg_hdr->magic != MAGIC_EL) && (pImg_hdr->magic != MAGIC_EB))
|
||||
{
|
||||
sputs("\n\n");
|
||||
sputs("Invalid image found at ");print_word((int)pFlashMem); sputs(". Abort.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
sputs("target_base = ");print_word(pImg_hdr->target_base);sputs("\n");
|
||||
sputs("img_base = ");print_word(pImg_hdr->img_base);sputs("\n");
|
||||
sputs("img_size = ");print_word(pImg_hdr->img_size);sputs("\n");
|
||||
|
||||
pSdram32 = (uint32_t*)pImg_hdr->target_base;
|
||||
|
||||
// It's safe to use cached Flash,
|
||||
// because D-Cache was invalidated during execution of start code
|
||||
pFlashMem += pImg_hdr->img_base/4;
|
||||
|
||||
for (i=0; i < pImg_hdr->img_size/4; i++)
|
||||
pSdram32[i] = pFlashMem[i];
|
||||
|
||||
sputs("Booting from ");print_word(pImg_hdr->target_base);sputs("\n\n");
|
||||
Exec_at((void*)pSdram32);
|
||||
|
||||
// ----------------------------------------------------------
|
||||
sputs("\n\n");
|
||||
PrintCPUinfo();
|
||||
|
||||
Reference in New Issue
Block a user