source: firmware/FSC/How_to_flash_the_FSC.txt@ 18715

Last change on this file since 18715 was 18185, checked in by dneise, 10 years ago
Page from Track wiki, in case one needs it herre
File size: 9.7 KB
Line 
1[[TOC]]
2Here 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
6Check 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{{{
8Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
9Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
10Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
11Bus 006 Device 007: ID 03eb:2104 Atmel Corp. AVR ISP mkII <--- this is it.
12Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
13}}}
14
15In order to speak to the programmer, the program called **avrdude** is needed. It can be simply installed by
16{{{
17sudo apt-get install avrdude
18}}}
19
20We can check, if avrdude can talk to the programmer, even before the programmer is connected to the board, by typing:
21{{{
22avrdude -p m328 -c avrispmkII -P usb -v
23}}}
24
25Here 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.
26The -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
28The ouput might look like this:
29{{{
30dneise@NeiseLenovo:~$ avrdude -p m32 -c avrispmkII -P usb -v
31
32avrdude: 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
42avrdude: usb_open(): cannot read serial number "error sending control message: Operation not permitted"
43avrdude: usb_open(): cannot read product name "error sending control message: Operation not permitted"
44avrdude: usbdev_open(): Found [unnamed product], serno: [unknown]
45avrdude: usbdev_open(): error setting configuration 1: could not set config 1: Operation not permitted
46avrdude: usbdev_open(): did not find any USB device "usb"
47}}}
48
49The 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{{{
51dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb -v
52
53avrdude: 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
63avrdude: 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
100avrdude: stk500v2_command(): command failed
101avrdude: stk500v2_program_enable(): bad AVRISPmkII connection status: Target not detected
102avrdude: initialization failed, rc=-1
103 Double check connections and try again, or use -F to override
104 this check.
105
106
107avrdude done. Thank you.
108}}}
109
110As 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.
111Make 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.
112Also make sure the board is powered, since it will not be powered through the programmer.
113In case all connections are fine and the board is powered your output might look like this:
114{{{
115dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb
116
117avrdude: AVR device initialized and ready to accept instructions
118
119Reading | ################################################## | 100% 0.01s
120
121avrdude: Device signature = 0x1e9502
122
123avrdude: safemode: Fuses OK (H:FF, E:D9, L:FE)
124
125avrdude done. Thank you.
126}}}
127
128You can even use the programmer in a kind of interactive session, and e.g. ask for the supply voltage level of the board.
129In order to change into interactive mode, add the **-t** option (for "terminal" mode).
130After you're conected to the board, you can ask for some paramters of the target, using the "parms" command.
131In order to quit, simply type "quit". It might look like this:
132{{{
133dneise@NeiseLenovo:~$ sudo avrdude -p m32 -c avrispmkII -P usb -t
134
135avrdude: AVR device initialized and ready to accept instructions
136
137Reading | ################################################## | 100% 0.01s
138
139avrdude: Device signature = 0x1e9502
140avrdude> parms
141>>> parms
142Vtarget : 4.9 V
143SCK period : 0.50 us
144avrdude> quit
145>>> quit
146
147avrdude: safemode: Fuses OK (H:FF, E:D9, L:FE)
148
149avrdude done. Thank you.
150}}}
151
152If you accomplished this, you can be sure, that your programmer is nicely connected to the FSC board.
153
154== Getting the firmware ==
155
156For your convenience, you can always find the latest version of the firmware in FACTs SVN repository.
157https://trac.fact-project.org/browser/firmware/FSC/FSC_firmware_version_from_20140318_1700.hex
158Simply check out that file.
159
160== Flashing the hex-file ==
161In 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
165In 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.
166The entire session looks like this.
167{{{
168dneise@NeiseLenovo:~/FSC_firmware_flash$ sudo avrdude -p m32 -c avrispmkII -P usb -U flash:w:FSC_firmware_version_from_20140318_1700.hex
169
170avrdude: AVR device initialized and ready to accept instructions
171
172Reading | ################################################## | 100% 0.00s
173
174avrdude: Device signature = 0x1e9502
175avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed
176 To disable this feature, specify the -D option.
177avrdude: erasing chip
178avrdude: reading input file "FSC_firmware_version_from_20140318_1700.hex"
179avrdude: input file FSC_firmware_version_from_20140318_1700.hex auto detected as Intel Hex
180avrdude: writing flash (4520 bytes):
181
182Writing | ################################################## | 100% 0.44s
183
184avrdude: 4520 bytes of flash written
185avrdude: verifying flash memory against FSC_firmware_version_from_20140318_1700.hex:
186avrdude: load data flash data from input file FSC_firmware_version_from_20140318_1700.hex:
187avrdude: input file FSC_firmware_version_from_20140318_1700.hex auto detected as Intel Hex
188avrdude: input file FSC_firmware_version_from_20140318_1700.hex contains 4520 bytes
189avrdude: reading on-chip flash data:
190
191Reading | ################################################## | 100% 0.29s
192
193avrdude: verifying ...
194avrdude: 4520 bytes of flash verified
195
196avrdude: safemode: Fuses OK (H:FF, E:D9, L:FE)
197
198avrdude done. Thank you.
199}}}
200
201Congrats, you just flashed the FSC!
Note: See TracBrowser for help on using the repository browser.