UBLOX C027 (LPC1768) - IAP call causes HardFault

31 Jan 2019

Hello Everyone,

I'm trying to read MCU serial number using IAP command (58). Whenever I try to call the IAP routine located at 0x1FFF1FF1, it ends up with HardFault. It seems that something guards that memory address from executing (however I can read from that). Has anybody encounter this problem and know what is the problem ? Here is the code snippet and HardFault dump (mbedOS 5.11.1) :

typedef void (*IAP)(uint32_t *, uint32_t *);

	uint32_t command[5] = { 58, 0, 0, 0, 0 };
	uint32_t output[5] = { 0, 0, 0, 0, 0 };
	IAP iap_entry = (IAP)(0x1FFF1FF1);

	iap_entry(command, output);

++ MbedOS Fault Handler ++

FaultType: HardFault

Context:
R0   : 100054B0
R1   : 100054C4
R2   : 00000004
R3   : 1FFF1FF1
R4   : 00000000
R5   : 100054E8
R6   : 100054B0
R7   : 00000000
R8   : 00000000
R9   : 00000000
R10  : 00000000
R11  : 00000000
R12  : 00010069
SP   : 100054A0
LR   : 00016655
PC   : 1FFF1FF0
xPSR : 01000000
PSP  : 10005480
MSP  : 10007FA0
CPUID: 412FC230
HFSR : 40000000
MMFSR: 00000001
BFSR : 00000000
UFSR : 00000000
DFSR : 00000008
AFSR : 00000000
Mode : Thread
Priv : Privileged
Stack: PSP

-- MbedOS Fault Handler --



++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x5AB
Error Value: 0x1FFF1FF0
Current Thread: main  Id: 0x100034CC Entry: 0xEE6B StackSize: 0x2000 StackMem: 0x10003510 SP: 0x10007F3C 
For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF013D
-- MbedOS Error Info --
04 Feb 2019

Problem solved.

It seemed out that since mbedOS v.5.11.0 MPU has been enabled by default (this way above code worked perfectly up to <= 5.10.4). From v. 5.11.0 the MPU has to be disabled (temporarily) by creating RAII type object of class ScopedRamExecutionLock before calling iap_entry().