The firmware runs on the microcontroller. The firmware was written as a C/C++
Arduino-compatible library. However, in our code, we mostly use custom
drivers, such as for PWM (pulse-width
modulation) and ADC
(analog-to-digital
converter),
instead of using Arduino's analogWrite()
and analogRead()
. We use the
Adafruit Feather nRF52840 board definition. Below are three ways to
program/compile firmware.
Given an ino.zip file, you can update the device firmware over a USB connection using the flash_firmware.py script.
This is a standard and convenient way to program an Arduino board and can be done from the Arduino IDE. This way the source code can be modified and compiled. The installation steps:
-
Download the latest Arduino IDE
-
Go to Arduino Preferences. Add https://www.adafruit.com/package_adafruit_index.json to Additional Board Manager URLs. For additional details see Adafruit installation guide.
-
Go to Tools → Boards → Boards Manager... Type feather in the search bar. Install the latest version of Adafruit nRF52 boards.
-
Select the Adafruit Feather nRF52840 board.
-
Install the audio-to-tactile library by copying into it Arduino Libraries folder:
Mac OSx:
Documents/Arduino/libraries
Linux:
~/Arduino/libraries
-
Restart the Arduino IDE.
-
Select the correct USB-serial port by going to Tools → Ports. You should see something like "
/dev/cu.usbmodem14301
" on Mac OSx. On Windows it will be COM#. -
Connect the device with USB to the computer. Compile and upload the code by clicking the upload button in the Arduino IDE.
If you are building the board from scratch or the bootloader is bricked, the bootloader needs to be flashed. The bootloader can easily get bricked during development if buggy code is uploaded. You will need a J-link programmer such as Segger EDU mini and a pogo-pin adapter by TagConnect.
-
Connect J-link to the board. Note that the J-link doesn't provide power. The programmer could be held by hand while programming or secured using a retainer clip attaching programmer
-
Select the Adafruit Feather nRF52840 board (Tools → Board → ...).
-
Burn bootloader: Tools → Burn Bootloader.
-
If successful, USB-serial port should show up in Tools → Port
The microcontroller can be programmed wirelessly over Bluetooth. This requires the Android application. I would not recommend this option during code development, as it requires more steps and time to get the code into the board.
-
Generate the firmware file. This can be done using Arduino IDE. Enable verbose output by going to Arduino → Preferences → Check “Show Verbose Output” during compilation and upload.
-
Compile and run the code in Arduino (make sure verbose output is enabled). You should see something like this in terminal output, with the
/var/folders..
is the path to the zip file, that can be used in OTA updates:/Users/$USER/Library/Arduino15/packages/adafruit/hardware/nrf52/0.24.0/tools/adafruit-nrfutil/macos/adafruit-nrfutil --verbose dfu serial -pkg /var/folders/wt/byc7v8fx4wn5vh54frzbd4gc00kcvr/T/arduino_build_196049/blinky_ota.ino.zip -p /dev/cu.usbmodem141401 -b 115200 --singlebank
-
I usually copy the path into the Chrome address bar, and that automatically starts the download of the zip file.
-
Copy that file to the phone. There are various ways to do it: using ADB debugger, connected over USB to a computer, or copying to Google Drive.
-
Open the Firmware tab in the dropdown menu in the Android app. Click on update and select the zip file. The default settings should work.