Project

General

Profile

SIMtrace Firmware » History » Version 21

Anonymous, 02/19/2016 10:48 PM
OpenPCD code is on git.osmocom.org now

1 1 laforge
= SIMtrace Firmware =
2
3 4 laforge
The Firmware for the AT91SAM7S device was written by reusing a lot of the code for the [http://www.openpcd.org/ OpenPCD]
4
RFID reader.  
5 1 laforge
6 21 laforge
There is a {{{simtrace}}} Makefile target in the git://git.osmocom.org/openpcd.git repository containing the latest firmware code.
7 4 laforge
8
Eventually, the OS part of OpenPCD/OpenPICC/SIMtrace will be separated.  At that point, the firmware source can become
9
part of simtrace.git
10
11
== Building the firmware ==
12
13 19 laforge
Precondition: You need to set your PATH in a way that contains an arm-elf [wiki:toolchain], i.e. the same way that you build [wiki:Software/GettingStarted OsmocomBB].
14 4 laforge
15
{{{
16 21 laforge
git clone git://git.osmocom.org/openpcd.git
17 15 tsaitgaist
cd openpcd/firmware
18
make -f Makefile.dfu BOARD=SIMTRACE
19
make BOARD=SIMTRACE DEBUG=1 TARGET=main_simtrace
20
cat dfu.bin main_simtrace.bin > main_simtrace.samba
21
cd ../..
22 4 laforge
}}}
23
24
=== Firmware parts ===
25
26
The firmware build process creates two images:
27
 * dfu.bin -- the sam7dfu 2nd level bootloader. It implements the USB DFU (Device Firmware Upgrade) profile.
28
 * main_simtrace.bin -- the actual simtrace program. To be loaded via DFU, using [http://dfu-util.gnumonks.org/ dfu-util].
29
 * main_simtrace.samba -- [http://www.openpcd.org/Sam7dfu sam7dfu] + simtrace image. to be loaded via SAM-BA, using sam7utils (see below).
30
31 16 tsaitgaist
== Flashing the firmware ==
32 4 laforge
33 16 tsaitgaist
There are two ways to flash the firmware:
34
 * DFU: over USB and simple.
35
 * SAM-BA: for AT91SAM7S without DFU installed, or when DFU fails.
36
37
=== DFU ===
38
39
SIMtrace comes with the Device Firmware Upgrade (DFU) already installed.
40
To install it on a new AT91SAM7S, use the SAM-BA procedure below.
41
DFU can be used to replace the SIMtrace payload.
42
43
To get dfu-util:
44
{{{
45
sudo apt-get install dfu-util
46
}}}
47
48
To flash the firmware:
49
{{{
50
sudo dfu-util -d 16c0:0762 -a0 -D ./main_simtrace.bin -R
51
}}}
52
53
dfu-util should reset the board and use the DFU bootloader.
54
Try the command a second time if it did not work at first.
55
If this still does not work, power up the board while pressing the '''BOOTLOADER''' button.
56
57 17 tsaitgaist
=== SAM-BA ===
58 1 laforge
59 17 tsaitgaist
The SAM-BA mode is provided by the AT91SAM7S.
60
This can be used at any time, even if the firmware bricks the device.
61
To flash the new firmware, sam7utils is used.
62
63
==== sam7utils ====
64
65 9 laforge
SAM-BA images contain a full NOR flash image.  They can be used in case the sam7dfu bootloader was corrupted,
66
and can be installed either using the '''sam7''' program released by Atmel, or via JTAG based flashing.
67
68
Installing firmware using SAM-BA is a bit cumbersome and requires strict adherence to a sequence of USB cable
69
plugging/unplugging and jumper setting, waiting, jumper removal, etc.
70
71 4 laforge
72 1 laforge
sam7utils will be used to flash the '''main_simtrace.samba''' image over SAM-BA.
73 15 tsaitgaist
{{{
74 17 tsaitgaist
sudo aptitude install libreadline-dev libusb-dev
75 15 tsaitgaist
wget http://www.openpcd.org/dl/sam7utils-0.2.1-bm.tar.bz2
76 1 laforge
tar xf sam7utils-*.tar.bz2
77 15 tsaitgaist
cd sam7utils
78
./configure --prefix=/usr/local
79 17 tsaitgaist
make AM_CFLAGS=""
80 1 laforge
}}}
81 4 laforge
82
==== Entering the SAM-BA mode ====
83 17 tsaitgaist
84 12 laforge
The first time you flash the device, you will have to use the SAM-BA method using the main_simtrace.samba image.
85
86
To put the board into SAM-BA mode, use the following steps:
87
88
 * unplug the board
89
 * short TEST to VCC (3.3V) pin using a jumper. leave PA0,PA1,PA2 unconnected.
90
 * power up the board
91
 * wait 20s
92
 * unplug board
93
 * remove jumper
94 14 laforge
95
[[Image(shortTEST.jpg)]]
96
97 12 laforge
Now when the board is attached to USB, lsusb should show :
98
{{{
99
Bus 002 Device 015: ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader
100
}}}
101
102 20 tsaitgaist
'''note''': sometimes switching to SAM-BA mode is not working.
103
This is the case if the 2 LEDs are on when powering up the board while VCC and TEST is shorted.
104
This is because PA0 should be pulled up to enter the SAM-BE mode, but the internal pull-up does not seem to be used.
105
There are several methods to correct this:
106 12 laforge
107 13 laforge
 * press the RESET button while powering up
108 12 laforge
 * touch PA0 (pin 48, on the right upper corner) with a piece of metal
109 1 laforge
 * short PA0 and PA1 (pin 48 and 47, next to each other on the right upper corner)
110
111 12 laforge
As soon as the LEDs go off, the SAM-BA mode is working.
112 20 tsaitgaist
113
'''note for SIMtace v1.3 boards''': Because of a [wiki:SIMtrace/Hardware#v1.3 hardware design bug], if you produced the board yourself, you have to cut a path on the board, and write the board version on flash the first time you install the firmware. Follow the detailed [wiki:ProductionFlashingV13 instructions].
114 1 laforge
115
For more information about SAM-BA, please refer to the Atmel documentation on the AT91SAM7S component.
116
117 17 tsaitgaist
==== Flashing the firmware with sam7 ====
118 1 laforge
119 17 tsaitgaist
You can flash with sam7utils using libusb or POSIX.
120 1 laforge
121 17 tsaitgaist
It may happen that sam7 loads a sam_ba module at the end.
122
If you want to use sam7 multiple times, remove the loaded module after each run:
123 1 laforge
{{{
124 17 tsaitgaist
sudo rmmod sam_ba
125 1 laforge
}}}
126 17 tsaitgaist
127
===== flashing using libusb =====
128
129
sam7utils tries to compile with libusb, so to access the device directly.
130
If libusb is not present, you must flash using serial.
131
132
On ubuntu the usb device 03eb:6124 is mapped on /dev/ttyACMx using the cdc_cam module.
133
Remove it while the board is plugged, so sam7utils is able to communicate with it.
134 1 laforge
{{{
135 17 tsaitgaist
sudo rmmod cdc_acm
136 11 laforge
}}}
137
138 17 tsaitgaist
to flash the samba image using libusb :
139 1 laforge
{{{
140 17 tsaitgaist
sudo ./sam7 --exec set_clock --exec unlock_regions --exec "flash ../openpcd/firmware/main_simtrace.samba"
141 9 laforge
}}}
142 6 laforge
143 17 tsaitgaist
===== using POSIX =====
144 6 laforge
145 17 tsaitgaist
If libusb is not present, sam7utils will be compiled to communicate with the board using POSIX.
146 6 laforge
147 17 tsaitgaist
If the device is not mapped to a node, use usbserial :
148 1 laforge
{{{
149
sudo rmmod usbserial
150 15 tsaitgaist
sudo modprobe usbserial vendor=0x03EB product=0x6124
151 1 laforge
}}}
152 9 laforge
153 17 tsaitgaist
to flash the samba image using serial :
154 2 laforge
{{{
155 17 tsaitgaist
sudo ./sam7 -l /dev/ttyUSB0 --exec set_clock --exec unlock_regions --exec "flash ../openpcd/firmware/main_simtrace.samba"
156 2 laforge
}}}
157 1 laforge
158 19 laforge
== Serial ==
159
160
The debug serial is available with 115200 baud and 8n1 with no flow control
161
162 1 laforge
== Bugs ==
163 9 laforge
164 19 laforge
With high speed SIM cards some bytes inside an APDU can be skipped. This is more likely to happen in a virtualized environment. The workaround is to decrease the buffer size inside the firmware. 
165 10 laforge
166 1 laforge
== Version History ==
167
 * v0.2 Fixes ATR handling for older SIMcards.
168 18 laforge
 * v0.4 fixes wrong Fi/Di computation in some cases
169
 * v0.5 fixes SIMtrace crashes, lost bytes, WDT expiration and many other issues
Add picture from clipboard (Maximum size: 48.8 MB)