This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF51822 flash programming over SWD

Hi, I would like to program nRF51822 flash over SWD interface. I have another micro LPC1100 series that has the flash image for RF51822 and connected to nRF51822 over SWDIO and SWCLK pins. What are the steps to achieve so? Could anyone please share the details or existing implementation? or better approach which doesn't require any tools like Segger or J-Link.

Parents
  • That's not very easy. You'd need a complete, well at least a partial, implementation of the SWD protocol on the LPC1100, enough to bit bang the SWD interface on the nrf51 into responding, halting and uploading data.

    Then you'd need to write more code on the LPC1100 to drive the SWD code and do the upload, which means understanding the SWD protocol.

    CMSIS-DAP has a free source implementation of a bit banger for SWD, it's designed for use with USB but the underlying code could be used.

    This is a very hard way to do it. You'd be better off putting a bootloader on the nrf51 and using one of the serial bootloader implementations to talk to it. That means however programming the chip once with some kind of commercial programmer (or buying modules which have bootloaders on them).

  • Hi RK,

    Thanks, unfortunately, we don't plan to use any commercial programmer or have pre-flashed boot loader on the nRF51822.

    If I interpret it correctly the sequence would be

    1. initialize SWD connection between LPC100 and nrf51822 by bit banging the SWDIO/SWCLK signals (50 clock cycles, reading IDCODE register and getting ack)

    2. send commands from LPC1100 to nRF51822 to halt //Do I need to do it under MEM-AP or any other register of nRFP8122 or DP?

    3. Write routine on LPC1100 to erase flash of nRF51822 and send those to nRF51822 //Do I need to connect to MEM-AP and send those command to memory, how does the nRF51822 knows that it needs to erase the flash?

    4. Write a routine on LPC1100 to upload the data to nRF51822// Do I need to connect to MEM-AP?

    5. Write a routine on LPC1100 to reset the nRF51822 to reset after the upload? //how do I do it under SWD control?

    This are the top level sequence (what I think) which will turn into sub section of each. If you can provide any pointers that would be appreciated.

Reply
  • Hi RK,

    Thanks, unfortunately, we don't plan to use any commercial programmer or have pre-flashed boot loader on the nRF51822.

    If I interpret it correctly the sequence would be

    1. initialize SWD connection between LPC100 and nrf51822 by bit banging the SWDIO/SWCLK signals (50 clock cycles, reading IDCODE register and getting ack)

    2. send commands from LPC1100 to nRF51822 to halt //Do I need to do it under MEM-AP or any other register of nRFP8122 or DP?

    3. Write routine on LPC1100 to erase flash of nRF51822 and send those to nRF51822 //Do I need to connect to MEM-AP and send those command to memory, how does the nRF51822 knows that it needs to erase the flash?

    4. Write a routine on LPC1100 to upload the data to nRF51822// Do I need to connect to MEM-AP?

    5. Write a routine on LPC1100 to reset the nRF51822 to reset after the upload? //how do I do it under SWD control?

    This are the top level sequence (what I think) which will turn into sub section of each. If you can provide any pointers that would be appreciated.

Children
No Data
Related