diff --git a/firmware/build.sh b/firmware/build.sh index 907a2249..11511037 100755 --- a/firmware/build.sh +++ b/firmware/build.sh @@ -60,15 +60,19 @@ set -xe --merge \ settings.hex \ application.hex \ - --output application.hex - rm settings.hex + --output application_merged.hex mergehex \ --merge \ bootloader.hex \ - application.hex \ + application_merged.hex \ softdevice.hex \ --output fullimage.hex - zip ${device_type}-binaries.zip *.hex + tmp_dir=$(mktemp -d -t cu_binaries_XXXXXXXXXX) + cp *.hex "$tmp_dir" + mv $tmp_dir/application_merged.hex $tmp_dir/application.hex + rm $tmp_dir/settings.hex + zip -j ${device_type}-binaries.zip $tmp_dir/*.hex + rm -rf $tmp_dir ) diff --git a/firmware/flash-dfu-app.sh b/firmware/flash-dfu-app.sh index 67483b64..94fb7a98 100755 --- a/firmware/flash-dfu-app.sh +++ b/firmware/flash-dfu-app.sh @@ -1,5 +1,9 @@ #!/bin/bash +if [[ $BASH_SOURCE = */* ]]; then + cd -- "${BASH_SOURCE%/*}/" || exit +fi + if ! ../resource/tools/enter_dfu.py; then echo "Wait for device to be off" echo "Press B and plug" @@ -9,4 +13,19 @@ while :; do lsusb|grep -q 1915:521f && break sleep 1 done -nrfutil device program --firmware objects/dfu-app.zip --traits nordicDfu + +device_type=ultra +lsusb | grep 1915:521f | grep -q ChameleonLite && device_type=lite + +echo "Flashing $device_type" + +dfu_package=objects/${device_type}-dfu-app.zip + +if [ ! -f $dfu_package ]; then + echo "DFU package for $device_type not found, aborting." + echo "Build firmware using CURRENT_DEVICE_TYPE=$device_type firmware/build.sh" + exit 1 +fi + +nrfutil device program --firmware $dfu_package --traits nordicDfu + diff --git a/firmware/flash-dfu-full.sh b/firmware/flash-dfu-full.sh index a974f215..0015f859 100755 --- a/firmware/flash-dfu-full.sh +++ b/firmware/flash-dfu-full.sh @@ -1,5 +1,9 @@ #!/bin/bash +if [[ $BASH_SOURCE = */* ]]; then + cd -- "${BASH_SOURCE%/*}/" || exit +fi + if ! ../resource/tools/enter_dfu.py; then echo "Wait for device to be off" echo "Press B and plug" @@ -9,4 +13,19 @@ while :; do lsusb|grep -q 1915:521f && break sleep 1 done -nrfutil device program --firmware objects/dfu-full.zip --traits nordicDfu + +device_type=ultra +lsusb | grep 1915:521f | grep -q ChameleonLite && device_type=lite + +echo "Flashing $device_type" + +dfu_package=objects/${device_type}-dfu-full.zip + +if [ ! -f $dfu_package ]; then + echo "DFU package for $device_type not found, aborting." + echo "Build firmware using CURRENT_DEVICE_TYPE=$device_type firmware/build.sh" + exit 1 +fi + +nrfutil device program --firmware $dfu_package --traits nordicDfu +