The case of the missing BCA (Bootloader Configuration Area:)

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

The case of the missing BCA (Bootloader Configuration Area:)

956 Views
robertpoor
Senior Contributor I

I've prepared a project along the lines discussed in How To Adapt KDS Applications for KBOOT Bootloader.  

 

Actually, I've prepared two, and the first one works and the second one doesn't.

 

Although both projects have identical .ld files, the working project successfully includes the Boot Control Area in the .srec file, the other project for some reason doesn't include the BCA.  Here's a snippet of the "good" .srec file: you can see the BCA starting a 0x83c0 ('6B 63 66 67 ...'), followed by the .text section at 0x8400:

...
S11380B09986000099860000998600009986000040
S11383C06B636667FFFFFFFFFFFFFFFFFFFFFFFF1A
S11383D001108813FFFFFFFFFFFFFFFFFFFFFE00F9
S11383E00000000000000000000000000000000089
S10783F00000000085
S113840010B5064C2378002B07D1054B002B02D066
...

My other project uses the identical .ld file and identical bootloader_support files (containing the BCA fields), yet produces the following .srec file.  As you can see, it doesn't include any records at 0x83c0:

...
S11380B051D100002D9200002D9200002D9200005D
S113840010B5064C2378002B07D1054B002B02D066
...

Can you think of any reason the BCA is not getting linked in?

 

I'm attaching the .ld file as well as the bootloader_support.[hc] files used in both projects.

Original Attachment has been moved to: bootloader_support.c.zip

Original Attachment has been moved to: bootloader_support.h.zip

Original Attachment has been moved to: MKL27Z64xxx4_flash.ld.zip

0 Kudos
2 Replies

524 Views
robertpoor
Senior Contributor I

It occurs to me that the linker might be optimizing out the BCA code since it's not referenced anywhere, but I do have a 'KEEP' directive in the .ld map:

 .bca :
 {
 . = ALIGN(4);
 KEEP(*(.BootloaderConfig)) /* Bootloader Configuration Area (BCA) */
 . = ALIGN(4);
 } > m_bootloader_config

Are there other things that would allow the linker to dead strip the .bca section?

0 Kudos

524 Views
robertpoor
Senior Contributor I

In the "answering my own question" department, here's a solution but I don't know why it's required:

I changed:

__attribute__((section(".BootloaderConfig")))
const bootloader_config_t BootloaderConfig =
{ ... }

to

__attribute__((section(".BootloaderConfig")))
__attribute__((used))
const bootloader_config_t BootloaderConfig =
{ ... }

and now it includes the BCA in the .srec file.

This solves my problem, but I would like to know why the KEEP directive in the .ld file was not sufficient.  (And why it worked without the __attribute__((used)) in the other project and not this one...)

0 Kudos