lpcware

Undefined Instruction in <__fclose_from_thumb>

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by HaukeR on Thu Feb 13 12:19:33 MST 2014
I'm currently making a bigger project with the LPC1115/302

After the last change (adding BTStack code) a strange error occured:

I am compiling with the semihosted RedLib library to debug all the stuff.
When the startup code is calling the __main, I get a hardfault interrupt.

I tracked it down to this section:
20d8:10000ec4 .word0x10000ec4
    20dc:00000000 .word0x00000000

000020e0 <__fclose_from_thumb>:
    20e0:e51ff004 ldrpc, [pc, #-4]; 20e4 <__fclose_from_thumb+0x4>
    20e4:10000ca4 .word0x10000ca4

000020e8 <__fseek_from_thumb>:
    20e8:e51ff004 ldrpc, [pc, #-4]; 20ec <__fseek_from_thumb+0x4>
    20ec:10000ca0 .word0x10000ca0
    20f0:74735442 .word0x74735442


When the __main is calling _initio the code on some point comes to calling __fclose_from_thumb
In the disassembly of the compiled code everything looks quite normal (to me)

But in the disassembly view of the debugger (LPC-Link) there is an undefined instruction:

000020da:   asrs    r0, r0, #32
000020dc:   movs    r0, r0
000020de:   movs    r0, r0
          __fclose_from_thumb:
000020e0:                   ; <UNDEFINED> instruction: 0xf004e51f
000020e4:   lsrs    r4, r4, #18
000020e6:   asrs    r0, r0, #32
          __fseek_from_thumb:
000020e8:                   ; <UNDEFINED> instruction: 0xf004e51f
000020ec:   lsrs    r0, r4, #18
000020ee:   asrs    r0, r0, #32


Which of course produces an HardFault Interrupt when this section is called.

What can I do? I have absolutely no clue how to avoid this, and why it is suddenly an undefined instruction.

Sadly I cant post a minimum example. When I create a minimal project, this part is not included in the binary (and everything works). But this part definitely is from the RedLib library, and therefore is not influenced by my code (only by if it is needed, or not)

Anything would help, thanks!

Outcomes