Programming a custom board with an NRF52840 dev kit

Hi,

I've made my own PCB with an nrf52840. Right now I'm hoping to test out the bluetooth and measure my board's power consumption - the only problem is that I can't reliably program the microcontroller! A long time ago I was able to program this device with ble_app_blinky so I know the bluetooth works - unfortunately, right now I keep running into JLink errors. The specific setup/issues are listed below:

Right now I'm trying to program my custom board/NRF with 2 example projects: blinky and ble_app_blinky. To do so, I've setup the boards as in the diagram below:

I am powering my custom board with an external supply set to 3.3V (the current limit is set to 3A so we should have more than enough juice) and the dev kit is "powered on" and plugged into my laptop via the uart/usb programming port (the left most usb port on the diagram). With this setup I can reliably program my custom board with the normal blinky program. Unfortunately, when I try to build&debug on my board with ble_app_blinky I get the following error:


Preparing target for download
Executing Reset script TargetInterface.resetAndStop()
Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading ‘s140_nrf52_7.0.1_softdevice.hex’ to J-Link
Programming 2.7 KB of addresses 00000000 — 00000aff
Programming 149.3 KB of addresses 00001000 — 00026597
Failed to download application.
Error during program/erase phase.
Please check J-Link and target connection.
Download failed

sometimes when I "build & run" directly I get a slightly different error:

Reset: Halt core after reset via DEMCR.VC_CORERESET.
Reset: Reset device via AIRCR.SYSRESETREQ.
Downloading ‘s140_nrf52_7.0.1_softdevice.hex’ to J-Link
Programming 2.7 KB of addresses 00000000 — 00000aff
Programming 149.3 KB of addresses 00001000 — 00026597
J-Link: Flash download: Bank 0 @ 0x00000000: 2 ranges affected (4096 bytes)
J-Link: Flash download: Total: 0.652s (Prepare: 0.172s, Compare: 0.027s, Erase: 0.170s, Program & Verify: 0.106s, Restore: 0.175s)
J-Link: Flash download: Program & Verify speed: 37 KiB/s
Failed to download application.
Error during program/erase phase.
Please check J-Link and target connection.
Download failed

I'm using the latest version of the sdk (v17) and s140. To program my board I'm using SES. I have done all my development so far with the nrf52840 dk (PCA10056) and I figured I could use the same example files. Do I have to change the starting/stopping memory locations for programming? If not, does anyone have any suggestions for further log/debug steps I can proceed with?

I beseech the Nordic (company) gods.

Thank you,

Ryan

Parents
  • hen I try to build&debug on my board with ble_app_blinky I get the following error:

    looks like the board might be resetting during the session. 

    If you do not use the debug function does it work ?

    It is a vary strange cease, only ble_app_blinky?, could you test a --recover command to whip the chip? No other BLE samples have this issue?

    Regards,
    Jonathan

  • Hi Jonathan,

    Thanks for getting back to me!

    looks like the board might be resetting during the session. 

    I saw this vaguely mentioned in a few other posts but those situations seemed to be related to faulty USB ports, low voltages, or faulty connections. I can try another usb port today but I think I tried this out yesterday and it didn't change anything. Is there a flag I should toggle in SES?

    If you do not use the debug function does it work ?

    No, unfortunately. I usually get the same error - sometimes it looks different (the second code block), but it usually looks like the first error (first code block).

    It is a vary strange cease, only ble_app_blinky?, could you test a --recover command to whip the chip? No other BLE samples have this issue?

    I'm glad it's not just me! I can try other ble examples. Is it possible to use the "recover" command in SES? If so, how? hahaha. 

    Edit:

    I've tried out a few more examples, their results are listed below:

    1) simple_timer: works

    2) ble_beacon: Does NOT work - similar error

    3) ble_app_alert_notification: Does NOT work - similar error

    4) blinky_rtc_freeRTOS: Does NOT work - similar error

    So it seems that larger programs (that may/may not include soft device) cause it to break while programming. Right now the external board is drawing around 110 mA at 3.3V and the dev kit is connected to my macbook pro (with a USB-C to USB hub as an adaptor). If I try to power the external boards with 3V (which I thought I saw somewhere) it ends up bricking the chip (I keep getting "No idcode detected" which I guess is another problem).

    Also I've found the board that I know has a functioning NRF52840 & antenna so I can rule out any potential board manufacturing issues.

    Also thanks for your prompt response, Jonathan. I'm really lost and this is incredibly frustrating. I can't tell you how much I appreciate you helping me with this.

    Kindest regards,

    Ryan

  • Hi Ryan, 

    Still uncertain what is the cause of the issue you have here, but i have some things that i want you to test and some more questions.

    Are the interface wires you use longer then 10 cm?

    Reduce the clock speed: Here si a post on SEGGER Forum on how to do that https://forum.segger.com/index.php/Thread/7445-SOLVED-Configure-SWD-speed-in-Embedded-Studio/ 

    Sett current limit to 100mA, 3A is a lott and we dont want to burn the SoC. 

    Did you change the external supply from 3.3V to 3V and that bricked the chip?

    Can you try to use nrfjprog or nrf connect for desktop programmer app to erase\recover. 

    Do you have any other HW related issues with the custom board?

    Do you have the a LFXO on the custom board?

    If you measure VDD_NRF on the DK, what is the voltage you see ?

    Regards,
    Jonathan

