cortex-m-rt icon indicating copy to clipboard operation
cortex-m-rt copied to clipboard

Make the address of the vector table configurable.

Open david-boles opened this issue 3 years ago • 3 comments

Not sure if this is the right way to do it; please let me know if there's a better alternative. I'm trying to add dummy sections for a bootloader header and trailer, this change allows my memory.x file to be pretty clear:

MEMORY
{
  /* NOTE K = KiBi = 1024 bytes */
  FLASH : ORIGIN = 0x00008000, LENGTH = 464K
  RAM : ORIGIN = 0x20000000, LENGTH = 64K
}

SECTIONS
{
  .mcuboot_header 0x8000 :
  {
    FILL(0xAAAAAAAA)
    . = . + 32;
  } > FLASH
  PROVIDE(_svector_table = 0x8020);
}
INSERT BEFORE .vector_table;

SECTIONS
{
  .mcuboot_trailer . :
  {
    FILL(0xFFFFFFFF)
    . = . + 40;
  } > FLASH
}
INSERT AFTER .gnu.sgstubs;

It seemed like a simple and useful enough change that you might want to incorporate it.

david-boles avatar Jan 19 '22 11:01 david-boles

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @therealprof (or someone else) soon.

Please see the contribution instructions for more information.

rust-highfive avatar Jan 19 '22 11:01 rust-highfive

This PR might be a good idea regardless, but as another option to solve your problem I wonder if you could do this? I've done something very similar in the past to leave room for configuration data before the vector table in bootloader applications.

MEMORY {
    HEADER : ORIGIN = 0x00008000, LENGTH = 32
    FLASH : ORIGIN = ORIGIN(HEADER) + LENGTH(HEADER), LENGTH = 464K - LENGTH(HEADER)
    RAM : ORIGIN = 0x20000000, LENGTH = 64K
}

SECTIONS {
    .mcuboot_header . : {
      FILL(0xAAAAAAAA)
      . = . + 32;
    } > HEADER
}

SECTIONS
{
  .mcuboot_trailer . : {
    FILL(0xFFFFFFFF)
    . = . + 40;
  } > FLASH
} INSERT AFTER .gnu.sgstubs;

adamgreig avatar Jan 21 '22 01:01 adamgreig

adamgreig, that definitely works too and I'll probably go with that unless and until this gets merged. It would feel nicer if the header and trailer could be treated the same way though.

david-boles avatar Jan 23 '22 01:01 david-boles