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).

  • Yep that's pretty much it. I would then really suggest you start with the CMSIS-DAP code, it's two parts, a bit-banger on one side to talk SWD and a thin veneer intended to attach to a USB interface to get the commands. You just need to separate out the interface piece and drive it directly. That's not the most-efficient way to do it, but it's code which works, the interface is pretty clean, you just call the functions and you have a comms channel.

    I wouldn't bother too much about MEM-AP or anything else, just get the startup sequence sent and use the rest of CMSIS-DAP as written. Effectively you're calling a sequence of the CMSIS-DAP functions, and there are only a couple of 10s of them, that's the fastest to market I can think of.

Reply
  • Yep that's pretty much it. I would then really suggest you start with the CMSIS-DAP code, it's two parts, a bit-banger on one side to talk SWD and a thin veneer intended to attach to a USB interface to get the commands. You just need to separate out the interface piece and drive it directly. That's not the most-efficient way to do it, but it's code which works, the interface is pretty clean, you just call the functions and you have a comms channel.

    I wouldn't bother too much about MEM-AP or anything else, just get the startup sequence sent and use the rest of CMSIS-DAP as written. Effectively you're calling a sequence of the CMSIS-DAP functions, and there are only a couple of 10s of them, that's the fastest to market I can think of.

Children
No Data
Related