Flashing » History » Version 2
tsaitgaist, 07/10/2018 04:10 PM
move from main page and updated to include sysmoQMOD
1 | 2 | tsaitgaist | {{>toc}} |
---|---|---|---|
2 | |||
3 | 1 | tsaitgaist | h1. Flashing |
4 | |||
5 | There are several ways to flash firmware images, depending on the image you can to flash. |
||
6 | |||
7 | h2. DFU |
||
8 | |||
9 | SIMtrace 2 comes with a USB DFU bootloader pre-installed which allows to flash the application firmware over USB using the @dfu-util@ utility. |
||
10 | |||
11 | To get @dfu-util@: |
||
12 | <pre> |
||
13 | sudo apt-get install dfu-util |
||
14 | </pre> |
||
15 | |||
16 | To flash the firmware: |
||
17 | <pre> |
||
18 | sudo dfu-util --device 1d50:PID --cfg 1 --alt 1 --reset --download BOARD-APP-dfu.bin |
||
19 | </pre> |
||
20 | |||
21 | *PID* is the USB product ID for the corresponding [[Wiki#Hardware|hardware platform]]: |
||
22 | * @60e3@ for the [[Wiki#SIMtrace 2|SIMtrace 2 board]] |
||
23 | * @4004@ for the [[Wiki#sysmoQMOD|sysmoQMOD board]] |
||
24 | |||
25 | *BOARD* is the name of the target board for which the firmware image has been built: |
||
26 | * @simtrace@ for the [[Wiki#SIMtrace 2|SIMtrace 2 board]] |
||
27 | * @qmod@ for the [[Wiki#sysmoQMOD|sysmoQMOD board]] |
||
28 | |||
29 | *APP* is the firmware application name as listed in the [[Wiki#Firmware|firmware section]]. |
||
30 | |||
31 | You can find pre-built images on the [[Wiki#Firmware|firmware section]]. |
||
32 | |||
33 | 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: |
||
34 | <pre> |
||
35 | 2 | tsaitgaist | # add current user to plugdev group (user needs to re-login for this change to take effect) |
36 | sudo adduser $USERNAME plugdev |
||
37 | # grant access permission to SIMtrace 2 for plugdev group |
||
38 | sudo wget --output-file=/etc/udev/rules.d/99-simtrace2.rules https://git.osmocom.org/simtrace2/plain/host/99-simtrace2.rules |
||
39 | 1 | tsaitgaist | # reload udev rules |
40 | sudo udevadm control --reload-rules |
||
41 | sudo udevadm trigger |
||
42 | </pre> |
||
43 | |||
44 | 2 | tsaitgaist | h3. Forcing DFU |
45 | |||
46 | @dfu-util@ should reset the board and start the DFU bootloader. |
||
47 | 1 | tsaitgaist | Try the command a second time if it did not work at first. |
48 | 2 | tsaitgaist | If this still does not work, you can force the board to boot the DFU bootloader: |
49 | * on [[Wiki#SIMtrace 2|SIMtrace 2 boards]] keep the *BOOTLOADER* button pressed while shortly pressing on the *RESET* button |
||
50 | !{width:20%}simtrace-board-buttons.jpg! |
||
51 | * on [[Wiki#sysmoQMOD|sysmoQMOD boards]] short the TX and RX pins next to the micro-controller while powering the board. |
||
52 | !{width:20%}sysmoqmod-dfu.jpg! |
||
53 | 1 | tsaitgaist | |
54 | 2 | tsaitgaist | If the USB DFU bootloader is missing, defective, or needs to be updated, use the JTAG or SAMBA methods to flash the bootloader firmware. |
55 | 1 | tsaitgaist | |
56 | 2 | tsaitgaist | h2. SAMBA |
57 | 1 | tsaitgaist | |
58 | The SAM3S micro-controller comes with an embedded bootloader called SAMBA, allowing to flash firmwares over USB. |
||
59 | The SAMBA bootloader can be used to flash the DFU bootloader. |
||
60 | 2 | tsaitgaist | |
61 | To activate the SAMBA bootloader on [[Wiki#SIMtrace 2|SIMtrace 2 boards]]: |
||
62 | 1 | tsaitgaist | # short the *ERASE* pin on the top of the board with the nearby 3V3 pin using a jumper |
63 | 2 | tsaitgaist | !{width:20%}simtrace-jumper-mini.jpg! |
64 | # connect SIMtrace 2 over USB to power it up (no LED will light up) and wait 1 second |
||
65 | # remove the jumper shorting *ERASE* to 3V3 |
||
66 | |||
67 | To activate the SAMBA bootloader on [[Wiki#sysmoQMOD|sysmoQMOD boards]]: |
||
68 | # connect using an USB to UART adapter to the serial port on the SAM3S micro-controller *opposite* of the one you want to reflash |
||
69 | !{width:20%}sysmoqmod-dfu.jpg! |
||
70 | # the serial configuration is 115200 8N1 |
||
71 | # enter 'y' |
||
72 | # wait 1 second |
||
73 | # enter 'Y' |
||
74 | |||
75 | To verifry if the SAMBA bootloader has been started: |
||
76 | 1 | tsaitgaist | # using @lsusb@ you should find the following entry: |
77 | <pre> |
||
78 | ID 03eb:6124 Atmel Corp. at91sam SAMBA bootloader |
||
79 | </pre> |
||
80 | # using @journalctl -f@ ensure SIMtrace 2 has been recognized as USB ACM device: |
||
81 | <pre> |
||
82 | kernel: usb 2-2: new full-speed USB device number 4 using xhci_hcd |
||
83 | kernel: usb 2-2: New USB device found, idVendor=03eb, idProduct=6124 |
||
84 | kernel: usb 2-2: New USB device strings: Mfr=0, Product=0, SerialNumber=0 |
||
85 | kernel: cdc_acm 2-2:1.0: ttyACM0: USB ACM device |
||
86 | kernel: usbcore: registered new interface driver cdc_acm |
||
87 | kernel: cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters |
||
88 | </pre> |
||
89 | 2 | tsaitgaist | |
90 | To flash using the SAMBA bootloader: |
||
91 | 1 | tsaitgaist | # install the @bossac@ utility to flash using the SAMBA protocol |
92 | <pre> |
||
93 | sudo apt install bossac |
||
94 | </pre> |
||
95 | 2 | tsaitgaist | # download the DFU bootloader firmware image corresponding to your board: |
96 | ** attachment:simtrace-dfu-flash.bin for [[Wiki#SIMtrace 2|SIMtrace 2 boards]] |
||
97 | ** attachment:qmod-dfu-flash.bin for [[Wiki#sysmoQMOD|sysmoQMOD boards]] |
||
98 | 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) |
99 | <pre> |
||
100 | 2 | tsaitgaist | sudo bossac --port /dev/ttyACM0 --erase --write BOARD-dfu-flash.bin --verify --boot=1 |
101 | 1 | tsaitgaist | </pre> |
102 | 2 | tsaitgaist | ## using the following firmware image: |
103 | |||
104 | 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 |
105 | <pre> |
||
106 | sudo adduser $USERNAME dialout |
||
107 | </pre> |
||
108 | |||
109 | 2 | tsaitgaist | Once the USB DFU bootloader is flashed, when re-pluging the SIMtrace 2 device over USB, you can flash the main application firmware using the [[Flashing#DFU|DFU]] method. |
110 | 1 | tsaitgaist | |
111 | 2 | tsaitgaist | h2. JTAG |
112 | 1 | tsaitgaist | |
113 | 2 | tsaitgaist | It is also possible to flash or debug [[Wiki#SIMtrace 2|SIMtrace 2 boards]] over JTAG using the ARM 20-pin JTAG header on the top of the board. |
114 | 1 | tsaitgaist | |
115 | To flash the USB DFU firmware using JTAG: |
||
116 | # install the JTAG utility @openOCD@ |
||
117 | <pre> |
||
118 | sudo apt install openocd |
||
119 | </pre> |
||
120 | # flash the USB DFU bootloader firmware |
||
121 | <pre> |
||
122 | 2 | tsaitgaist | openocd --file interface/jlink.cfg --file target/at91sam3sXX.cfg --command "init" --command "halt" --command "flash write_bank 0 simtrace-dfu-flash.bin 0" --command "at91sam3 gpnvm set 1" --command "reset" --command "shutdown" |
123 | 1 | tsaitgaist | </pre> |
124 | #* replace @interface/jlink.cfg@ with the configuration file for your JTAG debugging adapter |
||
125 | #* @at91sam3 gpnvm set 1@ ensures the micro-controller will boot from the internal flash (i.e. not from the embedded SAMBA bootloader) |
||
126 | |||
127 | 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): |
||
128 | <pre> |
||
129 | 2 | 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.bin 0" --command "at91sam3 gpnvm set 1" --command "reset" --command "shutdown" |
130 | 1 | tsaitgaist | </pre> |
131 | |||
132 | SWD pinout: |
||
133 | 2 | tsaitgaist | !{width:20%}simtrace_swd.jpg! |
134 | 1 | tsaitgaist | |
135 | 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. |