Central mode get wrong device mac address.

SDK:nRF5_SDK_17.1.0_ddde560

example: ble_app_multilink_central

softdevice: s140_nrf52_7.2.0

PCB: PCA10059 as Cental

My peripheral device's mac is 00:96:81:16:E0:9F (checked by pc software and device self printf)

But when i print p_gap_evt->params.adv_report.peer_addr.addr[0]~[5], it shows 81:16:E0:94:02:18

And I checked memory as below pic.

How can i fix this? kind like data structure problem?

I also tried nRF5_SDK_12.3.0_d7731ad \ble_central\ble_app_uart_c with nrf51422 (PCA10028), it can print correct mac address.

Thanks for any help :D

  • Hi,

    I assum the peripheral is using a static address so that you know what to expect? I notice that the addr_type value is invalid as well, so I wonder if something has corrupted this data somehow. Have you made any changes to the ble_app_multilink_central example? Can you explain what those changes are? Are you ablet o reproduce this issue without your changes (if any)?

  • Hi, thanks for reply. I did combine USB and LED fuction. 

    So I download and unzip nRF5_SDK_17.1.0_ddde560.zip make sure all clean. And open ble_app_multilink_central as attached file.

    Here's my change:

    1. Set Optimization to Level 0
    2. Change define BOARD_PCA10056 to BOARD_PCA10059
    3. Change m_target_periph_name[] to my device name.
    4. Add NRF_LOG_INFO("MAC %02X:%02X:%02X:%02X:%02X:%02X \r\n", p_gap_evt->params.adv_report.peer_addr.addr[0], at case BLE_GAP_EVT_CONNECTED:

    Than I test 2 different devices, 1 is made with ST bluenrg-lp and the other is Nordic 52832.

    And still can't get the correct mac address :(

    Any idea?

    8688.ble_app_multilink_central.zip

  • Hi,

    I don't see any issues in the code here or your changes. I notice you are using Keil which I have not been able to test, but I have some questions:

    • Which version of Keil are you using?
    • Do you only see this with optimization level 0?
    • Can you build the project with Segger Embedded Studio version 5.42a (this is the version used with the nRF5 SDK 17.1.0 release test) to see if you can reproduce the issue there?
    • I assume you are using an external debugger as the nRF52840 dongle does not have an onboard debugger, or are you testing on a different board (the DK for instance)?

    The backtround for these questions is that it the address type as well as the address are invalid, so I wonder if there could be a stack overflow or similar corrupting the memory. Can you try to increase the stack size and see if that helps?

  • Hi, 

    • Which version of Keil are you using?
      • uVision 5.28
    • Do you only see this with optimization level 0?
      • debug mode only work well with level 0. I tried level 3 and print mac to usb, still got wrong mac as level 0.
    • Can you build the project with Segger Embedded Studio version 5.42a (this is the version used with the nRF5 SDK 17.1.0 release test) to see if you can reproduce the issue there?
      • This need take some time to get everything work, will try it next few days.
    • I assume you are using an external debugger as the nRF52840 dongle does not have an onboard debugger, or are you testing on a different board (the DK for instance)?
      • I connect PCA10059 with PCA10028 as picture.
    • The backtround for these questions is that it the address type as well as the address are invalid, so I wonder if there could be a stack overflow or similar corrupting the memory. Can you try to increase the stack size and see if that helps?
      • How to increase stack size?
      • Now my IRAM1: 0x200043A8 0x3BC58, I tried 0x20010000 0x30000 doesn't help.

  • Hi,

    I see. In Keil projects, the easiest way to adjust the stack size is to modify modules/nrfx/mdk/arm_startup_nrf52840.s and where you have a line starting with "Stack_Size EQU", modify the number to a higher value. Alternatively, it should work to go to Options for Target -> C/C++ -> Preprocessor Symbols  and define __STACK_SIZE to the value you want. (The stack size may not be the issue here, but it is worth increasing it to check).

Related