PlatformIO Community

STM32 project with assembly files build problems

I develop a forked version of Gnuk project (GNUK - Debian Wiki) and after upgrading to PlatformIO 6 I stumbled upon build errors (“unrecognized option -x”) for assembly files. I use Windows 10.

By searching, I found this issue (Cannot use assembly files in MCS51 platform due to core issue · Issue #3917 · platformio/platformio-core · GitHub) and renamed .s files to .S in my platformio.ini. This problem went away with platform ststm32 up to 15.3.0. I understood that it was a bug and .s files should be passed directly to assembler whereas .S files should be passed to it through gcc. Previously, they all went through gcc.

On platform ststm32@15.4.0, the following error is given:

ChibiOS_2.0.8\os\ports\GCC\ARMCMx\crt0.S:70: Error: selected processor does not support requested special purpose register -- `msr PSP,r0'
ChibiOS_2.0.8\os\ports\GCC\ARMCMx\crt0.S:122: Error: selected processor does not support requested special purpose register -- `msr CONTROL,r0'

Build command for ststm32@15.3.0:

arm-none-eabi-gcc -x assembler-with-cpp -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -DF_CPU=72000000L -DPLATFORMIO=60002 -DSTM32F1 -DSTM32F103xB -DARDUINO_BLUEPILL_F103C8 -DCORTEX_USE_BASEPRI=TRUE -DKEYGEN_SUPPORT -Isrc -I.pio\libdeps\STM32F103_12Mhz\tiny-AES-c -Ipolarssl-0.14.0\include -IChibiOS_2.0.8\os\hal\include -IChibiOS_2.0.8\os\hal\platforms\STM32 -IChibiOS_2.0.8\os\ports\GCC\ARMCMx -IChibiOS_2.0.8\os\ports\GCC\ARMCMx\STM32F10x -IChibiOS_2.0.8\os\ports\GCC\ARMCMx\cmsis -IChibiOS_2.0.8\os\kernel\include -Iboards\common 
-IChibiOS_2.0.8\os\various -Iclrc632 -Iboards\STM32F103_12Mhz -c -o .pio\build\STM32F103_12Mhz\ChibiOS_2.0.8\os\ports\GCC\ARMCMx\STM32F10x\vectors.o ChibiOS_2.0.8\os\ports\GCC\ARMCMx\crt0.S

Build command for ststm32@15.4.0:

arm-none-eabi-gcc -x assembler-with-cpp -DF_CPU=72000000L -DPLATFORMIO=60002 -DSTM32F1 -DSTM32F103xB -DARDUINO_BLUEPILL_F103C8 -DCORTEX_USE_BASEPRI=TRUE -DKEYGEN_SUPPORT -Isrc -I.pio\libdeps\STM32F103_12Mhz\tiny-AES-c -Ipolarssl-0.14.0\include -IChibiOS_2.0.8\os\hal\include -IChibiOS_2.0.8\os\hal\platforms\STM32 -IChibiOS_2.0.8\os\ports\GCC\ARMCMx -IChibiOS_2.0.8\os\ports\GCC\ARMCMx\STM32F10x -IChibiOS_2.0.8\os\ports\GCC\ARMCMx\cmsis -IChibiOS_2.0.8\os\kernel\include -Iboards\common -IChibiOS_2.0.8\os\various -Iclrc632 -Iboards\STM32F103_12Mhz -c -o .pio\build\STM32F103_12Mhz\ChibiOS_2.0.8\os\ports\GCC\ARMCMx\crt0.o ChibiOS_2.0.8\os\ports\GCC\ARMCMx\crt0.S

I don’t see the critical

options there at all, so it doesn’t know what CPU it’s compiling for… Commit Improve support for hand-written asm source files · platformio/platform-ststm32@9f46435 · GitHub changed this behavior. Maybe the fix was incorrect? CC @ivankravets

1 Like

Which framework did you use?

No framework, bare-metal.

I think the removal of env.Append(ASFLAGS=env.get("CCFLAGS", [])[:]) when no framework = .. line is set killed this, or it needs that env.Append(ASFLAGS= ["-mthumb", "-mcpu=%s" % board.get("build.cpu")]) thing.

1 Like

This is a bug.

@azarubkin, could you re-test with a development version of STM32 dev-platform?

platform =

If you have this dev-platform already cloned, please change the project working directory and run pio pkg update.

Does it work now?

It works, thank you!