Embedded controller: Difference between revisions
RafaelOrtiz (talk | contribs) m (srecord version) |
No edit summary |
||
(34 intermediate revisions by 15 users not shown) | |||
Line 1: | Line 1: | ||
{{OLPC}} |
|||
{{Translations}} |
{{Translations}} |
||
== Introduction == |
|||
{{Olpcboxtop}} |
|||
{{OBX source dev|projects/openec}} |
|||
{{Olpcboxbottom}} |
|||
[[Category:Firmware]] |
|||
[[Category:SoC Project]] |
|||
{{OLPC}} |
|||
= Introduction = |
|||
The [[Hardware#XO_Laptop|XO-1 laptop]] uses a small micro-controller, an ENE KB3700 ([[Media:KB3700-ds-01.pdf|Datasheet]]), to control the battery charging operation and perform other tasks associated with starting and stopping the laptop. |
|||
OLPC is now working in an Open Source implementation of the XO's Embedded Controller firmware. |
|||
This Embedded Controller (EC) consists of a 8051 micro-controller, a dedicated LPC interface to communicate with the processor, and an SPI Flash ROM interface. The SPI Flash ROM supports two code segments, and a table of [[Manufacturing Data]]. The EC supports the Boot Hub Protocol, allowing the XO's main processor to boot from one of the code segments in the SPI Flash. |
|||
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 implimentation for the 8051, run on the KB3700. |
|||
== Details == |
|||
The need for an open implementation is due to the fact that the actual EC has some flakiness in the recovery process.(among many other things). |
|||
An example of a bug of the old EC can be found in {{ticket|477}} |
|||
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]] over a physical LPC interface. For more information, see the [[Ec specification]]. |
|||
== Background == |
|||
The KB3700 also communicates with the Maxim [http://www.maxim-ic.com/quick_view2.cfm/qv_pk/5104 DS2756] battery fuel gauge IC within the battery pack, via the [http://en.wikipedia.org/wiki/1-Wire 1-wire] Dallas protocol. [[Media:DS2756.pdf|DS2756 data sheet]]. |
|||
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]]). |
|||
=== ec-status === |
|||
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 [http://dev.laptop.org/~joel/ec-dump.fth ec-dump.fth] under |
One can deduce part of the internal state of the EC using [http://dev.laptop.org/~joel/ec-dump.fth ec-dump.fth] under [[Open Firmware]]. Running the ec-dump script gives us valuable data about internals of the EC, being the [[EC Register Settings]]. |
||
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: |
The procedure to run '''ec-dump''' over internet in a wireless connection is: |
||
Line 32: | Line 25: | ||
ok to-file u:\ec-dump fload http:\\18.85.2.147\~joel\ec-dump.fth |
ok to-file u:\ec-dump fload http:\\18.85.2.147\~joel\ec-dump.fth |
||
== Source and Licensing == |
|||
The firmware running on the XO-1's EC, while heavily modified and supported by OLPC, was originally written by two different companies. OLPC had no success convincing those companies to open source their code. |
|||
= openec firmware project = |
|||
The OLPC community did work on [[OpenEC]], an Open Source implementation of the XO-1's Embedded Controller firmware. It reached an early stage and was not functional. |
|||
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. |
|||
The XO-1.75 and XO-4 embedded controller firmware is open source. See [[Firmware]]. |
|||
== Tools for openec == |
|||
== Related Documentation == |
|||
; 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. 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 |
|||
; Terminal Software : minicom (recommended). Needed to see or capture debugging output. Parameters 115kBaud, 8N1, no handshake - other terminal programs can be used too. |
|||
*[[XO_Full_Reset|Rebooting the Embedded Controller in a laptop]] |
|||
== Related documentation == |
|||
*[[Media:KB3700-ds-01.pdf|ENE KB3700 Datasheet]] |
|||
* See other articles in [[:Category:EC]] |
|||
http://wiki.laptop.org/go/Category.EC |
|||
http://sdcc.sourceforge.net/doc/sdccman.pdf |
|||
== Getting the source == |
|||
All the work is going to be in the git repository [http://dev.laptop.org/git.do?p=projects/openec;a=summary OpenEC] |
|||
To get this code in 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 |
|||
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:) |
|||
== Skeleton C implementation == |
|||
*battery.c Skeleton for battery handling with the Embedded Controller (key) |
|||
*Doxyfile Documentation file |
|||
*fs_entry.c Trampoline for a bankswitching routine |
|||
*Makefile.gcc Makefile per gcc |
|||
*port_0x6c.c host communication routines for the EC of the OLPC |
|||
*ds2756.c Handle Maxim/Dallas DS2756 |
|||
*kb3700.h kb3700.h - header file for ENE KB3700 Keyboard Controler |
|||
*matrix_3x3.c Routines to handle 3x3 matrix within the OLPC project |
|||
*timer.c Timer routines for the Embedded Controller of the OLPC project |
|||
*unused_irq.c Safe IRQ stubs for unused IRQ |
|||
*build.c Keeps version related info |
|||
*main.c Skeleton for the Embedded Controller of the OLPC project |
|||
*sfr_rw.c reading/writing mcs-51 sfr (special function registers) |
|||
*compiler.h include file to allow compiling with SDCC and GCC |
|||
*failsafe/ Failsafe Code |
|||
*Makefile SDCC Makefile |
|||
*openec.ctl Control file for D52 disassembler |
|||
*states.c Debugging state machine header |
|||
*uart.c handle serial IO on the EC |
|||
*watchdog.c Watchdog of the EC |
|||
== Forth tools == |
|||
For doing some of the ec work you might need the sdkit tools (sdkit permits that forth runs over linux) and also some other openfirmware code like |
|||
[http://dev.laptop.org/~wmb/spiflash.dic spiflash.dic] |
|||
== Desired Features == |
|||
* Failsafe Code |
|||
* Easy debugging |
|||
* GCC compilable. |
|||
== To Do == |
|||
* lots |
|||
==Mailing list== |
|||
* http://lists.laptop.org/listinfo/openec |
|||
[[Category:Hardware]] |
|||
[[Category:Developers]] |
|||
[[Category:EC]] |
[[Category:EC]] |
||
[[Category:Firmware]] |
Latest revision as of 04:05, 13 August 2013
Introduction
The XO-1 laptop uses a small micro-controller, an ENE KB3700 (Datasheet), to control the battery charging operation and perform other tasks associated with starting and stopping the laptop.
This Embedded Controller (EC) consists of a 8051 micro-controller, a dedicated LPC interface to communicate with the processor, and an SPI Flash ROM interface. The SPI Flash ROM supports two code segments, and a table of Manufacturing Data. The EC supports the Boot Hub Protocol, allowing the XO's main processor to boot from one of the code segments in the SPI Flash.
Details
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 over a physical LPC interface. For more information, see the Ec specification.
The KB3700 also communicates with the Maxim DS2756 battery fuel gauge IC within the battery pack, via the 1-wire Dallas protocol. DS2756 data sheet.
ec-status
One can deduce part of the internal state of the EC using ec-dump.fth under Open Firmware. Running the ec-dump script gives 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
Source and Licensing
The firmware running on the XO-1's EC, while heavily modified and supported by OLPC, was originally written by two different companies. OLPC had no success convincing those companies to open source their code.
The OLPC community did work on OpenEC, an Open Source implementation of the XO-1's Embedded Controller firmware. It reached an early stage and was not functional.
The XO-1.75 and XO-4 embedded controller firmware is open source. See Firmware.
Related Documentation
- Rebooting the Embedded Controller in a laptop
- ENE KB3700 Datasheet
- See other articles in Category:EC