0

NRF52832 Module Mass Production
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

NRF52832 Module Mass Production

by jasonterance on Tue Mar 16, 2021 7:24 am

I am using the Adafruit Feather nRF52 Bluefruit LE - nRF52832 and the Arduino IDE for development and I'm trying to move to mass production. For that reason, I got the hex file from the Arduino IDE and sent it out to a module maker (Minew) with the same chip to see if it would work and it didn't. The hex file worked perfectly fine on the Feather. The company said the module does not advertise itself, but the power consumption is high. I'm still trying to figure out the issue. My top guess is that this has something to do with the SoftDevice. However, is there anything I should know before I keep trying to send the hex file? Thank you

jasonterance
 
Posts: 9
Joined: Thu Jan 21, 2021 11:58 pm

Re: NRF52832 Module Mass Production

by reschue on Tue Mar 16, 2021 3:47 pm

When you say to "got the HEX file from the Arduino IDE", what do you mean? Was it just the linked executable that you would "upload" to a Feather board or did you send them the entire memory image (executable, Softdevice, boot loader, and UICR) like you would extract from the working Feather board with J-Link?

Rick

reschue
 
Posts: 148
Joined: Sun Jun 17, 2018 4:36 pm

Re: NRF52832 Module Mass Production

by jasonterance on Tue Mar 16, 2021 3:59 pm

reschue wrote:When you say to "got the HEX file from the Arduino IDE", what do you mean?

I am thinking that's where I messed up. I did Sketch -> Export compiled binary then went to the folder and got the hex file from there. I am thinking that parts of the entire memory image were left out and the SoftDevice was not flashed. How do I check to make sure that I have the entire memory image and not just the linked executable? Thank you!

Jason

jasonterance
 
Posts: 9
Joined: Thu Jan 21, 2021 11:58 pm

Re: NRF52832 Module Mass Production

by adafruit2 on Wed Mar 17, 2021 10:57 am

you need the bootloader and soft device as well. we dont have any tutorials or support for that - you may want to hire someone with experience in nRF52 design and coding to help with creating your product.

adafruit2
Site Admin
 
Posts: 20200
Joined: Fri Mar 11, 2005 7:36 pm

Re: NRF52832 Module Mass Production

by reschue on Wed Mar 17, 2021 11:38 am

Jason,

I think you've identified the problem. To confirm, check the .map file that was produced by the linker. It can be examined with any text editor. Look for the "Memory Configuration" section and you'll find something like this:

Memory Configuration

Name Origin Length Attributes
FLASH 0x00026000 0x00047000 xr
RAM 0x20003600 0x0000ca00 xrw
*default* 0x00000000 0xffffffff


Notice that the FLASH (code) section starts at 0x0002:6000. This is your code, and it's way up in memory.

What's missing is the boot loader code (that starts at address 0). You're also missing the SoftDevice that lives up at x0007:4000 and the UICR (at 0x1000:0000). The Adafruit bootloader hex file includes both of these.

And you're also missing the BOOTLOADER_SETTINGS record at 0x0007:F000.

So the basic floor plan of the FLASH is:
0x0000:0000
bootloader
0x0001:5XXX
gap
0x0002:6000
your sketch
0x000X:XXXX
gap
0x0007:4000
Softdevice
0x0007:8FFF
gap
0x0007:F000
bootloader_settings
gap
0x1000:1000
UICR

So here's how to fix your problem:

Rick's brute force solution: Get a Segger J-Link EDU-mini (about $20), solder a 10-pin header onto the Feather board and once you've got your program running on the Feather, extract the entire FLASH image with the J-Link (nrfprog --readcode myfile.hex). Send this file to you supplier and have them burn this into a blank nrf52832. I've done this countless times. It works.

A more sophisticated solution:
(step 1) Provide your supplier with the standard Adafruit boot loader file (found at C:\Users\...\AppData\Local\Arduino15\packages\adafruit\hardware\nrf52\0.20.5/bootloader/feather_nrf52832/feather_nrf52832_bootloader-0.3.2_s132_6.1.1.hex) and have them burn that into the FLASH along with your program.

(step 2) Provide your supplier with a dummy BOOTLOADER_SETTING image, like the one below, and have them burn that into memory as well.


:020000040007F3
:10F0000001000000FF000000C0220100000000001D
:10F01000000000000000000000000000FFFFFFFFF4
:00000001FF

The only important byte in the above string is the one highlighted in RED, that tells the Adafruit bootloader that the FLASH contains a valid program. Without this byte set to 0x01, the bootloader spins in a cycle waiting for you to download a program (it pulses the RED LED slowly from dim to bright during this time).

I tried the above using my J-Link to program the three separate files and it worked for me. The steps are:
erase the chip with nrfjprog -e
program the bootloader (nrfjprog --program bootloaderfile.hex)
program your sketch generated by the "Export compiled binary" option (nrfjprog --program yourfilename.hex)
program the BOOTLOADER_SETTINGS shown above (copy the text to a file and use nrfjprog --program bootloadersettings.hex)

One could combine all three hex files into one. Just make sure there's only one "End of File" record at the end.

Good luck.

Rick

reschue
 
Posts: 148
Joined: Sun Jun 17, 2018 4:36 pm

Re: NRF52832 Module Mass Production

by jasonterance on Wed Mar 17, 2021 2:23 pm

Thank you Rick! I am going to try the first method. I'll let you know how it goes

jasonterance
 
Posts: 9
Joined: Thu Jan 21, 2021 11:58 pm

Re: NRF52832 Module Mass Production

by reschue on Wed Mar 17, 2021 5:35 pm

Jason,

I forgot one important step in Method #1. In addition to extracting the FLASH data, you also need to extract the UICR, which is above the top of FLASH and in not included in the --readcode option. The BOOTLOADER_SETTING data is below the top of FLASH and it will be extracted properly with --readcode.

So, you need to do one more extraction with
nrfjprog --readuicr filename.hex

and then send this file along with the FLASH image to your vendor.

You could probably combine them into one by removing the end-of-file record from one file (the very last line of the hex file that is :00000001FF) and appending the other file. This makes a combined file with just one end-of-file record. Just make sure you don't accidentally change any of the data in the process.

Rick

reschue
 
Posts: 148
Joined: Sun Jun 17, 2018 4:36 pm

Re: NRF52832 Module Mass Production

by jasonterance on Wed Mar 17, 2021 7:03 pm

Hey Rick, I decided that I might as well give the 2nd method a try considering I would have to wait for the extra supplies to come in. In the process, I came across the mergehex command. Could I use that then send the one merged hex file to the company? (merging the three hex files that you mentioned into one)

https://infocenter.nordicsemi.com/pdf/nRF5x_Command_Line_Tools_v1.0.pdf
For more on the mergehex. (Page 10)

Thank you

jasonterance
 
Posts: 9
Joined: Thu Jan 21, 2021 11:58 pm

Re: NRF52832 Module Mass Production

by reschue on Wed Mar 17, 2021 8:11 pm

Sure, give it a try and see how it works. I was aware of this utilty, but being the Neanderthal that I am, I lust merged them together with a text editor. I also deleted all the lines of FF's to make the file smaller, but that's playing with fire if you screw anything up.

Rick

reschue
 
Posts: 148
Joined: Sun Jun 17, 2018 4:36 pm

Re: NRF52832 Module Mass Production

by jasonterance on Thu Mar 18, 2021 7:11 am

Looks like the mergehex command worked! Thank you so much again for your help Rick!

jasonterance
 
Posts: 9
Joined: Thu Jan 21, 2021 11:58 pm

Please be positive and constructive with your questions and comments.