Project

General

Profile

Flashing » History » Version 5

tsaitgaist, 08/13/2019 02:39 PM
rewrite flashing page

1 2 tsaitgaist
{{>toc}}
2
3 1 tsaitgaist
h1. Flashing
4
5 5 tsaitgaist
There are several ways to flash [[Wiki#Firmware|firmware images]], depending on your board, the image you want to flash, and the state of your device.
6 1 tsaitgaist
7 5 tsaitgaist
h1. SIMtrace2 board
8
9
This section will cover the flashing methods for the [[Wiki#SIMtrace v2|SIMtrace board]].
10
11 1 tsaitgaist
h2. DFU
12
13 5 tsaitgaist
*precondition*: a functioning application firmware or DFU bootloader must already be installed.
14 1 tsaitgaist
15 5 tsaitgaist
SIMtrace2 comes with a USB DFU bootloader pre-installed which allows to flash the application firmware over USB using the @dfu-util@ utility.
16
17
To check if you have a functioning application firmware or DFU bootloader, power the board:
18
* if both green and red LEDs are on, you should have a functioning application firmware
19
* if only the green LED is on, the application firmware is missing, but the DFU bootloader is present
20
* in case the application firmware is buggy, you can force the board to boot the DFU bootloader: on the board keep the *BOOTLOADER* button pressed while re-plugging the USB connector (pressing the *RESET* might not be sufficient)
21
!{width:20%}simtrace-board-buttons.jpg!
22
* if the USB DFU bootloader is missing, defective, or needs to be updated, use the JTAG or SAM-BA methods to flash the DFU bootloader.
23
24
To update the application firmware over the DFU bootloader, we will use @dfu-util@:
25
# get @dfu-util@:
26 1 tsaitgaist
<pre>
27
sudo apt-get install dfu-util
28
</pre>
29 5 tsaitgaist
# check if the board and DFU bootloader are detected:
30 1 tsaitgaist
<pre>
31 5 tsaitgaist
sudo dfu-util --list
32
...
33
Found Runtime: [1d50:60e3] ver=0002, devnum=20, cfg=1, intf=1, path="2-3.1", alt=0, name="UNKNOWN", serial="..."
34 1 tsaitgaist
</pre>
35 5 tsaitgaist
# get the "latest firmware":http://ftp.osmocom.org/binaries/simtrace2/firmware/latest or [[Wiki#Development|build it]]. Here we will use the _trace_ application firmware as example:
36 1 tsaitgaist
<pre>
37 5 tsaitgaist
wget https://ftp.osmocom.org/binaries/simtrace2/firmware/latest/simtrace-trace-dfu-latest.bin
38 1 tsaitgaist
</pre>
39 5 tsaitgaist
# flash the firmware using @dfu-util@:
40
<pre>
41
dfu-util --device 1d50:60e3 --cfg 1 --alt 1 --reset --download simtrace-trace-dfu-latest.bin
42
</pre>
43
# the green and red LED should turn on, showing the application firmware is flashed and started
44 3 tsaitgaist
45 5 tsaitgaist
h2. SAM-BA
46 1 tsaitgaist
47 5 tsaitgaist
The SAM3S micro-controller comes with an embedded bootloader called SAM-BA, allowing to flash firmware over USB.
48
The SAM-BA bootloader can be used to flash the DFU bootloader.
49 1 tsaitgaist
50 5 tsaitgaist
This method should be used if:
51
* no firmware is flashed on the device, or it has been erased (no LED turns on when the board is powered)
52
* the DFU bootloader is buggy
53
* you want to update the DFU bootloader
54 1 tsaitgaist
55 5 tsaitgaist
You can also activate the SAM-BA bootloader by erasing the flash content (this is not reversible):
56
# short the *ERASE* pin on the top of the board with the nearby 3V3 pin using a jumper or tweezers
57 1 tsaitgaist
!{width:20%}simtrace-jumper-mini.jpg!
58 5 tsaitgaist
# re-plug the USB connector and wait 1 second (pressing the *RESET* button is not sufficient)
59 1 tsaitgaist
# remove the jumper shorting *ERASE* to 3V3
60 5 tsaitgaist
# no LED should turn on
61
# to verify if the SAM-BA bootloader has been started:
62
** using @lsusb@ you should find the following entry:
63 1 tsaitgaist
<pre>
64 2 tsaitgaist
ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader
65
</pre>
66 5 tsaitgaist
** using @journalctl -f@ ensure the board has been recognized as USB ACM device:
67 2 tsaitgaist
<pre>
68
kernel: usb 2-2: new full-speed USB device number 4 using xhci_hcd
69
kernel: usb 2-2: New USB device found, idVendor=03eb, idProduct=6124
70
kernel: usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
71 1 tsaitgaist
kernel: cdc_acm 2-2:1.0: ttyACM0: USB ACM device
72
kernel: usbcore: registered new interface driver cdc_acm
73
kernel: cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
74
</pre>
75
76 5 tsaitgaist
To flash using the SAM-BA bootloader:
77 1 tsaitgaist
# install the @bossac@ utility to flash using the SAMBA protocol
78
<pre>
79
sudo apt install bossac
80
</pre>
81 5 tsaitgaist
# download the DFU bootloader:
82 1 tsaitgaist
<pre>
83 5 tsaitgaist
wget https://ftp.osmocom.org/binaries/simtrace2/firmware/latest/simtrace-dfu-flash-latest.bin
84 1 tsaitgaist
</pre>
85 5 tsaitgaist
# flash the USB DFU bootloader using @bossac@ (note: @erase@ ensures no main application remains so to force booting the USB DFU bootloader; @boot=1@ ensures the micro-controller will boot from the internal flash instead of the embedded bootloader next time it is powered up)
86
<pre>
87
sudo bossac --port=/dev/ttyACM0 --usb-port=1 --erase --verify --boot=1 --write simtrace-dfu-flash-latest.bin
88
</pre>
89
# re-plug the USB connector (be sure the *ERASE* pin is not shorted). If the DFU bootloader has been flashed correctly:
90
** only the green LED should be on
91
** the USB device should be listed as SIMtrace instead od SAMBA
92
<pre>
93
lsusb
94
...
95
Bus 002 Device 024: ID 1d50:60e3 OpenMoko, Inc. Osmocom SIMtrace 2
96
</pre>
97
** the DFU bootloader should be recognized:
98
<pre>
99
sudo dfu-util --list
100
...
101
Found DFU: [1d50:60e3] ver=0000, devnum=24, cfg=1, intf=0, path="2-3.1", alt=1, name="Flash (Application Partition)", serial="UNKNOWN"
102
Found DFU: [1d50:60e3] ver=0000, devnum=24, cfg=1, intf=0, path="2-3.1", alt=0, name="RAM", serial="UNKNOWN"
103
</pre>
104 1 tsaitgaist
105 5 tsaitgaist
Once the USB DFU bootloader is flashed, you can flash the application firmware using the [[Flashing#DFU|DFU]] method.
106
107
To prevent using @sudo@, grant to current user the permission to access USB serial devices (e.g. @/dev/ttyACM0@). Note: this change only takes effect after re-logging-in
108 1 tsaitgaist
<pre>
109
sudo adduser $USERNAME dialout
110
</pre>
111
112
h2. JTAG
113
114 5 tsaitgaist
It is also possible to flash he firmware over JTAG/SWD using the ARM 20-pin JTAG header on the top of the board.
115 1 tsaitgaist
116 5 tsaitgaist
This is mainly meant for [[Wiki#Development|development]] since it also allows to debug the firmware.
117
118 1 tsaitgaist
To flash the USB DFU firmware using JTAG:
119
# install the JTAG utility @openOCD@
120
<pre>
121
sudo apt install openocd
122
</pre>
123 5 tsaitgaist
# download the DFU bootloader:
124
<pre>
125
wget https://ftp.osmocom.org/binaries/simtrace2/firmware/latest/simtrace-dfu-flash-latest.bin
126
</pre>
127 1 tsaitgaist
# flash the USB DFU bootloader firmware
128
<pre>
129 5 tsaitgaist
openocd --file interface/jlink.cfg --file target/at91sam3sXX.cfg --command "init" --command "halt" --command "flash write_bank 0 simtrace-dfu-flash-latest.bin 0" --command "at91sam3 gpnvm set 1" --command "reset" --command "shutdown"
130 1 tsaitgaist
</pre>
131
#* replace @interface/jlink.cfg@ with the configuration file for your JTAG debugging adapter
132 5 tsaitgaist
#* @at91sam3 gpnvm set 1@ ensures the micro-controller will boot from the internal flash (i.e. not from the embedded SAM-BA bootloader)
133 1 tsaitgaist
134
The SAM3S also offers the low pin-count SWD alternative to JTAG, allowing to use an inexpensive ST-Link V2 (clone) to flash (and debug):
135
<pre>
136 5 tsaitgaist
openocd --file interface/stlink-v2.cfg --command "set CPUTAPID 0x2ba01477" --file target/at91sam3sXX.cfg --command "init" --command "halt" --command "flash write_bank 0 simtrace-dfu-flash-latest.bin 0" --command "at91sam3 gpnvm set 1" --command "reset" --command "shutdown"
137 1 tsaitgaist
</pre>
138
139
SWD pinout:
140
!{width:20%}simtrace_swd.jpg!
141
142 5 tsaitgaist
Once the USB DFU bootloader is flashed, after re-plugging the USB connector, you can flash the main application firmware using the DFU method.
143
144
h1. sysmoQMOD
145
146
This section will cover the flashing methods for the [[Wiki#sysmoQMOD|sysmoQMOD board]].
147
148
The sysmoQMOD has two SAM3S micro-controllers, each emulating the card for two modems:
149
* ST12 is the micro-controller on the right (when the power jack is on top), and emulates cards for the two right-most modems
150
* ST34 is the micro-controller on the left (when the power jack is on top), and emulates cards for the two left-most modems
151
* each card slot has one red LED nearby (e.g. two per micro-controllers) to show the status of the firmware
152
153
All the following procedures can be independently performed on each of the SAM3S micro-controllers, providing you use the corresponding USB path/device names.
154
155
h2. DFU
156
157
*precondition*: a functioning application firmware or DFU bootloader must already be installed.
158
159
sysmoQMOD comes with a USB DFU bootloader pre-installed which allows to flash the application firmware over USB using the @dfu-util@ utility.
160
161
To check if you have a functioning application firmware or DFU bootloader (per micro-controller and set of two modems/card slot), power the board:
162
* if both red LEDs are on, you should have a functioning application firmware
163
* if only one red LED is on, the application firmware is missing, but the DFU bootloader is present
164
* in case the application firmware is buggy, you can force the board to boot the DFU bootloader: short the TX and RX pins next to the micro-controller while powering the board.
165
!{width:20%}sysmoqmod-dfu.jpg!
166
* if the USB DFU bootloader is missing, use the SAM-BA method to flash the DFU bootloader.
167
168
To update the application firmware over the DFU bootloader, we will use @dfu-util@:
169
# get @dfu-util@:
170
<pre>
171
sudo apt-get install dfu-util
172
</pre>
173
# check if the board and DFU bootloader are detected (here for both micro-controllers):
174
<pre>
175
sudo dfu-util --list
176
...
177
Found Runtime: [1d50:4004] ver=0002, devnum=36, cfg=1, intf=2, path="2-2.1", alt=0, name="UNKNOWN", serial="UNKNOWN"
178
Found Runtime: [1d50:4004] ver=0002, devnum=37, cfg=1, intf=2, path="2-2.4", alt=0, name="UNKNOWN", serial="UNKNOWN"
179
</pre>
180
# get the "latest firmware":http://ftp.osmocom.org/binaries/simtrace2/firmware/latest or [[Wiki#Development|build it]].
181
<pre>
182
wget https://ftp.osmocom.org/binaries/simtrace2/firmware/latest/qmod-cardem-dfu-latest.bin
183
</pre>
184
# flash the firmware using @dfu-util@:
185
<pre>
186
dfu-util --device 1d50:4004 --cfg 1 --alt 1 --path "2-2.1" --reset --download qmod-cardem-dfu-latest.bin
187
</pre>
188
# both red LEDs should turn on, showing the application firmware is flashed and started
189
190
h2. SAM-BA
191
192
If none of the LEDs are on, the flash of the micro-controller might have been erased.
193
In this case, the SAM3S micro-controller should start the embedded bootloader called SAM-BA, allowing to flash firmware over USB.
194
The SAM-BA bootloader can be used to flash the DFU bootloader.
195
196
To verify if the SAM-BA bootloader has been started:
197
* using @lsusb@ you should find the following entry:
198
<pre>
199
ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader
200
</pre>
201
* using @journalctl -f@ ensure the board has been recognized as USB ACM device:
202
<pre>
203
kernel: usb 2-2: new full-speed USB device number 4 using xhci_hcd
204
kernel: usb 2-2: New USB device found, idVendor=03eb, idProduct=6124
205
kernel: usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
206
kernel: cdc_acm 2-2:1.0: ttyACM0: USB ACM device
207
kernel: usbcore: registered new interface driver cdc_acm
208
kernel: cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
209
</pre>
210
211
To flash using the SAM-BA bootloader:
212
# install the @bossac@ utility to flash using the SAMBA protocol
213
<pre>
214
sudo apt install bossac
215
</pre>
216
# download the DFU bootloader:
217
<pre>
218
wget https://ftp.osmocom.org/binaries/simtrace2/firmware/latest/qmod-dfu-flash-latest.bin
219
</pre>
220
# flash the USB DFU bootloader using @bossac@ (note: @erase@ ensures no main application remains so to force booting the USB DFU bootloader; @boot=1@ ensures the micro-controller will boot from the internal flash instead of the embedded bootloader next time it is powered up)
221
<pre>
222
sudo bossac --port=/dev/ttyACM0 --usb-port=1 --erase --verify --boot=1 --write qmod-dfu-flash-latest.bin
223
</pre>
224
# Re-power the board. If the DFU bootloader has been flashed correctly:
225
** only one red LED should be on
226
** the USB device should be listed as OpenMoko/"quad modem" instead of SAMBA
227
<pre>
228
lsusb
229
...
230
Bus 002 Device 024: ID 1d50:4004 OpenMoko, Inc.
231
</pre>
232
** the DFU bootloader should be recognized:
233
<pre>
234
sudo dfu-util --list
235
...
236
Found DFU: [1d50:4004] ver=0010, devnum=58, cfg=1, intf=0, path="2-2.4", alt=1, name="Flash (Application Partition)", serial="UNKNOWN"
237
Found DFU: [1d50:4004] ver=0010, devnum=58, cfg=1, intf=0, path="2-2.4", alt=0, name="RAM", serial="UNKNOWN"
238
</pre>
239
240
Once the USB DFU bootloader is flashed, you can flash the application firmware using the [[Flashing#DFU-2|DFU]] method.
241
242
To prevent using @sudo@, grant to current user the permission to access USB serial devices (e.g. @/dev/ttyACM0@). Note: this change only takes effect after re-logging-in
243
<pre>
244
sudo adduser $USERNAME dialout
245
</pre>
246
247
If no LED is on and the SAM-BA bootloader is not present, or you require to update the DFU bootloader, please contact the customer support of sysmocom.
Add picture from clipboard (Maximum size: 48.8 MB)