RaspberryPi: Difference between revisions

From flashrom
Jump to navigation Jump to search
(Added initial RaspberryPi documentation)
 
m (Add reference to Micron's appnote in the decoupling caps)
(15 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[http://www.raspberrypi.org/faqs RaspberryPi] is a cheap single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of
__FORCETOC__
stimulating the teaching of basic computer science in schools. It can run a fully-functional GNU/Linux distribution and exposes SPI, I2C and several GPIOs on its expansion header.
[http://www.raspberrypi.org/faqs RaspberryPi] is a cheap single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of stimulating the teaching of basic computer science in schools.  
It can run a fully-functional GNU/Linux distribution and exposes SPI, I2C and several GPIOs on its expansion header.


= Prerequisites =
= Prerequisites =
You need to be running a kernel from [http://www.bootc.net/ Chris Boot] which includes a proper SPI driver, grab it from http://www.bootc.net/projects/raspberry-pi-kernel/ (and do not forget to use the latest firmware from https://github.com/raspberrypi/firmware/tree/master/boot). Beware, if just untarring, do not forget to do <code>depmod</code> appropriately.
Use latest Raspbian (or any other distribution with a recent kernel).
Run the following commands (or make sure these kernel modules are loaded successfully):


= Compiling flashrom =
modprobe spi_bcm2835 # If that fails you may wanna try the older spi_bcm2708 module instead
If you want to compile it from the sources, use the following line:
  modprobe spidev
<pre>
make CONFIG_INTERNAL=no CONFIG_RAYER_SPI=no CONFIG_NIC3COM=no CONFIG_GFXNVIDIA=no CONFIG_SATASII=no \
CONFIG_ATAHPT=no CONFIG_DRKAISER=no CONFIG_NICREALTEK=no CONFIG_NICNATSEMI=no \
  CONFIG_NICINTEL=no CONFIG_NICINTEL_SPI=no CONFIG_OGP_SPI=no CONFIG_SATAMV=no
</pre>


= Connecting the flash chip =
= Connecting the flash chip =
To learn more about the RPi's expansion header refer to http://elinux.org/Rpi_Low-level_peripherals . Please do not try to draw more than 50mA from the 3.3V pin.
To learn more about the RPi's expansion header refer to http://elinux.org/Rpi_Low-level_peripherals . Please do not try to draw more than 50mA from the 3.3V pin. If the flash chip is still placed in a foreign circuit (e.g. soldered to a PC mainboard) please refer to [[ISP]] for further details.


{| border="0" style="background-color: #eeeeee"
{| border="0" style="background-color: #eeeeee"
|- bgcolor="#6699ff"
|- bgcolor="#6699ff"
! align="left" | RPi header
!| RPi header
! align="left" | SPI flash
!| SPI flash


|- valign="top"
|- valign="top"
|- bgcolor="#eeeeee"
|| 25 || GND
|| 1 || Vcc 3.3V


|- valign="top"
|- valign="top"
|- bgcolor="#eeeeee"
|| 24 || /CS
|| 6 || GND


|- valign="top"
|- valign="top"
|- bgcolor="#eeeeee"
|| 23 || SCK
|| 19 || DI


|- valign="top"
|- valign="top"
|- bgcolor="#eeeeee"
|| 21 || DO
|| 21 || DO


|- valign="top"
|- valign="top"
|- bgcolor="#eeeeee"
|| 19 || DI
|| 23 || SCK


|- valign="top"
|- valign="top"
|- bgcolor="#eeeeee"
|| 17 || VCC 3.3V (+ /HOLD, /WP)
|| 24 || /CS
|}
|}


= Example output =
<div style="margin-top:0.5em; padding:0.5em 0.5em 0.5em 0.5em; background-color:#a00000; color:#ffffff; text-align:center; border:1px solid #aabbcc; font-size:20px;">
<pre>
'''Always''' connect '''all''' input pins of integrated circuits (not only flash chips).
paul@raspberrypi:~/flashrom$ time ./flashrom -r wr741nd-flash.bin -V -p linux_spi:dev=/dev/spidev0.0
</div>
flashrom v0.9.5.2-r1547 on Linux 3.2.21-rpi1+ (armv6l)
 
flashrom is free software, get the source code at http://www.flashrom.org
 
In general the other pins (usually pin 3 is /WP and pin 7 is /HOLD) should be connected to Vcc unless they are required to be floating or connected to GND (both extremely uncommon for SPI flash chips). Please consult the datasheet for the flash chip in question.
 
If your flash chip is detected but your read/write/verify operations tend to fail, try to add decoupling capacitors (one 100nF and one 4.7uF ceramic capacitor is preferred) close to the flash chip's power pin.


flashrom was built with GCC 4.6.3, little endian
See Micron's TN-25-09: Layout Guidelines PCB Design Recommendations/VCC Power Supply Decoupling
Command line (5 args): ./flashrom -r wr741nd-flash.bin -V -p linux_spi:dev=/dev/spidev0.0
[https://www.micron.com/-/media/client/global/documents/products/technical-note/nor-flash/tn2509_layout_guidelines_spi_nor_mt25q.pdf]
Calibrating delay loop... OS timer resolution is 5 usecs, 210M loops per second, 10 myus = 11 us, 100 myus = 109 us, 1000 myus = 1237 us, 10000 myus = 10299 us, 20 myus = 37 us, OK.
Initializing linux_spi programmer
Using device /dev/spidev0.0
The following protocols are supported: SPI.
...
Chip status register is 00
Found Winbond flash chip "W25Q32" (4096 kB, SPI) on linux_spi.
...
Found Winbond flash chip "W25Q32" (4096 kB, SPI).
This chip may contain one-time programmable memory. flashrom cannot read
and may never be able to write it, hence it may not be able to completely
clone the contents of this chip (see man page for details).
Reading flash... done.


0.85user 0.66system 1:28.12elapsed 1%CPU (0avgtext+0avgdata 18976maxresident)k
= Running flashrom =
0inputs+8192outputs (0major+1232minor)pagefaults 0swaps
Flashrom uses the Linux-native SPI driver, which is implemented by flashrom's
</pre>
''linux_spi'' module. To use the RaspberryPi with flashrom, you have to specify
that driver. You should always tell it at what speed the SPI bus should run;
you specify that with the ''spispeed'' parameter (given in kHz). You also have
to specify the Linux SPI device, e.g.
flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=1000

Revision as of 20:07, 7 August 2019

RaspberryPi is a cheap single-board computer developed in the UK by the Raspberry Pi Foundation with the intention of stimulating the teaching of basic computer science in schools. It can run a fully-functional GNU/Linux distribution and exposes SPI, I2C and several GPIOs on its expansion header.

Prerequisites

Use latest Raspbian (or any other distribution with a recent kernel). Run the following commands (or make sure these kernel modules are loaded successfully):

modprobe spi_bcm2835 # If that fails you may wanna try the older spi_bcm2708 module instead
modprobe spidev

Connecting the flash chip

To learn more about the RPi's expansion header refer to http://elinux.org/Rpi_Low-level_peripherals . Please do not try to draw more than 50mA from the 3.3V pin. If the flash chip is still placed in a foreign circuit (e.g. soldered to a PC mainboard) please refer to ISP for further details.

RPi header SPI flash
25 GND
24 /CS
23 SCK
21 DO
19 DI
17 VCC 3.3V (+ /HOLD, /WP)

Always connect all input pins of integrated circuits (not only flash chips).


In general the other pins (usually pin 3 is /WP and pin 7 is /HOLD) should be connected to Vcc unless they are required to be floating or connected to GND (both extremely uncommon for SPI flash chips). Please consult the datasheet for the flash chip in question.

If your flash chip is detected but your read/write/verify operations tend to fail, try to add decoupling capacitors (one 100nF and one 4.7uF ceramic capacitor is preferred) close to the flash chip's power pin.

See Micron's TN-25-09: Layout Guidelines PCB Design Recommendations/VCC Power Supply Decoupling [1]

Running flashrom

Flashrom uses the Linux-native SPI driver, which is implemented by flashrom's linux_spi module. To use the RaspberryPi with flashrom, you have to specify that driver. You should always tell it at what speed the SPI bus should run; you specify that with the spispeed parameter (given in kHz). You also have to specify the Linux SPI device, e.g.

flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=1000