1 | [[TOC]]
|
---|
2 | Here I try to collect some information about flashing new firmware onto the FSC board. While the FSC has been built to be Arduino-compatible, we never really managed to install the well known Arduino bootloader onto the FSC. So the firmware can't be installed via USB, but needs to be programmed via the ISP port using an external ISP programmer like the one shown in the picture below. This is an original "AVR ISP mkII", but others should work as well.
|
---|
3 |
|
---|
4 | == The AVR ISP mkII on Ubuntu ==
|
---|
5 |
|
---|
6 | Check if the USB connection works. Leave the programmer unplugged from the board to be programmed, but connect it to your PC via USB. You should see it, when typing **lsusb** in a terminal, e.g. like this:
|
---|
7 | {{{
|
---|
8 | Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
|
---|
9 | Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
|
---|
10 | Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
|
---|
11 | Bus 006 Device 007: ID 03eb:2104 Atmel Corp. AVR ISP mkII <--- this is it.
|
---|
12 | Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
|
---|
13 | }}}
|
---|
14 |
|
---|
15 | In order to speak to the programmer, the program called **avrdude** is needed. It can be simply installed by
|
---|
16 | {{{
|
---|
17 | sudo apt-get install avrdude
|
---|
18 | }}}
|
---|
19 |
|
---|
20 | We can check, if avrdude can talk to the programmer, even before the programmer is connected to the board, by typing:
|
---|
21 | {{{
|
---|
22 | avrdude -p m328 -c avrispmkII -P usb -v
|
---|
23 | }}}
|
---|
24 |
|
---|
25 | Here the -p parameter, specifies the type of the microcontroller (MCU) we want to program, since we actually don't want to program any MCU right now, but just check, if we can talk to the programmer, this parameter doesn't matter. However this parameter is not optional.
|
---|
26 | The -c parameter specifies the type of programmer, we want to use and -P specifies the port, we connnected the programmer to. (Luckily specifying 'usb' is enough and we don't have to specify the bus and device number).
|
---|
27 |
|
---|
28 | The ouput might look like this:
|
---|
29 | {{{
|
---|
30 | dneise@NeiseLenovo:~$ avrdude -p m32 -c avrispmkII -P usb -v
|
---|
31 |
|
---|
32 | avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
|
---|
33 | Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
|
---|
34 | Copyright (c) 2007-2009 Joerg Wunsch
|
---|
35 |
|
---|
36 | System wide configuration file is "/etc/avrdude.conf"
|
---|
37 | User configuration file is "/home/dneise/.avrduderc"
|
---|
38 | User configuration file does not exist or is not a regular file, skipping
|
---|
39 |
|
---|
40 | Using Port : usb
|
---|
41 | Using Programmer : avrispmkII
|
---|
42 | avrdude: usb_open(): cannot read serial number "error sending control message: Operation not permitted"
|
---|
43 | avrdude: usb_open(): cannot read product name "error sending control message: Operation not permitted"
|
---|
44 | avrdude: usbdev_open(): Found [unnamed product], serno: [unknown]
|
---|
45 | avrdude: usbdev_open(): error setting configuration 1: could not set config 1: Operation not permitted
|
---|
46 | avrdude: usbdev_open(): did not find any USB device "usb"
|
---|
47 | }}}
|
---|
48 |
|
---|
49 | The problem here is, that your user does not have access rights for this USB device. We solve this quickly by putting **sudo** in front of the command. Also we add the **-v** option in order to get more information
|
---|
50 | {{{
|
---|
51 | dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb -v
|
---|
52 |
|
---|
53 | avrdude: Version 6.0.1, compiled on Oct 21 2013 at 15:55:32
|
---|
54 | Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
|
---|
55 | Copyright (c) 2007-2009 Joerg Wunsch
|
---|
56 |
|
---|
57 | System wide configuration file is "/etc/avrdude.conf"
|
---|
58 | User configuration file is "/home/dneise/.avrduderc"
|
---|
59 | User configuration file does not exist or is not a regular file, skipping
|
---|
60 |
|
---|
61 | Using Port : usb
|
---|
62 | Using Programmer : avrispmkII
|
---|
63 | avrdude: usbdev_open(): Found AVRISP mkII, serno: 000200059292
|
---|
64 | AVR Part : ATmega32
|
---|
65 | Chip Erase delay : 9000 us
|
---|
66 | PAGEL : PD7
|
---|
67 | BS2 : PA0
|
---|
68 | RESET disposition : dedicated
|
---|
69 | RETRY pulse : SCK
|
---|
70 | serial program mode : yes
|
---|
71 | parallel program mode : yes
|
---|
72 | Timeout : 200
|
---|
73 | StabDelay : 100
|
---|
74 | CmdexeDelay : 25
|
---|
75 | SyncLoops : 32
|
---|
76 | ByteDelay : 0
|
---|
77 | PollIndex : 3
|
---|
78 | PollValue : 0x53
|
---|
79 | Memory Detail :
|
---|
80 |
|
---|
81 | Block Poll Page Polled
|
---|
82 | Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
|
---|
83 | ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
|
---|
84 | eeprom 4 10 64 0 no 1024 4 0 9000 9000 0xff 0xff
|
---|
85 | flash 33 6 64 0 yes 32768 128 256 4500 4500 0xff 0xff
|
---|
86 | lfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
|
---|
87 | hfuse 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
|
---|
88 | lock 0 0 0 0 no 1 0 0 2000 2000 0x00 0x00
|
---|
89 | signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
|
---|
90 | calibration 0 0 0 0 no 4 0 0 0 0 0x00 0x00
|
---|
91 |
|
---|
92 | Programmer Type : STK500V2
|
---|
93 | Description : Atmel AVR ISP mkII
|
---|
94 | Programmer Model: AVRISP mkII
|
---|
95 | Hardware Version: 1
|
---|
96 | Firmware Version Master : 1.13
|
---|
97 | Vtarget : 0.0 V
|
---|
98 | SCK period : 0.50 us
|
---|
99 |
|
---|
100 | avrdude: stk500v2_command(): command failed
|
---|
101 | avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Target not detected
|
---|
102 | avrdude: initialization failed, rc=-1
|
---|
103 | Double check connections and try again, or use -F to override
|
---|
104 | this check.
|
---|
105 |
|
---|
106 |
|
---|
107 | avrdude done. Thank you.
|
---|
108 | }}}
|
---|
109 |
|
---|
110 | As we see, in the end avrdude complains about a missing target. The reason is simply, that we did not yet connect the board. Now let's connect the board.
|
---|
111 | Make sure the connector is plugged the right way around. Pin 1 of the ISP connector on the FSC board is the one farthest away from the MCU.
|
---|
112 | Also make sure the board is powered, since it will not be powered through the programmer.
|
---|
113 | In case all connections are fine and the board is powered your output might look like this:
|
---|
114 | {{{
|
---|
115 | dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb
|
---|
116 |
|
---|
117 | avrdude: AVR device initialized and ready to accept instructions
|
---|
118 |
|
---|
119 | Reading | ################################################## | 100% 0.01s
|
---|
120 |
|
---|
121 | avrdude: Device signature = 0x1e9502
|
---|
122 |
|
---|
123 | avrdude: safemode: Fuses OK (H:FF, E:D9, L:FE)
|
---|
124 |
|
---|
125 | avrdude done. Thank you.
|
---|
126 | }}}
|
---|
127 |
|
---|
128 | You can even use the programmer in a kind of interactive session, and e.g. ask for the supply voltage level of the board.
|
---|
129 | In order to change into interactive mode, add the **-t** option (for "terminal" mode).
|
---|
130 | After you're conected to the board, you can ask for some paramters of the target, using the "parms" command.
|
---|
131 | In order to quit, simply type "quit". It might look like this:
|
---|
132 | {{{
|
---|
133 | dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb -t
|
---|
134 |
|
---|
135 | avrdude: AVR device initialized and ready to accept instructions
|
---|
136 |
|
---|
137 | Reading | ################################################## | 100% 0.01s
|
---|
138 |
|
---|
139 | avrdude: Device signature = 0x1e9502
|
---|
140 | avrdude> parms
|
---|
141 | >>> parms
|
---|
142 | Vtarget : 4.9 V
|
---|
143 | SCK period : 0.50 us
|
---|
144 | avrdude> quit
|
---|
145 | >>> quit
|
---|
146 |
|
---|
147 | avrdude: safemode: Fuses OK (H:FF, E:D9, L:FE)
|
---|
148 |
|
---|
149 | avrdude done. Thank you.
|
---|
150 | }}}
|
---|
151 |
|
---|
152 | If you accomplished this, you can be sure, that your programmer is nicely connected to the FSC board.
|
---|
153 |
|
---|
154 | == Getting the firmware ==
|
---|
155 |
|
---|
156 | For your convenience, you can always find the latest version of the firmware in FACTs SVN repository.
|
---|
157 | https://trac.fact-project.org/browser/firmware/FSC/FSC_firmware_version_from_20140318_1700.hex
|
---|
158 | Simply check out that file.
|
---|
159 |
|
---|
160 | == Flashing the hex-file ==
|
---|
161 | In order to tell avrdude to write the hex-file into the MCUs flash memory, we use the **-U** option in the form:
|
---|
162 |
|
---|
163 | -U <memtype>:r|w|v:<filename>[:format]:
|
---|
164 |
|
---|
165 | In our case memtype is "flash", the want to write so we choose "w" next, and then we just give the filename, since the format can be inferred from that.
|
---|
166 | The entire session looks like this.
|
---|
167 | {{{
|
---|
168 | dneise@NeiseLenovo:~/FSC_firmware_flash$ sudo avrdude -p m32 -c avrispmkII -P usb -U flash:w:FSC_firmware_version_from_20140318_1700.hex
|
---|
169 |
|
---|
170 | avrdude: AVR device initialized and ready to accept instructions
|
---|
171 |
|
---|
172 | Reading | ################################################## | 100% 0.00s
|
---|
173 |
|
---|
174 | avrdude: Device signature = 0x1e9502
|
---|
175 | avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
|
---|
176 | To disable this feature, specify the -D option.
|
---|
177 | avrdude: erasing chip
|
---|
178 | avrdude: reading input file "FSC_firmware_version_from_20140318_1700.hex"
|
---|
179 | avrdude: input file FSC_firmware_version_from_20140318_1700.hex auto detected as Intel Hex
|
---|
180 | avrdude: writing flash (4520 bytes):
|
---|
181 |
|
---|
182 | Writing | ################################################## | 100% 0.44s
|
---|
183 |
|
---|
184 | avrdude: 4520 bytes of flash written
|
---|
185 | avrdude: verifying flash memory against FSC_firmware_version_from_20140318_1700.hex:
|
---|
186 | avrdude: load data flash data from input file FSC_firmware_version_from_20140318_1700.hex:
|
---|
187 | avrdude: input file FSC_firmware_version_from_20140318_1700.hex auto detected as Intel Hex
|
---|
188 | avrdude: input file FSC_firmware_version_from_20140318_1700.hex contains 4520 bytes
|
---|
189 | avrdude: reading on-chip flash data:
|
---|
190 |
|
---|
191 | Reading | ################################################## | 100% 0.29s
|
---|
192 |
|
---|
193 | avrdude: verifying ...
|
---|
194 | avrdude: 4520 bytes of flash verified
|
---|
195 |
|
---|
196 | avrdude: safemode: Fuses OK (H:FF, E:D9, L:FE)
|
---|
197 |
|
---|
198 | avrdude done. Thank you.
|
---|
199 | }}}
|
---|
200 |
|
---|
201 | Congrats, you just flashed the FSC! |
---|