- fixed data types
git-svn-id: http://moon:8086/svn/mips@12 a8ebac50-d88d-4704-bea3-6648445a41b3
This commit is contained in:
@@ -6,27 +6,27 @@
|
||||
|
||||
typedef struct _ssrec_t
|
||||
{
|
||||
UINT32 addr;
|
||||
UINT32 size;
|
||||
UINT32 type;
|
||||
UINT8 *data;
|
||||
uint32_t addr;
|
||||
uint32_t size;
|
||||
uint32_t type;
|
||||
uint8_t *data;
|
||||
|
||||
} srec_t;
|
||||
typedef struct _sflash_alloc_tbl_t
|
||||
{
|
||||
UINT32 images[16];
|
||||
uint32_t images[16];
|
||||
|
||||
} flash_alloc_tbl_t;
|
||||
|
||||
typedef struct _sflash_img_hdr_t
|
||||
{
|
||||
UINT32 magic;
|
||||
UINT32 target_base;
|
||||
UINT32 img_base;
|
||||
UINT32 img_size;
|
||||
UINT32 hdr_next;
|
||||
UINT8 img_name[128];
|
||||
UINT8 res[108];
|
||||
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;
|
||||
|
||||
@@ -35,10 +35,10 @@ enum srec_type
|
||||
srec_err, srec_sob, srec_data, srec_rec, srec_eob
|
||||
};
|
||||
|
||||
UINT8 h2i(UINT8 *c)
|
||||
uint8_t h2i(uint8_t *c)
|
||||
{
|
||||
int i;
|
||||
UINT8 t, b = 0;
|
||||
uint8_t t, b = 0;
|
||||
|
||||
for (i=0; i < 2; i++)
|
||||
{
|
||||
@@ -53,9 +53,9 @@ UINT8 h2i(UINT8 *c)
|
||||
return b;
|
||||
}
|
||||
|
||||
int decode_srec(srec_t *pRec, UINT8 *pBuf, int buflen)
|
||||
int decode_srec(srec_t *pRec, uint8_t *pBuf, int buflen)
|
||||
{
|
||||
UINT8 chksum, byte;
|
||||
uint8_t chksum, byte;
|
||||
int alen, i;
|
||||
|
||||
if (!buflen)
|
||||
@@ -92,7 +92,7 @@ int decode_srec(srec_t *pRec, UINT8 *pBuf, int buflen)
|
||||
}
|
||||
pRec->size -= (alen+1);
|
||||
|
||||
pRec->data = (UINT8*) &pBuf[4 + 2*alen];
|
||||
pRec->data = (uint8_t*) &pBuf[4 + 2*alen];
|
||||
for (i=0; i < (int)pRec->size; i++)
|
||||
{
|
||||
byte = h2i(&pRec->data[2*i]);
|
||||
@@ -107,7 +107,7 @@ int decode_srec(srec_t *pRec, UINT8 *pBuf, int buflen)
|
||||
return pRec->type;
|
||||
}
|
||||
|
||||
int srec_getline(UINT8 *pLine)
|
||||
int srec_getline(uint8_t *pLine)
|
||||
{
|
||||
char c;
|
||||
int i = 0;
|
||||
@@ -220,27 +220,27 @@ void Exec_RE_at(void *pEntry)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
UINT8 buf[256];
|
||||
uint8_t buf[256];
|
||||
srec_t srec;
|
||||
int srec_state, i;
|
||||
UINT32 haddr, result;
|
||||
uint32_t haddr, result;
|
||||
flash_t flash;
|
||||
flash_img_hdr_t img_hdr = {0};
|
||||
flash_img_hdr_t *pImg_hdr;
|
||||
UINT32 img_size, block_sel;
|
||||
uint32_t img_size, block_sel;
|
||||
|
||||
volatile UINT32 *pGPIO_DATA = (UINT32*)SYS_GPIO_0_DATA;
|
||||
volatile UINT32 *pGPIO_DIR = (UINT32*)SYS_GPIO_0_DIR;
|
||||
volatile UINT8 *pMem;
|
||||
volatile UINT32 *pFlashIO = (UINT32*)FLASH_BASE_IO; // Flash in uncached area
|
||||
volatile UINT32 *pFlashMem = (UINT32*)FLASH_BASE_MEM; // Flash in cached area
|
||||
volatile UINT32 *ram32 = (UINT32*)SDRAM_BASE;
|
||||
UINT32 flash_offset;
|
||||
volatile uint32_t *pGPIO_DATA = (uint32_t*)SYS_GPIO_0_DATA;
|
||||
volatile uint32_t *pGPIO_DIR = (uint32_t*)SYS_GPIO_0_DIR;
|
||||
volatile uint8_t *pMem;
|
||||
volatile uint32_t *pFlashIO = (uint32_t*)FLASH_BASE_IO; // Flash in uncached area
|
||||
volatile uint32_t *pFlashMem = (uint32_t*)FLASH_BASE_MEM; // Flash in cached area
|
||||
volatile uint32_t *ram32 = (uint32_t*)SDRAM_BASE;
|
||||
uint32_t flash_offset;
|
||||
|
||||
*pGPIO_DIR = GPIO_0_DFLT_DIR;
|
||||
*pGPIO_DATA = GPIO_0_DFLT_DATA;
|
||||
haddr = 0;
|
||||
block_sel = 0x7F & (UINT32)((*pGPIO_DATA & GPIO_0_DIP) >> GPIO_0_ALIGN_DIP);
|
||||
block_sel = 0x7F & (uint32_t)((*pGPIO_DATA & GPIO_0_DIP) >> GPIO_0_ALIGN_DIP);
|
||||
|
||||
// ----------------------------------------------------------
|
||||
if (IS_ERROR(flash_find(&flash, SYS_FLASH_IO)))
|
||||
@@ -252,8 +252,8 @@ int main(int argc, char *argv[])
|
||||
// Get flash offset by value of DIP-switch
|
||||
flash_offset = flash_get_offset_by_blocknum(&flash, block_sel);
|
||||
|
||||
ram32 = (UINT32*)(SDRAM_BASE);
|
||||
pFlashIO = (UINT32*)(SYS_FLASH_IO + flash_offset);
|
||||
ram32 = (uint32_t*)(SDRAM_BASE);
|
||||
pFlashIO = (uint32_t*)(SYS_FLASH_IO + flash_offset);
|
||||
|
||||
if (!(((*pGPIO_DATA & GPIO_0_BTN) >> GPIO_0_ALIGN_BTN) & 8))
|
||||
{
|
||||
@@ -268,12 +268,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
sputs("Booting application from flash (");print_word(flash_offset);sputs(")...");
|
||||
|
||||
ram32 = (UINT32*)pImg_hdr->target_base;
|
||||
ram32 = (uint32_t*)pImg_hdr->target_base;
|
||||
img_size = pImg_hdr->img_size;
|
||||
|
||||
// It's safe to use cached Flash,
|
||||
// because D-Cache was invalidated during execution of start code
|
||||
pFlashMem = (UINT32*)pImg_hdr->img_base;
|
||||
pFlashMem = (uint32_t*)pImg_hdr->img_base;
|
||||
|
||||
for (i=0; i < img_size/4; i++)
|
||||
ram32[i] = pFlashMem[i];
|
||||
@@ -308,7 +308,7 @@ int main(int argc, char *argv[])
|
||||
if ((srec.addr + srec.size) > haddr)
|
||||
haddr = srec.addr + srec.size;
|
||||
|
||||
pMem = (UINT8*)srec.addr;
|
||||
pMem = (uint8_t*)srec.addr;
|
||||
for (i=0; i < srec.size; i++)
|
||||
*pMem++ = srec.data[i];
|
||||
|
||||
@@ -335,13 +335,13 @@ int main(int argc, char *argv[])
|
||||
sputs("done\n");
|
||||
|
||||
sputs("Flash write...");
|
||||
result = flash_program(&flash, flash_offset, (UINT8*)&img_hdr, sizeof(flash_img_hdr_t));
|
||||
result = flash_program(&flash, flash_offset, (uint8_t*)&img_hdr, sizeof(flash_img_hdr_t));
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
sputs("failed (");print_word(result);sputs(")\n");
|
||||
break;
|
||||
}
|
||||
result = flash_program(&flash, img_hdr.img_base, (UINT8*)img_hdr.target_base, img_hdr.img_size);
|
||||
result = flash_program(&flash, img_hdr.img_base, (uint8_t*)img_hdr.target_base, img_hdr.img_size);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
sputs("failed (");print_word(result);sputs(")\n");
|
||||
@@ -350,7 +350,7 @@ int main(int argc, char *argv[])
|
||||
sputs("done\n");
|
||||
|
||||
sputs("Flash verify...");
|
||||
result = flash_verify(&flash, img_hdr.img_base, (UINT8*)img_hdr.target_base, img_hdr.img_size);
|
||||
result = flash_verify(&flash, img_hdr.img_base, (uint8_t*)img_hdr.target_base, img_hdr.img_size);
|
||||
if (IS_ERROR(result))
|
||||
{
|
||||
sputs("failed (");print_word(result);sputs(")\n");
|
||||
|
||||
Reference in New Issue
Block a user