ARMmbed / mbed-os-example-nfc

Examples of NFC use with Mbed OS
Apache License 2.0
4 stars 20 forks source link

[5.14-OOB] mbed-os-example-nfc\NFC_SmartPoster failed when building with GCC_ARM compiler #45

Closed korjaa closed 5 years ago

korjaa commented 5 years ago

Board: DISCO_L475VG_IOT01A Build command: mbed compile -m DISCO_L475VG_IOT01A -t GCC_ARM --flash --clean Log output:

++ MbedOS Fault Handler ++

FaultType: HardFault

Context:
R0   : 200029C0
R1   : 00000000
R2   : 08001F79
R3   : 00000000
R4   : 00000000
R5   : 0801344C
R6   : 0801343C
R7   : 200021B4
R8   : 0801341C
R9   : 00000000
R10  : 00000000
R11  : 00000000
R12  : 00000000
SP   : 20002190
LR   : 080008B3
PC   : 08001EC8
xPSR : 210F0000
PSP  : 20002128
MSP  : 10007FC0
CPUID: 410FC241
HFSR : 40000000
MMFSR: 00000082
BFSR : 00000000
UFSR : 00000000
DFSR : 00000008
AFSR : 00000000
MMFAR: 00000070
Mode : Thread
Priv : Privileged
Stack: PSP

-- MbedOS Fault Handler --

++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x8000B33
Error Value: 0x8001EC8
Current Thread: main  Id: 0x20001A24 Entry: 0x8006FCB StackSize: 0x1000 StackMem: 0x20001A68 SP: 0x10007F58 
For more info, visit: https://armmbed.github.io/mbedos-error/?error=0x80FF013D
-- MbedOS Error Info --

= System will be rebooted due to a fatal error =
= Reboot count(=1) reached maximum, system will halt after rebooting =

crash_dump analysis

Crash Info:
    Crash location = mbed::nfc::NFCController::start_discovery() [0x08001EC8] (based on PC value)
    Caller location = main [0x080008B3] (based on LR value)
    Stack Pointer at the time of crash = [20002190]
    Target and Fault Info:
        Processor Arch: ARM-V7M or above
        Processor Variant: C24
        Forced exception, a fault with configurable priority has been escalated to HardFault
        Data access violation. Faulting address: 00000070

addr2line

$ arm-none-eabi-addr2line -e BUILD/DISCO_L475VG_IOT01A/GCC_ARM/NFC_SmartPoster.elf -a 0x080008B3
0x080008b3
mbed-os-example-nfc/NFC_SmartPoster/./main.cpp:174
korjaa commented 5 years ago

Updating to mbed-os-5.14.0-rc2 still fails on HardFault

++ MbedOS Fault Handler ++

FaultType: HardFault

Context:
R0   : 20002A88
R1   : 00000000
R2   : 08001EF9
R3   : 00000000
R4   : 00000000
R5   : 08013590
R6   : 08013580
R7   : 200022F4
R8   : 08013560
R9   : 00000000
R10  : 00000000
R11  : 00000000
R12  : 00000000
SP   : 200022D0
LR   : 080008C7
PC   : 08001E3C
xPSR : 210F0000
PSP  : 20002268
MSP  : 10000648
CPUID: 410FC241
HFSR : 40000000
MMFSR: 00000082
BFSR : 00000000
UFSR : 00000000
DFSR : 00000008
AFSR : 00000000
MMFAR: 00000070
Mode : Thread
Priv : Privileged
Stack: PSP

-- MbedOS Fault Handler --

++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0x8006073
Error Value: 0x8001E3C
Current Thread: main  Id: 0x20001120 Entry: 0x8006F6B StackSize: 0x1000 StackMem: 0x20001B30 SP: 0x100005E0 
For more info, visit: https://mbed.com/s/error?error=0x80FF013D&tgt=DISCO_L475VG_IOT01A
-- MbedOS Error Info --

= System will be rebooted due to a fatal error =
= Reboot count(=4) reached maximum, system will halt after rebooting
maciejbocianski commented 5 years ago

@jamesbeyond

Tharazi97 commented 5 years ago
nfc_err_t ret = nfc_process.init();
printf("Initialize: ret = %u\r\n", ret);

@korjaa What do these lines of code return in your run?

korjaa commented 5 years ago

Ah, sorry to not include the top part of the log.

Initialize: ret = 16
Tharazi97 commented 5 years ago

I got that return value when I was trying to reproduce this problem, but didn't connect the PN512 shield.

Tharazi97 commented 5 years ago

@korjaa Did you connect PN512 shield to your device?

korjaa commented 5 years ago

Ooo, that's most likely it. I only tried with the DISCO board as the other NFC example worked well with it without additional hardware.

Tharazi97 commented 5 years ago

Do you have that shield on your side? Can you test it with it?

korjaa commented 5 years ago

Unfortunately I couldn't find any PN512 shields from the office.

jamesbeyond commented 5 years ago

without shield would be a main cause to the initialization hard-fault

korjaa commented 5 years ago

I'm thinking should we add a note to the readme.md that unlike the EEPROM example, this example doesn't work with DISCO_L475VG_IOT01A.

I'm not so familiar with NFC, are there any technical limitations why this example shouldn't work with DISCO_L475VG_IOT01A?

Tharazi97 commented 5 years ago
Requirements
Verification of the sample application can be seen on any a smartphone with an NFC reader. After running you will be able to read the tag with an NFC tag reader application.

This example is known to work on boards connected to a PN512 shield.
NFCProcess(events::EventQueue &queue) :
        _pn512_transport(D11, D12, D13, D10, A1, A0),
        _pn512_driver(&_pn512_transport),
        _queue(queue),
        _ndef_buffer(),
        _nfc_controller(&_pn512_driver, &queue, _ndef_buffer)

SmartPoster example uses PN512 shield. The class created in it is based on this shield drivers. EEPROM example uses M24SR, or probably PN512, so it doesn't need a shield because DISCO_L475VG_IOT01A has it on board.

Tharazi97 commented 5 years ago

Maybe we should change the body of main function in this example to something like this.

int main()
{
    events::EventQueue queue;
    NFCProcess nfc_process(queue);

    nfc_err_t ret = nfc_process.init();
    printf("Initialize: ret = %u\r\n", ret);
    MBED_ASSERT(ret == NFC_OK);

    ret = nfc_process.start_discovery();
    printf("Start Discovery: ret = %u\r\n", ret);
    MBED_ASSERT(ret == NFC_OK);

    queue.dispatch_forever();

    return 0;
}
jamesbeyond commented 5 years ago

The example itself is working fine with the shield correctly connected, Here is an update on the readme #50