| 1 |
========= |
| 2 |
CH341A/B |
| 3 |
========= |
| 4 |
|
| 5 |
.. meta:: |
| 6 |
:author: Stephan Schneider |
| 7 |
|
| 8 |
The CH341\ **A** is a chip that provides a bridge between USB and serial communication. The |
| 9 |
CH341\ **B** is almost identical, it also has a built-in oscillator. However, it is not |
| 10 |
recommended to use the CH341\ **B** with the built-in oscillator and without a crystal |
| 11 |
as the accuracy of the built-in oscillator is very poor and timing problems can occur |
| 12 |
during data transmission. The serial communication of the CH341A/B can be UART or SPI/I2C, |
| 13 |
here we are only interested in the SPI/I2C mode. The following description applies to both |
| 14 |
chips, it does not matter which one you have. With a crystal, flashrom works with both the |
| 15 |
CH341A and the CH341B without changing the software. |
| 16 |
|
| 17 |
|
| 18 |
There are 2 ready-made boards that are suitable for use with flashrom, one with an IC socket |
| 19 |
(Textool) with a mostly black board and one without an IC socket with a mostly blue board. |
| 20 |
|
| 21 |
Image 1: Black board with IC socket |
| 22 |
|
| 23 |
.. image:: black_board_with_IC_socket.jpg |
| 24 |
|
| 25 |
Image 2: Blue board without IC socket |
| 26 |
|
| 27 |
.. image:: blue_board_without_IC_socket.jpg |
| 28 |
|
| 29 |
Both boards have advantages and disadvantages. The black board with IC socket is more practical |
| 30 |
because the IC socket is already installed. However, it has an error in the circuit diagram that |
| 31 |
must be corrected so as not to jeopardize the EEPROMs. There is a voltage converter on the board to |
| 32 |
convert the 5 volts of the USB to 3.3 volts, the 3.3 volts are then fed to the IC socket, but |
| 33 |
unfortunately the CH341A is still supplied with 5 volts. The CH341A also works with 5 volts, but then |
| 34 |
there is a voltage of just under 5 volts at the outputs of the CH341A that lead to the IC socket, |
| 35 |
which is usually too much for the inputs of the EEPROMs and can cause them to break. The blue board |
| 36 |
without an IC socket is correctly designed, but you also need an IC socket and some connecting wires, |
| 37 |
which makes things complicated and error-prone. |
| 38 |
|
| 39 |
Image 3: Blue board and additional IC socket with wiring |
| 40 |
|
| 41 |
.. image:: blue_board_additional_IC_socket_with_wiring.jpg |
| 42 |
|
| 43 |
The conversion of the black circuit board with IC socket is simple: You need a soldering iron, |
| 44 |
some insulated wire, some insulating tape and a steady hand. First you need to lift pin 28 of the |
| 45 |
CH341A by approx. 1 mm, heat the pin with the soldering iron and insert a thin knife blade between |
| 46 |
the pin and the board. Then stick a small piece of insulating tape between the pin and the circuit |
| 47 |
board to prevent contact. Then you have to connect the bent up pin 28 with 3.3 volts and pin 9 also |
| 48 |
with 3.3 volts, the connections are shown in the next picture. |
| 49 |
|
| 50 |
Image 4: Yellow: insulating tape, pink: new connections |
| 51 |
|
| 52 |
.. image:: yellow_insulating_tape_pink_new_connections.jpg |
| 53 |
|
| 54 |
For programming with flashrom you have to set the SPI/I2C mode of the CH341A, the corresponding jumper |
| 55 |
must be set to the position shown in the pictures (it is the yellow jumper in each case). On the blue |
| 56 |
board without IC socket you have to set the operating voltage with 2 jumpers (here blue), this is |
| 57 |
usually 3.3 volts, there are only a few older EEPROMs that still require 5 volts, please check the data |
| 58 |
sheet of the EEPROM to be on the safe side. |
| 59 |
|
| 60 |
Image 5: Green: 3.3 Volt, orange: 5 Volt |
| 61 |
|
| 62 |
.. image:: green_3_3V_orange_5V.jpg |
| 63 |
|
| 64 |
When using the blue board, you still have to make the correct connections between the EEPROM and the CH341A board: |
| 65 |
|
| 66 |
+---------------+--------------+ |
| 67 |
| Pin 1 -> CS0 | Pin 8 -> Vcc | |
| 68 |
+---------------+--------------+ |
| 69 |
| Pin 2 -> MISO | Pin 7 -> Vcc | |
| 70 |
+---------------+--------------+ |
| 71 |
| Pin 3 -> Vcc | Pin 6 ➔ SCK | |
| 72 |
+---------------+--------------+ |
| 73 |
| Pin 4 -> GND | Pin 5 ➔ MOSI | |
| 74 |
+---------------+--------------+ |
| 75 |
|
| 76 |
Pin 1 of the EEPROM is usually marked with a dot or similar, see also the EEPROM data sheet |
| 77 |
|
| 78 |
Image 6: Pinout of an EEPROM |
| 79 |
|
| 80 |
.. image:: pinout_of_EEPROM.jpg |
| 81 |
|
| 82 |
The following commands are some examples how to call flashrom with CH341A:: |
| 83 |
|
| 84 |
flashrom -p ch341a_spi |
| 85 |
flashrom -p ch341a_spi -r filename.bin |
| 86 |
flashrom -p ch341a_spi -w filename.bin |
| 87 |
|
| 88 |
That's all, good luck! |