Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memory bank example, improve docs a bit #4

Merged
merged 3 commits into from
Nov 18, 2024

Conversation

multiplemonomials
Copy link
Contributor

This example has gotten a bit out of date, so I am updating it with:

  • An example of how to specify memory banks for your custom target, with a link back to the main memory bank page
  • An example of how to specify custom upload methods for all of the provided custom targets

I also took the chance to update the github action workflow and to update a few comments in CMakeLists.txt to provide some more details.

@JojoS62
Copy link

JojoS62 commented Nov 14, 2024

Its nice to have this feature, but if the linker script changes names, it may break the custom target. This happens all the time I try to compile with updated Mbed-os. So I would prefer to use existing MCU names, especially for devices with many memory banks.

@multiplemonomials
Copy link
Contributor Author

fwiw, I am working on a linker script "style guide" that will help standardize on what to use in linker scripts. It should cut down on instances where linker scripts change in incompatible ways. Here's what I've got so far:

  • You must use MBED_CONF_TARGET_BOOT_STACK_SIZE to set the boot stack size
  • You should use the memory bank defines to define the MEMORY{} section if possible.
  • You should use the configured flash size to determine where to put your application, not the physical size. This allows easy support for (a) bootloaders and (b) different part numbers with less or more flash size, without modifying the linker script
  • If the MCU has multiple RAM banks and there's a bank other than the main one that has a significant amount of available space, you should activate split heap support for the device so that both banks can be used.
    • To activate split heap support, add the MBED_SPLIT_HEAP macro and declare the correct symbols (TODO add example)
  • You should have a crash capture RAM section. Crash capture for a device must be enabled in mbed-os/platform/mbed_lib.json
  • You should verify that you don't have extraneous symbols in your linker script or startup ASM that consume an excessive amount of space. Examples:
    • Heap placeholder symbols. The heap section should be declared as empty space.
    • Symbols with an absolute location that is not at the start of a memory bank, if at all possible. This will cause the build report to think that that memory bank is filled up to where the symbol is.
  • Space taken up by the boot stack should be accounted for in the linker script. You may choose to do this with a symbol or by just creating an empty section filled with zeros for the stack size:
. = ORIGIN(ram) + LENGTH(ram) - STACK_SIZE;
.stack (NOLOAD):
{
    . = ALIGN(8);
    . += STACK_SIZE;
} > ram
  • You should NOT use the MBED_APP_START or MBED_APP_SIZE defines, these are not set anymore in Mbed CE
  • You should NOT use the old-style MBED_RAM[n]_START defines as it's not predictable which memory bank you'll get

@multiplemonomials multiplemonomials merged commit ac67ef1 into master Nov 18, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants