Comment 7 for bug 1763050

Revision history for this message
Philip Karlsson Gisslow (philip-karlsson-gisslow) wrote :

Hi, I have also encountered this issue. As the problem seems to be related to the ldr generating a too long jump to the literal pool a simple solution is to add a .ltorg at the end of each of the two inlined functions to ensure that the pool gets placed there.

static void prvPortStartFirstTask( void )
{
__asm volatile(
  " ldr r0, =0xE000ED08 \n" /* Use the NVIC offset register to locate the stack. */
  " ldr r0, [r0] \n"
  " ldr r0, [r0] \n"
  " msr msp, r0 \n" /* Set the msp back to the start of the stack. */
  " cpsie i \n" /* Globally enable interrupts. */
  " cpsie f \n"
  " dsb \n"
  " isb \n"
  " svc 0 \n" /* System call to start first task. */
  " nop \n"
  " .ltorg \n");
}

static void vPortEnableVFP( void )
{
__asm volatile (
  " ldr.w r0, =0xE000ED88 \n" /* The FPU enable bits are in the CPACR. */
  " ldr r1, [r0] \n"
  " \n"
  " orr r1, r1, #( 0xf << 20 ) \n" /* Enable CP10 and CP11 coprocessors, then save back. */
  " str r1, [r0] \n"
  " bx r14 \n"
  " .ltorg ");
}

Looking at the generated machine code, the ldr offset is now in the range of 20 bytes.

BR,
Philip