STM32F10x_StdPeriph_Lib_V3.6 编译错误 Error: registers may not be the same -- `strexb r3,r2,[r3]‘

     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.

..CMSIS\CM3\CoreSupport\core_cm3.c"

/**
 * @brief  STR Exclusive (8 bit)
 *
 * @param  value  value to store
 * @param  *addr  address pointer
 * @return        successful / failed
 *
 * Exclusive STR command for 8 bit values
 */
uint32_t __STREXB(uint8_t value, uint8_t *addr)
{
   uint32_t result=0;
  
   __ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
   return(result);
}

/**
 * @brief  STR Exclusive (16 bit)
 *
 * @param  value  value to store
 * @param  *addr  address pointer
 * @return        successful / failed
 *
 * Exclusive STR command for 16 bit values
 */
uint32_t __STREXH(uint16_t value, uint16_t *addr)
{
   uint32_t result=0;
  
   __ASM volatile ("strexh %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value) );
   return(result);
}

你可能感兴趣的:(stm32,单片机,嵌入式硬件)