I'm sharing here personal notes, in the hope it can help other people willing to contribute to development from a Linux environment (I'm using a Debian testing).
Things are still a big foggy so I prefer to not merge what is working for me in the official doc yet.
Thanks to the early hackers who shared useful findings not yet merged at the time of writing ( https://github.com/RfidResearchGroup/ChameleonUltra/pull/15/files and https://github.com/RfidResearchGroup/ChameleonUltra/pull/14/files)
Tools
arm-none-eabi-gcc
I'm trying to use the latest version 12.2.1 from Debian (apt install gcc-arm-none-eabi) but one can also use locally the vesion 10.3 with gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
from https://developer.arm.com/downloads/-/gnu-rm
nrfutil
From https://www.nordicsemi.com/Products/Development-tools/nrf-util
mkdir tools
(
cd tools
wget https://developer.nordicsemi.com/.pc-tools/nrfutil/x64-linux/nrfutil
./nrfutil install nrf5sdk-tools
./nrfutil install device
)
mergehex
From https://www.nordicsemi.com/Products/Development-tools/nrf-command-line-tools/download
wget https://nsscprodmedia.blob.core.windows.net/prod/software-and-other-downloads/desktop-software/nrf-command-line-tools/sw/versions-10-x-x/10-22-0/nrf-command-line-tools_10.22.0_amd64.deb
sudo dpkg -i nrf-command-line-tools_10.22.0_amd64.deb
Compiling FW
Using Debian gcc-arm-none-eabi
12.2.1, the compilation emits a few warnings from the nRF SDK.
As we're using the system ARM cross-compiler, we can configure firmware/Makefile.defs
in a very generic manner:
GNU_INSTALL_ROOT ?=
GNU_PREFIX ?= arm-none-eabi
This could become the default choice in the repo code...
One last thing, with ARM GCC 12.2.1 I got an error about the bootloader to be 128b too large. So I changed the boundaries as follows.
firmware/application/application.ld
:
- FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xCC000
+ FLASH (rx) : ORIGIN = 0x27000, LENGTH = 0xCB000
firmware/bootloader/bootloader.ld
:
- FLASH (rx) : ORIGIN = 0xF3000, LENGTH = 0xB000
+ FLASH (rx) : ORIGIN = 0xF2000, LENGTH = 0xC000
Now we can compile the firmware:
(
cd firmware
rm -rf objects
)
(
cd firmware/bootloader
make
) || exit 1
(
cd firmware/application
make
) || exit 1
(
cd firmware
../tools/nrfutil settings generate --family NRF52840 --application objects/application.hex --application-version 1 --bootloader-version 1 --bl-settings-version 2 objects/settings.hex
mergehex --merge objects/bootloader.hex objects/settings.hex --output objects/bootloader_settings.hex
mergehex --merge objects/bootloader_settings.hex objects/application.hex nrf52_sdk/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex --output objects/project.hex
)
The final image is firmware/objects/project.hex
Flashing FW
With stlink v2:
Connect
- Ultra <> Stlink V2 (translucent green)
- Vcc left disconnected
- SWC <> 4:SWCLK
- SWD <> 6:SWDIO
- GND <> 7:GND
- SWO left disconnected
Do not connect over USB at same time, it will work over battery.
openocd -f interface/stlink.cfg -f target/nrf52.cfg -c "flash init; init; reset halt; flash erase_sector 0 1 last; exit"
openocd -f interface/stlink.cfg -f target/nrf52.cfg -c "program firmware/objects/project.hex verify reset ; shutdown"
With jlink:
Connect
- Ultra <> Jlink
- Vcc left disconnected
- SWC <> 9:SWCLK
- SWD <> 7:SWDIO
- GND <> 8:GND
- SWO left disconnected
openocd -f interface/jlink.cfg -c "transport select swd" -f target/nrf52.cfg -c "flash init; init; reset halt; flash erase_sector 0 1 last; exit"
openocd -f interface/jlink.cfg -c "transport select swd" -f target/nrf52.cfg -c "program firmware/objects/project.hex verify reset ; shutdown"
Compiling FW for DFU
Stealing @gentilkiwi recipe...
(
cd firmware
rm -rf objects
)
(
cd firmware/bootloader
make
) || exit 1
(
cd firmware/application
make
) || exit 1
../tools/nrfutil nrf5sdk-tools pkg generate \
--application firmware/objects/application.hex --application-version 1 \
--bootloader firmware/objects/bootloader.hex --bootloader-version 1 \
--hw-version 0 \
--sd-req 0x100 --sd-id 0x100 \
--softdevice firmware/nrf52_sdk/components/softdevice/s140/hex/s140_nrf52_7.2.0_softdevice.hex \
--sd-boot-validation NO_VALIDATION \
--app-boot-validation NO_VALIDATION \
--key-file resource/dfu_key/chameleon.pem Ultra.DFU.zip
Flashing FW via DFU
echo "Wait for device to be off"
echo "Press B and plug"
echo "LEDS 4 & 5 should blink"
while :; do
lsusb|grep -q 1915:521f && break
sleep 1
done
../tools/nrfutil device program --firmware Ultra.DFU.zip --traits nordicDfu
Software
Setup
(
cd software/src
rm -rf tmp
mkdir tmp
cd tmp
cmake ..
make
echo "DONE. bins in software/bin"
)
Python CLI
Setup
(
cd software/script
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
deactivate
)
Usage
(
cd software/script
source venv/bin/activate
python chameleon_cli_main.py
deactivate
)
To connect once in the CLI:
hw connect -p /dev/ttyACM0