Arduino flasher 3.3v

From flashrom
Jump to navigation Jump to search

This wiki is retired

Our website is https://www.flashrom.org, instructions on how to add or update documentation are here

All wiki content available in read-only mode at wiki.flashrom.org

Introduction

This explains how to:

  • Easily lower the voltage of an arduino
  • Use that arduino to flash a coreboot image on a GM45 Thinkpad with a SOIC16 chip

It requires:

  • An AVR Arduino at 5v
  • An USB<->Serial adapter capable of providing enough current to power up:
    • The arduino
    • The flash chip
    • The circuits around the flash chip

It was tested with:

  • An Arduino.org "nano version 3.3"
  • A Sparkfun "FTDI Basic 3v3" (Uses an FTDI FT232R)

Caveats:

  • It requires not to ever connect an USB cable between the Arduino USB port and the computer while the flasher is connected to a flash chip. 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.
  • For now it requires to patch frser-duino

Theory

In the Atmega328/P datasheet, 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.

HOWTO

Build the code and flash it

First download frser-duino:

$ git clone --recursive https://github.com/urjaman/frser-duino.git
$ cd frser-duino

Then modify the F_CPU value in main.h to be 12Mhz instead of 16Mhz: F_CPU will look like that:

#define F_CPU 16000000UL

Change it to:

#define F_CPU 12000000UL
  • Flash the Arduino with frser-duino
$ make ftdi
$ ls -l /dev/ttyUSB0 
crw-rw---- 1 root uucp 188, 0 27 févr. 14:30 /dev/ttyUSB0


$ make flash-ftdi

You can now test that everything went fine with:

$ flashrom -p serprog:dev=/dev/ttyUSB0:2000000

If everything went fine it will look more or less like that:

$ flashrom -p serprog:dev=/dev/ttyUSB0:2000000
/sys/firmware/dmi/tables/smbios_entry_point: Permission denied
/dev/mem: Permission denied
/sys/firmware/dmi/tables/smbios_entry_point: Permission denied
/dev/mem: Permission denied
flashrom v1.0 on Linux 4.15.2-gnu-1 (i686)
flashrom is free software, get the source code at https://flashrom.org

Using clock_gettime for delay loops (clk_id: 1, resolution: 1ns).
serprog: Programmer name is "frser-duino"
serprog: requested mapping AT45CS1282 is incompatible: 0x1080000 bytes at 0xfef80000.
No EEPROM/flash device found.
Note: flashrom can never write if the flash chip isn't found automatically.

This is the important line:

serprog: Programmer name is "frser-duino"

It means that flashrom is able to talk to the flasher, which reports itself as "frser-duino" We also have the following line:

No EEPROM/flash device found.

which tells that it didn't find any flash. This is what's supposed to happen since we didn't connect any yet.

Build the programmer

  • Connect the FTDI adapter to RX and TX of the arduino
  • Connect the 3V3 of the FTDI adapter to the 5V pin of the Arduino
  • Connect the GND of the FTDI adapter to the GDN of the arduino.
Arduino USB<->Serial port adapter
RX TX
TX RX
5v 3.3v
GND GND
  • You can now check that the programmer is responding with:
flashrom -p serprog:dev=/dev/ttyUSB0:2000000

Since you didn't connect yet a flash chip, it will says it found no flash chips:

[TODO]


  • If you use a clip (Like a SOIC-8 or SOIC16 Pomona clip), connect it to the arduino
  • Connect the chip to the clip, or if you don't use a clip, the chip to the arduino
Arduino pin number Function Flash chip function SOIC8 Flash chip pin SOIC16 Flash chip pin
D13 CLK CLK
  • Connect an USB cable between the USB<->Serial adapter and the computer. Never connect the cable between the Arduino USB port and the computer while the flasher is connected to a flash chip. That would result in the I/O voltage being 5V instead of 3.3V.

Flashing

Run flashrom like that:

flashrom -p serprog:dev=/dev/ttyUSB0:2000000

With some strange macronix flash chip (that are present in the Thinkpad X200) you might need to add spispeed=100k like that:

flashrom -p serprog:dev=/dev/ttyUSB0:2000000,spispeed=100k

Thanks

Thanks a lot to SwiftGeek on IRC (#libreboot on Freenode) for finding the first workaround to make it detect flash chips at lower voltage. This project would not have been possible without that.

Page license

This page is available under the following licenses: