Project

General

Profile

SIMtrace Firmware » History » Version 18

laforge, 02/19/2016 10:48 PM

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 4 laforge
There is a {{{simtrace}}} Makefile target in the git://git.gnumonks.org/openpcd.git repository containing the latest firmware code.
7
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
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:GettingStarted OsmocomBB].
14
15
{{{
16 15 tsaitgaist
git clone git://git.gnumonks.org/openpcd.git
17
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 13 laforge
'''note for v1.0p boards''': sometimes the SAM-BA mode is not working. This is the case
103
if the 2 LEDs are on when powering up the board while VCC and TEST is shorted. The
104 12 laforge
reason in unknown, but there are several methods to correct this:
105
106 13 laforge
 * press the RESET button while powering up
107 12 laforge
 * touch PA0 (pin 48, on the right upper corner) with a piece of metal
108
 * short PA0 and PA1 (pin 48 and 47, next to each other on the right upper corner)
109
110
As soon as the LEDs go off, the SAM-BA mode is working.
111 1 laforge
112
For more information about SAM-BA, please refer to the Atmel documentation on the AT91SAM7S component.
113
114 17 tsaitgaist
==== Flashing the firmware with sam7 ====
115 1 laforge
116 17 tsaitgaist
You can flash with sam7utils using libusb or POSIX.
117 1 laforge
118 17 tsaitgaist
It may happen that sam7 loads a sam_ba module at the end.
119
If you want to use sam7 multiple times, remove the loaded module after each run:
120 1 laforge
{{{
121 17 tsaitgaist
sudo rmmod sam_ba
122 1 laforge
}}}
123 17 tsaitgaist
124
===== flashing using libusb =====
125
126
sam7utils tries to compile with libusb, so to access the device directly.
127
If libusb is not present, you must flash using serial.
128
129
On ubuntu the usb device 03eb:6124 is mapped on /dev/ttyACMx using the cdc_cam module.
130
Remove it while the board is plugged, so sam7utils is able to communicate with it.
131 1 laforge
{{{
132 17 tsaitgaist
sudo rmmod cdc_acm
133 11 laforge
}}}
134
135 17 tsaitgaist
to flash the samba image using libusb :
136 1 laforge
{{{
137 17 tsaitgaist
sudo ./sam7 --exec set_clock --exec unlock_regions --exec "flash ../openpcd/firmware/main_simtrace.samba"
138 9 laforge
}}}
139 6 laforge
140 17 tsaitgaist
===== using POSIX =====
141 6 laforge
142 17 tsaitgaist
If libusb is not present, sam7utils will be compiled to communicate with the board using POSIX.
143 6 laforge
144 17 tsaitgaist
If the device is not mapped to a node, use usbserial :
145 1 laforge
{{{
146
sudo rmmod usbserial
147 15 tsaitgaist
sudo modprobe usbserial vendor=0x03EB product=0x6124
148 1 laforge
}}}
149 9 laforge
150 17 tsaitgaist
to flash the samba image using serial :
151 2 laforge
{{{
152 17 tsaitgaist
sudo ./sam7 -l /dev/ttyUSB0 --exec set_clock --exec unlock_regions --exec "flash ../openpcd/firmware/main_simtrace.samba"
153 2 laforge
}}}
154 3 laforge
155
== Bugs ==
156 9 laforge
157
Currently there is a bug in the firmware that makes the device fail to enumerate on OSX. We provide an alternative hacked firmware until we have resolved the issue properly.
158 10 laforge
159 1 laforge
== Version History ==
160
 * v0.2 Fixes ATR handling for older SIMcards.
161 18 laforge
 * v0.4 fixes wrong Fi/Di computation in some cases
162
 * v0.5 fixes SIMtrace crashes, lost bytes, WDT expiration and many other issues
Add picture from clipboard (Maximum size: 48.8 MB)