I tried to switch my compiler from ARM V5 to V6, and I faced a inline assembly funciton conversion issue:
[Original]
DATA_RAM_FUNCTION __asm void prvEnableVFP_RTT(void) { PRESERVE8 /* The FPU enable bits are in the CPACR. */ ldr.w r0, = 0xE000ED88 ldr r1, [r0] /* Enable CP10 and CP11 coprocessors, then save back. */ // orr r1, r1, #( 0xf << 20 ) orr r1, r1, #0xf00000 str r1, [r0] bx r14 nop }
[After Conversion]
DATA_RAM_FUNCTION void prvEnableVFP_RTT(void) { __asm volatile( ".eabi_attribute Tag_ABI_align_preserved, 1 \n" "ldr.w r0, = %0 \n" "ldr r1, [r0] \n" "orr r1, r1, #0xf00000 \n" "str r1, [r0] \n" "bx r14 \n" "nop \n" : /* no outputs */ : "r"(0xE000ED88) : "r0", "r1", "r14" ); }
There is a error:
./.rtt-studio/Debug\rtthread.axf: Error: L6218E: Undefined symbol r2 (referred from lto-llvm-293411.o).
What's going wrong?
After I fixed syntax errors, there is the newest compilable inline assembly function, and my project stuck here.
DATA_RAM_FUNCTION void prvEnableVFP_RTT(void) { __ASM volatile( ".eabi_attribute Tag_ABI_align_preserved, 1 \n\t" "ldr.w r0, = 0xE000ED88 \n\t" "ldr r1, [r0] \n\t" "orr r1, r1, #0xf00000 \n\t" "str r1, [r0] \n\t" "bx r14 \n\t" "nop \n\t" : : : "r0", "r1", "r14", "memory" ); }
I just set multi print function in my inline funciton to check where the bug was
DATA_RAM_FUNCTION void prvEnableVFP_RTT(void) { rt_kprintf("function entry \n"); __ASM volatile(".eabi_attribute Tag_ABI_align_preserved, 1 \n\t"); rt_kprintf("function point(1) \n"); __ASM volatile("ldr.w r0, = 0xE000ED88 \n\t"); rt_kprintf("function point(2) \n"); __ASM volatile("ldr r1, [r0] \n\t"); rt_kprintf("function point(3) \n"); __ASM volatile("orr r1, r1, #0xf00000 \n\t"); rt_kprintf("function point(4) \n"); __ASM volatile("str r1, [r0] \n\t"); rt_kprintf("function point(5) \n"); __ASM volatile("bx r14 \n\t"); rt_kprintf("function point(6) \n"); __NOP(); rt_kprintf("function end \n"); }
It seems here is the break point
__ASM volatile("bx r14 \n\t");
And fnially I found that project is past project, so some image in flash are not compatible(in the correct memory address) with defined address in code.