Category: Code Sourcery CodeBench

Fix “registers may not be the same” ARM GCC error

I was developing a project using STM32F2 microcontroller when I decided to update the ARM toolchain. After have updated Code Sourcery CodeBench Lite Edition to version 2013.11-24 I encountered the following error:

 

core_cm3.s:826: Error: registers may not be the same — `strexb r3,r2,[r3]’

 

After some investigation I found this thread and according to it we need to edit some functions.

OpenĀ core_cm3.c (typically in Libraries/CMSIS/CM3/CoreSupport/core_cm3.c if using the STM32F2xx Standard Peripherals Library) and look for the functions __STREXB and __STREXH.

You have to change “=r” to “=&r” in order to have:

from

__ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );

to:

__ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );

I solved in this way and I hope ST will upgrade their libraries soon.

WordPress Themes