[wiki-lib] Change spacing with the new font...
[wikipediardware.git] / bootloader / README.txt
blobe534ce03fcfe13f489bfb7e8ab214c3d9a433867
2         OpenMoko Dictionary hardware bootloader
3         Copyright (c) 2008 by Daniel Mack <daniel@caiaq.de>
6 (0) Preamble
8 Epson's S1C33E07 CPU has the possibility to boot from the following media:
10         * NAND flash
11         * NOR flash
12         * SPI EEPROM
13         * RS232
15 For the Wikipedia reader, we only support SPI EEPROM (for normal operation)
16 and RS232 (for initial bootstrapping and development). This two options are
17 selected by the CE10# line which is available at the PCB. The default is
18 CE10# = low which make the CPU boot from EEPROM.
20 The goal is to have the kernel for the application located on the SD card
21 and keep the bootloader as simple as possible.
23 On each power cycle, the CPU reads 512 bytes of instruction code, copies
24 them to address 0x0 (internal RAM) and then vectors to this address. As
25 this is not enough space to store a bootloader which communicates with
26 the SD card, there is need for some more fuzzy logic.
28 The bootloader is thus split into three parts which are described in
29 detail here.
32 (1) The first stage bootloader (rs232)
34 This image is needed for bootstrapping a naked device and for debugging
35 only. It is loaded via the serial port and has the following tasks to do:
37         * Set up the serial console to 57600/8N1
38         * Take commands from serial line to toggle the EEPROM's CS# signal
39           and to read and write from the EEPROM
41 Hence, it is more or less a remote control for the EEPROM to allow the
42 host to write an initial EEPROM image.
45 (2) The first stage EEPROM bootloader (eeprom-1st)
47 Once the device booted from EEPROM, we run into the same problem like
48 before - the CPU only copied 512 bytes from EEPROM page 0 to address 0x0
49 and then vectors to it. The job of this image is to load more bytes from
50 the EEPROM and call the next bootloader. These are the functions:
52         * Initialize the SPI interface
53         * Set up the serial console to 57600/8N1
54         * Read a fix number (determined at compile time) of bytes from
55           EEPROM's logical address 0x300 and copy the to the internal
56           RAM @0x200, right after the image we loaded before.
57         * Outputs the character '!' to indicate the following jump
58         * Jump to the location of the newly loaded code
60 For development purposes (to avoid time intensive EEPROM flashing/
61 rebooting cycles all the time), this loader also has a second use case
62 which can be selected at compile time with a simple #define switch in
63 the first lines. When compiled for serial mode, it does the following:
65         * Set up the serial console to 57600/8N1
66         * Loads a fix number (hardcoded in this case, 8192-512 = 7680)
67           of bytes from the RS232 line and copies them to the internal
68           RAM at address 0x200.
69         * Outputs the character '!' to indicate the following jump
70         * Jump to the location of the newly loaded code
72 With this mode, development became a lot easier, even though it is not
73 the usual case for deployment later.
76 (3) The second stage EEPROM bootloader (eeprom-2nd)
78 At this bootloader stage, we have to load our kernel from the SD card to
79 extern SDRAM and execute it. FAT/FAT32 and SD card specific tasks are
80 done be libfat, located in fatfs/. This bootloader stage has to fit into
81 the internal RAM, starting at address 0x200. As this internal RAM has
82 a size limit of 8192 bytes, the binary has to fit in 8192-512 = 7680
83 bytes.
85 The kernel is then loaded to external SDRAM. In fact, as the kernel is
86 deployed as ELF32 binary and the load address is taken from the ELF32
87 headers, the final location of the kernel can be anywhere in the memory
88 map. The kernel is built in a way that all its sections and its entry
89 point is located at address 0x10000000.
91         * Initialize the external SDRAM (mapped to area 19, 0x10000000)
92         * Use libfat to access the SD card and load the ELF32 file
93           '/kernel' to wherever it wants to be loaded.
94         * Jump to the entry point of the kernel image
97 (4) The e07load utility
99 To flash the device and bootstrap the bootloaders, there is a little
100 utility called e07load. It assumes the CPU is in RS232 boot mode and
101 does the following things when started:
103         * Opens the serial console with 57600/8N1
104         * Sends out 4 sync bytes (0x80, 0x80, 0x80, 0x80)
105         * Reads back the CPU ID (supposed to be 0x06, 0x0e, 0x07, 0x00)
106         * Sends out the 512 bytes of bootstrap code (read from file 'rs232')
107         * Reads back the 512 bytes of bootstrap code for verification
108         * By now, the CPU has already vectored to our 'remote control' code
109           so we can use it now
110         * Use the 'SPI remote control' code implemented in the first stage
111           bootloader and write the 512 bytes EEPROM code
112         * Read back the 512 bytes EEPROM code for verification
113         * Write the 2nd level EEPROM bootloader at address 0x300 where it
114           will be read by the first stage EEPROM loader later
115         * Read back this image for verification
118 (*) Links
120 S1C33E07 datasheet: