Compiling and running simtrace firmware with a recent toolchain

Denis 'GNUtoo' Carikli GNUtoo at no-log.org
Fri Mar 9 16:01:23 UTC 2018


Hi,

The simtrace firmware is in the OpenPCD git repository at:
> git://git.osmocom.org/openpcd.git

I used the last revision at the time of writing:
> dc2983d firmware: Makefiles: enable changing toolchain

With a fairly recent gcc version:
> $ arm-none-eabi-gcc --version
> arm-none-eabi-gcc (Arch Repository) 7.3.0
> Copyright (C) 2017 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There
> is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
> PARTICULAR PURPOSE.

Compiling the firmware the usual way works, with many warnings:
> $ make BOARD=SIMTRACE DEBUG=1 TARGET=main_simtrace \
> CROSS_COMPILE=arm-none-eabi-
[...]

Installing that firmware went fine:
> $ sudo dfu-util -d 16c0:0762 -a0 -D ./main_simtrace.bin -R
> dfu-util 0.9
> 
> Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
> Copyright 2010-2016 Tormod Volden and Stefan Schmidt
> This program is Free Software and has ABSOLUTELY NO WARRANTY
> Please report bugs to http://sourceforge.net/p/dfu-util/tickets/
> 
> dfu-util: Invalid DFU suffix signature
> dfu-util: A valid DFU suffix will be required in a future dfu-util
> release!!! Opening DFU capable USB device...
> ID 16c0:0762
> Run-time device DFU version 0100
> Claiming USB DFU Interface...
> Setting Alternate Setting #0 ...
> Determining device status: state = dfuIDLE, status = 0
> dfuIDLE, continuing
> DFU mode device DFU version 0100
> Device returned transfer size 256
> Copying data from PC to DFU device
> Download	[=========================] 100%        23084 bytes
> Download done.
> state(7) = dfuMANIFEST, status(0) = No error condition is present
> state(2) = dfuIDLE, status(0) = No error condition is present
> Done!
> dfu-util: can't detach
> Resetting USB to switch back to runtime mode

Unfortunately with the new compiler the device gets re-enumerated
continuously:
> usb 4-1: new full-speed USB device number 3 using uhci_hcd
> usb 4-1: new full-speed USB device number 4 using uhci_hcd
> usb 4-1: new full-speed USB device number 5 using uhci_hcd
[...]

