AdaCore / bb-runtimes

Source repository for the GNAT Bare Metal BSPs
Other
65 stars 51 forks source link

Add support for Nucleo F401RE #40

Closed FredPraca closed 3 years ago

Fabien-Chouteau commented 3 years ago

Hello @FredPraca ,

We have new source template system in place and this PR will benefit from using it.

For a file to be handled as a template, it just needs to have a .tmpl extension. For instance memory-map.ld.tmpl. And template configuration values are added using the add_template_config_value() function. For instance in cortexm.py:

self.add_template_config_value('Board_Name', self.board)

See:

I'll let you change the code accordingly and open a new PR.

FredPraca commented 3 years ago

Ok, which branch should I now use ? Still community-2020 ?

Fabien-Chouteau commented 3 years ago

Yes, you have to rebase since there are new patches on this branch now.

damaki commented 3 years ago

We have new source template system in place and this PR will benefit from using it.

For a file to be handled as a template, it just needs to have a .tmpl extension. For instance memory-map.ld.tmpl. And template configuration values are added using the add_template_config_value() function. For instance in cortexm.py:

FYI the current template system on the community-2020 branch (at commit 3d1542e at the time of writing) doesn't work properly with linker script files (e.g. memory-map.ld.tmpl files) due to a bug where the template config values aren't passed to the generator for linker script files. It works fine with Ada source files though.

I've already made a fix for this in #44, but this hasn't been merged yet. The relevant patch to fix this in support/bsp_sources/archsupport.py can be found in commit 4c5e438.

FredPraca commented 3 years ago

Well at the moment, I ported it similarly to what's done with other boards but compilation fails with a strange error when using _python3 build_rts.py --build --verbose --force --output=/opt/gnat-2020-arm-elf/arm-eabi/lib/gnat nucleof411re command line:

building project /opt/gnat-2020-arm-elf/arm-eabi/lib/gnat/zfp-nucleo_f411re/runtime_build.gpr
Setup
   [mkdir]        object directory for project Runtime_Build
   [mkdir]        library directory for project Runtime_Build
Compile
   [Asm_Cpp]      start-ram.S
   [Asm_Cpp]      start-rom.S
   [Asm_Cpp]      breakpoint_handler-cortexm.S
   [Asm_Cpp]      start-common.S
   [Ada]          s-stm32.ads
   [Ada]          i-stm32-usart.ads
cannot generate code for file s-stm32.ads (package spec)

   compilation of s-stm32.ads failed

Any advice welcomed, I've been struggling too long with this port.

damaki commented 3 years ago

I think that error occurs when you try to build a package spec (.ads file). It sounds like the s-stm32.adb file has not been copied by the runtime.

I looked at the code in your nucleo_f411re branch and I think that s-stm32.adb is not being copied into the generated runtime.

The problem seems to be in the configuration in cortexm.py. On line 691 you set self.mcu to 'stm32f411', but then later on line 731 you compare it against 'stm32f411re' which has an re on the end. This means that s-stm32.adb is never added to the gnat sources. If you fix that mismatch then I think the error you're seeing will go away.

FredPraca commented 3 years ago

Thanks Daniel ! I'll try this but I'm confident that's the problem. I think it was a bit late when I've done it :smile: