cancel
Showing results for 
Search instead for 
Did you mean: 

dangerous relocation: unsupported relocation in generated STM32WL3 Wm-BUS Phy Concentrator code

hub
Associate II

Hi, I have Nucleo-WL33CC1, and I'm not able to generate compileable code

I installed fresh CubeIDE and MX on my Ubuntu machine. I have 2 issues.

1) Unsupported relocation error

13:52:04 **** Incremental Build of configuration Debug for project wMBus_Phy_Concentrator ****
make -j16 all 
arm-none-eabi-gcc -mcpu=cortex-m0plus -g3 -DDEBUG -c -x assembler-with-cpp -MMD -MP -MF"Application/User/System/Startup/cpu_context_switch.d" -MT"Application/User/System/Startup/cpu_context_switch.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Application/User/System/Startup/cpu_context_switch.o" "/home/martin/STM32Cube/Example/wMBus_Phy_Concentrator/System/Startup/cpu_context_switch.s"
arm-none-eabi-gcc -o "wMBus_Phy_Concentrator.elf" @"objects.list"   -mcpu=cortex-m0plus -T"/home/martin/STM32Cube/Example/wMBus_Phy_Concentrator/STM32CubeIDE/STM32WL33CCVX_FLASH.ld" --specs=nosys.specs -Wl,-Map="wMBus_Phy_Concentrator.map" -Wl,--gc-sections -static --specs=nano.specs -mfloat-abi=soft -mthumb -Wl,--start-group -lc -lm -Wl,--end-group
/opt/st/stm32cubeide_2.1.1/plugins/com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.14.3.rel1.linux64_1.0.100.202602081740/tools/bin/../lib/gcc/arm-none-eabi/14.3.1/../../../../arm-none-eabi/bin/ld: ./Application/User/System/Startup/cpu_context_switch.o(CPUcontextRestore): Unknown destination type (ARM/Thumb) in ./Drivers/CMSIS/system_stm32wl3x.o
./Drivers/CMSIS/system_stm32wl3x.o: in function `SystemInit':
/home/martin/STM32Cube/Example/wMBus_Phy_Concentrator/Core/Src/system_stm32wl3x.c:203:(.text.SystemInit+0x2e): dangerous relocation: unsupported relocation
collect2: error: ld returned 1 exit status
make: *** [makefile:72: wMBus_Phy_Concentrator.elf] Error 1
"make -j16 all" terminated with exit code 2. Build might be incomplete.

Which I fixed when added .thumb_func in cpu_context_switch.c to the two EXPORT_FUNC:

 

.thumb_func

EXPORT_FUNC(CPUcontextSave)

 

.thumb_func

EXPORT_FUNC(CPUcontextRestore)

 

2) Missing MX_wMbus* functions in main.c

 

13:53:58 **** Incremental Build of configuration Debug for project wMBus_Phy_Concentrator ****

make -j16 all

arm-none-eabi-gcc -mcpu=cortex-m0plus -g3 -DDEBUG -c -x assembler-with-cpp -MMD -MP -MF"Application/User/System/Startup/cpu_context_switch.d" -MT"Application/User/System/Startup/cpu_context_switch.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Application/User/System/Startup/cpu_context_switch.o" "/home/martin/STM32Cube/Example/wMBus_Phy_Concentrator/System/Startup/cpu_context_switch.s"

arm-none-eabi-gcc "/home/martin/STM32Cube/Example/wMBus_Phy_Concentrator/Core/Src/main.c" -mcpu=cortex-m0plus -std=gnu11 -g3 -DDEBUG -DWFI_ENABLE -DSTM32WL3XX -DUSE_HAL_DRIVER -DAUTOMATIC_FORMAT_DETECTION_C_MODE -DPREAMBLE_AND_SYNC_IRQ_ENABLE -DWMBUS_RX_PERFORMANCE_ENABLED -DT1C1_ACTIVATED_C1_MODE -DWMBUS_ACTIVE_POWER_MODE_ENABLED -DWMBUS_FIRST_CRC_CHECK -c -I../../Core/Inc -I../../System/Interfaces -I../../System/Modules -I../../System/Startup -I../../wMBus/App -I../../Drivers/BSP/STM32WL3x-Nucleo -I../../Drivers/CMSIS/Device/ST/STM32WL3X/Include -I../../Drivers/CMSIS/Include -I../../Drivers/STM32WL3x_HAL_Driver/Inc -I../../Middlewares/ST/wMBus/Phy/Inc -I../../Utilities/lpm/tiny_lpm -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -fcyclomatic-complexity -MMD -MP -MF"Application/User/Core/main.d" -MT"Application/User/Core/main.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Application/User/Core/main.o"

/home/martin/STM32Cube/Example/wMBus_Phy_Concentrator/Core/Src/main.c: In function 'main':

/home/martin/STM32Cube/Example/wMBus_Phy_Concentrator/Core/Src/main.c:108:3: error: implicit declaration of function 'MX_wMBus_Init' [-Wimplicit-function-declaration]

108 | MX_wMBus_Init();

| ^~~~~~~~~~~~~

/home/martin/STM32Cube/Example/wMBus_Phy_Concentrator/Core/Src/main.c:124:5: error: implicit declaration of function 'MX_wMBus_Process' [-Wimplicit-function-declaration]

124 | MX_wMBus_Process();

| ^~~~~~~~~~~~~~~~

make: *** [Application/User/Core/subdir.mk:31: Application/User/Core/main.o] Error 1

"make -j16 all" terminated with exit code 2. Build might be incomplete.

 

13:53:59 Build Failed. 3 errors, 0 warnings. (took 180ms)

 

In main.c I see all the other functions called and defined. So I guess those wmbus functions should also be generated in main.c? But they are not here.

 

MX_GPIO_Init();

MX_MRSUBG_Init();

MX_USART1_UART_Init();

 

But those wmbus function are note generated to the main.c, even I have in CubeMX in the middleware selected Wmbus.

 

Thanks for any ideas.

1 REPLY 1
Andrew Neil
Super User

This has been raised before; eg,

https://community.st.com/t5/stm32cubeide-mcus/cubeide-2-1-0-system-stm32wl3x-o-dangerous-relocation/m-p/883253/highlight/true#M41180

 

The solution is to use GNU Tools for STM32 (13.3.rel1):

https://community.st.com/t5/stm32cubeide-mcus/system-stm32wb0x-c-dangerous-relocation-unsupported-relocation/m-p/882621/highlight/true#M41119

 

@Mahmoud Ben Romdhane @Ghofrane GSOURI 

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.