Thingy91: Process to flash s340 and 52840

Hi,

I have been doing my development on the 9160DK and now its time to move the code over to the thingy 91.  I managed to get the 9160 flashed by following (https://devzone.nordicsemi.com/guides/cellular-iot-guides/b/getting-started-cellular/posts/how-to-program-any-project-to-the-thingy-91-with-dfu), but the 52840 and s340 softdevice seem to be a different story.

I  tried to follow, without success:
https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_thingy91_gsg%2FUG%2Fthingy91_gsg%2Fupdating_fw.html

What I am not sure or have tried:
* Do I need to have the SWD-Select on nRF52, before I power-up (whilst holding sw4) ?  I saw one document indicating you needed to, but the above doesnt indicate you need to.  (I tried both)

* The image starts to load, but then I get the `Image Upload Failed: Bad response from device`.  I got the same error with the 9160, but by following the DFU link above, got around the problem - I am not sure how to get around it with the 52840, since I am not using zephyr.

* My 52840 software is using ANT+ therefore, I require the s340 softdevice and am using the legacy nRF5 SDK - since its not supported in zephyr.  The original way to load the s340 was with `nrfjprog` but that doesnt seem to work.

* For the 52840, do I need to use an external connection - say the 9160dk to be able to flash it ?

regards
-brett

  • Thanks for the valuable feedback, Brett!

    Brett said:
    * SW 9160 - read (fails with the error you can see a the bottom of the log)

    I’m a little bit confused here, because the log does not say nRF9160:

    2021-11-24T10:35:03.512Z INFO Using nrfjprog to communicate with target
    2021-11-24T10:35:04.420Z INFO Using J-Link Software version 6.88
    2021-11-24T10:35:05.170Z INFO Segger serial:  801036805
    2021-11-24T10:35:05.170Z INFO Segger speed:  2000  kHz
    2021-11-24T10:35:05.170Z INFO Segger version:  J-Link EDU Mini V1 compiled Feb 18 2021 11:25:23
    2021-11-24T10:35:05.171Z INFO Core probed: 801036805
    2021-11-24T10:35:05.171Z INFO Core RAM: 256KiB
    2021-11-24T10:35:05.171Z INFO Core ROM: 1024KiB in pages of 4KiB
    2021-11-24T10:35:05.291Z INFO Model: NRF52840_xxAA_REV2.
    2021-11-24T10:35:06.083Z INFO Core0: Reading device non-volatile memory. This may take a few seconds.
    2021-11-24T10:35:15.877Z INFO Core0: Non-volatile memory has been read. 4 non-empty memory blocks identified 
    2021-11-24T10:35:15.987Z INFO SoftDevice detected, id 0xCE (S340 v7.0.1)
    2021-11-24T10:35:15.990Z INFO SoftDevice detected, id 0xCE (S340 v7.0.1)
    2021-11-24T10:35:25.414Z INFO Using nrfjprog to communicate with target
    2021-11-24T10:35:26.001Z ERROR Could not fetch memory size of target devkit: Error: Error occured when get library info. Errorcode: CouldNotOpenDevice (0x4)
    Lowlevel error: JLINKARM_DLL_ERROR (ffffff9a)
    
    2021-11-24T10:38:39.050Z ERROR Unable to open log file: Could not find file at path: /Users/bdunstan/Library/Application Support/nrfconnect/pc-nrfconnect-programmer/logs/2021-11-24T04_00_30.042Z-log.txt
    2021-11-24T10:38:41.589Z ERROR Unable to open log file: Could not find file at path: /Users/bdunstan/Library/Application Support/nrfconnect/pc-nrfconnect-programmer/logs/2021-11-24T04_00_30.042Z-log.txt

    2021-11-24T10:35:05.291Z INFO Model: NRF52840_xxAA_REV2.

    Have you switched SWD SELECT (SW2) to nRF91?

    Regards,

    Markus

  • Yes the selector is on nRF91.

    When I change the switch to nRF91, and then do a read, or close/open the device or powercycle the device I always get the error:
    `2021-11-24T10:35:26.001Z ERROR Could not fetch memory size of target devkit: Error: Error occured when get library info. Errorcode: CouldNotOpenDevice (0x4) Lowlevel error: JLINKARM_DLL_ERROR (ffffff9a)`

    This only happens when I have my code loaded onto the 52840.

    regards
    -brett

  • A few more debugs:

    This is with my code on the 52840 and SW2 on nRF91:

    JLinkExe -if SWD
    SEGGER J-Link Commander V6.88a (Compiled Nov 18 2020 15:09:53)
    DLL version V6.88a, compiled Nov 18 2020 15:09:35

    Connecting to J-Link via USB...O.K.
    Firmware: J-Link EDU Mini V1 compiled Feb 18 2021 11:25:23
    Hardware version: V1.00
    S/N: 801036805
    License(s): FlashBP, GDB
    VTref=1.788V


    Type "connect" to establish a target connection, '?' for help
    J-Link>connect
    Please specify device / core. <Default>: CORTEX-M4
    Type '?' for selection dialog
    Device>?
    Specify target interface speed [kHz]. <Default>: 4000 kHz
    Speed>
    Device "NRF9160_XXAA" selected.


    Connecting to target via SWD
    ConfigTargetSettings() start
    ---Setting ROM table---
    ConfigTargetSettings() end
    ConfigTargetSettings() start
    ---Setting ROM table---
    ConfigTargetSettings() end
    ConfigTargetSettings() start
    ---Setting ROM table---
    ConfigTargetSettings() end
    ConfigTargetSettings() start
    ---Setting ROM table---
    ConfigTargetSettings() end
    Cannot connect to target.

    I then SW2 (nRF52) erased my code, put it back on the 9160 SW2 (nRF91) and did the same:

    JLinkExe -if SWD
    SEGGER J-Link Commander V6.88a (Compiled Nov 18 2020 15:09:53)
    DLL version V6.88a, compiled Nov 18 2020 15:09:35

    Connecting to J-Link via USB...O.K.
    Firmware: J-Link EDU Mini V1 compiled Feb 18 2021 11:25:23
    Hardware version: V1.00
    S/N: 801036805
    License(s): FlashBP, GDB
    VTref=1.791V


    Type "connect" to establish a target connection, '?' for help
    J-Link>connect
    Please specify device / core. <Default>: CORTEX-M33
    Type '?' for selection dialog
    Device>
    Specify target interface speed [kHz]. <Default>: 4000 kHz
    Speed>
    Device "CORTEX-M33" selected.


    Connecting to target via SWD
    Found SW-DP with ID 0x6BA02477
    SWD speed too high. Reduced from 4000 kHz to 2025 kHz for stability
    DPIDR: 0x6BA02477
    Scanning AP map to find all available APs
    AP[7]: Stopped AP scan as end of AP map has been reached
    AP[0]: AHB-AP (IDR: 0x84770001)
    AP[1]: AHB-AP (IDR: 0x24770011)
    AP[2]: JTAG-AP (IDR: 0x12880000)
    AP[3]: APB-AP (IDR: 0x54770002)
    AP[4]: JTAG-AP (IDR: 0x12880000)
    AP[5]: JTAG-AP (IDR: 0x12880000)
    AP[6]: MEM-AP (IDR: 0x128800A1)
    Iterating through AP map to find AHB-AP to use
    AP[0]: Core found
    AP[0]: AHB-AP ROM base: 0xE00FF000
    CPUID register: 0x410FD212. Implementer code: 0x41 (ARM)
    Found Cortex-M33 r0p2, Little endian.
    FPUnit: 8 code (BP) slots and 0 literal slots
    Security extension: implemented
    Secure debug: enabled
    CoreSight components:
    ROMTbl[0] @ E00FF000
    ROMTbl[0][0]: E000E000, CID: B105900D, PID: 000BBD21 Cortex-M33
    ROMTbl[0][1]: E0001000, CID: B105900D, PID: 000BBD21 DWT
    ROMTbl[0][2]: E0002000, CID: B105900D, PID: 000BBD21 FPB
    ROMTbl[0][3]: E0000000, CID: B105900D, PID: 000BBD21 ITM
    ROMTbl[0][5]: E0041000, CID: B105900D, PID: 002BBD21 ETM
    ROMTbl[0][6]: E0042000, CID: B105900D, PID: 000BBD21 CSS600-CTI
    Cortex-M33 identified.



  • Hi Markus,

    I also noticed. 

    If I have the JLinkExe connected to the 9160 and then try to connect again from the nrfConnect programmer, I get the same error, `Could not fetch memory size of target devkit: Error: Error occured when get library info. Errorcode: CouldNotOpenDevice (0x4) Lowlevel error: JLINKARM_DLL_ERROR (ffffff9a)`.

    Is there any way my code is doing something which has the same effect as this ? Be that, opening a port, clocking , UART or ?

    All of this works on the 9160DK, is there something fundamentally different between the thingy91 and 9160DK which I have not catered for ?

    regards
    -brett

  • Hey Markus,


    One more comment for today, after some testing:

    I tested each set of code individually and they work independently, I still have the issue of not being able to access the 9160 when I have my code on the 52840, but:

    52840 : (9160 is empty/erased) - receives ANT+ messages and displays them in the log

    9160 : (52840 is empty/erased) - connects to MQTT server, receives GPS and sends to MQTT

    Its only when I load them both together I am unable to test, as I cant connect to the 9160 interface for debugging.

    regards
    -brett

Related