Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

OLPC XO-1

From Texas Instruments Wiki
Jump to: navigation, search

"Engineers in the bud" can learn to use MSP430 microcontrollers with the rugged and reliable One Laptop Per Child's XO, of which over 2 million have been distributed to children in different parts of the world, often among those in severely disadvantaged situations. Some of those might be gifted in electronics, the MSP430 Launchpad being an affordable way to do some serious stuff.

Beginner? go to OLPC MSP430 Install

see the robot -> link

Updated by Yamaplos 24 November 2012

Scope

These instructions have been tested for current OLPC OS Release 12.1, a variant of GNU/Linux Fedora 17, released July 2012, using a TI MSP430 Launchpad "out of the box".

The instructions also work with OS releases 11.3 and older, as long as you replace the MSP430 chip in the Launchpad with the one that comes in a sealed bag, see OLPC_XO-1#2553_issue 2553 issue.

These instructions have not been tested in XO 1.5 or 1.75.

follows several blocks

  • Instructions for experts
meant for people familiar with Terminal and other Linux tools
hopefully simple enough for anyone with even zero experience using Terminal and command-line Linux to be able to do some MSP430 work
  • Routine steps
usual work flow with MSP430 tools in an XO environment
  • More code examples
  • Current issues
some outstanding bugs. The toolchain works so far at least sort of, but several issues remain
  • Old instructions
an older version of this page. Some older versions of the OLPC OS need some complicated maneuvers to install the toolchain

Instructions for experts

Install the toolchain

sudo yum mspdebug msp430-libc

Compile

With C code file test.c and output file compiled

msp430-gcc -g test.c -o compiled

plug your Launchpad to any XO USB port

sudo mspdebug rf2500

when you get the (mspdebug) prompt, type

prog compiled

click Ctrl-D to exit mspdebug

OLPC MSP430 Install

follow this link OLPC MSP430 Install for detailed instructions

Routine process

  • code in C using Gedit, within Documents (recommended)
  • compile using msp430-gcc filenamein.c -o filenameout
  • upload to the Launchpad using sudo mspdebug rf2500, then prog filenameout. Exit mspdebug with Ctrl-D.

More code examples

follow link here -> OLPC XO MSP430 code examples

Current issues

2553 issue

OLPC OS previous to Release 12 will not recognize the MSP430 2553 chip that currently ships pre-installed on the Launchpad. (due to Fedora 14, which allows only mspdebug up to v15)

To find out what version you have, using Terminal, type

cat /etc/issue

if you get something lower than 12.1, you may want to either update your OLPC OS (do not forget to backup your data!) or use MSP430 chips older than the 2553, which appear to work fine (older chips usually have a lower number). The Launchpad ships with a 2442 in a little bag, which works in older OLPC OS.

The instructions presented here have been tested to work in versions 11.3.1 and 11.3.0, with such a chip change.

Some other earlier OS releases have a complex issue with the repositories, as explained in OLPC_XO-1#old_instructions, and also work only with chips earlier than the 2553.

Note: changing chips has to be done very carefully to avoid bending or breaking the pins, or ending up with a chip implanted on one's hand... Also, for some reason the pins in new chips often have too wide a stance, and need to be carefully bent in a little to complete the replacement procedure.

msp430mcu

according to the mspdebug wiki, the mcu files should be installed. However, yum indicates a conflict with -libc. It has been reported by people who know better than I that the -libc currently getting installed from within the XO is very, very old. I am too noob to know how to fix that. Apparently the fix involves new package bundles or 'make' from source. :-(

if someone knows how to, please!!! need mspdebug msp430-libc msp430-binutils msp430-gcc msp430mcu msp430-gdb (this one is a maybe)

So far, and for many uses, the toolchain installed as per the instructions here *does* work, yet things like UART do not, and I haven't be able to figure out if it is because mcu is missing

OLPC OS is supposed to migrate to Fedora 18 for the next iteration, which might add other issues.

Why not Gnome?

While "Sugar" is wonderful, I can't make any sense of its file structure to call edited files to compile. Current versions hide Terminal. I just learned that gedit can be called from Sugar, so things would be sort of manageable maybe, bypassing that "Journal" feature. For a long time I have been using Gnome, and recommend it, though the examples here work fine in "Sugar", in the understanding that it might be an easier path of entry, maybe hopefully...

old instructions

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

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.
  1. Click on the bars icon in the top right corner
  2. 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
  3. Click on the "target" icon next to the bars - that returns you to the normal Sugar GUI
  4. 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

  sudo 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

   sudo msp430-gcc -g -o LED led.c

here led.c is the input file we just made, with C code LED 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 LED

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

  1. right-click
  2. Create Document
  3. Empty File
  4. 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.