Project

General

Profile

Flashing » History » Version 1

tsaitgaist, 07/10/2018 03:36 PM
put content from main page and update it

1 1 tsaitgaist
h1. Flashing
2 1 tsaitgaist
3 1 tsaitgaist
There are several ways to flash firmware images, depending on the image you can to flash.
4 1 tsaitgaist
5 1 tsaitgaist
h2. DFU
6 1 tsaitgaist
7 1 tsaitgaist
SIMtrace 2 comes with a USB DFU bootloader pre-installed which allows to flash the application firmware over USB using the @dfu-util@ utility.
8 1 tsaitgaist
9 1 tsaitgaist
To get @dfu-util@:
10 1 tsaitgaist
<pre>
11 1 tsaitgaist
sudo apt-get install dfu-util
12 1 tsaitgaist
</pre>
13 1 tsaitgaist
14 1 tsaitgaist
To flash the firmware:
15 1 tsaitgaist
<pre>
16 1 tsaitgaist
sudo dfu-util --device 1d50:PID --cfg 1 --alt 1 --reset --download BOARD-APP-dfu.bin
17 1 tsaitgaist
</pre>
18 1 tsaitgaist
19 1 tsaitgaist
*PID* is the USB product ID for the corresponding [[Wiki#Hardware|hardware platform]]:
20 1 tsaitgaist
* @60e3@ for the [[Wiki#SIMtrace 2|SIMtrace 2 board]]
21 1 tsaitgaist
* @4004@ for the [[Wiki#sysmoQMOD|sysmoQMOD board]]
22 1 tsaitgaist
23 1 tsaitgaist
*BOARD* is the name of the target board for which the firmware image has been built:
24 1 tsaitgaist
* @simtrace@ for the [[Wiki#SIMtrace 2|SIMtrace 2 board]]
25 1 tsaitgaist
* @qmod@ for the [[Wiki#sysmoQMOD|sysmoQMOD board]]
26 1 tsaitgaist
27 1 tsaitgaist
*APP* is the firmware application name as listed in the [[Wiki#Firmware|firmware section]].
28 1 tsaitgaist
29 1 tsaitgaist
You can find pre-built images on the [[Wiki#Firmware|firmware section]].
30 1 tsaitgaist
31 1 tsaitgaist
To prevent having to use @sudo@ in order to use @dfu-util@ on SIMtrace 2, grant access permission to the USB device to the current user:
32 1 tsaitgaist
<pre>
33 1 tsaitgaist
# create osmocom group
34 1 tsaitgaist
sudo groupadd osmocom
35 1 tsaitgaist
# add current user to osmocom group (user needs to re-login for this change to take effect)
36 1 tsaitgaist
sudo adduser $USERNAME osmocom
37 1 tsaitgaist
# grant access permission to SIMtrace 2 for osmocom group
38 1 tsaitgaist
sudo tee -a /etc/udev/rules.d/10-osmocom.rules << EOF
39 1 tsaitgaist
# SIMtrace 2
40 1 tsaitgaist
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d50", ATTR{idProduct}=="60e3",  MODE="0660", GROUP="osmocom" 
41 1 tsaitgaist
# sysmoQMOD
42 1 tsaitgaist
SUBSYSTEM=="usb", ATTRS{idVendor}=="1d50", ATTR{idProduct}=="4004",  MODE="0660", GROUP="osmocom" 
43 1 tsaitgaist
EOF
44 1 tsaitgaist
# reload udev rules
45 1 tsaitgaist
sudo udevadm control --reload-rules
46 1 tsaitgaist
sudo udevadm trigger
47 1 tsaitgaist
</pre>
48 1 tsaitgaist
49 1 tsaitgaist
@dfu-util@ should reset the board and use the DFU bootloader.
50 1 tsaitgaist
Try the command a second time if it did not work at first.
51 1 tsaitgaist
If this still does not work, power up the board while pressing the *BOOTLOADER* button.
52 1 tsaitgaist
53 1 tsaitgaist
If the USB DFU bootloader is missing, defective, or needs to be updated, use the JTAG or SAM-BA methods to flash the bootloader firmware.
54 1 tsaitgaist
55 1 tsaitgaist
h4. SAMBA
56 1 tsaitgaist
57 1 tsaitgaist
The SAM3S micro-controller comes with an embedded bootloader called SAMBA, allowing to flash firmwares over USB.
58 1 tsaitgaist
The SAMBA bootloader can be used to flash the DFU bootloader.
59 1 tsaitgaist
To activate the SAMBA bootloader:
60 1 tsaitgaist
# short the *ERASE* pin on the top of the board with the nearby 3V3 pin using a jumper
61 1 tsaitgaist
# connect SIMtrace 2 over USB to power it up (no LED will light up)
62 1 tsaitgaist
# using @lsusb@ you should find the following entry:
63 1 tsaitgaist
<pre>
64 1 tsaitgaist
ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader
65 1 tsaitgaist
</pre>
66 1 tsaitgaist
# using @journalctl -f@ ensure SIMtrace 2 has been recognized as USB ACM device:
67 1 tsaitgaist
<pre>
68 1 tsaitgaist
kernel: usb 2-2: new full-speed USB device number 4 using xhci_hcd
69 1 tsaitgaist
kernel: usb 2-2: New USB device found, idVendor=03eb, idProduct=6124
70 1 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
# remove the jumper shorting *ERASE* to 3V3
76 1 tsaitgaist
# install the @bossac@ utility to flash using the SAMBA protocol
77 1 tsaitgaist
<pre>
78 1 tsaitgaist
sudo apt install bossac
79 1 tsaitgaist
</pre>
80 1 tsaitgaist
# flash the USB DFU firmware 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)
81 1 tsaitgaist
<pre>
82 1 tsaitgaist
sudo bossac --port /dev/ttyACM0 --erase --write ./bin/simtrace-dfu-flash.bin --verify --boot=1
83 1 tsaitgaist
</pre>
84 1 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
85 1 tsaitgaist
<pre>
86 1 tsaitgaist
sudo adduser $USERNAME dialout
87 1 tsaitgaist
</pre>
88 1 tsaitgaist
89 1 tsaitgaist
Once the USB DFU bootloader is flashed, when re-pluging SIMtrace 2 over USB, you can flash the main application firmware using the DFU method.
90 1 tsaitgaist
91 1 tsaitgaist
h4. JTAG
92 1 tsaitgaist
93 1 tsaitgaist
It is also possible to flash or debug SIMtrace 2 over JTAG using the ARM 20-pin JTAG header on the top of the board.
94 1 tsaitgaist
95 1 tsaitgaist
To flash the USB DFU firmware using JTAG:
96 1 tsaitgaist
# install the JTAG utility @openOCD@
97 1 tsaitgaist
<pre>
98 1 tsaitgaist
sudo apt install openocd
99 1 tsaitgaist
</pre>
100 1 tsaitgaist
# flash the USB DFU bootloader firmware
101 1 tsaitgaist
<pre>
102 1 tsaitgaist
openocd --file interface/jlink.cfg --file target/at91sam3sXX.cfg --command "init" --command "halt" --command "flash write_bank 0 ./bin/simtrace-dfu-flash.bin 0" --command "at91sam3 gpnvm set 1" --command "reset" --command "shutdown"
103 1 tsaitgaist
</pre>
104 1 tsaitgaist
#* replace @interface/jlink.cfg@ with the configuration file for your JTAG debugging adapter
105 1 tsaitgaist
#* @at91sam3 gpnvm set 1@ ensures the micro-controller will boot from the internal flash (i.e. not from the embedded SAMBA bootloader)
106 1 tsaitgaist
107 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):
108 1 tsaitgaist
<pre>
109 1 tsaitgaist
openocd --file interface/stlink-v2.cfg --command "set CPUTAPID 0x2ba01477" --file target/at91sam3sXX.cfg --command "init" --command "halt" --command "flash write_bank 0 ./bin/simtrace-dfu-flash.bin 0" --command "at91sam3 gpnvm set 1" --command "reset" --command "shutdown"
110 1 tsaitgaist
</pre>
111 1 tsaitgaist
112 1 tsaitgaist
SWD pinout:
113 1 tsaitgaist
!simtrace_swd.jpg!
114 1 tsaitgaist
115 1 tsaitgaist
Once the USB DFU bootloader is flashed, when re-pluging SIMtrace 2 over USB, you can flash the main application firmware using the DFU method.
Add picture from clipboard (Maximum size: 48.8 MB)