Here's what I have on the serial port:
> [000000] 
> [000001] (C) 2006-2011 by Harald Welte <hwelte at hmw-consulting.de>
> This software is FREE SOFTWARE licensed under GNU GPL
> [000002] Version 0.5.30-dc29 compiled 20180309-165435 by gnutoo at second-laptop
> 
> [000003] 
> DEBUG Interface:
> 0) Set Pull-up 1) Clear Pull-up 2) Toggle LED1 3) Toggle LED2
> 9) Reset
> [000004] RSTC_SR=0x00010000
> [000005] LARGE req_ctx[00] initialized at 002055AC, Data: 00200A68 => 00200E28
> [000006] LARGE req_ctx[01] initialized at 002055C0, Data: 00200E28 => 002011E8
> [000007] LARGE req_ctx[02] initialized at 002055D4, Data: 002011E8 => 002015A8
> [000008] LARGE req_ctx[03] initialized at 002055E8, Data: 002015A8 => 00201968
> [000009] LARGE req_ctx[04] initialized at 002055FC, Data: 00201968 => 00201D28
> [00000A] LARGE req_ctx[05] initialized at 00205610, Data: 00201D28 => 002020E8
> [00000B] LARGE req_ctx[06] initialized at 00205624, Data: 002020E8 => 002024A8
> [00000C] LARGE req_ctx[07] initialized at 00205638, Data: 002024A8 => 00202868
> [00000D] LARGE req_ctx[08] initialized at 0020564C, Data: 00202868 => 00202C28
> [00000E] LARGE req_ctx[09] initialized at 00205660, Data: 00202C28 => 00202FE8
> [00000F] LARGE req_ctx[10] initialized at 00205674, Data: 00202FE8 => 002033A8
> [000010] LARGE req_ctx[11] initialized at 00205688, Data: 002033A8 => 00203768
> [000011] LARGE req_ctx[12] initialized at 0020569C, Data: 00203768 => 00203B28
> [000012] LARGE req_ctx[13] initialized at 002056B0, Data: 00203B28 => 00203EE8
> [000013] LARGE req_ctx[14] initialized at 002056C4, Data: 00203EE8 => 002042A8
> [000014] LARGE req_ctx[15] initialized at 002056D8, Data: 002042A8 => 00204668
> [000015] LARGE req_ctx[16] initialized at 002056EC, Data: 00204668 => 00204A28
> [000016] LARGE req_ctx[17] initialized at 00205700, Data: 00204A28 => 00204DE8
> [000017] LARGE req_ctx[18] initialized at 00205714, Data: 00204DE8 => 002051A8
> [000018] LARGE req_ctx[19] initialized at 00205728, Data: 002051A8 => 00205568
> [000019] Inititalizing usbcmd_gen_init
> [00001A] udp_open(440): entering
> [00001B] USART Initializing
> [00001C] pio_irq_register(109): registering handler 001079bc for PIOA 7
> [00001D] RST
> [00001E] computed Fi(1) Di(1) ratio: 372
> [000000] 
> [000001] (C) 2006-2011 by Harald Welte <hwelte at hmw-consulting.de>
> This software is FREE SOFTWARE licensed under GNU GPL
> [000002] Version 0.5.30-dc29 compiled 20180309-165435 by gnutoo at second-laptop
> 
> [000003] 
> DEBUG Interface:
> 0) Set Pull-up 1) Clear Pull-up 2) Toggle LED1 3) Toggle LED2
> 9) Reset
> [000004] RSTC_SR=0x00010200
> [000005] LARGE req_ctx[00] initialized at 002055AC, Data: 00200A68 => 00200E28
> [000006] LARGE req_ctx[01] initialized at 002055C0, Data: 00200E28 => 002011E8
> [000007] LARGE req_ctx[02] initialized at 002055D4, Data: 002011E8 => 002015A8
> [000008] LARGE req_ctx[03] initialized at 002055E8, Data: 002015A8 => 00201968
> [000009] LARGE req_ctx[04] initialized at 002055FC, Data: 00201968 => 00201D28
> [00000A] LARGE req_ctx[05] initialized at 00205610, Data: 00201D28 => 002020E8
> [00000B] LARGE req_ctx[06] initialized at 00205624, Data: 002020E8 => 002024A8
> [00000C] LARGE req_ctx[07] initialized at 00205638, Data: 002024A8 => 00202868
> [00000D] LARGE req_ctx[08] initialized at 0020564C, Data: 00202868 => 00202C28
> [00000E] LARGE req_ctx[09] initialized at 00205660, Data: 00202C28 => 00202FE8
> [00000F] LARGE req_ctx[10] initialized at 00205674, Data: 00202FE8 => 002033A8
> [000010] LARGE req_ctx[11] initialized at 00205688, Data: 002033A8 => 00203768
> [000011] LARGE req_ctx[12] initialized at 0020569C, Data: 00203768 => 00203B28
> [000012] LARGE req_ctx[13] initialized at 002056B0, Data: 00203B28 => 00203EE8
> [000013] LARGE req_ctx[14] initialized at 002056C4, Data: 00203EE8 => 002042A8
> [000014] LARGE req_ctx[15] initialized at 002056D8, Data: 002042A8 => 00204668
> [000015] LARGE req_ctx[16] initialized at 002056EC, Data: 00204668 => 00204A28
> [000016] LARGE req_ctx[17] initialized at 00205700, Data: 00204A28 => 00204DE8
> [000017] LARGE req_ctx[18] initialized at 00205714, Data: 00204DE8 => 002051A8
> [000018] LARGE req_ctx[19] initialized at 00205728, Data: 002051A8 => 00205568
> [000019] Inititalizing usbcmd_gen_init
> [00001A] udp_open(440): entering
> [00001B] USART Initializing
> [00001C] pio_irq_register(109): registering handler 001079bc for PIOA 7
> [00001D] RST
> [00001E] computed Fi(1) Di(1) ratio: 372
> [000000] 

So it gets reset in a loop.

I can get it to work with the following diff:
--- a/firmware/src/simtrace/tc_etu.c
+++ b/firmware/src/simtrace/tc_etu.c
@@ -96,8 +96,8 @@ void tc_etu_init(void)
                                    ((unsigned int) 1 << AT91C_ID_TC0));
 
        /* Connect TCLK0 to XC0 */
-       tcb->TCB_BMR &= ~(AT91C_TCB_TC0XC0S);
-       tcb->TCB_BMR |=  AT91C_TCB_TC0XC0S_TCLK0;
+//     tcb->TCB_BMR &= ~(AT91C_TCB_TC0XC0S);
+//     tcb->TCB_BMR |=  AT91C_TCB_TC0XC0S_TCLK0;
 
        /* Register Interrupt handler */
        AT91F_AIC_ConfigureIt(AT91C_BASE_AIC, AT91C_ID_TC0,
@@ -124,5 +124,5 @@ void tc_etu_init(void)
        tcetu->TC_CCR = AT91C_TC_CLKEN;
 
        /* Reset to start timers */
-       tcb->TCB_BCR = 1;
+//     tcb->TCB_BCR = 1;
 }

