You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@mynewt.apache.org by "Christopher Collins (JIRA)" <ji...@apache.org> on 2017/03/02 21:45:45 UTC

[jira] [Commented] (MYNEWT-509) Linker script should limit image size to allow for trailer

    [ https://issues.apache.org/jira/browse/MYNEWT-509?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15893080#comment-15893080 ] 

Christopher Collins commented on MYNEWT-509:
--------------------------------------------

Unfortunately, I wasn't able to accomplish this with linker script modifications.  For completeness, here is what I tried:

h4. Reduce size of FLASH region by (tlvs-size + boot-trailer-size)
{noformat}
MEMORY
{
  FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 0x3a000 - _imgtlvs_size - _boot_trailer_size
  RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x10000
}
{noformat}

Where _imgtlvs_size and _boot_trailer_size are linker script variables.  This elicits the following ld error:
{quote}
Error: /Users/ccollins/repos/mynewt/core/hw/bsp/nrf52dk/nrf52xxaa.ld:41: nonconstant expression for length
{quote}

_boot_trailer_size needs to be a variable because its value depends on the MCU's minimum flash write size.

h4. Create NOLOAD sections corresponding to the TLVs and boot trailer.
{noformat}
    .imgtlvs (NOLOAD):
    {
        . = . + _imgtlvs_size;
    } > FLASH
    .boottrailer (NOLOAD):
    {
        . = . + _boot_trailer_size;
    } > FLASH
{noformat}

This is what we do to reserve 32 bytes for the image header.  Sadly, this doesn't work in this case.  Since these sections don't come at the start of the image (they are at the end), they are zero-filled in the generated binary.  This is obviously not what we want.  We need these sections to be unwritten.

h4. Adjust the location counter by hand
{noformat}
    __exidx_end = .;

    . += _imgtlvs_size;
    . += _boot_trailer_size;

    __etext = .;
{noformat}

This works in that __etext gets the correct value.  Unfortunately, ld does not report an error when these adjustments push the location counter beyond the end of flash.  The linker only seems to report an error if it tries to place a section outside the bounds of the region.


> Linker script should limit image size to allow for trailer
> ----------------------------------------------------------
>
>                 Key: MYNEWT-509
>                 URL: https://issues.apache.org/jira/browse/MYNEWT-509
>             Project: Mynewt
>          Issue Type: Bug
>            Reporter: Christopher Collins
>            Assignee: Christopher Collins
>             Fix For: v1_0_0_rel
>
>




--
This message was sent by Atlassian JIRA
(v6.3.15#6346)