I have three functions A, B, C. Both function A and B are mapped to FlexNVM sector (>= 0x1000000 in the memory map) and function C is allocated in the app flash sector. If I attempt to call function B from C, MCU got lost. I can see the disassembled code: instead of bl functionC to the correct address, the actual assmbly code is bogus: bl functionC_veneer (???? what's that?) which branches to an invalid address and causes an exception. My question is: is it possible to call a function located in FlexNVM region from normal flash region? If the caller is another function is the FlexNVM region, the jmp is correct.
Let me be more specific here:
I am placing my boot loader code including Flash erase/write APIs generated by PE into FlexNVM region (>=0x1000000), separated from normal flash sect. I have a function called flash_entry(), in the map file, it's located at the following address:
.flash_operate
0x100000dc 0xac ./Sources/flash_init_HW.o
0x100000dc a_reset
0x10000120 flash_entry
Now from my app code, it attempts to enter boot loader mode by calling flash_entry(). Under debug mode, I can observe the disassembled branch instruction:
91 flash_entry();
0000f074: bl __flash_entry_veneer (0x177b0); 0x000177b0
the assembly code branches address 0x177b0, which clearly is NOT the correction location. Please note that the instruction refers __flash_entry_veneer instead of flash_entry
If another function that is also located in the FlexNVM sector calls flash_entry(), it works expected.
65 flash_entry(); // never returns!
1000011a: bl flash_entry (0x10000120); 0x10000120
Any suggestion what did I do wrong? Can caller from normal flash sector invoking function in the FlexNVM sector or vice versa?
Hi Ming Jiang,
I saw in our internal system that this problem is already solved. I will share the answer here in the community.
"If you place function B in FlexNVM section and invokes it from function A located in flash section, you can't single step into it at c level under debug mode, but it will branch to the correct function call after few steps."
Best regards,
Carlos
Technical Support Engineer