🎁📬❄️📦 Holiday Shipping Deadlines are approaching! International customers and domestic ground - get your orders in 12/9/2020 📦❄️📬🎁

Procedure for programming blank NRF51822 modules
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Procedure for programming blank NRF51822 modules

by crthomas24 on Wed Sep 23, 2020 6:06 pm


I'm currently working on a project that includes a NRF51822 BTLE module that is soldered down to a custom PCBA. As is made clear on the product page, the standalone module comes unprogrammed. I'm interested in how and when during the production process Adafruit programs their blank modules that are loaded on to boards such as the Bluefruit Shield and the Bluefruit SPI Friend.

Some background: the custom board I'm working with replicates the circuitry connected to the NRF51822 on the Bluefruit Shield, including the level shifter on the SPI bus and the 5V/3.3V level shifter on the SWDIO/RST pin. These are connected to a ATMEGA328 MCU. It does not include an external clock. I have also verified that the 3.3V rail is good. My goal is to load the adafruit bootloader, soft device, and SPIFriend firmware on to the module on this custom PCBA.

When I tried to connect to an NRF51822 module via the SDWIO/SWCLK interface via a JLINK programmer, both Adalink and NordicSemi's NRFgo software couldn't see the device. I tried removing the FET and resistor on the SWDIO/RST pin, and after doing so NRFgo was able to see and program the module. Adalink was still unable to communicate with the module. However, despite verifying the hex was written correctly from NRFgo, I can't get the device to turn on in DFU mode which is my first test of if the adafruit firmware is loaded and running.

So, my question is this - is it expected that the level shifting FET/resistor on the SWDIO/RST pin would prevent the device from being programmed through the SWIO interface? If so, how does adafruit load their code on to the modules? Additionally, why would adalink be unable to see the device if NRFgo software seems to see it fine? I have verified the JLINK executables are in the system path and all dependencies are installed so I don't think it's a software issue.

Any help would be super appreciated. Thanks!

Posts: 1
Joined: Wed Sep 23, 2020 5:49 pm

Re: Procedure for programming blank NRF51822 modules

by fe7565 on Tue Oct 20, 2020 1:04 pm

In the overview for the module. Need to read it thoroughly:

https://learn.adafruit.com/adafruit-fea ... aq-2346709

How do I reflash my Bluefruit LE module over SWD?
Reflashing Bluefruit LE modules over SWD (ex. switching to the sniffer firmware and back) is at your own risk and can lead to a bricked device, and we can't offer any support for this operation! You're on your own here, and there are unfortunately 1,000,000 things that can go wrong, which is why we offer two separate Bluefruit LE Friend boards -- the sniffer and the normal Bluefruit LE Friend board with the non-sniffer firmware, which provides a bootloader with fail safe features that prevents you from ever bricking boards via OTA updates.

AdaLink (SWD/JTAG Debugger Wrapper)

Transitioning between the two board types (sniffer and Bluefruit LE module) is unfortunately not a risk-free operation, and requires external hardware, software and know-how to get right, which is why it isn't covered by our support team.

That said ... if you're determined to go down that lonely road, and you have a Segger J-Link (which is what we use internally for production and development), or have already erased your Bluefruit LE device, you should have a look at AdaLink, which is the tool we use internally to flash the four files required to restore a Bluefruit LE module. (Note: recent version of AdaLink also support the cheaper STLink/V2, though the J-Link is generally more robust if you are going to purchase a debugger for long term use.)

The mandatory Intel Hex files are available in the Bluefruit LE Firmware repo. You will need to flash:

An appropriate bootloader image
An appropriate SoftDevice image
The Bluefruit LE firmware image
The matching signature file containing a CRC check so that the bootloader accepts the firmware image above (located in the same folder as the firmware image)
The appropriate files are generally listed in the version control .xml file in the firmware repository.

If you are trying to flash the sniffer firmware (at your own risk!), you only need to flash a single .hex file, which you can find here. The sniffer doesn't require a SoftDevice image, and doesn't use the fail-safe bootloader -- which is why changing is a one way and risky operation if you don't have a supported SWD debugger.


We also have an internal python tool available that sits one level higher than AdaLink (referenced above), and makes it easier to flash specific versions of the official firmware to a Bluefruit LE module. For details, see the Adafruit_nRF51822_Flasher repo.

Posts: 15
Joined: Thu Apr 02, 2020 6:04 pm

Please be positive and constructive with your questions and comments.