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

mergehex with s310v1 and .bin generation

Hi, I need a .bin file of the whole flash memory for production programming. The procedure I have used until now (with s310v2) was the following:

  1. Upload .hex file of firmware with nrfgo;
  2. Upload .hex file of softdevice with nrfgo;
  3. Download the whole memory in a .hex file with nrfjprog;
  4. Convert the .hex file to a .bin with hex2bin.

Now it happens that s310v1 has readback protection enabled (s310v2 doesn't have that). So reading back the flash memory is not possible. I have tried the following solutions, with bad results:

  • Using mergehex for generating a unique .hex file to convert in .bin -> hex2bin complains about "overlapped records" (probably the UICR registers?), and the generated .bin file doesn't work as expected (infinite reboots)
  • Trying to tweak the softdevice .hex file by removing the definition in the 0x10001000 and 0x10000010 addresses (s310v2 leaves those addresses untouched) -> firmware doesn't work as expected, nrfgo complains about softdevice
  • Trying to download a .bin image with segger Jlink tool -> generates a .bin file which doesn't work when downloaded again to the flash memory

Is there another workaround for this problem?

Parents
  • You can use objcopy, the standard binutils utility, with the --remove-section (-R). --gap-fill and --pad-to to make 3 separate bin files, one from 0x00000000 to 0x1FFFF, 1 byte before the start of program code with the first 2 sections in the softdevice hex file (ie remove section 3), a file from from 0x20000 to 0x10000FFF with the program code, and one from 0x10001000 to 0x10001018 with the third section of the softdevice (ie remove sections 1 and 2). Then you just cat them together and you have one long bin file you can use.

    I believe the sections are called '.sec1' and '.sec2' and '.sec3'

    The first piece for instance would look like this

    objcopy -Iihex -Obinary -R .sec3 --gap-fill=0xff --pad-to=0x20000 s310_nrf51422_1.0.0_softdevice.hex s310_nrf51422_1.0.0_softdevice.1.bin
    

    the rest are similar

Reply
  • You can use objcopy, the standard binutils utility, with the --remove-section (-R). --gap-fill and --pad-to to make 3 separate bin files, one from 0x00000000 to 0x1FFFF, 1 byte before the start of program code with the first 2 sections in the softdevice hex file (ie remove section 3), a file from from 0x20000 to 0x10000FFF with the program code, and one from 0x10001000 to 0x10001018 with the third section of the softdevice (ie remove sections 1 and 2). Then you just cat them together and you have one long bin file you can use.

    I believe the sections are called '.sec1' and '.sec2' and '.sec3'

    The first piece for instance would look like this

    objcopy -Iihex -Obinary -R .sec3 --gap-fill=0xff --pad-to=0x20000 s310_nrf51422_1.0.0_softdevice.hex s310_nrf51422_1.0.0_softdevice.1.bin
    

    the rest are similar

Children
No Data
Related