Secondary bootloader AN11258 example for LPCXpresso

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Secondary bootloader AN11258 example for LPCXpresso

1,622 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by robertpalmerjr on Thu Aug 28 09:59:30 MST 2014
I'm working on adding a secondary bootloader to my project.  AN11258 is almost exactly what I'm looking for except the example projects are for Keil and I'm using LPCXpresso.  Has anyone converted this project over to an LPCXpresso project. 

The main portion I'm having difficulty with is the scatter loading/memory map configuration.
Labels (1)
0 Kudos
Reply
5 Replies

1,383 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by robertpalmerjr on Mon Nov 17 08:23:37 MST 2014
SOLUTION:

WRONG WAY: If you use the memory configuration editor and section macros to create a code section at 0x0000 for the main code and a section at 0xFF0 for the SBL_APICall().  This will not work.  I've tried it and the problem is that the flash programming tool appears to use the section information for programming.  It attempts to program a page starting at 0xFF0 which fails because it's not a page boundary.

WORKS:  I won't say this is the correct or best way to do it, but I do know this works... Using the information from "Using your own linker scripts" and the "Linker script templates", I created a customized link_template.ld file.  I added these lines, AFTER the SECOND text section (after the section that contains "INSERT RODATA" and "INSERT CPP_INFO".

    .text : ALIGN(${text_align})    
    {
        FILL(0xff)
         *(.text*)
        
        . = 0x00000FF0 ;
        *(.sbl_api*)
    } > ${CODE}


This defines a section, after the main code and after the RO_DATA that starts at 0xFF0 and is named sbl_api.

In the source code, I have the following now:
__attribute__ ((section(".sbl_api")))
void SBL_APICall(uint32_t API, uint8_t* pData){
    SBL_APICall_Handler(API, pData);
}


I can now flash and debug this code.  The only oddity, which I have been unable to resolve is that the bytes between then end of the code and the end of the flash page are NOT 0xff, they are getting filled with some value.  It appears that the 4 bytes after the code are a checksum, but then there are 8 more bytes that should be 0xFF but they're not. 
0 Kudos
Reply

1,383 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by robertpalmerjr on Sat Aug 30 07:35:33 MST 2014
Sorry typo on my part, I meant __RODATA (two underscores). 

It looks like the discrepancy is that with this specific project, I'm using LPCXpresso 5.2.4 and I'm guessing this is BEFORE __RODATA was introduced.

The reason I'm using an older IDE is because the project has certification requirements and it has passed certification - I cannot risk the compiler changing anything in terms of output code.

In any case, I'm using the __SECTION_EXT to accomplish the needed code placement.
0 Kudos
Reply

1,383 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Fri Aug 29 08:00:00 MST 2014
The section macro is called __RODATA (two underscores). This has not changed since it was first released several years ago...

Which FAQ are you suggesting is out of date? AFAIK, there are no out of date FAQs.
0 Kudos
Reply

1,383 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by robertpalmerjr on Fri Aug 29 07:46:51 MST 2014
Yep, I've done all that.  The RDB1768 example is for a USB bootloader.  I'm in the process of getting it working.  I've found that the LPCWare FAQs are out of date with respect to the section allocation macros (_RODATA does not exist in cr_section_macros.h for example).   I'm slowly getting it working, but was hoping that someone might have already made the change.

I'm getting it working by modifying the memory configuration in Settings along with some section allocation macros and continuing to use the managed linker scripts.  Just wondering if that's a better way than abandoning the managed linker scripts and doing a custom linker script.  So far, it appears that the linker is generating the code in the correct locations, but I have yet to actually debug.
0 Kudos
Reply

1,383 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by whitecoe on Fri Aug 29 00:03:59 MST 2014
There is one in the LPC1700 Examples folder within your LPCXpresso installation - in the RDB1768 zip. (the RDB1768 was a board Code Red used to sell before NXP acquired them).

You should look at the LPCXpresso User Guide section on the "memory configuration editor" too.

Also, I would suggest that you read through the various previous bootloader forum threads. Use the forum search option to look for "LPC17 boot loader".

HTH!

0 Kudos
Reply