Friday, January 29, 2010

How to add new user application to uClinux

In order to add your own user application to uClinux-dist, do the following:

1. Create a sub-directory in .../uClinux-dist/user directory, this sub-directory is corresponding to your application.
2. Copy all your source files into the sub-directory, including .c, .h and Makefile. You can originize your files anyway you like within the sub-dir.
3. Edit and modify these 3 files:
uClinux-dist/user/Makefile ---- add make rule for your application
uClinux-dist/config/config.in ---- add configuration for your application
uClinux-dist/config/config.help ---- add configuration help for your app, this help will show up when you click on the "Help" button in "make xconfig" submenu.
4. Build new image (romfs)
make xconfig ---- customize user application settings and select your newly added apps.
make

Once the image.bin is built, downloaded and running in the target, you can find your apps in the /bin directory, along with other existing applications such as ping, web server, ftp, etc.

How to write/modify Makefile is key here, there are more to know about.

Thursday, January 28, 2010

Make wifi work on Ubuntu 9.10

My ubuntu was installed and setup, but wireless doesn't work so it's not connected to internet yet.

First of all I tried to make a linksys WUSB11 v1 work. This is the 802.11b usb adapter connected to the mechine and being used by WinXP system. Ubuntu 9.10 default installation has WUSB11 driver installed but unfornately the driver is for v2.6 and up. After trying for a while I decided to buy a new one , hopefully a plug and play one.

I got a TP-Link WN353G PCI card for cheap from pccyber. According to the hardware support document from https://help.ubuntu.com/community/WifiDocs/WirelessCardsSupported, the card should be work out of the box.

No it's not. The bootloader GRUB will stop in the middle and the mechine just freeze. Don't know why. Maybe what I got is WN353G and the document says WN353GD?

There seems to be a native driver for this card, but it's a lot of work to do. So I decided to go the path of using ndiswrapper, which wraps up windows driver for Linux. The following is how I make it work.

1. Download ndiswrapper packages.
Since the mechine is offline, so I download them on another mechine and copy them over using USB disk.
http://packages.ubuntu.com/karmic/misc/ndiswrapper-common
http://packages.ubuntu.com/karmic/misc/ndiswrapper-utils-1.9
http://packages.ubuntu.com/karmic/net/ndisgtk

2. Install the packages in the order
sudo dpkg -i ndiswrapper-common_*.deb
sudo dpkg -i ndiswrapper-utils-*.deb
sudo dpkg -i ndisgtk_*.deb

3. Install windows driver on Ubuntu
After installed ndiswrapper (all 3 packages) , open Windows Wireless Drivers from System->Administration menu.Then click Install New Drivers and select your Windows card driver file to install. The driver file should be *.inf from the disc accompanied with the card. I chose the one for windows2000.

Finally,the installed network card driver will list in the left box.You can click the network manager icon at right-top of your screen and find wireless network.

After the above installation, the system reboots successfully and my wifi AP is autimatically detected. After configuring the wireless network such as security, the system is connected!

Wednesday, January 27, 2010

Run uClinux on cf5272 board

Now I have build 2 kernels, one from Redhat and the other is from Ubuntu. I'll try both on cf5272.

The lab configuration is simple. cf5272 connects to a linux host through RS232, and connect to the network through ethernet cable. The linux host acts as a stage server to download image, operate the board using minicom.

I made all the files ready on the stage server, download image.bin into the board through RS232, run the OS and monitor the output from minicom. Now the board is alive by responding to commands in minicom.

The image from redhat seems to have less commands than the one from Ubuntu. I must have select fewer when I configure the kernel's applications (Busybox).

By using the image from Ubuntu, I have the mkdir, cd, cat etc command to mount a nfs dir (on my laptop linux) to a target dir under /var, and see my files on the target.

Few things to mount a nfs files system:
1. On nfs server, export the dir by editing /etc/exports.
2. Run "/etc/init.d/nfs" stop to stop nfs service, and re-start it with the new exported dir by running "/et/init.d/nfs start"
3. On client (in this case the cf5272 board), run "mount -t nfs -o nolock :/ /var/"

Monday, January 25, 2010

Build uClinux on Ubuntu 9.10

I have successfully build a uClinux kernel on Redhat Linux. Now I'm trying to setup a Ubuntu and build it again on it.

I have spent the past few days trying to setting up a Ubuntu 9.10 box and finially got it installed and running on a Dell dimension 2400 desktop. (The system will boot to Win XP or Ubuntu by changing the BIOs. For Win XP, turn Ubuntu disk off; for Ubuntu, turn Win XP disk off).

When I install m68k took chain for uClinux by running:
m68k-elf-tools-20031003.sh

I got error: tail: cannot open input `+43' for reading, no such file ...

Some smart people give a solution, by running the following command in sequence:
1. tail -n +43 m68k-elf-tools-20031003.sh > m68k-elf-tools-20031003.tar (this retrieve the tar ball file from within the .sh file)

2. tar xvf m68k-elf-tools-20031003.tar (untar the toolchain to ./usr/local dir. So if you want to install the tool chain to /usr/local, you can run the tar command from root dir)

This is where they are talking about this: http://www.linuxquestions.org/questions/linux-newbie-8/fc-6-gunzip-stdin-invalid-compressed-data-format-violated-535785/

Now install the uClinux distribution ... smooth!

make xconfig, make dep, and make. images are successfully generated!

BTW: looks like a newer version of mk68k tool chain installation doesn't has the above problem.

Friday, January 22, 2010

The make of uClinux

Configuring kernel is to generate .config file as far as I know. The .config will be used by "make" to generate vmLinux, the kernel proper. As this point of time, I'm not quite sure about whether "make xconfig" or the actual "make" prepares the source code tree for compile.

Something interesting from a book:
"Most kernel software modules also read the configuration indirectly via the .config file. During the build process, the .config file is processed into a C header file found in the .../include/linux directory, called autoconf.h. For each entry in the .config file, a corresponding entry is created in autoconf.h. Many kernel source files include this file directly using #include preprocessor directive. This is how the cource files in the kernel source tree reference the kernel configuration."

Run "make" and I get this error after the make runs for a while:


"The file /usr/src/linux/Makefile is missing!
Perhapes your kernel source is broken?"


The "kernel source" is the compiling host's kernel source, or the uClinux's kernel source? uClinux distribution doesn't include all the Linux kernel files? Is it just a patch to the standard kernel?

Anyway, I downloaded the Linux 2.4.8-20 (which is the version of the host) source code and untar it into the /usr/src/ dir. And re-make.

Fine, it's compiling until it's stopped by other errors. (can't remember exactly ...)

This evening in the class, asked the teacher and it turned out that I chose a wrong uClibc! It should be "uC-libc" instead of "uClibc". uC-libc is specific and optimised for Coldfire 68k and the other one is more generic.

Ola, make flys and image.bin is built in .../images dir!

Note: the image.bin file is the uClinux kernel plus root file system, it is the one that's going to be download into cf5272 and run.

Something else:
1. the uClinux distribution (source code) is complete to build the kernel, no dependency on any other source codes such as the source code of the host linux.
2. the tool chain for the specific architecture is complete and no dependency on host's gcc.

Thursday, January 21, 2010

Solve the "make: wish: Command not found" error

Since it's a Redhat linux system, I'm looking for a rpm package for tk 8.3. The system has tcl 8.3.5 installed so I'm looking specifically tk 8.3.5 rpm package.

Googling can't find it. The closest rpm I can find is tk 8.3.2. Tried to install it, but fail since it's looking for tck 8.3.2.

Then I tried to build it from source code, failed again. I think if I build from source, I have to build both tcl and tk.

Getting a bit frustrated! Gave up doing it and went to bed.

Getting up this morning, tried different key words searching and found one at: http://www.rpmfind.net/linux/RPM/index.html I have ever had toubles finding some rpm. I'll consider other Linux distributions later.

I've had touble installing the rpm again. The rpm command just freeze!

Searching on internet and solved the problem by "rm -f /var/lib/rpm/__db*".

Finally got "make xconfig" running!

Getting started

I finally started my blog on embedded system development. I'm gonna use this blog to keep a record of whatever I'm experiencing during my embedded system development. I hope this can be a valuable resource for whoever are interested in embedded system learning and development.

If I have a contract, I'll be just working on the contract. If I don't have any on hand, I'm just doing whatever I feel like to do. So the blogs will not be in any specific order, and usually there will be no dependencies from one topic to another.

So I'll start from the thing I'm doing now, to compile a uClinux kernel and run it on a Freescale Codefire dev board uC5272. The spec of the board can be found at: http://www.arcturusnetworks.com/products/uc5272/

The build process is straight forward based on the instruction. But when I configure the kernel as the first step, I got problem.

The make xconfig give me the error:
"... make: wish: Command not found ..."

It turned out that my Linux doesn't have tk 8.3 intalled. Strange! I have to find it and install it.