Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 5 months ago.
Failed to read hex file - problem with uploading nRF51 bed hex to production hardware.
We are trying to get an mBed-compiled hex file uploaded to production hardware but it is throwing the error "failed to read hex file".
The code is compiled for the nRF51-DK target and the production chipset is the nRF51822. We are using a Segger J-Link to upload to the board.
The app uses the BLE soft device (incase this matters).
I've read problems related to not getting the code to run due to getting the internal/external clock settings wrong (especially with running BLE code).
I've not seen problems related to just not being able to read the hex file on 1st instance... Any ideas would be massively appreciated.
Have I selected the wrong target for the compiler? I noticed the nRF51-DK board is actually an nRF51422 and we are using an nRF51822 chip...
UPDATE: Other dumb things I may have done: - I changed the .hex filename after it was compiled - I may have opened the .hex in Mac OS and then saved it again (possibly ruining encoding)....
posted by CJ Shaw 13 Jun 2016PROBLEM SOLVED: For anyone who has a similar problem in the future here's my adventure. The particular solution is in 4th paragraph after this, but the other tests may help other situations:
Following guidance found on other similar questions and mainly help from my knowledgable friend, I found-out that this particular error indicates that something is wrong with the format/data inside the hex file itself, it's nothing (usually) to do with the code, compiler or compiler settings. If a valid hex file was presented, even if it was nonsense data, it would normally get uploaded.
So, I checked to see if the hex file was indeed a properly-formatted "Intel HEX" file. The file was all OK. It wasn't raw binary data in disguise or a badly formatted/encoded hex or anything. It was all legit.
I then copied the factory's exactly software setup & tested myself. They are using nRFgo Studio to upload to chips via Segger J-Link devices. Fortunately the nRF51-DK board I was using can behave as an mbed or a J-Link uploader depending on what firmware you put on it. So I tested myself, with latest nRFgo Studio, and it worked just fine.
Next I scoured Nordic's site for help with nRFgo Studio, seeing if there are some settings it could get wrong. Then I found that with version 1.12.1 and above the "Fixed an issue related verification of large hex files". I thought this had to be it. I instructed the factory to check & update their nRFgo Studio software and........ IT WORKED!!!
Problem solved. It was due to the uploader software (nRFgo) incorrectly panicking when it tried to verify the hex file before uploading to the nRF51822 device.
It's yet to be seen how well the abed-compiled code runs on the custom hardware, but at least it's possible to test now.
Hope this helps someone in the future. Chris
posted by CJ Shaw 15 Jun 2016