J.C
February 24, 2017, 10:14am
1
Hi,
I did the test to rebuild .hex file firmware from source, with Atmel Studio 5.6, and put this firmware on nitrokey storage. But this generate firmware doesn’t work on nitrokey.
For information, everything works well with firmwares provided on github.
Do you know if an additional step is required for the firmware is valid? A firmware signature perhaps?
jan
February 27, 2017, 12:10pm
2
Hi!
Could you provide the compiled HEX, BIN, LSS and ELF files, please? Perhaps upload to pastebin.
J.C
February 27, 2017, 12:37pm
3
Yes ! Here are HEX, LSS and ELF files (version 0.44) : https://files.fm/u/ppcbmdc6 (too big for pastebin )
I don’t have BIN file.
J.C
February 27, 2017, 3:11pm
4
I found the problem, but I don’t know how to fix it …
The application code begins at bootloader address (0x8000000) and not application address(0x80002000)
So, a part of application code is in bootloader area, and when I put the firmware, I have the option ‘–suppress-bootloader-mem’ to not modify bootloader area on nitrokey.
And as i have a part of application code in bootloader area, the firmware is incomplete…
Do you know why during the build step, the application code begins on bootloader address (0x8000000) ? A problem with linker ?
rubo
March 7, 2017, 8:11pm
5
Hi,
the problem seems to be that the DUF section at the start of the hex file isn’t included.
The DUF section include the update tool in the first 8kb of the flash and couldn’t erased.
In the lss file the DUF section (at .reset) had to be a size of 0x2008:
USB_MASS_V0.45.elf: file format elf32-avr32
Sections:
Idx Name Size VMA LMA File off Algn
0 .reset 00002008 80000000 80000000 00000400 22
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .rela.got 00000000 80002008 80002008 00002408 2 2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .text 00029a44 80002008 80002008 00002408 22
CONTENTS, ALLOC, LOAD, READONLY, CODE
3 .exception 00000200 8002bc00 8002bc00 0002c000 2 9
The DUF section is included by the file
\src\SOFTWARE_FRAMEWORK\ASM\trampoline.x
.section .reset, “ax”, @progbits
.global _trampoline
.type _trampoline, @function
_trampoline:
// Jump to program start.
// rjmp program_start
// Include the ISP raw binary image.
.incbin ISP_BIN
.org PROGRAM_START_OFFSET
program_start:
// Jump to the C runtime startup routine.
lda.w pc, _stext
Please check that the DUF section with the biniary from
#define ISP_BIN "…/src/SOFTWARE_FRAMEWORK/UTILS/DFU_1.0.3.bin"
is included in your output file.
Yet I had no idea why the DUF section isn’t included on your system.
rubo
March 18, 2017, 8:56am
6
I guess that the problem is in the makefile.
The linker use the default startup funktion “_start” from crt0.x and not the startup funktion “_trampoline” from _trampoline.x.
Please insert the command “-Wl,-e,_trampoline” in the linker command of the makefile.
Because I only used the IDE, I have problems to test it with the makefile.
The linker command from my IDE which worked is
avr32-gcc -nostartfiles -L…/src/SOFTWARE_FRAMEWORK/UTILS/LIBS/NEWLIB_ADDONS -L…/src/SOFTWARE_FRAMEWORK/BOARDS -Wl,–gc-sections -Wl,-e,_trampoline -T…/src/SOFTWARE_FRAMEWORK/UTILS/LINKER_SCRIPTS/AT32UC3A3/256/GCC/link_uc3a3256.lds -mpart=uc3a3256s -Wl,–gc-sections --rodata-writable -Wl,–direct-data -oUSB_MASS.elf src\tools.o src\nitrokey.o src\VIRTUAL_MEM\virtual_mem.o src\USHELL\ushell_task.o src\USER_INTERFACE\html_io.o src\USER_INTERFACE\file_io.o src\USB_CCID\USB_CCID_task.o src\USB_CCID\USB_CCID.o src\Tools\xxHash.o src\Tools\fastHash.o src\Tools\TIME_MEASURING.o src\Tools\SD_Test.o src\Tools\OTP_Test.o src\Tools\LED_test.o src\Tools\Interpreter.o src\Tools\Inbetriebnahme.o src\Tools\DFU_test.o src\Tools\BUFFERED_SIO.o src\Tools\AD_Test.o src\SOFTWARE_FRAMEWORK\UTILS\STARTUP_FILES\GCC\crt0.o src\SOFTWARE_FRAMEWORK\UTILS\DEBUG\print_funcs.o src\SOFTWARE_FRAMEWORK\UTILS\DEBUG\debug.o src\SOFTWARE_FRAMEWORK\SERVICES\USB\CLASS\MASS_STORAGE\host_mass_storage_task.o src\SOFTWARE_FRAMEWORK\SERVICES\USB\CLASS\MASS_STORAGE\device_mass_storage_task.o src\SOFTWARE_FRAMEWORK\SERVICES\USB\CLASS\MASS_STORAGE\SCSI_DECODER\scsi_decoder.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\xtea.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\x509parse.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\timing.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\ssl_tls.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\ssl_srv.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\ssl_cli.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\sha4.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\sha2.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\sha1.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\rsa.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\padlock.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\net.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\md5.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\md4.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\md2.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\havege.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\dhm.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\des.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\debug.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\certs.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\camellia.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\bignum.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\base64.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\arc4.o src\SOFTWARE_FRAMEWORK\SERVICES\POLARSSL\aes.o src\SOFTWARE_FRAMEWORK\SERVICES\MEMORY\CTRL_ACCESS\ctrl_access.o src\SOFTWARE_FRAMEWORK\SERVICES\FREERTOS\Source\tasks.o src\SOFTWARE_FRAMEWORK\SERVICES\FREERTOS\Source\queue.o src\SOFTWARE_FRAMEWORK\SERVICES\FREERTOS\Source\portable\MemMang\heap_3.o src\SOFTWARE_FRAMEWORK\SERVICES\FREERTOS\Source\portable\GCC\AVR32_UC3\port.o src\SOFTWARE_FRAMEWORK\SERVICES\FREERTOS\Source\portable\GCC\AVR32_UC3\exception.o src\SOFTWARE_FRAMEWORK\SERVICES\FREERTOS\Source\list.o src\SOFTWARE_FRAMEWORK\SERVICES\FREERTOS\Source\croutine.o src\SOFTWARE_FRAMEWORK\SERVICES\FAT\navigation.o src\SOFTWARE_FRAMEWORK\SERVICES\FAT\fsaccess.o src\SOFTWARE_FRAMEWORK\SERVICES\FAT\file.o src\SOFTWARE_FRAMEWORK\SERVICES\FAT\fat_unusual.o src\SOFTWARE_FRAMEWORK\SERVICES\FAT\fat.o src\SOFTWARE_FRAMEWORK\DRIVERS\USBB\usb_drv.o src\SOFTWARE_FRAMEWORK\DRIVERS\USBB\ENUM\usb_task.o src\SOFTWARE_FRAMEWORK\DRIVERS\USBB\ENUM\HOST\usb_host_task.o src\SOFTWARE_FRAMEWORK\DRIVERS\USBB\ENUM\DEVICE\usb_standard_request.o src\SOFTWARE_FRAMEWORK\DRIVERS\USBB\ENUM\DEVICE\usb_specific_request.o src\SOFTWARE_FRAMEWORK\DRIVERS\USBB\ENUM\DEVICE\usb_device_task.o src\SOFTWARE_FRAMEWORK\DRIVERS\USBB\ENUM\DEVICE\usb_descriptors.o src\SOFTWARE_FRAMEWORK\DRIVERS\USART\usart.o src\SOFTWARE_FRAMEWORK\DRIVERS\TC\tc.o src\SOFTWARE_FRAMEWORK\DRIVERS\SPI\spi.o src\SOFTWARE_FRAMEWORK\DRIVERS\PM\power_clocks_lib.o src\SOFTWARE_FRAMEWORK\DRIVERS\PM\pm_conf_clocks.o src\SOFTWARE_FRAMEWORK\DRIVERS\PM\pm.o src\SOFTWARE_FRAMEWORK\DRIVERS\MCI\mci.o src\SOFTWARE_FRAMEWORK\DRIVERS\INTC\intc.o src\SOFTWARE_FRAMEWORK\DRIVERS\GPIO\gpio.o src\SOFTWARE_FRAMEWORK\DRIVERS\FLASHC\flashc.o src\SOFTWARE_FRAMEWORK\DRIVERS\AES\ram_aes_ram_example.o src\SOFTWARE_FRAMEWORK\DRIVERS\AES\aes.o src\SOFTWARE_FRAMEWORK\DRIVERS\ADC\adc.o src\SOFTWARE_FRAMEWORK\COMPONENTS\MEMORY\SD_MMC\SD_MMC_MCI\sd_mmc_mci_mem.o src\SOFTWARE_FRAMEWORK\COMPONENTS\MEMORY\SD_MMC\SD_MMC_MCI\sd_mmc_mci.o src\SOFTWARE_FRAMEWORK\COMPONENTS\MEMORY\DATA_FLASH\AT45DBX\at45dbx_mem.o src\SOFTWARE_FRAMEWORK\COMPONENTS\MEMORY\DATA_FLASH\AT45DBX\at45dbx.o src\SOFTWARE_FRAMEWORK\BOARDS\EVK1104\led.o src\SOFTWARE_FRAMEWORK\ASM\trampoline.o src\OTP\sha1.o src\OTP\report_protocol.o src\OTP\keyboard.o src\OTP\hotp.o src\OTP\hmac-sha1.o src\OTP\aes.o src\INTERNAL_WORK\internal_work.o src\HighLevelFunctions\password_safe.o src\HighLevelFunctions\MatrixPassword.o src\HighLevelFunctions\HiddenVolume.o src\HighLevelFunctions\HandleAesStorageKey.o src\HighLevelFunctions\FlashStorage.o src\FILE_IO\FileAccessInterface.o src\Cipher\Xts\xts.o src\Cipher\Xts\modetest.o src\Cipher\Xts\aestab.o src\Cipher\Xts\aeskey.o src\Cipher\Xts\aescrypt.o src\CCID\USART\ISO7816_USART_INT.o src\CCID\USART\ISO7816_USART.o src\CCID\USART\ISO7816_Prot_T1.o src\CCID\USART\ISO7816_Prot_T0.o src\CCID\USART\ISO7816_ADPU.o src\CCID\UNIT_TEST\SIM_USB_CCID.o src\CCID\LOCAL_ACCESS\OpenPGP_V20.o src\CCID\LOCAL_ACCESS\Debug_T1.o -lnewlib_addons-at32ucr2-speed_opt