Embedded Motion Control/Ubuntu Installation: Difference between revisions
(One intermediate revision by one other user not shown) | |||
Line 14: | Line 14: | ||
=== Download the packages === | === Download the packages === | ||
First the following packages need to be downloaded | First the following packages need to be downloaded | ||
*brickos [http://packages.ubuntu.com/ | *brickos [http://packages.ubuntu.com/hardy/i386/brickos/download 32-bit], [http://packages.ubuntu.com/hardy/amd64/brickos/download 64-bit]. | ||
*binutils-h8300-hms [http://packages.ubuntu.com/ | *binutils-h8300-hms [http://packages.ubuntu.com/hardy/i386/binutils-h8300-hms/download 32-bit], [http://packages.ubuntu.com/hardy/amd64/binutils-h8300-hms/download 64-bit]. | ||
*gcc-h83000-hms [http://packages.ubuntu.com/ | *gcc-h83000-hms [http://packages.ubuntu.com/hardy/i386/gcc-h8300-hms/download 32-bit], [http://packages.ubuntu.com/hardy/amd64/gcc-h8300-hms/download 64-bit]. | ||
*brickos-doc [http://packages.ubuntu.com/ | *brickos-doc [http://packages.ubuntu.com/hardy/all/brickos-doc/download Download]. | ||
The main page can be found at http://packages.ubuntu.com/ | The main page can be found at http://packages.ubuntu.com/hardy/brickos. | ||
=== Installing the packages === | === Installing the packages === | ||
After all the files are download the installation is as easy as in Windows. | After all the files are download the installation is as easy as in Windows. | ||
Line 47: | Line 47: | ||
Now everything is ready to use. | Now everything is ready to use. | ||
REMARK: Do not put your computer on standby (hibernate not tested). It seems that a program, compiled by a computer that was waked from standby is causing the brick to crash. To avoid this just turn off your computer instead of standby/hibernate. | |||
== Putting a kernel into the RCX == | == Putting a kernel into the RCX == |
Latest revision as of 09:13, 15 June 2011
This document describes how to the install the necessary and sufficient software to start programming your own RCX from LEGO Mindstorms to control your Marslander. After reading this small manual, you should be able to run your own program on the RCX.
Installing Ubuntu 10.04 LTS
Ubuntu can be installed according 2 methods
- Using an USB stick.
- Using the hard drive.
For both methods the most recent installation instructions can be found on http://www.ubuntu.com/desktop/get-ubuntu/download. Make sure that you download the appropriate architecture ie. 32 or 64-bit. Creating a dual-boot system, ie. installing Ubuntu on the hard drive is the most convenient. When installing Ubuntu on an USB stick make sure to use some persistence/extra space during the install such that information is still there after a reboot.
If you installed Ubuntu on an USB stick you have to make sure that your notebook will boot from the USB stick. This can be edited in the BIOS or for most notebooks during the booting process, F9
can be pressed to select the USB drive.
Installing the packages
Download the packages
First the following packages need to be downloaded
- brickos 32-bit, 64-bit.
- binutils-h8300-hms 32-bit, 64-bit.
- gcc-h83000-hms 32-bit, 64-bit.
- brickos-doc Download.
The main page can be found at http://packages.ubuntu.com/hardy/brickos.
Installing the packages
After all the files are download the installation is as easy as in Windows.
- Double-click the package.
- Click
install package
. - After the package is installed it can be closed.
Now a directory can be created for the project files for example /home/ubuntu/emc
. Note that the /home/<user>
is the same as the user directory in Windows.
Open the terminal, this can be found in Applications->Accessoires->Terminal
. In the terminal do the following
ubuntu@ubuntu~$: cd ~ ubuntu@ubuntu~$: mkdir emc ubuntu@ubuntu~$: cd emc ubuntu@ubuntu~$: cp -r /usr/share/doc/brickos/examples/demo demo
The first line changes the directory (cd
) to the home folder. Then the directory emc
is created. Finally the demo
directory is copied from the documentation directory.
Installing the USB IR tower
First plug in the USB IR tower. To make sure you have permission to use the tower type in the terminal
ubuntu@ubuntu:~$ sudo chmod 666 /dev/usb/legousbtower0
You may test the tower with a simple
ubuntu@ubuntu:~$ echo test > /dev/usb/legousbtower0
The green LED on the tower should light for a second.
Now everything is ready to use.
REMARK: Do not put your computer on standby (hibernate not tested). It seems that a program, compiled by a computer that was waked from standby is causing the brick to crash. To avoid this just turn off your computer instead of standby/hibernate.
Putting a kernel into the RCX
In order for the RCX to be able to run your programs, it needs to be provided with dedicated firmware. The RCX is equipped with a ROM chip on which the standard Mindstorms firmware is stored. Every time the RCX loses power (e.g. when changing batteries), the firmware which was running on the RCX is replaced by this standard firmware. Therefore, every time the RCX has lost power, the dedicated firmware has to be installed again.
N.B.: If there is already a kernel running on the RCX (not the original one), then this one has to be deleted before a new one can be transferred to it. This can be done by pushing the Prgm button immediately after you push the On-Off button to swith the RCX off (this may take some practice).
To install the firmware for BrickOS, power on your RCX, open the terminal and type
ubuntu@ubuntu:~$ firmdl3 --tty=/dev/usb/legousbtower0 /usr/lib/brickos/brickOS.srec
Now the kernel is being transferred to the RCX and when this is finished, your RCX is ready to be programmed with your own programs.
Downloading your program to the RCX
The programming language used to control the RCX is C. Suppose you wrote a program in C to display "hello world" on the LCD of the RCX. This simple file helloworld.c
can be found in the demo directory ~/emc/demo
. In order to compile this code we use the command make
. This command uses the Makefile
already present in the same directory. Therefore, all your C-code should be put into that directory. To compile type
ubuntu@ubuntu:~/emc/demo$ make helloworld.lx
This will start the compilation process and delivers (amongst others) the file helloworld.lx
. This is the actual program that will run on the RCX. To download it to the RCX, type
ubuntu@ubuntu:~/emc/demo$ dll --tty=/dev/usb/legousbtower0 helloworld.lx -p1
where the option -pX
is used to specify the program number on the RCX, here number 1 (there is room for 7 different programs, hence X is in the range 1 to 7). The program is now loaded on the RCX and by hitting the run button, the text hello world will be displayed on the screen.
If you want the tty
part out in the future you may define a local variable by typing
export RCXTTY=/dev/usb/legousbtower0
However when opening a new terminal the local variable does not exist anymore. Therefore it might be convenient to add the line to your .bashrc
. Do this by typing
ubuntu@ubuntu:~$ gedit ~/.bashrc
The application gedit will now open, add the line add the bottom of the file, save and close.
Now a second program which plays sound (sound.c) can be compiled and downloaded to the RCX by typing
ubuntu@ubuntu:~/emc/demo$ make sound.lx ubuntu@ubuntu:~/emc/demo$ dll sound.lx -p3
You can now switch between these two programs (1 & 3) using the Prgm button on the RCX.