Debian Codegraph @

doc/supported_hw/supported_prog/serprog/arduino_flasher_3.3v.rst

raw
1 ====================
2 Arduino flasher 3.3v
3 ====================
4
5 Introduction
6 ============
7
8 This explains how to:
9
10 * Easily lower the voltage of an arduino
11 * Use that arduino to flash a coreboot image on a GM45 Thinkpad with a SOIC16 chip
12
13 It requires:
14
15 * An AVR Arduino at 5v
16 * An USB<->Serial adapter capable of providing enough current to power up:
17
18 * The arduino
19 * The flash chip
20 * The circuits around the flash chip
21
22 It was tested with:
23
24 * An Arduino.org "nano version 3.3"
25 * A Sparkfun "FTDI Basic 3v3" (Uses an FTDI FT232R)
26
27 Caveats and warnings:
28
29 * It requires you to to never connect an USB cable between the Arduino USB port and the computer while the flasher is connected to a flash chip.
30 This would result in the I/O voltage being 5V instead of 3.3V. If you think you may accidentally connect it this way, this flasher isn't the right solution for you.
31 * You need to read the tutorial, if you don't understand it, it's probably not for you. In doubt you could ask for some help in flashrom real-time channels
32 or on the mailing list, see :doc:`/contact`.
33 * For now it requires to patch frser-duino
34
35 Theory
36 ========
37
38 In the `Atmega328/P datasheet <https://web.archive.org/web/20181004225154/ww1.microchip.com/downloads/en/DeviceDoc/Atmel-42735-8-bit-AVR-Microcontroller-ATmega328-328P_Datasheet.pdf>`_,
39 the "32.3. Speed Grades" chapter describes (pages 368 and 369) the link between maximum frequency of the microcontroller and the voltage. At 3.3v, the maximum frequency is 12Mhz.
40
41 HOWTO
42 ========
43
44 Build the code installing it on the arduino
45 -------------------------------------------
46
47 Building frser-duino
48 ^^^^^^^^^^^^^^^^^^^^
49
50 First download frser-duino::
51
52 $ git clone --recursive https://github.com/urjaman/frser-duino.git
53 $ cd frser-duino
54
55 Then modify the ``F_CPU`` value in ``main.h`` to be 12Mhz instead of 16Mhz. ``F_CPU`` will look like that::
56
57 #define F_CPU 16000000UL
58
59 Change it to::
60
61 #define F_CPU 12000000UL
62
63 You can then build the code::
64
65 $ make ftdi
66
67 Installing the code on the arduino
68 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
69
70 Before installing the code on arduino we want to make sure that we are talking to the right device.
71 To do that make sure that the arduino is not connected to your computer and run::
72
73 $ ls -l /dev/ttyUSB0
74
75 If everything went fine it will output something like that::
76
77 ls: cannot access '/dev/ttyUSB0': No such file or directory
78
79 If instead it looks like that::
80
81 crw-rw---- 1 root uucp 188, 0 27 févr. 14:30 /dev/ttyUSB0
82
83 then something else is connected to your computer at ``/dev/ttyUSB0``. If you can't figure what's going on by yourself,
84 it's better to try get help on the flashrom channels to fix the issue, see :doc:`/contact`.
85
86 Then connect your arduino to the computer and run the same command::
87
88 $ ls -l /dev/ttyUSB0
89
90 This time it's supposed to output a line that looks more or less like that::
91
92 crw-rw---- 1 root uucp 188, 0 27 févr. 14:30 /dev/ttyUSB0
93
94 At this point we're pretty confident that ``/dev/ttyUSB0`` corresponds to the arduino, so we can install the code with::
95
96 $ make flash-ftdi
97
98 Once it is installed we can now test that everything went fine with::
99
100 $ flashrom -p serprog:dev=/dev/ttyUSB0:2000000
101
102 This will make flashrom talk to the arduino to verify if everything is fine up to this point.
103
104 If everything went fine it will look more or less like that::
105
106 $ flashrom -p serprog:dev=/dev/ttyUSB0:2000000
107 /sys/firmware/dmi/tables/smbios_entry_point: Permission denied
108 /dev/mem: Permission denied
109 /sys/firmware/dmi/tables/smbios_entry_point: Permission denied
110 /dev/mem: Permission denied
111 flashrom v1.0 on Linux 4.15.2-gnu-1 (i686)
112 flashrom is free software, get the source code at https://flashrom.org
113
114 Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
115 serprog: Programmer name is "frser-duino"
116 serprog: requested mapping AT45CS1282 is incompatible: 0x1080000 bytes at 0xfef80000.
117 No EEPROM/flash device found.
118 Note: flashrom can never write if the flash chip isn't found automatically.
119
120 This is the important line::
121
122 serprog: Programmer name is "frser-duino"
123
124 It means that flashrom is able to talk to the flasher, which reports itself as "frser-duino" We also have the following line::
125
126 No EEPROM/flash device found.
127
128 which tells that it didn't find any flash. This is what's supposed to happen since we didn't connect any yet.
129
130 Build the programmer
131 --------------------
132
133 Connect the programmer to the USB<->Serial adapter
134 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
135
136 To do that:
137
138 * Connect the FTDI adapter RX to the TX of the arduino
139 * Connect the FTDI adapter TX to the RX of the arduino
140 * Connect the 3V3 of the FTDI adapter to the 5V pin of the Arduino
141 * Connect the GND of the FTDI adapter to the GDN of the arduino.
142
143 Here's a summary of the above:
144
145 ======== =========================
146 Arduino USB<->Serial port adapter
147 ======== =========================
148 RX TX
149 TX RX
150 5v 3.3v
151 GND GND
152 ======== =========================
153
154 You can now check that the programmer is responding with::
155
156 flashrom -p serprog:dev=/dev/ttyUSB0:2000000
157
158 Since you didn't connect yet a flash chip, it will says it found no flash chips::
159
160 $ flashrom -p serprog:dev=/dev/ttyUSB0:2000000
161 /sys/firmware/dmi/tables/smbios_entry_point: Permission denied
162 /dev/mem: Permission denied
163 /sys/firmware/dmi/tables/smbios_entry_point: Permission denied
164 /dev/mem: Permission denied
165 flashrom v1.0 on Linux 4.15.2-gnu-1 (i686)
166 flashrom is free software, get the source code at https://flashrom.org
167
168 Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
169 serprog: Programmer name is "frser-duino"
170 serprog: requested mapping AT45CS1282 is incompatible: 0x1080000 bytes at 0xfef80000.
171 No EEPROM/flash device found.
172 Note: flashrom can never write if the flash chip isn't found automatically.
173
174 Again like before the important parts are::
175
176 serprog: Programmer name is "frser-duino"
177
178 And::
179
180 No EEPROM/flash device found.
181
182 If you made it up to this point, you successfully built the flasher.
183
184 Using the programmer
185 --------------------
186
187 Connect the programmer to a flash chip
188 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
189
190 Since the flasher has been built, you probably want to use it.
191
192 If you use a clip (Like a SOIC-8 or SOIC16 Pomona clip), connect it to the Arduino
193 Connect the chip to the clip, or if you don't use a clip, the chip to the Arduino
194 Here's how to connect the flash chips to the programmer:
195
196 =========== ========================== =================== =====================
197 Arduino pin Function Flash chip pin name SOIC16 Flash chip pin
198 =========== ========================== =================== =====================
199 D13 CLK (Clock) CLK 16
200 D12 MISO (Master In Slave Out) MISO or SO 8
201 D11 MOSI (Master Out Slave In) MOSI or SI 15
202 D10 CS# (Chip Select) CS# or CS OR SS 7
203 GND GND (Ground) GND 10
204 5V 3.3V VCC 2
205 5V 3.3V WP# (Write Protect) 9
206 5V 3.3V HOLD# 1
207 =========== ========================== =================== =====================
208
209 Then connect an USB cable between the USB<->Serial adapter and the computer.
210 Never connect the cable between the Arduino USB port and the computer while the flasher is connected to a flash chip.
211 That would result in the I/O voltage being 5V instead of 3.3V.
212
213 Flashing
214 ^^^^^^^^
215
216 Run flashrom like that::
217
218 flashrom -p serprog:dev=/dev/ttyUSB0:2000000
219
220 With some models of Macronix flash chip (that are present in the Thinkpad X200) you might need to add ``spispeed=100k`` like that::
221
222 flashrom -p serprog:dev=/dev/ttyUSB0:2000000,spispeed=100k
223
224 Thanks
225 ========
226
227 Thanks a lot to SwiftGeek on IRC (#libreboot on Libera) for finding the first workaround to make it detect flash chips at lower voltage.
228 Thanks also for telling me about the Macronix issues on the Thinkpad X200. This project would not have been possible without that.
229
230 Page license
231 ============
232
233 This page is available under the following licenses:
234
235 * `CC-BY-SA 3.0 <https://creativecommons.org/licenses/by-sa/3.0/legalcode>`_
236 * `CC-BY-SA 4.0 <https://creativecommons.org/licenses/by-sa/4.0/legalcode>`_ or later
237 * `GFDL 1.3 <https://www.gnu.org/licenses/fdl-1.3.txt>`_ or later