hello.I try to write bootloder in C language.The bootloder (boot()) in boot.c file comes with a application project. In the project ,the main funcion ,of course,don't call boot().
The result is in the project map file ,the section "boot_loader" set for boot function is lost.I think the compiler has ignore the boot function.I want to know how to solve this problem.
the following is my boot.c and link.cmd:
/*******************************
boot.c
*******************************/
#include "c6x.h"
#include "c6747.h"
#define NAND_BASE 0x62000000 // SNAND.CS0 BASE
#define NAND_CLE_PTR *( volatile Uint8* )( NAND_BASE + 0x10 )
#define NAND_ALE_PTR *( volatile Uint8* )( NAND_BASE + 0x08 )
#define NAND_CMD( cmd ) NAND_CLE_PTR = cmd;
#define NAND_ADDR_4( addr ) NAND_ALE_PTR = (addr >> 0) & 0xff;
#define CODE_ADDR 00800400h
extern far c_int00(void);
extern far unsigned int text_size;
#pragma CODE_SECTION(boot,"boot_loader");
void boot(void)
{
Uint32 i, j;
Uint16 flag = 0;
register int code_count=0;
volatile Uint32 *dst8 =(volatile Uint32 *)0x00800400;
Uint32 src=0x400;
//AEMIF configure
AEMIF_A2CR = 0x0886632C;
AEMIF_NANDFCR = 0x00000002;
// Code Copy
for ( i = 0 ; i < 4 ; i++ )//copy 4 pages
{
NAND_CMD( 0x00 ); // Read page
NAND_ADDR_4( src );
NAND_CMD(0x30 );
// Read MAIN array
for ( j = 0 ; j < 2*1024 ; j++ )
{
*dst8++ = 0x62000000;
code_count++;
if(code_count==text_size)
{
flag = 1;
break;
}
}
if(!flag )
src += 0x1000;//4K
}
c_int00();
}
/*******************************
link.cmd
******************************/
-c
-heap 0x1000
-stack 0x1000
MEMORY
{
BOOTRAM: o = 00800000h l = 00000400h //1K
IRAM: o = 00800400h l = 0083FFFFh
FLASH_BOOT: o = 0x62000000 l = 00000400h
FLASH_REST: o = 0x62000400 l = 63FFFFFFh
}
SECTIONS
{
.boot_loader : load = FLASH_BOOT, run = BOOTRAM
/* Initialized User Code Section */
.text : load = FLASH_REST, run = IRAM
SIZE(_text_size)
.cinit > IRAM
.const > IRAM
.stack > IRAM
.bss > IRAM
.data > IRAM
.far > IRAM
.switch > IRAM
.sysmem > IRAM
.cio > IRAM
.vectors > IRAM, RUN_START(_ISTP_START)
}