Project

General

Profile

Flashing » History » Version 6

tsaitgaist, 09/04/2019 02:16 PM
add how to install bossa

1 2 tsaitgaist
{{>toc}}
2 2 tsaitgaist
3 1 tsaitgaist
h1. Flashing
4 1 tsaitgaist
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 5 tsaitgaist
9 5 tsaitgaist
This section will cover the flashing methods for the [[Wiki#SIMtrace v2|SIMtrace board]].
10 5 tsaitgaist
11 1 tsaitgaist
h2. DFU
12 1 tsaitgaist
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 5 tsaitgaist
17 5 tsaitgaist
To check if you have a functioning application firmware or DFU bootloader, power the board:
18 5 tsaitgaist
* if both green and red LEDs are on, you should have a functioning application firmware
19 5 tsaitgaist
* if only the green LED is on, the application firmware is missing, but the DFU bootloader is present
20 5 tsaitgaist
* 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 5 tsaitgaist
!{width:20%}simtrace-board-buttons.jpg!
22 5 tsaitgaist
* 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 5 tsaitgaist
24 5 tsaitgaist
To update the application firmware over the DFU bootloader, we will use @dfu-util@:
25 5 tsaitgaist
# get @dfu-util@:
26 1 tsaitgaist
<pre>
27 1 tsaitgaist
sudo apt-get install dfu-util
28 1 tsaitgaist
</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 5 tsaitgaist
...
33 5 tsaitgaist
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 5 tsaitgaist
<pre>
41 5 tsaitgaist
dfu-util --device 1d50:60e3 --cfg 1 --alt 1 --reset --download simtrace-trace-dfu-latest.bin
42 5 tsaitgaist
</pre>
43 5 tsaitgaist
# 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 5 tsaitgaist
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 5 tsaitgaist
* no firmware is flashed on the device, or it has been erased (no LED turns on when the board is powered)
52 5 tsaitgaist
* the DFU bootloader is buggy
53 5 tsaitgaist
* 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 5 tsaitgaist
# 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 5 tsaitgaist
# to verify if the SAM-BA bootloader has been started:
62 5 tsaitgaist
** using @lsusb@ you should find the following entry:
63 1 tsaitgaist
<pre>
64 2 tsaitgaist
ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader
65 2 tsaitgaist
</pre>
66 5 tsaitgaist
** using @journalctl -f@ ensure the board has been recognized as USB ACM device:
67 2 tsaitgaist
<pre>
68 2 tsaitgaist
kernel: usb 2-2: new full-speed USB device number 4 using xhci_hcd
69 2 tsaitgaist
kernel: usb 2-2: New USB device found, idVendor=03eb, idProduct=6124
70 2 tsaitgaist
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 1 tsaitgaist
kernel: usbcore: registered new interface driver cdc_acm
73 1 tsaitgaist
kernel: cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
74 1 tsaitgaist
</pre>
75 1 tsaitgaist
76 5 tsaitgaist
To flash using the SAM-BA bootloader:
77 1 tsaitgaist
# install the @bossac@ utility to flash using the SAMBA protocol
78 1 tsaitgaist
<pre>
79 1 tsaitgaist
sudo apt install bossac
80 1 tsaitgaist
</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 5 tsaitgaist
<pre>
87 5 tsaitgaist
sudo bossac --port=/dev/ttyACM0 --usb-port=1 --erase --verify --boot=1 --write simtrace-dfu-flash-latest.bin
88 5 tsaitgaist
</pre>
89 5 tsaitgaist
# re-plug the USB connector (be sure the *ERASE* pin is not shorted). If the DFU bootloader has been flashed correctly:
90 5 tsaitgaist
** only the green LED should be on
91 5 tsaitgaist
** the USB device should be listed as SIMtrace instead od SAMBA
92 5 tsaitgaist
<pre>
93 5 tsaitgaist
lsusb
94 5 tsaitgaist
...
95 5 tsaitgaist
Bus 002 Device 024: ID 1d50:60e3 OpenMoko, Inc. Osmocom SIMtrace 2
96 5 tsaitgaist
</pre>
97 5 tsaitgaist
** the DFU bootloader should be recognized:
98 5 tsaitgaist
<pre>
99 5 tsaitgaist
sudo dfu-util --list
100 5 tsaitgaist
...
101 5 tsaitgaist
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 5 tsaitgaist
Found DFU: [1d50:60e3] ver=0000, devnum=24, cfg=1, intf=0, path="2-3.1", alt=0, name="RAM", serial="UNKNOWN"
103 5 tsaitgaist
</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 5 tsaitgaist
107 5 tsaitgaist
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 1 tsaitgaist
sudo adduser $USERNAME dialout
110 1 tsaitgaist
</pre>
111 1 tsaitgaist
112 1 tsaitgaist
h2. JTAG
113 1 tsaitgaist
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 5 tsaitgaist
118 1 tsaitgaist
To flash the USB DFU firmware using JTAG:
119 1 tsaitgaist
# install the JTAG utility @openOCD@
120 1 tsaitgaist
<pre>
121 1 tsaitgaist
sudo apt install openocd
122 1 tsaitgaist
</pre>
123 5 tsaitgaist
# download the DFU bootloader:
124 5 tsaitgaist
<pre>
125 5 tsaitgaist
wget https://ftp.osmocom.org/binaries/simtrace2/firmware/latest/simtrace-dfu-flash-latest.bin
126 5 tsaitgaist
</pre>
127 1 tsaitgaist
# flash the USB DFU bootloader firmware
128 1 tsaitgaist
<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 1 tsaitgaist
#* 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 1 tsaitgaist
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 1 tsaitgaist
<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 1 tsaitgaist
139 1 tsaitgaist
SWD pinout:
140 1 tsaitgaist
!{width:20%}simtrace_swd.jpg!
141 1 tsaitgaist
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 5 tsaitgaist
144 5 tsaitgaist
h1. sysmoQMOD
145 5 tsaitgaist
146 5 tsaitgaist
This section will cover the flashing methods for the [[Wiki#sysmoQMOD|sysmoQMOD board]].
147 5 tsaitgaist
148 5 tsaitgaist
The sysmoQMOD has two SAM3S micro-controllers, each emulating the card for two modems:
149 5 tsaitgaist
* 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 5 tsaitgaist
* 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 5 tsaitgaist
* each card slot has one red LED nearby (e.g. two per micro-controllers) to show the status of the firmware
152 5 tsaitgaist
153 5 tsaitgaist
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 5 tsaitgaist
155 5 tsaitgaist
h2. DFU
156 5 tsaitgaist
157 5 tsaitgaist
*precondition*: a functioning application firmware or DFU bootloader must already be installed.
158 5 tsaitgaist
159 5 tsaitgaist
sysmoQMOD comes with a USB DFU bootloader pre-installed which allows to flash the application firmware over USB using the @dfu-util@ utility.
160 5 tsaitgaist
161 5 tsaitgaist
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 5 tsaitgaist
* if both red LEDs are on, you should have a functioning application firmware
163 5 tsaitgaist
* if only one red LED is on, the application firmware is missing, but the DFU bootloader is present
164 5 tsaitgaist
* 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 5 tsaitgaist
!{width:20%}sysmoqmod-dfu.jpg!
166 5 tsaitgaist
* if the USB DFU bootloader is missing, use the SAM-BA method to flash the DFU bootloader.
167 5 tsaitgaist
168 5 tsaitgaist
To update the application firmware over the DFU bootloader, we will use @dfu-util@:
169 5 tsaitgaist
# get @dfu-util@:
170 5 tsaitgaist
<pre>
171 5 tsaitgaist
sudo apt-get install dfu-util
172 5 tsaitgaist
</pre>
173 5 tsaitgaist
# check if the board and DFU bootloader are detected (here for both micro-controllers):
174 5 tsaitgaist
<pre>
175 5 tsaitgaist
sudo dfu-util --list
176 5 tsaitgaist
...
177 5 tsaitgaist
Found Runtime: [1d50:4004] ver=0002, devnum=36, cfg=1, intf=2, path="2-2.1", alt=0, name="UNKNOWN", serial="UNKNOWN"
178 5 tsaitgaist
Found Runtime: [1d50:4004] ver=0002, devnum=37, cfg=1, intf=2, path="2-2.4", alt=0, name="UNKNOWN", serial="UNKNOWN"
179 5 tsaitgaist
</pre>
180 5 tsaitgaist
# get the "latest firmware":http://ftp.osmocom.org/binaries/simtrace2/firmware/latest or [[Wiki#Development|build it]].
181 5 tsaitgaist
<pre>
182 5 tsaitgaist
wget https://ftp.osmocom.org/binaries/simtrace2/firmware/latest/qmod-cardem-dfu-latest.bin
183 5 tsaitgaist
</pre>
184 5 tsaitgaist
# flash the firmware using @dfu-util@:
185 5 tsaitgaist
<pre>
186 5 tsaitgaist
dfu-util --device 1d50:4004 --cfg 1 --alt 1 --path "2-2.1" --reset --download qmod-cardem-dfu-latest.bin
187 5 tsaitgaist
</pre>
188 5 tsaitgaist
# both red LEDs should turn on, showing the application firmware is flashed and started
189 5 tsaitgaist
190 5 tsaitgaist
h2. SAM-BA
191 5 tsaitgaist
192 5 tsaitgaist
If none of the LEDs are on, the flash of the micro-controller might have been erased.
193 5 tsaitgaist
In this case, the SAM3S micro-controller should start the embedded bootloader called SAM-BA, allowing to flash firmware over USB.
194 5 tsaitgaist
The SAM-BA bootloader can be used to flash the DFU bootloader.
195 5 tsaitgaist
196 5 tsaitgaist
To verify if the SAM-BA bootloader has been started:
197 5 tsaitgaist
* using @lsusb@ you should find the following entry:
198 5 tsaitgaist
<pre>
199 5 tsaitgaist
ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader
200 5 tsaitgaist
</pre>
201 5 tsaitgaist
* using @journalctl -f@ ensure the board has been recognized as USB ACM device:
202 5 tsaitgaist
<pre>
203 5 tsaitgaist
kernel: usb 2-2: new full-speed USB device number 4 using xhci_hcd
204 5 tsaitgaist
kernel: usb 2-2: New USB device found, idVendor=03eb, idProduct=6124
205 5 tsaitgaist
kernel: usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0
206 5 tsaitgaist
kernel: cdc_acm 2-2:1.0: ttyACM0: USB ACM device
207 5 tsaitgaist
kernel: usbcore: registered new interface driver cdc_acm
208 5 tsaitgaist
kernel: cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
209 5 tsaitgaist
</pre>
210 5 tsaitgaist
211 5 tsaitgaist
To flash using the SAM-BA bootloader:
212 5 tsaitgaist
# install the @bossac@ utility to flash using the SAMBA protocol
213 5 tsaitgaist
<pre>
214 5 tsaitgaist
sudo apt install bossac
215 5 tsaitgaist
</pre>
216 5 tsaitgaist
# download the DFU bootloader:
217 5 tsaitgaist
<pre>
218 5 tsaitgaist
wget https://ftp.osmocom.org/binaries/simtrace2/firmware/latest/qmod-dfu-flash-latest.bin
219 5 tsaitgaist
</pre>
220 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)
221 5 tsaitgaist
<pre>
222 5 tsaitgaist
sudo bossac --port=/dev/ttyACM0 --usb-port=1 --erase --verify --boot=1 --write qmod-dfu-flash-latest.bin
223 5 tsaitgaist
</pre>
224 5 tsaitgaist
# Re-power the board. If the DFU bootloader has been flashed correctly:
225 5 tsaitgaist
** only one red LED should be on
226 5 tsaitgaist
** the USB device should be listed as OpenMoko/"quad modem" instead of SAMBA
227 5 tsaitgaist
<pre>
228 5 tsaitgaist
lsusb
229 5 tsaitgaist
...
230 5 tsaitgaist
Bus 002 Device 024: ID 1d50:4004 OpenMoko, Inc.
231 5 tsaitgaist
</pre>
232 5 tsaitgaist
** the DFU bootloader should be recognized:
233 5 tsaitgaist
<pre>
234 5 tsaitgaist
sudo dfu-util --list
235 5 tsaitgaist
...
236 5 tsaitgaist
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 5 tsaitgaist
Found DFU: [1d50:4004] ver=0010, devnum=58, cfg=1, intf=0, path="2-2.4", alt=0, name="RAM", serial="UNKNOWN"
238 5 tsaitgaist
</pre>
239 5 tsaitgaist
240 5 tsaitgaist
Once the USB DFU bootloader is flashed, you can flash the application firmware using the [[Flashing#DFU-2|DFU]] method.
241 5 tsaitgaist
242 5 tsaitgaist
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 5 tsaitgaist
<pre>
244 5 tsaitgaist
sudo adduser $USERNAME dialout
245 5 tsaitgaist
</pre>
246 5 tsaitgaist
247 5 tsaitgaist
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.
248 6 tsaitgaist
249 6 tsaitgaist
h1. Install bossa
250 6 tsaitgaist
251 6 tsaitgaist
"BOSSA":https://github.com/shumatech/BOSSA is a flash programming utility for Atmel's SAM family of flash-based ARM microcontrollers.
252 6 tsaitgaist
It allows to flash the DFU bootloader on the SAM3S micro-controller used on the SIMtrace2 boards.
253 6 tsaitgaist
254 6 tsaitgaist
h2. Debian/Ubuntu
255 6 tsaitgaist
256 6 tsaitgaist
Debian (10, buster) and Ubuntu (19.04, disco) only provide pacjages for bossa-cli v1.3 from 2012 ("debian":https://packages.debian.org/buster/bossa-cli, "ubuntu":https://packages.ubuntu.com/disco/bossa-cli).
257 6 tsaitgaist
This is too old and does not support the SAM3S micro-controller used in SIMtrace2.
258 6 tsaitgaist
259 6 tsaitgaist
Thus you will have to install the current version of bossa (v1.9.1 from 2018-08 as of 2019-09):
260 6 tsaitgaist
# install the required libraries
261 6 tsaitgaist
<pre>
262 6 tsaitgaist
sudo apt install libwxgtk3.0-dev libreadline-dev
263 6 tsaitgaist
</pre>
264 6 tsaitgaist
# install required tools
265 6 tsaitgaist
<pre>
266 6 tsaitgaist
sudo apt install wget
267 6 tsaitgaist
</pre>
268 6 tsaitgaist
# get the current bossa
269 6 tsaitgaist
<pre>
270 6 tsaitgaist
wget https://github.com/shumatech/BOSSA/archive/1.9.1.tar.gz
271 6 tsaitgaist
</pre>
272 6 tsaitgaist
# decompress archive
273 6 tsaitgaist
<pre>
274 6 tsaitgaist
tar xf 1.9.1.tar.gz
275 6 tsaitgaist
</pre>
276 6 tsaitgaist
# compile bossa
277 6 tsaitgaist
<pre>
278 6 tsaitgaist
cd BOSSA-1.9.1/
279 6 tsaitgaist
make
280 6 tsaitgaist
</pre>
281 6 tsaitgaist
# install the bossa command line tool to your system (bossa does not provide install scripts)
282 6 tsaitgaist
<pre>
283 6 tsaitgaist
sudo cp bin/bossa* /usr/local/bin/
284 6 tsaitgaist
</pre>
285 6 tsaitgaist
# clean up
286 6 tsaitgaist
<pre>
287 6 tsaitgaist
cd ..
288 6 tsaitgaist
rm -r BOSSA-1.9.1/
289 6 tsaitgaist
rm 1.9.1.tar.gz
290 6 tsaitgaist
</pre>
291 6 tsaitgaist
292 6 tsaitgaist
h2. Arch
293 6 tsaitgaist
294 6 tsaitgaist
Install the "AUR":https://wiki.archlinux.org/index.php/AUR package "bossa":https://aur.archlinux.org/packages/bossa/ (v1.9.1 from 2018-08 as of 2019-09).
295 6 tsaitgaist
<pre>
296 6 tsaitgaist
pacaur -S bossa
297 6 tsaitgaist
</pre>
Add picture from clipboard (Maximum size: 48.8 MB)