TI cmsis library is broken
If you read this, most likely you have faced the same issue I did. It means that most likely you have downloaded cmsis implementation from one of the biggest silicon manufacturer in the world - TI. And the library does not work. Even worth, your toolchain cannot assemble it and failed on strex instruction.
strex r0, r0, [r1]
It seems like someone do not give a dump about specifications. Because it cleary states that For STREX, Rd must not be the same register as Rt, Rt2, or Rn.
So in order to fix this you need to replace all
strex instructions with
uint32_t result = 0; __ASM volatile ("strexb %0, %2, [%1]" : "=&r" (result) : "r" (addr), "r" (value)); return result;
The important thing here is "=&" specificator. It forces GCC to substitute different register into second operand. For more information on "=&" pleace see over here.
Beside patching TI version, what is wrong in so many ways, it is way more convinient just to generate from CMSIS-SVD file. One way to generate them is just to install Keil IDE trial, grab these files and proceed with gcc.