TI中文支持网
TI专业的中文技术问题搜集分享网站

RM48 Boodloader linker for keil

各位前輩好:

小弟最近移值官網的HDK BootLoader Sample Code 到keil C 開發環境,在linker 檔遇到問題,問題如下:

下面是CCS  bl_link.cmd 資料

–retain="*(.intvecs)"

MEMORY
{
VECTORS (X) : origin=0x00000000 length=0x00000020
FLASH_API (RX) : origin=0x00000020 length=0x000014E0
FLASH0 (RX) : origin=0x00001500 length=0x002FEB00 //LS31x Flash size is 0x300000
SRAM (RW) : origin=0x08002000 length=0x0002D000
STACK (RW) : origin=0x08000000 length=0x00002000
}
SECTIONS
{
.intvecs : {} > VECTORS
flashAPI :
{
..\Debug\Fapi_UserDefinedFunctions.obj (.text)
..\Debug\bl_flash.obj (.text)

–library= I:\CCS_Test\SafetyMCU_Bootloader\lib\F021_API_CortexR4_LE.lib < FlashStateMachine.IssueFsmCommand.obj
FlashStateMachine.SetActiveBank.obj
FlashStateMachine.InitializeFlashBanks.obj
FlashStateMachine.EnableMainSectors.obj
FlashStateMachine.IssueFsmCommand.obj
FlashStateMachine.ScaleFclk.obj
Init.obj
Utilities.CalculateEcc.obj
Utilities.WaitDelay.obj
Utilities.CalculateFletcher.obj
Read.MarginByByte.obj
Read.Common.obj
Read.FlushPipeline.obj
Read.WdService.obj
Async.WithAddress.obj
Program.obj > (.text)
} load = FLASH_API, run = SRAM, LOAD_START(api_load), RUN_START(api_run), SIZE(api_size)

.text > FLASH0
.const > FLASH0
.cinit > FLASH0
.pinit > FLASH0
.data > SRAM
.bss > SRAM
}

SECTIONS的這段code該怎麼移值到keil C 的,目前下面是我的設定,不過SECTIONS部份還沒辦法移值過來,compiler 出來的map檔跟CCS在FLASH_API段不一樣。

