C Programming for the RS Media

If you're interested in trying your hand at some C programming for the RS Media, helibot over on the Robosapien.TK forums recently discovered that the Board Support Package for the MC9328MXL processor in the RS Media is available on a VMWare image intended for development of a different processor range.

This is great news, and not just because Freescale pulled the BSP from their website towards the end of last year. Previously if you wanted to write some C programs for use with the RS Media you needed a linux box, and a fair bit of effort to set it up. Even though this makes it pretty easy to compile C programs for the RS Media, I still wouldn't recommend trying this to anyone who doesn't have at least a little knowledge about Linux, and some experience programing in C.

VMWare, for those of you who don't know, is a company that makes software that emulates another computer inside your computer. With the Linux image from Freescale and the free VMPlayer from VMWare, you can be up and running in no time, regardless of if you are using Windows, Mac or Linux.

First you will need the VMPlayer software for your computer, which you can download here, get the one appropriate for your OS. The Windows version is about 170 meg. Then you will need the Linux image from Freescale, which you can get here , its about 520 meg, and contains a complete Linux OS along with the tools required to compile C programs for the RS Media.

Once you have installed the player, and unzipped the Linux image, fire up the player and load the Linux image. After a few minutes booting you should have a login prompt. There are two users, vm_user (password vm_user) and root (password vm_root), you should only really need the vm_user account. Since the Linux image is setup for a different processor, you should really change the kernel source that things are being compiled against. First you need to extract the correct kernel source, so log in as vm_user and issue the following commands.

    cd ~/BSP/MX1/mx1_rel_0.3.8/Kernel/Source/
    tar -zxf Kernel.tgz
    mv Source linux

For the last part, you will need to be logged in as root, so log out by pressing Ctrl-D and login back in as root.

    cd /home/public
    rm linux
    ln -s /home/vm_user/BSP/MX1/mx1_rel_0.3.8/Kernel/Source/linux linux

Now thats done, log out and back in as vm_user, you can find the contents of the board support package in the BSP/MX1/mx1_rel_0.3.8 subdirectory. Ignore the contents of BSP/MX21 as its for a different processor / development board. Most of the code in the BSP is not directly usable, but its a good reference, and with a little adaptation, can be put to use.

You may be wondering how to get files in and out of the Linux image, fortunately the Linux image has file shares enabled, so fire up windows explorer and type the following into the address bar.


You will be asked for a username and password, use vm_user. You should now see the contents of vm_user's home directory, allowing you to cut and paste (or drag and drop) files. Unless of course, you are using Windows Vista, in which case you will have to use a SCP client, I suggest WinSCP.

I've never really been too big a fan of the traditional "Hello World!" programs (though if you are, you can find one in tutorials/application), I prefer something a little more flashy. This file (click here to view), when compiled and run, will make your RS Media's LCD screen show a bunch of pretty colours. Transfer the file to the Linux image as described above, and then compile it with the following command.

    arm-linux-gcc -o lcd_cycle lcd_cycle.c
Finally, there are two ways to transfer your newly compiled programs onto the RS Media. You can use an SD card, or if you have access to the serial console and a proper terminal program, you can use Z-Modem to transfer files (zmtx and zmrx are the Z-Modem programs on the RS Media). To really make use of any compiled programs, you are going to need to modify your RS Media to access the serial console. It is possible to run the programs you compile without serial access, you can use the rsupdate/rsupdateapp trick with an SD Card or you can call the programs from a macro. Without access to the serial console though, you will find it hard going, particularly if you program has a few bugs.

Good luck, and happy compiling.



xanxion's picture

hmm interresting.

Definatly gonna try it out. But i might have to learn some programming etc first.

Thanks for this post :-)

TimJohnson's picture

Why should you have to go through all this C programming just to modify software for a robot? We all know these are not children's toys. These robots are for geeks, yes grown men and women to play with and modify. Modifying the software and controlling robots in a unique way is what we all want. We should be able to WiFi connect to these robots and load up new programs to control every bit on the lcd screen and control every movement, etc. When is someone going to start designing electronics on a open concept. Everyone who buys a TiVo wants to hack it. Everyone who buys a robot wants to modify the basic functions that come out of the box. Manufacturers should start providing simple open concept ways of controlling their creations.

