Linkcmds files, my adventure continues

TL;DR

What is the proper way to instruct the manual build process within RTEMS v7 to use a different (custom) linkcmds file?

;---------------------------

The long version:

I don’t know how it has been with others, but the struggle to understand how RTEMS builds and operates has been a difficult one (compared to the other RTOS’ I have worked with). Anyway, I have been messing around with the manual build process and while I am starting to come to grips with it the one piece I am stumbling over is the proper way to utilize a different linkcmds file within v7 of RTEMS.

Since I have a large amount of STM32 based devices (with a majority being STM32F4s), I selected the arm/stm32f4 bsp via (./waf configure --rtems-bsps=arm/stm32f4 --rtems-config=./stm32f4.ini --rtems-tools=$HOME/rtems-compilers/compiler/7) and the issued the build command; with all working as expected, However, when I loaded the sample hello.exe into the target board (via gdb, exactly the way that is shown in the user manual) the base address for _start is incorrect (it’s set to 0x00000000) which results in a crash and disconnect of gdb.

To resolve this I created a new linkcmds file (for the NUCLEO-STM32F446RE board that I am using), changing the default linkcmds.stm32f4 memory map section from

MEMORY {
RAM_INT : ORIGIN = 0x20000000, LENGTH = 128k
ROM_INT : ORIGIN = 0x00000000, LENGTH = 1M
}

To
MEMORY {
RAM_INT : ORIGIN = 0x20000000, LENGTH = 128k
ROM_INT : ORIGIN = 0x08000000, LENGTH = 512K
}

and saved this new file as linkcmds.nucleo_f446re

After making this change I next hit both the documentation and web in-search-of where to both add and then specify the utilization of this new file. Unfortunately, the result of this searching only seems to turn up old information, dealing with RTEMS v6 on down (even in the latest user manual – unless I am just missing something); which has brought me to this point.

So, rather than making modifications directly to the origin linkcmds.stm32f4 file (which works) what is the proper way (or future proof way if you will) to instruct the manual build process to use a user specified linkcmds file (is see that within the arm/stm32f4 directory there is a second linker file: linkcmds.stm32f105r but I have yet to discover how to use it)?

In general, most linker scripts used in RTEMS are templated such that various sections can be moved around, changed in size, or omitted if necessary. There are many linker sections that RTEMS expects to exist and writing your own full linker script from scratch will be error-prone at best. The existing linker script is typically adjusted using variables in config.ini.

In the case of stm32f4, it appears that the linker script is not templated at all and is instead a static file in the source tree.

For an example of a templated linker script for a similar chip that allows a lot of flexibility, you can take a look at spec/build/bsps/arm/stm32h7/linkcmds*.yml.

For a simpler example of a templated linker script, see spec/build/bsps/aarch64/a53/linkcmds_lp64.yml.

Thanks for your assistance on this. I will head off and check out the to scripts you recommended

If you’d like to take a crack at adding that templating and options to configure it, I’d be happy to review a MR on it.

That sounds like an interesting task. Let me do some digging and then if it looks achievable by me Ill follow the instructions under the software engineering manual and issue a MR