Embedded controller: Difference between revisions
(olpc & translation sequence + categories at bottom + cosmetics) |
m (cosmetic section depth) |
||
Line 4: | Line 4: | ||
{{OBX source dev|projects/openec}} |
{{OBX source dev|projects/openec}} |
||
{{Olpcboxbottom}} |
{{Olpcboxbottom}} |
||
= Introduction = |
== Introduction == |
||
OLPC is now working in an Open Source implementation of the XO's Embedded Controller firmware. |
OLPC is now working in an Open Source implementation of the XO's Embedded Controller firmware. |
||
Line 10: | Line 10: | ||
The EC hardware consists of the ENE KB3700 ([[Image:KB3700-ds-01.pdf]]), which has a 8051 microprocessor at it's core. We have chosen to impliment the firmware in C, using [[SDCC]] as our compiler. Efforts are also under way to have CamelForth, a Forth implementation for the 8051, run on the KB3700. |
The EC hardware consists of the ENE KB3700 ([[Image:KB3700-ds-01.pdf]]), which has a 8051 microprocessor at it's core. We have chosen to impliment the firmware in C, using [[SDCC]] as our compiler. Efforts are also under way to have CamelForth, a Forth implementation for the 8051, run on the KB3700. |
||
== Background == |
=== Background === |
||
The EC, implemented as a KB3700, has a paramount importance in controlling the XO when the CPU is not active. To do so, the KB3700 communicates with the CPU via the [[Revised_EC_Port_6C_Command_Protocol|EC protocol]], this protocol is managed in the ports 0x66 and 0x62 of the KB3700. These two ports are serially connected with the 0x6C and 0x68 ports of the CPU. (for more info check [[Ec_specification]]). |
The EC, implemented as a KB3700, has a paramount importance in controlling the XO when the CPU is not active. To do so, the KB3700 communicates with the CPU via the [[Revised_EC_Port_6C_Command_Protocol|EC protocol]], this protocol is managed in the ports 0x66 and 0x62 of the KB3700. These two ports are serially connected with the 0x6C and 0x68 ports of the CPU. (for more info check [[Ec_specification]]). |
||
Line 28: | Line 28: | ||
= OpenEc firmware project = |
== OpenEc firmware project == |
||
openec is an effort for an open implementation of the firmware on the EC. |
openec is an effort for an open implementation of the firmware on the EC. |
||
Line 35: | Line 35: | ||
so unless you know what you are doing. |
so unless you know what you are doing. |
||
== Tools for OpenEc == |
=== Tools for OpenEc === |
||
; git : source revision tool |
; git : source revision tool |
||
Line 52: | Line 52: | ||
; Terminal Software : minicom (recommended). Needed to see or capture debugging output. Parameters 115kBaud, 8N1, no handshake - other terminal programs can be used too. |
; Terminal Software : minicom (recommended). Needed to see or capture debugging output. Parameters 115kBaud, 8N1, no handshake - other terminal programs can be used too. |
||
== Related Documentation == |
=== Related Documentation === |
||
http://wiki.laptop.org/go/Category.EC |
http://wiki.laptop.org/go/Category.EC |
||
Line 60: | Line 60: | ||
http://sdcc.sourceforge.net/doc/sdccman.pdf |
http://sdcc.sourceforge.net/doc/sdccman.pdf |
||
=== Mailing List === |
==== Mailing List ==== |
||
* http://lists.laptop.org/listinfo/openec |
* http://lists.laptop.org/listinfo/openec |
||
== Getting the source == |
=== Getting the source === |
||
The source is in the git repository [http://dev.laptop.org/git.do?p=projects/openec;a=summary OpenEC] and can be browsed online there. |
The source is in the git repository [http://dev.laptop.org/git.do?p=projects/openec;a=summary OpenEC] and can be browsed online there. |
||
Line 71: | Line 71: | ||
git-clone git://dev.laptop.org/projects/openec |
git-clone git://dev.laptop.org/projects/openec |
||
== Compiling on the host for the EC == |
=== Compiling on the host for the EC === |
||
If the necessary tools are installed it is a simple "make" inside the openec directory: |
If the necessary tools are installed it is a simple "make" inside the openec directory: |
||
make |
make |
||
Line 77: | Line 78: | ||
(Intentionally no more details here about how to proceed:) |
(Intentionally no more details here about how to proceed:) |
||
== Compiling on the host for the host == |
=== Compiling on the host for the host === |
||
Run make with an additional argument inside the openec directory: |
Run make with an additional argument inside the openec directory: |
||
make -f Makefile.gcc |
make -f Makefile.gcc |
||
Line 86: | Line 88: | ||
host does not endanger the host:) |
host does not endanger the host:) |
||
== Files of the C implementation == |
=== Files of the C implementation === |
||
battery.c Skeleton for battery handling with the Embedded Controller (key) |
battery.c Skeleton for battery handling with the Embedded Controller (key) |
||
Line 110: | Line 112: | ||
watchdog.c Watchdog of the EC |
watchdog.c Watchdog of the EC |
||
== Status == |
=== Status === |
||
Compilable, timer IRQ functional, blinks LEDs, decodes cursor keys, |
Compilable, timer IRQ functional, blinks LEDs, decodes cursor keys, |
||
Line 121: | Line 123: | ||
Confirmed for B2 |
Confirmed for B2 |
||
== Desired Features == |
=== Desired Features === |
||
* Failsafe Code |
* Failsafe Code |
||
* Easy debugging |
* Easy debugging |
||
* GCC compilable. |
* GCC compilable. |
||
== To Do == |
=== To Do === |
||
* lots |
* lots |
||
Revision as of 04:58, 9 September 2007
Introduction
OLPC is now working in an Open Source implementation of the XO's Embedded Controller firmware.
The EC hardware consists of the ENE KB3700 (File:KB3700-ds-01.pdf), which has a 8051 microprocessor at it's core. We have chosen to impliment the firmware in C, using SDCC as our compiler. Efforts are also under way to have CamelForth, a Forth implementation for the 8051, run on the KB3700.
Background
The EC, implemented as a KB3700, has a paramount importance in controlling the XO when the CPU is not active. To do so, the KB3700 communicates with the CPU via the EC protocol, this protocol is managed in the ports 0x66 and 0x62 of the KB3700. These two ports are serially connected with the 0x6C and 0x68 ports of the CPU. (for more info check Ec_specification).
The KB3700 also communicates with the DS2657 (The battery charger) via the 1 wire Dallas protocol. One can deduce part of the internal state of the EC using ec-dump.fth under OpenFirmware. Running the ec-dump script give us valuable data about internals of the EC, being the EC_Register_Settings.
The procedure to run ec-dump over internet in a wireless connection is:
ok wifi media lab 802.11 *change it to your name AP ok fl http:\\18.85.2.147\~joel\ec-dump.fth *change to your AP IP direction
Running ec-dump over internet and saving the file in a USB key:
ok wifi media lab 802.11 *change it to your name AP ok fload http:\\18.85.2.147\~rafael\to-file.fth ok to-file u:\ec-dump fload http:\\18.85.2.147\~joel\ec-dump.fth
OpenEc firmware project
openec is an effort for an open implementation of the firmware on the EC. It currently is in an early stage and not functional yet. Downloading openec to an XO might damage the XO, please do not do so unless you know what you are doing.
Tools for OpenEc
- git
- source revision tool
- sdcc
- Compiler sdcc 2.7.0 or later (needed) http://sdcc.sf.net (Compiler which generates the binary for the EC)
- gcc
- Compiler (optional for openec) the source is currently also compilable with GCC
- doxygen
- Source documentation tool (optional), http://www.doxygen.org
- LaTeX
- text tool (optional), needed if a pdf version of the documentation should be generated. A html version of the source documentation can be generated without LaTeX
- Srecord
- srecord (needed), http://srecord.sf.net, handling of hex (etc.) files (Version 1.36)
- Make
- (needed), GNU make, should be there anyway.
- D52
- Disassembler (optional), http://www.8052.com/users/disasm/ , generates disassembled file openec.d52
- Download software
- spiflash.dic (needed), see http://lists.laptop.org/pipermail/openec/2007-August/000061.html . Forth software to download the EC firmware to the target. Be sure to backup the complete firmware (including manufacturing data) first
- Hardware adapter
- serial adapter (needed) http://wiki.laptop.org/go/Image:Serial_adapter.jpg Hardware adapter to download to target. Connects to CN24 and an RS232 null-modem cable (an additional oscillator is needed (66MHz(?) to CN24,Pin5)). Additional instructions are at SPI_FLASH_Recovery. (The instructions there address recovery of the complete flash)
- Jumpers
- 2 jumpers for Recovery Mode jumper block (see above)
- Null modem cable
- (needed) to connect the serial adapter to a serial port
- Serial port
- (needed) Not all new PC and very few notebooks still have a serial port (an USB to serial adapter might be additionally needed then)
- Terminal Software
- minicom (recommended). Needed to see or capture debugging output. Parameters 115kBaud, 8N1, no handshake - other terminal programs can be used too.
Related Documentation
http://wiki.laptop.org/go/Category.EC
http://sdcc.sourceforge.net/doc/sdccman.pdf
Mailing List
Getting the source
The source is in the git repository OpenEC and can be browsed online there.
To get this code onto your machine please do:
git-clone git://dev.laptop.org/projects/openec
Compiling on the host for the EC
If the necessary tools are installed it is a simple "make" inside the openec directory:
make
Listing files and a binary file currently named openec.do_not_use.bin are generated. (Intentionally no more details here about how to proceed:)
Compiling on the host for the host
Run make with an additional argument inside the openec directory:
make -f Makefile.gcc
you can then run
./openec.gcc | less
there. The EC specific hardware is not present on the host, so openec.gcc will be of limited use. Running openec.gcc on the host does not endanger the host:)
Files of the C implementation
battery.c Skeleton for battery handling with the Embedded Controller (key) build.c Keeps version related info compiler.h include file to allow compiling with SDCC and GCC Doxyfile Control file for Source Documentation tool Doxygen ds2756.c Handle Maxim/Dallas DS2756 failsafe/ Failsafe Code fs_entry.c Trampoline for a bankswitching routine kb3700.h kb3700.h - header file for ENE KB3700 Keyboard Controler main.c Skeleton for the Embedded Controller of the OLPC project Makefile.gcc Makefile for compiling with GCC Makefile SDCC Makefile matrix_3x3.c Routines to handle 3x3 matrix within the OLPC project openec.ctl Control file for D52 disassembler port_0x6c.c host communication routines for the EC of the OLPC sfr_dump.c dump register settings sfr_rw.c reading/writing mcs-51 sfr (special function registers) states.c Helps debugging state machines timer.c Timer routines for the Embedded Controller of the OLPC project uart.c handle serial IO on the EC unused_irq.c Safe IRQ stubs for unused IRQ watchdog.c Watchdog of the EC
Status
Compilable, timer IRQ functional, blinks LEDs, decodes cursor keys, uart output functional (TX, no RX), dumps registers outputs (ec-dump.fth like) on boot and cursor key press, outputs status of internal state machines onto serial line. Reacts on Power button but does not power up the XO yet.
Status is tested on B1 but yet to be confirmed for others. Confirmed for B2
Desired Features
- Failsafe Code
- Easy debugging
- GCC compilable.
To Do
- lots