posted on 2016-01-02 16:24:55
To directly dump contents of a NOR flash chip directly via the serial peripheral interface bus (SPI), a tool called
flashrom will help.
If you read this and want to do what is described, you dont need a disclaimer to know you can kill your hardware through electrostatic discharge or whatever. Else you should not be doing this anyway, except you can afford grilling things and/or insist on learning things. This is likely the only disclaimer on this site for quite some time.
Why would you want to do that at all?
Flashing new content onto flash chip usually takes place after the chips contents (also containing either the operating system or at least the bootloader or some part of it) were loaded into the RAM. With that OS running, the flash content gets exchanged with a new image. So if the image is faulty, or the flashing process gets interrupted through power loss, you won't have a bootable system anymore. A simple live disk or bootable USB stick won't help much if you can't even find the USB bus (or your other devices with the bootable operation system image) can be found.
In other words, your computer (or if you do stuff with your smartphone, your device) is
Basically, it becomes a very expensive paper weight.
If you however use the SPI bus directly for ISP (in-systems programming/in-situ programming), you do not have to care for breaking things through faulty images if you have a working one already. This enables you to test things without having to fear you will render your hardware unusable. Which leaves room for trying out things which were impossible prior.
Like fiddling directly with proprietary software which wants to prohibit you from booting a proper operating system on some hardware of choice from you. I don't know when this hobby project will be finished, but I sure learned a lot about electronics within the last half year.
ddyour OS image onto)
In my case a debian installation was put onto an SD card of a raspberry pi (which is ARM based, as one might know), only to find out that the existing
flashrom package exists for intel architecture based processors only.
Ok, so lets install a proper environment and build stuff by hand then, as
apt install build-essential apt install libusb-dev apt install pciutils-dev apt install bzip2 wget http://download.flashrom.org/releases/flashrom-0.9.8.tar.bz2 tar xjvf flashrom-0.9.8.tar.bz2 cd flashrom-0.9.8 make -j4 make install
Google the chip you want to work on, and look after a description of its pins. (Chances are you already did this, which told you that you could use the SPI bus at all.) Put the SOIC clip on the chip.
Google a raspberry pinout table, and connect the SPI pins (MISO, MOSI, CE0, CLOCK, GND, 3.3V) accordingly.
Use short cables, long ones may cause connection problems.
All the following was done without a power supply being connected to the board, as the chip got the power from the raspberry's 3.3V Vcc pin.
As I had no prior knowledge on how to use
flashrom ('i dont even know what im doing here'[TM]), this is what I tried:
# go to $HOME and create a temp folder cd mkdir flashromming cd flashromming # show help flashrom -h # try directly flashrom # try using the programmer which might work flashrom --programmer linux_spi # search for spi device ls -alh /dev/spidev0.* # use appropriate programmer, which then found my chip flashrom --programmer linux_spi:dev=/dev/spidev0.0 # look up help to find out how to dump the flash content into a file flashrom flashrom -h # actual dumping (-r = READ flash content into file) flashrom --programmer linux_spi:dev=/dev/spidev0.0 -r nas-flash-original.bin # always work on copies, not originals!!! cp nas-flash-original.bin nas-flash-copy.bin # have a look at the dumps contents dd if=nas-flash-copy.bin | hexdump -vC | less
For starters, this worked. There is more:
## OTHER STUFF: # flash new content onto chip (-w = WRITE file to chip) flashrom --programmer linux_spi:dev=/dev/spidev0.0 -w newimage.bin # erase chip contents (-E) flashrom --programmer linux_spi:dev=/dev/spidev0.0 -E # verify chip contents against file (-v) # this is only needed when in doubt which file got flashed, verifying is done automatically after each flashing procedure flashrom --programmer linux_spi:dev=/dev/spidev0.0 -v newimage.bin
The motherboard which was used also had a serial interface (UART/RS232) which I used have a look at the boot process and for console access. When the SOIC clip was connected to the chip, it just would not boot.
View posts from 2017-04, 2017-03, 2017-02, 2017-01, 2016-12, 2016-11, 2016-10, 2016-09, 2016-08, 2016-07, 2016-06, 2016-05, 2016-04, 2016-03, 2016-02, 2016-01, 2015-12, 2015-11, 2015-10, 2015-09, 2015-08, 2015-07, 2015-06, 2015-05, 2015-04, 2015-03, 2015-02, 2015-01, 2014-12, 2014-11, 2014-10, 2014-09, 2014-08, 2014-07, 2014-06, 2014-05, 2014-04, 2014-03, 2014-01, 2013-12, 2013-11, 2013-10