With the diff I have the following on serial:
> [000000] 
> [000001] (C) 2006-2011 by Harald Welte <hwelte at hmw-consulting.de>
> This software is FREE SOFTWARE licensed under GNU GPL
> [000002] Version 0.5.30-dc29-dirty compiled 20180309-165717 by gnutoo at second-laptop
> 
> [000003] 
> DEBUG Interface:
> 0) Set Pull-up 1) Clear Pull-up 2) Toggle LED1 3) Toggle LED2
> 9) Reset
> [000004] RSTC_SR=0x00010000
> [000005] LARGE req_ctx[00] initialized at 00205630, Data: 00200AEC => 00200EAC
> [000006] LARGE req_ctx[01] initialized at 00205644, Data: 00200EAC => 0020126C
> [000007] LARGE req_ctx[02] initialized at 00205658, Data: 0020126C => 0020162C
> [000008] LARGE req_ctx[03] initialized at 0020566C, Data: 0020162C => 002019EC
> [000009] LARGE req_ctx[04] initialized at 00205680, Data: 002019EC => 00201DAC
> [00000A] LARGE req_ctx[05] initialized at 00205694, Data: 00201DAC => 0020216C
> [00000B] LARGE req_ctx[06] initialized at 002056A8, Data: 0020216C => 0020252C
> [00000C] LARGE req_ctx[07] initialized at 002056BC, Data: 0020252C => 002028EC
> [00000D] LARGE req_ctx[08] initialized at 002056D0, Data: 002028EC => 00202CAC
> [00000E] LARGE req_ctx[09] initialized at 002056E4, Data: 00202CAC => 0020306C
> [00000F] LARGE req_ctx[10] initialized at 002056F8, Data: 0020306C => 0020342C
> [000010] LARGE req_ctx[11] initialized at 0020570C, Data: 0020342C => 002037EC
> [000011] LARGE req_ctx[12] initialized at 00205720, Data: 002037EC => 00203BAC
> [000012] LARGE req_ctx[13] initialized at 00205734, Data: 00203BAC => 00203F6C
> [000013] LARGE req_ctx[14] initialized at 00205748, Data: 00203F6C => 0020432C
> [000014] LARGE req_ctx[15] initialized at 0020575C, Data: 0020432C => 002046EC
> [000015] LARGE req_ctx[16] initialized at 00205770, Data: 002046EC => 00204AAC
> [000016] LARGE req_ctx[17] initialized at 00205784, Data: 00204AAC => 00204E6C
> [000017] LARGE req_ctx[18] initialized at 00205798, Data: 00204E6C => 0020522C
> [000018] LARGE req_ctx[19] initialized at 002057AC, Data: 0020522C => 002055EC
> [000019] Inititalizing usbcmd_gen_init
> [00001A] udp_open(440): entering
> [00001B] USART Initializing
> [00001C] pio_irq_register(109): registering handler 001079bc for PIOA 7
> [00001D] RST
> [00001E] computed Fi(1) Di(1) ratio: 372
> [00001F] ISO_SW Initializing
> [000020] pio_irq_register(109): registering handler 00107fb0 for PIOA 8
> [000021] pio_irq_register(109): registering handler 00107fdc for PIOA 25
> [000022] VCC_PHONE off
> [000023] USART Entering Rx Mode
> [000024] RST
> [000025] computed Fi(1) Di(1) ratio: 372
> [000026] MODE: SNIFFER
> 
> [000027] RST
> [000028] computed Fi(1) Di(1) ratio: 372
> [000029] main(76): entering main (idle) loop
> [00002A] Heart beat 00000000
> [00002B] Heart beat 00000001
> [00002C] Heart beat 00000002
> [00002D] Heart beat 00000003
> [00002E] Heart beat 00000004
> [00002F] Heart beat 00000005

And I could even get some packet trace from my Galaxy SIII (i9300):
> GSM SIM 80 3 9f : 00d2 
> GSM SIM 67 ISO/IEC 7816-4 SELECT File MF 
> GSM SIM 67 ISO/IEC 7816-4 SELECT /EF.ELP 
> GSM SIM 90 ISO/IEC 7816-4 GET RESPONSE 
> GSM SIM 75 ISO/IEC 7816-4 READ BINARY Offset=0 
> GSM SIM 67 ISO/IEC 7816-4 SELECT File EF.ICCID 
> GSM SIM 90 ISO/IEC 7816-4 GET RESPONSE 
> GSM SIM 75 ISO/IEC 7816-4 READ BINARY Offset=0 
> GSM SIM 85 ETSI TS 102.221 TERMINAL PROFILE 
> GSM SIM 67 ISO/IEC 7816-4 SELECT File EF.DIR 
> GSM SIM 93 ISO/IEC 7816-4 GET RESPONSE 
> GSM SIM 103 ISO/IEC 7816-4 READ RECORD RecordNr=1 
> GSM SIM 81 ISO/IEC 7816-4 SELECT Application a0000000871002ff33ff018900000100 
> GSM SIM 108 ISO/IEC 7816-4 GET RESPONSE 
> GSM SIM 67 ISO/IEC 7816-4 SELECT File MF 

Denis.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.osmocom.org/pipermail/simtrace/attachments/20180309/1a8b1b18/attachment.bin>


More information about the simtrace mailing list