FLASH 0x00000000 0x00300000
{
 VECTORS 0x00000000 0x00000020 {
 *.o (intvecs, +First)
 }
 FLASH_API 0x00000020 0x000044E0 {
 *(+RO) }
 FLASH0 0x00004500 0x002FEB00
 {
 .ANY2 (+RO)
 }
 SRAM 0x08002000 0x0002D000
 {
 *.o (.data, +ZI +RW)*.o (.bss) .ANY (+ZI +RW) }
 STACK 0x08000000 0x00002000
 { .ANY (+RW)
 }

有沒有人有這方面的經驗可以分享的,謝謝! 

gaoyang9992006:

不清楚,不知道他们的编译器通用不通用。并不是所有的都通用的。比如编译51Keil编译器,就跟编译ARM的keil编译器不同。还是按照官方指定的开发工具做吧

Felix2:

回复 gaoyang9992006:

有人知道下面這三段code在做什麼?

/* initalise copy table */ if ((unsigned *)&__binit__ != (unsigned *)0xFFFFFFFF) {    extern void copy_in(void *binit);    copy_in((void *)&__binit__); }

/* initalise the C global variables */ if (&__TI_Handler_Table_Base < &__TI_Handler_Table_Limit) {    unsigned char **tablePtr = (unsigned char **)&__TI_CINIT_Base;    unsigned char **tableLimit = (unsigned char **)&__TI_CINIT_Limit;

    while (tablePtr < tableLimit)    {        unsigned char *loadAdr = *tablePtr++;        unsigned char *runAdr = *tablePtr++;        unsigned char idx = *loadAdr++;        handler_fptr handler = (handler_fptr)(&__TI_Handler_Table_Base)[idx];

        (*handler)((const unsigned char *)loadAdr, runAdr);    } }

/* initalise contructors */ if (__TI_PINIT_Base < __TI_PINIT_Limit) {    void (**p0)() = (void *)__TI_PINIT_Base;

    while ((unsigned)p0 < __TI_PINIT_Limit)    {        void (*p)() = *p0++;        p();    } }

————————————————————————-

/* initalise the C global variables */if (&__TI_Handler_Table_Base < &__TI_Handler_Table_Limit){    unsigned char **tablePtr = (unsigned char **)&__TI_CINIT_Base;    unsigned char **tableLimit = (unsigned char **)&__TI_CINIT_Limit;

    while (tablePtr < tableLimit)    {        unsigned char *loadAdr = *tablePtr++;        unsigned char *runAdr = *tablePtr++;        unsigned char idx = *loadAdr++;        handler_fptr handler = (handler_fptr)(&__TI_Handler_Table_Base)[idx];

        (*handler)((const unsigned char *)loadAdr, runAdr);    }}

這段code還會跑copy_decompress_lzss.c的下面這段code

 

/*****************************************************************************/

/*                                                                           */

/* __TI_DECOMPRESS_LZSS() – Decompress data encoded using LZSS encoding.     */

/*                          Input buffer (inbuf) has the encoded data and    */

/*                          uncompressed data is returned in outbuf.         */

/*                                                                           */

/*****************************************************************************/

__attribute__((section(".text:decompress:lzss")))

void __TI_decompress_lzss(pointer_to_const_t inbuf, pointer_t outbuf)

{

    while (1)

    {

        flags_t flags = READ_CHAR_ADV(inbuf);

 

        int i;

        for (i=0; i<CHAR_BIT ; i++)

        {

           if (flags & 0x1)

           {

              /*—————————————————————*/

              /* We have an uncoded byte, just write it out.                   */

              /*—————————————————————*/

              WRITE_CHAR_ADV(outbuf, READ_CHAR_ADV(inbuf));

           }

           else

           {

              /*—————————————————————*/

              /* Read and unpack the offset and length                         */

              /*—————————————————————*/             

              offset_t offset;

              length_t length;

#if CHAR_BIT == 8

              offset = READ_CHAR_ADV(inbuf);

              length = READ_CHAR_ADV(inbuf);

              offset <<= 4;

              offset |= ((length & 0x00F0) >> 4);

              length = (length & 0x000F) + 3;

              /*—————————————————————*/

              /* If the length is 3->17, we only use 4 bits. If the length is  */

              /* >= 18, we read an additional 8 bits and add it to the length. */

              /*                                                               */

              /* If the msb of the second byte is 1, we read an additional     */

              /* 8 bits and use that for bits 7-14 of the length. This gives   */

              /* us a range of 3->32785.                                       */

              /*—————————————————————*/

              if (length == 18)

              {

                 length_t length2 = READ_CHAR_ADV(inbuf);

                 if (length2 & 0x80)

                 {

                    length_t length3 = READ_CHAR_ADV(inbuf);

                    length2 = (length2 & 0x7f) | (length3 << 7);

                 }

                 length += length2;

              }

#elif CHAR_BIT == 16

              unsigned char temp = READ_CHAR_ADV(inbuf);

              length = (temp & 0xf) + 2;

              offset = temp >> 4;

 

              /*—————————————————————*/

              /* If the length is the maximum value encoded in 4 bits, read an */

              /* additional 16-bit value and add it to the length.             */

              /*—————————————————————*/             

              if (length == 17)

                 length += READ_CHAR_ADV(inbuf);

#endif

              /*—————————————————————*/

              /* If the offset indicates end of data, exit.                    */

              /*—————————————————————*/

              if (offset == LZSS_EOD)

                 return;          

              /*—————————————————————*/

              /* Copy the decoded string from sliding window to output buffer. */

              /*—————————————————————*/

              length_t j;

              pointer_t pos = outbuf – offset – 1;

              for (j = 0; j < length; j++)

                 WRITE_CHAR_ADV(outbuf, READ_CHAR_ADV(pos));

           }

           flags >>= 1;

        }

    }

}

赞(0)
未经允许不得转载:TI中文支持网 » RM48 Boodloader linker for keil
分享到: 更多 (0)