cancel
Showing results for 
Search instead for 
Did you mean: 

How to organise nested projects with shared code and binary image encapsulation ?

Peter L.
Associate II

Hi, I have a challenge about IDE configuration and build steps to make a clean new project.

The context is the following : I have a device including 2 micro-controller, 1x STM32F303 and 1x STM32F101. The F303 communicates with the serial bootloader input of the F101 through an isolation barrier as safety requirement. The goal is to bootload the F303 using STM32Cubeprogrammer and let it update the F101 at next power on.

What I need is to create a project that allows to debug both uC (ideally at the same time). So far its easy. But I also need to include the image of the F101 uC inside the image of the F303 uC to allow the update mechanism mentionned above. This should ideally by transparent for the devs once configured to avoid human errors : building the F303 project should trigger a build of the F101 as pre-build step before building the F303 image that include it.

I feel like I need to have either a master project including both or a nested project. Attached the structure I obtained trying both options. Arrows represent folder links to the shared part of the code. Any advice on one or another is welcome.

0693W00000Hqc7HQAR.png 

My main question so far is :

1) How can I configure the main project to build the nested one(s) ? I know about prebuild steps but would like to make sure of what command line I should use to guarantee the same build as clicking on "Build" manually, taking nested project(s) properties and configuration into account.

Follow up question would be :

2) How should I then embed the subproject binary image in the main one ? Should I have a look in the linker syntax or is there an easier way ?

Thanks a lot for your insights. ;)

3 REPLIES 3
TDK
Guru

1)

Go into project properties -> Project References in the F3 project and select the F1 project. That will cause the F1 project to be built before.

2)

One way would be to convert both outputs to BIN files, then combine them. You would need to leave room for the second BIN file and pad accordingly.

I don't see how debugging both projects at once would be possible.

If you feel a post has answered your question, please click "Accept as Solution".
Peter L.
Associate II

Hi TDK,

Thanks, indeed this is a straightforward solution to get the dependency to compile. However I noted while experimenting that it does not build the F1 project if it is not opened in the workspace but still run the F3 build without warning. The danger is to modify the common code, build the F3 project and not noticing the F1 is not yet updated. Do you know of any way to further strenghten the process against this ?

Peter L.
Associate II

Building with project F1 closed or not opened using "Configure -> detect nested projects" :

10:14:50 **** Incremental Build of configuration Debug for project SOFT_000171_SP0186_Primary ****
make -j12 all 
arm-none-eabi-size   SOFT_000171_SP0186_Primary.elf 
   text	   data	    bss	    dec	    hex	filename
   7572	     20	   1572	   9164	   23cc	SOFT_000171_SP0186_Primary.elf
Finished building: default.size.stdout
 
 
10:14:51 Build Finished. 0 errors, 0 warnings. (took 370ms)
 

Building with project F1 detected and opened :

10:15:10 **** Build of configuration Debug for project SOFT_000172_SP0186_Secondary ****
make -j12 all 
arm-none-eabi-gcc "../Core/Src/gpio.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DDEBUG -DUSE_HAL_DRIVER -DSTM32F101x6 -c -I../Core/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Core/Src/gpio.d" -MT"Core/Src/gpio.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Core/Src/gpio.o"
arm-none-eabi-gcc -o "SOFT_000172_SP0186_Secondary.elf" @"objects.list"   -mcpu=cortex-m3 -T"[...]\SOFT_000171_SP0186_SCC\SOFT_000172_SP0186_Secondary\STM32F101R4TX_FLASH.ld" --specs=nosys.specs -Wl,-Map="SOFT_000172_SP0186_Secondary.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
Finished building target: SOFT_000172_SP0186_Secondary.elf
 
arm-none-eabi-size   SOFT_000172_SP0186_Secondary.elf 
arm-none-eabi-objdump -h -S  SOFT_000172_SP0186_Secondary.elf  > "SOFT_000172_SP0186_Secondary.list"
arm-none-eabi-objcopy  -O binary  SOFT_000172_SP0186_Secondary.elf  "SOFT_000172_SP0186_Secondary.bin"
   text	   data	    bss	    dec	    hex	filename
   4700	     20	   1572	   6292	   1894	SOFT_000172_SP0186_Secondary.elf
Finished building: default.size.stdout
Finished building: SOFT_000172_SP0186_Secondary.list
 
 
Finished building: SOFT_000172_SP0186_Secondary.bin
 
 
10:15:11 Build Finished. 0 errors, 0 warnings. (took 943ms)
 
10:15:11 **** Incremental Build of configuration Debug for project SOFT_000171_SP0186_Primary ****
make -j12 all 
arm-none-eabi-size   SOFT_000171_SP0186_Primary.elf 
   text	   data	    bss	    dec	    hex	filename
   7572	     20	   1572	   9164	   23cc	SOFT_000171_SP0186_Primary.elf
Finished building: default.size.stdout
 
 
10:15:11 Build Finished. 0 errors, 0 warnings. (took 370ms)