Mbed assembler errors

Hi all, I’ve been trying mbed under Platformio, and have struck a problem. When I compile a simple program (the mbed-os-example-blinky program from the mbed examples, that uses rtos I think) I get an assembler error. In fact, thousands of them, starting with the first line of the assembler module program. The error occurs in “irq_ca.S”. Every line gets an “Error: bad instruction”, but there are a few other error messages as well. It looks to my untrained eye like the wrong assembler is being invoked, or the wrong program to compile the module.
I am using Linux Mint 18.1 and CodeBlocks. I created the project using “pio init --ide codeblocks -b disco_f407vg”. I’m not entirely sure what version of mbed I’m using, I tried “mbed --version” which returns 1.3.0, but that’s about all I know.
I found a post about including “-D PIO_FRAMEWORK_MBED_RTOS_PRESENT” in the platformio.ini file, which seems to have cured another problem I had; the compiler could not find cmsis_os2.h, even though the library was definitely included in the include path. But now I just get the assembler error. I have no idea how to get around it.
Thanks, Ian

Could you point to the source code of example?

Hi Ivan, thanks for the quick response. I’ve copy and pasted the program in below. The source is from the PIO mbed-blinky example.

#include "mbed.h"

DigitalOut led1(LED1);

// main() runs in its own thread in the OS
int main() {
while (true) {
led1 = !led1;
wait(0.5);
}
}

This is the platformio.ini
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; Redirecting...

[env:disco_f407vg]
platform = ststm32
board = disco_f407vg
framework = mbed
build_flags = -std=gnu++14 -D PIO_FRAMEWORK_MBED_RTOS_PRESENT

This is the CodeBlocks build log

-------------- Build: Debug in mbedTest (compiler: GNU GCC Compiler)---------------

Checking if target is up-to-date: 1
Running command: /usr/local/bin/platformio -f -c codeblocks run
[Wed Jan 17 15:21:51 2018] Processing disco_f407vg (platform: ststm32; build_flags: -std=gnu++14 -D PIO_FRAMEWORK_MBED_RTOS_PRESENT; board: disco_f407vg; framework: mbed)

Verbose mode can be enabled via -v, --verbose option
Collected 26 compatible libraries
Scanning dependencies…
Library Dependency Graph ( Library Dependency Finder (LDF) — PlatformIO latest documentation )
|--
| |--
| | |-- <6.3>
| |-- <6.3>
| |-- Include@src-cf59268128a6523ab6f3684e27806472
| |-- <TARGET_CORTEX>
| | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | |--
| | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | |--
| | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | | |--
| | | | |--
| | | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | | |--
| | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | |-- <6.3>
| | |--
| | | |--
| | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| |--
| | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | |--
| | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| |--
| | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | |-- <6.3>
| | |-- <TARGET_CORTEX>
| | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | | |--
| | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | | |--
| | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | | | |--
| | | | | |--
| | | | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | | | |--
| | | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | | |-- <6.3>
| | | |--
| | | | |--
| | | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| |--
| | |-- <6.3>
| |--
| | |-- Include@src-cf59268128a6523ab6f3684e27806472
| |--
| | |--
| | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| |--
| | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | |--
| | | |--
| | | | |-- Include@src-cf59268128a6523ab6f3684e27806472
| | |--
| | | |-- Include@src-cf59268128a6523ab6f3684e27806472
Compiling .pioenvs/disco_f407vg/src/main.o
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S: Assembler messages:
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:26: Error: bad instruction mode_fiq EQU 0x11' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:27: Error: bad instruction mode_irq EQU 0x12’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:28: Error: bad instruction mode_svc EQU 0x13' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:29: Error: bad instruction mode_abt EQU 0x17’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:30: Error: bad instruction mode_und EQU 0x1B' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:32: Error: bad instruction cpsr_bit_t EQU 0x20’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:34: Error: bad instruction k_state_running EQU 2' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:34: Error: junk at end of line, first unrecognized character is :’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:35: Error: bad instruction i_k_state_ofs EQU 8' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:35: Error: unexpected character k’ in type specifier
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:35: Error: bad instruction osrtxinfo.kernel.state offset' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:36: Error: bad instruction i_tick_irqn_ofs EQU 16’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:36: Error: unexpected character t' in type specifier .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:36: Error: bad instruction osrtxinfo.tick_irqn offset’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:37: Error: bad instruction i_t_run_ofs EQU 20' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:37: Error: unexpected character t’ in type specifier
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:37: Error: bad instruction osrtxinfo.thread.run offset' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:38: Error: bad instruction tcb_sp_frame EQU 34’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:38: Error: bad size 0 in type specifier
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:38: Error: bad instruction osrtxthread_t.stack_frame offset' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:39: Error: bad instruction tcb_sp_ofs EQU 56’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:39: Error: bad size 0 in type specifier
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:39: Error: bad instruction osrtxthread_t.sp offset' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:42: Error: bad instruction preserve8’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:43: Error: bad instruction arm' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:46: Error: bad instruction area |.constdata|,DATA,READONLY’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:47: Error: bad instruction export irqRtxLib' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:48: Error: bad instruction irqrtxlib DCB 0’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:48: Error: bad instruction non weak library reference' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:51: Error: bad instruction area |.data|,DATA,READWRITE’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:52: Error: bad instruction export IRQ_PendSV' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:53: Error: bad instruction irq_nestlevel DCD 0’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:53: Error: bad instruction irq nesting level counter' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:54: Error: bad instruction irq_pendsv DCB 0’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:54: Error: bad instruction pending SVC flag' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:55: Error: bad instruction svc_active DCB 0’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:55: Error: garbage following instruction – svc handler execution active flag' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:58: Error: bad instruction area |.text|,CODE,READONLY’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:61: Error: bad instruction undef_handler PROC' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:63: Error: bad instruction export Undef_Handler’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:64: Error: bad instruction import CUndefHandler' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:66: Error: selected processor does not support srsfd SP!,#MODE_UND’ in Thumb mode
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:67: Error: invalid register list to push/pop instruction – push {R0-R4,R12}' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:67: Error: bad instruction save APCS corruptible registers to UND mode stack’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:69: Error: selected processor does not support requested special purpose register – mrs R0,SPSR' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:70: Error: unshifted register required -- tst R0,#CPSR_BIT_T
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:70: Error: bad instruction check mode' .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:71: Error: Thumb does not support conditional execution .piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:71: Error: junk at end of line, first unrecognized character is A’
.piolibdeps/Source/TOOLCHAIN_ARM/TARGET_CORTEX_A/irq_ca.S:72: Error: Thumb does not support conditional execution
Process terminated with status 1 (0 minute(s), 27 second(s))
50 error(s), 0 warning(s) (0 minute(s), 27 second(s))

Thanks,
Ian

You are going to use mbed OS and wait() what is impossible. You need to use Thread::wait(). See example

Thanks Ivan, that fixed it.
:wink: