Programming the SPI FLASH: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
The OLPC LinuxBIOS includes an "olpcflash" utility that lets you reprogram the main SPI FLASH that contains LinuxBIOS and the microcode for the EC controller chip.
(Preliminary instructions from Richard Smith)


==Usage==
==olpcflash now works==


* If you plan to write to the SPI FLASH, make sure you won't lose power; you really don't want to have a bad BIOS flash. If possible, plug your board into an uninterruptible power supply.
The source code is [[olpcflash.c]]
* Boot to the LinuxBIOS shell prompt.
* Mount some device (e.g. a USB flash key) to use for file storage. If you want to write a new image to the SPI FLASH, make sure that image file is already on the device.
* cd to a directory on the mounted device


- To Read
I'm booting my board with Linuxbios from the SPI part.
$ olpcflash -r filename


- To Write (Write does an erase first)
If you are currently booting from a PLCC then please give this a try.
$ olpcflash -w filename
''The rest of you should probably wait a bit and see if I've changed
professions to bricklaying.''


- To Verify
One thing I noticed is that SPI boot is slower than the PLCC by just
$ olpcflash -v filename
enough that I thought it had crashed after "Copying LinuxBIOS to RAM."

To compile:

gcc -O olpcflash.c -o olpcflash

or if you test it under the buildrom uClibc env then you will need to
add the -static option
: '''Note''': The buildrom ROM image now includes the olpcflash binary by default.--[[User:JordanCrouse|JordanCrouse]] ([[User talk:JordanCrouse|Talk to me!]]) 12:03, 16 August 2006 (EDT)

First, make sure you won't lose power; you really don't want to have a bad BIOS flash. If possible, plug your board into an uninterruptible power supply.

To use:

- Read.
./olpcflash -r filename

- Write (Write does an erase first)
./olpcflash -w filename

- Verify
./olpcflash -v filename


If the verify fails, <b>do not power off or reboot your machine</b> as you may not be able to reboot if the flash has been corrupted; please reattempt to write and verify the flash. If the write/verify operations continue to fail, please get help. A good channel for help is the #OLPC IRC channel on irc.freenode.net.
If the verify fails, <b>do not power off or reboot your machine</b> as you may not be able to reboot if the flash has been corrupted; please reattempt to write and verify the flash. If the write/verify operations continue to fail, please get help. A good channel for help is the #OLPC IRC channel on irc.freenode.net.
Line 41: Line 23:
Then using a serial console I boot under the buildrom env from PLCC,
Then using a serial console I boot under the buildrom env from PLCC,
mount the USB key, and run the program.
mount the USB key, and run the program.

A side note is that I build with my USB mass storage 'use_delay' set
zero and that appears to be working fine for my massive sample set of
1 key.

==What I claim to have tested and Works For Me==

* read
* write
* verify
* erase


==Known Issues==
==Known Issues==


''''THERE ARE NO SAFEGUARDS!!!''''
* '''THERE ARE NO SAFEGUARDS!!!'''


* Writing to the SPI FLASH is really slow.
nuff said.

- Its really slow.


Currently it takes a little over 11 minutes to program the part. A
Currently it takes a little over 11 minutes to program the part. A
Line 69: Line 38:
be worth it.
be worth it.


- Re-entry from KBC reset back into KBC run mode causes the board to reboot.
* Re-entry from KBC reset back into KBC run mode causes the board to reboot.


Need to ask EnE about this. For now putting the KBC back into run
Need to ask EnE about this. For now putting the KBC back into run
Line 75: Line 44:
use verify and make sure it worked ok. If you use a PS2 keyboard you
use verify and make sure it worked ok. If you use a PS2 keyboard you
are toast at this point.
are toast at this point.

* Booting from the SPI FLASH is a bit slower than from the PLCC FLASH. The main place where
this is noticeable is just after the message "Copying LinuxBIOS to RAM."

==How to do it the first time==
So how can you get it going the first time, before you have an olpcflash-equipped LinuxBIOS installed?

If you have the ability to program PLCC FLASH chips for the OLPC board (see [[Flashing LinuxBIOS]]), you can just build the latest LinuxBIOS (see [[Building LinuxBIOS]]), load it into a PLCC FLASH, then boot from that.

Otherwise, you'll have to build olpcflash.c from source, put the executable file onto an external device like a USB FLASH, and run it under a Linux environment.

You can get the latest source code from the buildrom tree (see [[Building LinuxBIOS]]) in work/olpcflash/olpcflash/olpcflash.c . (Perhaps the string "olpclflash" should appear a few more times in the path; one wonders if 3 copies is enough :-)

To compile:

gcc -O olpcflash.c -o olpcflash

or if you test it under the buildrom uClibc env then you will need to add the -static option

Revision as of 20:28, 16 August 2006

The OLPC LinuxBIOS includes an "olpcflash" utility that lets you reprogram the main SPI FLASH that contains LinuxBIOS and the microcode for the EC controller chip.

Usage

  • If you plan to write to the SPI FLASH, make sure you won't lose power; you really don't want to have a bad BIOS flash. If possible, plug your board into an uninterruptible power supply.
  • Boot to the LinuxBIOS shell prompt.
  • Mount some device (e.g. a USB flash key) to use for file storage. If you want to write a new image to the SPI FLASH, make sure that image file is already on the device.
  • cd to a directory on the mounted device

- To Read

$ olpcflash -r filename

- To Write (Write does an erase first)

$ olpcflash -w filename

- To Verify

$ olpcflash -v filename

If the verify fails, do not power off or reboot your machine as you may not be able to reboot if the flash has been corrupted; please reattempt to write and verify the flash. If the write/verify operations continue to fail, please get help. A good channel for help is the #OLPC IRC channel on irc.freenode.net.

My testing/developement method was to compile it static and copy it to a USB key. Then using a serial console I boot under the buildrom env from PLCC, mount the USB key, and run the program.

Known Issues

  • THERE ARE NO SAFEGUARDS!!!
  • Writing to the SPI FLASH is really slow.

Currently it takes a little over 11 minutes to program the part. A large part of this is due to only doing a single byte each program cycle. The part can program up to 256 bytes each cycle so that may be the next feature to add. According to the typical program time in the datasheet it will only drop to around 6 minutes though so it may not be worth it.

  • Re-entry from KBC reset back into KBC run mode causes the board to reboot.

Need to ask EnE about this. For now putting the KBC back into run mode after I finish the operation is disabled. This will allow you to use verify and make sure it worked ok. If you use a PS2 keyboard you are toast at this point.

  • Booting from the SPI FLASH is a bit slower than from the PLCC FLASH. The main place where

this is noticeable is just after the message "Copying LinuxBIOS to RAM."

How to do it the first time

So how can you get it going the first time, before you have an olpcflash-equipped LinuxBIOS installed?

If you have the ability to program PLCC FLASH chips for the OLPC board (see Flashing LinuxBIOS), you can just build the latest LinuxBIOS (see Building LinuxBIOS), load it into a PLCC FLASH, then boot from that.

Otherwise, you'll have to build olpcflash.c from source, put the executable file onto an external device like a USB FLASH, and run it under a Linux environment.

You can get the latest source code from the buildrom tree (see Building LinuxBIOS) in work/olpcflash/olpcflash/olpcflash.c . (Perhaps the string "olpclflash" should appear a few more times in the path; one wonders if 3 copies is enough :-)

To compile:

gcc -O olpcflash.c -o olpcflash

or if you test it under the buildrom uClibc env then you will need to add the -static option