Reply Children
  • So while I was going through these I think I found a mistake. When I unplugged the external supply (so that the dev kit was powering my custom board with vdd_nrf), things started to work! Not fully though...

    To summarize my current setup for anyone else who may see this, I followed the diagram in my original post: connected my custom board to the dev kit's VDD_nrf, GND, SWDIO, SWDCLK & plugged GND_Connect and VTG to VSS and VDD_nrf, respectively. I did NOT power my custom board (it's only being powered from the dev kit) and the dev kit is plugged into my computer.

    My current roadblock: When I do this, I can "Debug & Run" the ble examples and they work. BUT if I just "run" them they don't work. Also if I programmed my board with "Debug & Run" and then power cycle the board, my custom board no longer seems to run the program. Is there something extra I have to do to "run" programs on the nrf?

    To answer your other questions (even if they may not be relevant anymore):


    1) The interface wires are about 10cm actually. Should they be shorter?
    2) I'm still running at the default clock speed, I can reduce it if you think it will help the current problem.
    3) I've reduced the current limit to 100mA!
    4) Yes, reducing the external supply to 3V results in a bricked chip. 
    5) I will try nrf connect to erase/recover. Can I run nrf connect with the same setup?
    6) No other HW problems that I know of right now.
    7) I do have a dedicated crystal for my custom board's nrf52840. 
    8) After I bricked the chips I looked at VDD_nrf on the DK and it was at 3.3V I believe. I will double-check this to confirm (I should have double-checked this before I started messing with the external supply ... I guess I've learned the hard way.)

    Thanks so much for your help, Jonathan! If you feel that this ticket has spiraled a little bit, I can close this and start a new ticket. In fact, we can ignore the bricking issue going forward and I can start another ticket for that.

    Kindest regards,

    Ryan

  • Thanks for the update Ryan,

    Nice to see some progression!

    ryerye120 said:
    1) The interface wires are about 10cm actually. Should they be shorter?

    This is ok, 10cm should be fine, but long cables can introduce extra parasitic resistive and capacitive properties that might interfere, so to keep things predictable its good to have short cables.

     

    ryerye120 said:
    2) I'm still running at the default clock speed, I can reduce it if you think it will help the current problem.

    Lets keep this on hold for now.


    ryerye120 said:
    3) I've reduced the current limit to 100mA!

    Great!


    ryerye120 said:
    4) Yes, reducing the external supply to 3V results in a bricked chip. 

    This is interesting, but deserves its own ticket. 


    ryerye120 said:
    5) I will try nrf connect to erase/recover. Can I run nrf connect with the same setup?

    Yes, it is just a desktop app that you can easily use to test certain things and use features we develop for ease of use. 

    Connect the device to your computer, then launch the app and click on the select device button top right and select you device, you can then READ the device and it will show what i looks like, you can save this file for later to program the same device or other without building the code again, just use the hex file. 

    There are many options here, Read, Write, Erase, Erase and write and Reset. All  handy for testing and debugging. 




    ryerye120 said:
    6) No other HW problems that I know of right now.

    Good to know.


    ryerye120 said:
    7) I do have a dedicated crystal for my custom board's nrf52840. 

    This eliminates some potential issues, but i need to know it is the HFXO or LFXO, so do you have only one crystal or two ?



    ryerye120 said:
    8) After I bricked the chips I looked at VDD_nrf on the DK and it was at 3.3V I believe. I will double-check this to confirm (I should have double-checked this before I started messing with the external supply ... I guess I've learned the hard way.)

    You are not the first, guilty of this myself :D



    Now for the roadblock you have, we can continue discussing this here i think. I can do a review of the schematic and board layout files, see if i see any things that could be a issue. If you dont want to share design public i can make this ticket private, or you can just make a new ticket that is private and refer to this ticket in the new review ticket. 


    One thing i am interested in knowing is what do you gett if you Read the custom pcb device with nRF connect programmer app... this will show if it has been programmed correctly. 

    Regards,
    Jonathan

  • Hi Jonathan,


    Now for the roadblock you have, we can continue discussing this here i think. I can do a review of the schematic and board layout files, see if i see any things that could be a issue. If you dont want to share design public i can make this ticket private, or you can just make a new ticket that is private and refer to this ticket in the new review ticket. 

    I don't mind posting the schematics here!

    Firstly, when I plug my boards into the nrf connect programmer, I can only see the dev kit (that I'm using to program my custom board). Is there something specific I need to do to see the downstream microcontroller (the one on my custom PCB)?

    Secondly, while looking at other threads I came across this one describing a similar error but on a different chip. It turns out that when I comment out "idle_state_handle()" I can build & run!! Problem is ... well I don't know what the problem is normally. Why does idle_state_handle() break the code? I don't think it has anything to do with my custom PCB's power planes since I'm still just powering the custom board with the dev kit (which is connected to my computer with a usb cable).

    We're getting close! I can almost taste it.

    Kindest regards,

    Ryan

  • ryerye120 said:
    Firstly, when I plug my boards into the nrf connect programmer, I can only see the dev kit (that I'm using to program my custom board). Is there something specific I need to do to see the downstream microcontroller (the one on my custom PCB)?

    This is the expected behaviour, It is the debugger/programmer chip that is shown. 


    I dont quite see what could be the issue with idle_state_handle(), is it only for the ble_app_blinky you have tested this? any other changes you do to the applicaton?

    I think i will take a look at the HW and schematics first and then we can go from there. Can you provide them as PDF and if you have the HW files as GERBER that would be fantastic. 

    Regards,
    Jonathan

  • This is the expected behaviour, It is the debugger/programmer chip that is shown.

    I've only tested this with ble_app_blinky so far. I made 2 changes, 1 was commenting out idle_state_handle() and the other was to the pinout of LED4 (because that is different between the dev kit and my pcb). I will try another example! 

    I am working on getting the gerbers - in the meantime here are pdfs of the schematic and layout. This board is meant to test a custom IC that our research group designed, the nrf52840 is in the top left of the board.

    Thanks again for your help!!

    board_schematic.pdfboard_layout.pdf

Related