OLPC XO-1
From Texas Instruments Embedded Processors Wiki
The One Laptop Per Child's XO is a small laptop designed for the use of children, with many features that make it rugged and reliable. The by-default GUI is called Sugar, and operates (Jan 2012) on Fedora 14. A Gnome GUI is also part of recent builds, and is easy to switch to, for those who want to use a graphic interface to access files easily - this latter being quite a pain in Sugar outside of command-line.
These instructions assume you will use command-line, which works fine using either Sugar or Gnome.
When using the XO, there is a major bug with the 2553 chip that ships plugged in the current version of Launchpad - this can be solved by switching the 2553 for the 2452 chip that is also part of the Launchpad shipped package. See OLPC_XO-1#fet:_identity_failed
Contents |
Expert Instructions
- Install toolchain
in Terminal type
sudo yum install mspdebug msp430-libc
- Compile C file
led.c is the input file, with C code, LED is compiled output, ready to upload to the MSP430 chip.
msp430-gcc -g -o LED led.c
- Upload / debug
sudo mspdebug rf2500
at the (msdebug) prompt, type
prog LED
Detailed Instructions
you need
- An XO 1
These instructions have been tested on Sugar version 11.3.0 from Nov 2011. A new version of Sugar was scheduled for Feb 2 2012 release, but is not yet available at the time of the writing of this page.
- Wireless internet access
Only needed to install the toolchain. From that moment on you do not need a connection.
- A TI MSP430 Launchpad with a chip that is not the 2553 (currently Launchpad ships by default with the 2553 chip installed, and an extra 2452 chip in a small bag. The 2452 works fine, and switching them is not hard)
What do I do if my Launchpad has a 2553?
Steps
The following steps are described from the viewpoint that you are new to Sugar/Fedora, and have Fedora 14 installed.
Install Toolchain
These instructions assume you will do your development work using the command-line interface. If you want to use a graphic interface to follow your files, you may prefer to use the pre-built Gnome UI rather than Sugar
- Connect to the Internet
- Open Terminal
- the Terminal is hidden id the default Sugar GUI.
- Click on the bars icon in the top right corner
- Find Terminal (wish they would alpha sort this!). It's sort of one page before the end. Click on the star at left so it is full
- Click on the "target" icon next to the bars - that returns you to the normal Sugar GUI
- Click on the icon on top, that looks sort of like this: [>_]
That should open Terminal
- after the greeting in Terminal appears, the pointer will be right after -]$
- type
sudo yum install mspdebug msp430-libc
- press [Enter]
this will take a while, depending on your internet speed
- what to do if you get Error : cannot retrieve repository metada for repository: fedora
- Type "y" [Enter] after every Is this ok [y/N]: (that will happen 3 times)
- Clean up! this will free about 30 M of storage, which is a lot for the XO (and might make the difference if you want to set up Arduino later)
sudo yum clean all
You're now ready to go - you have all the tools needed to transform code into C to something the MSP430 in your Launchpad will understand, and to load it and debug the Launchpad operation.
Testing the Toolchain
- plug your Launchpad into any USB port
as soon as it powers up, whatever was programmed will start running right away (amazing! - no load delay), for example the LEDs will star flashing. This proves the Launchpad is receiving power, but to test if we can actually use it to program the chip we need to run some tests. If your chip is brand new (with no program), only the power led will light up.
- using Terminal, type
sudo mspdebug rf2500
after a moment your chip should be recognized, and a (mspdebug) pointer will appear. if you see no errors, your toolchain is A-ok, and we can start programming.
- type
exit
to exit mspdebug
- what to do if you get fet: identity failed error
First Program Ever (yeeha!)
- set up the workspace
- Create a new folder, msp430, inside the user olpc main folder
Still inside Terminal, type
mkdir msp430
- get inside the workspace
cd msp430
- Create a new file
nano led.c
Inside nano, type
#include <msp430x16x.h>
main(void) {
P1DIR = 0xff;
P1OUT = 0xff;
}
now close nano. To do this, type Control-X. Nano asks for confirmation. Type y. Nano will ask the name of the file, just press [Enter] We should be back in terminal, inside our workspace.
- Compile
type
msp430-gcc -g -o LED led.c
- Upload to the chip
With your Launchpad attached to an USB port, type
sudo mspdebug rf2500
After a few seconds where the debugger is identifying the chip, the Terminal prompt will change to (msdebug) To upload our compiled code to the chip, type
prog LED
To actually run the program we just uploaded we need now to type
run
If all went well, both the red and green LEDs should light up. Type CTRL-C to stop - sometimes it takes a moment. You will notice debug output, and again the (mspdebug) prompt. Now exit mspdebug by typing
exit
We should be back in Terminal workspace
Routine Programming
- get inside the workspace
from anywhere in terminal, we can go directly to our workspace by typing
cd /msp430
- Edit or Create a file
Nano can create new files or edit old ones. Let's edit our first file so now only the red light turns on
nano led.c
Inside nano, change all chip addresses from 0xff to 0x01, so out code looks like this (you cannot use the mouse inside nano. You have to navigate using the arrow keys)
#include <msp430x16x.h>
main(void) {
P1DIR = 0x01;
P1OUT = 0x01;
}
now close nano by typing Control-X. Nano asks for confirmation. Type y. Nano will ask the name of the file. Caution! If you just press [Enter], that will overwrite our first code experiment, which is fine, since we have the compiled version. You could put a different name here if you want. Let's do that and call this on led02.c, followed by [Enter] We should be back in terminal, inside our workspace.
- Compile
type
msp430-gcc -g -o LED02 led02.c
here led02.c is the input file we just made, with C code LED02 will be the new output file, ready to upload to the MSP430 chip.
- Upload to the chip
attach your Launchpad, and type
sudo mspdebug rf2500
After a few seconds where the debugger is identifying the chip, the Terminal prompt will change to (msdebug) To upload the new compiled code to the chip, type
prog LED02
To actually run the program we just uploaded we need now to type
run
If all went well, only the red LED should light up. Type CTRL-C to stop - sometimes it takes a moment. You will notice debug output, and again the (mspdebug) prompt.
You can go back to the previous 2-LED version, by simply uploading it again type
prog LED
and
run
Type CTRL-C to stop when the (mspdebug) prompt is back, type
reset
This turns of the run of your program - the output LEDs should go off, only the power one stays on.
exit
will get us back to Terminal Inside Terminal, we can type
ls
to find out what files we have. Notice it is a good idea to mark the compiled files away from the C code ones. I use lower case, and the extension .c for the C language ones, and upper case with no extension for the compiled files.
Gnome
- Go to Gnome from Sugar (In Sugar, right click on the XO logo, My Settings, Switch desktop, Switch to GNOME, Restart now)
- Inside Gnome
- click Applications (Top left in the screen)
- select System tools
- select Terminal
To create a new C language file in Gnome
To create a new file, open the file directory
- right-click
- Create Document
- Empty File
- type led.c [Enter]
(instead of 'led.c', you may enter any file name you wish) Press [Enter] again. The file led.c opens in an editor.
Errors
Error : cannot retrieve repository metada
frequency: random, severity: nuisance, step: toolchain install Sometimes the Fedora repositories appear to have changed settings and are unreachable for several hours. This recipe has worked for me when this error appears:
- open Terminal
- type
cd /etc/yum.repos.d
- type
sudo nano fedora.repo
the system will ask you to enter your admin password
- a window will open with the content of the fedora.repo file.
Using the arrow keys, find and replace every https you find to http (that is, remove the 's' from all https instances, there are 3)
- press Control-X, agree to save the file as fedora.repo
The window will close
- now do the same with updates
sudo nano fedora.updates.repo
- to go back to workspace, type
cd /msp430
- now re-enter
sudo yum install mspdebug msp430-libc
- trick: You do not need to type all of that again. Use the arrow-up key to scroll through previous instructions you have entered in Terminal. Very soon you will find sudo yum install mspdebug msp430-libc. Click [Enter].
Follow the rest of the instructions
fet: identity failed
frequency: when using 2553 chip, severity: terminal, step: using mspdebug So far the procedure in this page has been tested and works perfectly with chips 2001, 2121, 2452, but mspdebug fails to identify the G2553, which comes installed with the Launchpad. This has to do with Fedora 14 having mspdebug v.0.15, and the G2553 is part of mspdebug starting with v 0.16... We're looking for a fix
Replace the 2553 chip
(TBD) be very careful not to bend the pins too much.
Leave a Comment