Here is what I mean. The designers should create a robot with basic functions, then allow all those functions to be called from a modern programming language like Java. Then have a simple upload client on a desktop PC for a user to unload the software to the robot for execution via WiFi. Next, on the remote control for the robot the user presses a button and can select from a list the new program to run. The Java programming would be able to access every bit and byte of the senors and displays for the robot. An open architecture for the user to modify. Not compile some C program and Zmodem load it to the robot.

Nocturnal's picture

There is a Java SDK for the RS Media, that can do most of what you want. The only problem is that it is not in the public domain, and almost impossible to get your hands on. Personally, I prefer C (or C++ is you want OOP) to Java any day of the week though.

I think there are a large number of people who wish things were the way you describe (myself included), you are not the first person to express such feelings. Convincing Wow Wee and other manufacturers that this is the way to go is, unfortunately, proving difficult.

Until that time though, if you want to modify the base programming, you are stuck jumping through hoops like those outlined in my article.

TikaC's picture

I think that it's like computer software or anything else. Boils down to property rights, copyright and all that stuff. They don't want someone improving on what they did. Also if it were that easy, and anyone could do it, so could those that know very little and can ruin the device, causing more expense for the company to hire on tech support personnel to field very technical questions such as "Why isn't my bot working after I reformatted it's hard drive?" I think you get the idea. :) We already know what happens with some computer users. LOL! Imagine that type of thing with BOTS!

So, it's difficult yes, but that's so those of us (like all of us in this community) who know how to do things and are good with technology will be able to figure it out. And since we know what we are doing, we have less chance of something stupidly disastrous going wrong. And what can go wrong we all can usually figure it out how to fix it (either alone or with help from others here).

At least that's my theory.

TikaC's picture

I am trying this. In Vista if you're using VMWare Server 2.x and WinSCP, you have to use the IP address for the host name. In the Linux console, type:


and get the IP that is after 'inet addr'. Use that for the host name.

TikaC's picture

To really make use of any compiled programs, you are going to need to modify your RS Media to access the serial console. It is possible to run the programs you compile without serial access, you can use the rsupdate/rsupdateapp trick with an SD Card or you can call the programs from a macro. Without access to the serial console though, you will find it hard going, particularly if you program has a few bugs.

Can someone give me instructions on the "non-serial hack" way? I haven't the stuff to get the serial port hack working and I don't know how to really read schematics to make the power supply to power it either. So I'm kinda stuck there. And have to do it the "hard way". I'm used to hard way around of stuff anyway. I used to hack Tandy CoCo 3's. ;)

TikaC's picture

I figured it out how to get C Programs working as a macro. It's really not all that hard.

First create a Bodycon1.sh (or whatever # you want to run it from) that has this code:

echo "1" > /tmp/state/scriptrun
/usr/bin/robot/pipe /tmp/robot_pipe 9 2 0 0 0
/usr/bin/robot/pipe /tmp/robot_pipe 9 2 1 0 0
echo "0" > /tmp/state/scriptrun

Now put the lcd_cycle executable in the same directory. Upload these to the appropriate CONANIM## directory in your /Personalities/Macros directory.

Go into the robot, Personalities Menu, Personalities and select the one that has the new macro.

Then go into the Audition menu and select the Bodycon you saved this to.

The screen will cycle in nice colors! :) You'll have to turn the robot off and back on though to get the display back to normal. (Leave at least 5 or 6 seconds between turning it off and back on.)

This opens up some interesting possibilities.

Nocturnal's picture

Actually, after a while the program will terminate (the colours will stop changing), though I have no idea how long it will take (I wrote that program a long time ago). Then if you change mode (or move up / down) or do anything else that causes a screen update, everything will be back to normal.

TikaC's picture

That's the thing. On mine it didn't update or go back to normal no matter what I pressed on the remote. The only way was to just reset the robot.
I still have it in there so I might experiment with it more a bit later on. Pretty program though. :)