Nitrokey Storage Firmware
Note: Tested with Windows 7
Install the following tools in this order:
The compile procedure is as follows (tested on ArchLinux but should work on any other GNU/Linux OS):
- Clone this git project (
git clone https://github.com/Nitrokey/nitrokey-storage-firmware.git)
- Download and extract AVR32 Studio. Example archive filename:
avr32studio-ide-188.8.131.523-linux.gtk.x86_64.zip. At the moment no newer version seems to be available for Linux.
- Start AVR32 Studio by executing
avr32studioin the extracted folder.
- Import project into AVR32 Studio: File | Import... | General | Existing Projects into Workspace | Choose the folder of downloaded git project.
pm_240.hin the git project folder to
pm_231.h. Make a backup of
as4e-ide/plugins/com.atmel.avr.toolchains.linux.x86_64_184.108.40.206009140852/os/linux/x86_64/avr32/include/avr32/pm_231.h. Replace that
pm_231.hwith the renamed
- In AVR32 Studio select Project | Build All.
- The builded file is now in the folder
Debugof the git project folder.
Converting to .HEX file
Before flashing there may be a need to convert binary file to .hex. If it was not done automatically execute the following in Debug or Release directory:
avr-objcopy -R .eeprom -O ihex USB_MASS.elf firmware.hex
Flashing the Firmware to Device
Note: To connect an external debugger as described here, you will need a development version of the Nitrokey Storage that makes the JTAG pins available (pictured below). This version is currently not for sale. The PCB layout for the developer version can be found in the Nitrokey Storage Hardware repository, inside the dev folders.
The JTAG connections on the PCB have a pitch of 1.27mm. To ease connecting and disconnecting, it is easiest to solder a pin header to the PCB and use a pin socket to quickly attach the device to the debugger. It is recommended to use the following parts for that (however any connector with a 1.27mm pitch will work):
|Part||Digikey Part Number|
|7-pin THT Pin header, 1.27mm Pitch||S9014E-07-ND|
|7-pin THT Pin header, 2.54mm Pitch||S1012EC-07-ND|
|7-pin Socket, 1.27mm Pitch||S9008E-07-ND|
|1.27mm Ribbon Cable, ca. 15cm|
- Solder the 1.27mm Pin header to the board
- Solder the 1.27mm socket and 2.54mm header to the cable and isolate individual contacts with heatshrink
Connect Debugger interface to the Nitrokey
Use jumper wires to connect the cable from the Nitrokey to the Debugger interface connector as pictured below:
|Nitrokey Side||AVR JTAG Connector Side|
The device still needs to be powered via USB during debugging. For an initial function test, you can issue the following commands from the AVR32Studio home directory:
cd /plugins/com.atmel.avr.utilities.linux.x86_64_220.127.116.11009140848/os/linux/x86_64/bin ./avr32program --part UC3A3256S cpuinfo
if the device is connected correctly, this should yield an output similar to this:
Connected to JTAGICE mkII version 6.6, 6.6 at USB. Device information: Device Name UC3A3256S Device Revision H JTAG ID 0x7202003f SRAM size 128 kB Flash size 256 kB
Using the debugger in AVR32Studio
To enable the debugger, follow these steps inside the IDE:
- Enable the "AVR Targets" dialog under
Window -> Show View -> AVR Targets
- Right click inside the "AVR Targets" window and select
Scan Targets. Your debugger should now be shown as a target.
- Right click on the debugger entry and select
- Select the "Details" tab. Under "Device", select
AVR UC3A Series -> AT32UC3A3256S
The debugger should now be available. Configure the debugging environment by following these steps:
Run -> Debug Configurations
- If there is no entry under
AVR Application, create one by double clicking on it. Otherwise select the existing entry.
- Under "File", select
- Under "Target" select
JTAGICE mkII(or your correspondig JTAG debugger)
- Under "Erase Options" select
- Under "Run Options" select
- Apply Settings and close the dialog window
Congratulations, your IDE should now be ready for debugging. Set breakpoints as needed and start a JTAG debugging session by pressing F11.
Defaulting to USB DFU
If you accidentally erased the DFU bootloader from the chip or run into any trouble, the stick can always be reprogrammed like this:
- In the "AVR Targets" dialog, right click on your JTAG debugger and select
- Leave all the entries in their default state and reprogram the bootloader by clicking
The device will now start in DFU mode and can be programmed as described above in the Firmware Upgrade Instructions