Programming the SPI FLASH: Difference between revisions

From OLPC
Jump to navigation Jump to search
No edit summary
(Deprecate LinuxBIOS related info)
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{deprecated}}

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


Line 8: Line 10:
* The LinuxBIOS area (0x10000 - 0xfffff)
* The LinuxBIOS area (0x10000 - 0xfffff)


The EC (Embedded Controller) area is where the code for the EC lives. Changing the code in this area unless you really know what you are doing and are prepared to deal with the breakage that can occur is a Very Bad Thing.
The EC (Embedded Controller) area is where the code for the 8051 uP in the EC lives. Changing the code in this area, unless you really know what you are doing and are prepared to deal with the breakage that can occur, is a Very Bad Thing.
'''There is currently not a recovery method if you trash your EC code.'''
'''There is currently not a recovery method if you trash your EC code.'''


Because of this olpcflash does not mess with the first 64KiB of the part.
Because of this, olpcflash does not mess with the first 64KiB of the part.


==Usage==
==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.
* If you plan to write to the SPI FLASH, make sure you're not going to 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.
* 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.
* 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
* cd to a directory on the mounted device.


To Read the LinuxBIOS area.
To Read the LinuxBIOS area.
Line 31: Line 33:
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.


Testing/developement method was to compile it static and copy it to
The method used during developement/testing was to link olpcflash staticly and copy it to
a USB key. Then using a serial console boot under the buildrom env from PLCC,
a USB key. Then using a serial console, boot under the buildrom env from PLCC,
mount the USB key, and run the program.
mount the USB key, and run olpcflash.


Olpcflash is in the process of getting added to buildrom and to various image files. Look for it to show up in a n image near you soon.
Olpcflash is currently being incorporated into buildrom and various root image files. Look for it soon in your favorite image.


==Known Issues==
==Known Issues==
Line 41: Line 43:
* '''THERE ARE NO SAFEGUARDS!!!'''
* '''THERE ARE NO SAFEGUARDS!!!'''


Adding them is on the TODO list. Think twice, flash once.
* Writing to the SPI FLASH is really slow.


* PS/2 keyboard/mouse are disabled during and after a flash attempt.
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.


Part of the programming sequence is to place the EC's 8051 uP in reset to keep it from conflicting with the program cycles. This disables PS/2 keyboard/mouse. The uP is left in reset after olpcflash is finished. This prevents the possibility of the EC running code you may have just corrupted. You must reboot to restore PS2 keyboard/mouse.
* Re-entry from KBC reset back into KBC run mode causes the board to reboot.

* Booting from the SPI FLASH is a bit slower than from the PLCC FLASH. This is most noticable just after the message "Copying LinuxBIOS to RAM."
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==
==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?
So how can you get it going 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.
If you have the ability to program PLCC FLASH chips for the OLPC board (see [[Flashing LinuxBIOS]]), you can 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.
Otherwise, you'll have to build olpcflash.c from source, put the executable file onto an external device like a USB disk, then 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 :-)
You can get the latest source code from the buildrom tree (see [[Building LinuxBIOS]]) in work/olpcflash/olpcflash/olpcflash.c .


To compile:
To compile standalone:


gcc -O olpcflash.c -o olpcflash
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
If you link under glibc, yet want to run it under the uClibc based buildrom env, then you will need to add the -static option

As stated earlier, olpcflash should start showing up as a standard command in OLPC images so building from source is probably not necessary.

[[Category:Hardware]]
[[Category:Developers]]
[[Category:OS]]

Latest revision as of 23:17, 6 June 2007

Stop hand.png WARNING:
The content of this section is considered
DEPRECATED and OBSOLETE
It is preserved for historical or documenting reasons.

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

Layout

The spansion 25FL008A SPI 1 MiB flash on the unit is divided into 2 main areas.

  • The EC area (0x0 - 0xffff)
  • The LinuxBIOS area (0x10000 - 0xfffff)

The EC (Embedded Controller) area is where the code for the 8051 uP in the EC lives. Changing the code in this area, unless you really know what you are doing and are prepared to deal with the breakage that can occur, is a Very Bad Thing. There is currently not a recovery method if you trash your EC code.

Because of this, olpcflash does not mess with the first 64KiB of the part.

Usage

  • If you plan to write to the SPI FLASH, make sure you're not going to 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 the LinuxBIOS area.

$ olpcflash -r filename

To Write the LinuxBIOS area. (Write will erase the area first)

$ olpcflash -w filename

To Verify the contents of the LinuxBIOS area vs a file.

$ 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.

The method used during developement/testing was to link olpcflash staticly and copy it to a USB key. Then using a serial console, boot under the buildrom env from PLCC, mount the USB key, and run olpcflash.

Olpcflash is currently being incorporated into buildrom and various root image files. Look for it soon in your favorite image.

Known Issues

  • THERE ARE NO SAFEGUARDS!!!

Adding them is on the TODO list. Think twice, flash once.

  • PS/2 keyboard/mouse are disabled during and after a flash attempt.

Part of the programming sequence is to place the EC's 8051 uP in reset to keep it from conflicting with the program cycles. This disables PS/2 keyboard/mouse. The uP is left in reset after olpcflash is finished. This prevents the possibility of the EC running code you may have just corrupted. You must reboot to restore PS2 keyboard/mouse.

  • Booting from the SPI FLASH is a bit slower than from the PLCC FLASH. This is most noticable just after the message "Copying LinuxBIOS to RAM."

How to do it the first time

So how can you get it going 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 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 disk, then 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 .

To compile standalone:

gcc -O olpcflash.c -o olpcflash

If you link under glibc, yet want to run it under the uClibc based buildrom env, then you will need to add the -static option

As stated earlier, olpcflash should start showing up as a standard command in OLPC images so building from source is probably not necessary.