2022-01-07 10:29:58 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2020-09-28 20:03:37 +00:00
|
|
|
# You probably don't want to use this script, it programs a custom bootloader build onto a nrf52 board
|
|
|
|
|
2020-09-28 22:18:32 +00:00
|
|
|
set -e
|
|
|
|
|
2020-10-15 05:47:10 +00:00
|
|
|
# dependencies
|
|
|
|
# apt install srecord
|
|
|
|
|
2020-09-28 20:03:37 +00:00
|
|
|
BOOTDIR=/home/kevinh/development/meshtastic/Adafruit_nRF52_Bootloader
|
2020-10-15 05:47:10 +00:00
|
|
|
BOARD=othernet_ppr1
|
|
|
|
BOOTVER=0.3.2
|
2020-10-28 05:01:50 +00:00
|
|
|
BOOTNUM=128
|
|
|
|
BOOTSHA=gc01b9ea
|
|
|
|
SDCODE=s113
|
|
|
|
SDVER=7.2.0
|
2020-10-15 05:47:10 +00:00
|
|
|
PROJ=ppr1
|
|
|
|
|
2020-10-28 05:01:50 +00:00
|
|
|
# FIXME for nRF52840 use 0xff000, for nRF52833 use 0x7f000
|
2020-10-15 05:47:10 +00:00
|
|
|
BOOTSET=0x7f000
|
2020-09-28 20:03:37 +00:00
|
|
|
|
|
|
|
nrfjprog --eraseall -f nrf52
|
|
|
|
|
|
|
|
# this generates an intel hex file that can be programmed into a NRF52 to tell the adafruit bootloader that the current app image is valid
|
|
|
|
# Bootloader settings are at BOOTLOADER_SETTINGS (rw) : ORIGIN = 0xFF000, LENGTH = 0x1000
|
|
|
|
# first 4 bytes should be 0x01 to indicate valid app image
|
|
|
|
# second 4 bytes should be 0x00 to indicate no CRC required for image
|
|
|
|
echo "01 00 00 00 00 00 00 00" | xxd -r -p - >/tmp/bootconf.bin
|
2020-10-15 05:47:10 +00:00
|
|
|
srec_cat /tmp/bootconf.bin -binary -offset $BOOTSET -output /tmp/bootconf.hex -intel
|
2020-09-28 20:03:37 +00:00
|
|
|
|
2020-10-28 05:01:50 +00:00
|
|
|
echo Generating merged hex file from .pio/build/$PROJ/firmware.hex
|
|
|
|
mergehex -o ${BOARD}_full.hex -m $BOOTDIR/_build/build-$BOARD/${BOARD}_bootloader-$BOOTVER-$BOOTNUM-$BOOTSHA-dirty_${SDCODE}_$SDVER.hex .pio/build/$PROJ/firmware.hex /tmp/bootconf.hex
|
2020-09-28 20:03:37 +00:00
|
|
|
|
|
|
|
echo Telling bootloader app region is valid and telling CPU to run
|
2020-10-15 05:47:10 +00:00
|
|
|
nrfjprog --program ${BOARD}_full.hex -f nrf52 --reset
|
2020-09-28 20:03:37 +00:00
|
|
|
|
|
|
|
# nrfjprog --readuicr /tmp/uicr.hex; objdump -s /tmp/uicr.hex | less
|