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

Upload .hex on nrf52 in Makefile

Hi,

for development i am using gcc and makefile on osx. I wanted to automate my makefile with the possibility to upload directly the hex file to my nrf52 devboard.

All Makefiles from Nordic using nrfjprog in this case, but i am running osx.

In the moment i use the following commands

nupload: upload.jlink 
$(JLINK) $(OUTPUT_BINARY_DIRECTORY)/upload.jlink

upload.jlink: echo "device $(DEVICE_NAME)\nspeed 1000\nloadbin $(PWD)/$(OUTPUT_BINARY_DIRECTORY)/nrf52832_xxaa.bin $(FLASH_START_ADDRESS)\nr\ng\nqc\n" > $(OUTPUT_BINARY_DIRECTORY)/upload.jlink

It works correctly but i am not shure if i had to enable something.

I also need a method for erasing. If i have a look on nrf51 i do not understand what

erase-all.jlink:
echo "device $(DEVICE_NAME)\nw4 4001e504 2\nw4 4001e50c 1\nw4 4001e514 1\nr\nexit\n" > $(OUTPUT_BINARY_DIRECTORY)/erase-all.jlink	

does this stand for ?

So maybe some can give me advice in correct using link to upload, recover, erase and upload soft device :)

Also if i want to use soft device how are the addresses for this in my makefile?

Bes regards, Nils

Parents
  • To erase the chip you have to enable erase and erase using the NVMC. It is documented here: infocenter.nordicsemi.com/.../Chunk208541660.html

    That would be:

    w4 4001e504 2  #CONFIG register, enable erase
    w4 4001e50c 1  #ERASEALL register
    

    To flash the softdevice you can write:

    loadbin $SOFTDEVICE 0x0  #flash in address location 0
    

    To flash the application you can write:

    loadbin $APPLICATION 0x1f000  #flash in address location 0x1f000  (s132_nrf52_1.0.0-2.alpha version)
    

    A script to erase, flash SD, flash application and reset would look something like this:

    device nrf52
    speed 1000
    w4 4001e504 2
    w4 4001e50c 1
    sleep 100
    r
    loadbin $SOFTDEVICE 0x0
    loadbin $APPLICATION 0x1f000
    sleep 100
    r
    g
    exit
    
Reply
  • To erase the chip you have to enable erase and erase using the NVMC. It is documented here: infocenter.nordicsemi.com/.../Chunk208541660.html

    That would be:

    w4 4001e504 2  #CONFIG register, enable erase
    w4 4001e50c 1  #ERASEALL register
    

    To flash the softdevice you can write:

    loadbin $SOFTDEVICE 0x0  #flash in address location 0
    

    To flash the application you can write:

    loadbin $APPLICATION 0x1f000  #flash in address location 0x1f000  (s132_nrf52_1.0.0-2.alpha version)
    

    A script to erase, flash SD, flash application and reset would look something like this:

    device nrf52
    speed 1000
    w4 4001e504 2
    w4 4001e50c 1
    sleep 100
    r
    loadbin $SOFTDEVICE 0x0
    loadbin $APPLICATION 0x1f000
    sleep 100
    r
    g
    exit
    
Children
Related