Tag Archives: code

Kernel develpoment on e60

Now that I have access to the serial console on Samsung e60 reader let’s build a new linux kernel for it.

The e60 reader has an ARM processor, to compile the kernel we need a cross compilation toolchain.
The first option is to use the one Samsung released with the other sources. It must work, however I don’t really like the idea to run binaries from unknown sources.
The second option is to build our own toolchain, we often have to do that for systems that requires patches on the compiler.
Here, Samsung’s binutils look like they were taken between 2.17 and 2.18 release (they are named 2.17.50 but are still slightly different from this snapshot) but they don’t seam to embed homemade patches. As for ggc I didn’t take time to check.
I choose to use the emdebian cross-development toolchain lenny version. (As the article in the french open silicium magazine #1 about FriendlyARM proposes to do).

Installing the cross-development toolchain on debian

First the archive keys:


sudo apt-get install emdebian-archive-keyring

Then we add a /etc/apt/sources.list.d/emdebian.list file with the following content:


deb http://ftp.uk.debian.org/emdebian/toolchains lenny main
deb-src http://ftp.uk.debian.org/emdebian/toolchains lenny main

The we update the package list to install the needed packages:


sudo apt-get update
sudo apt-get install libc6-armel-cross libc6-dev-armel-cross libstdc++6-armel-cross binutils-arm-linux-gnueabi gcc-4.3-arm-linux-gnueabi g++-4.3-arm-linux-gnueabi

That’s it ! We have now our cross-compilation toolchain installed from packages, so easy to update or remove.

The kernel sources

Samsung released it’s modified 2.6.29.4 version. By cloning the kernel 2.6.29.y git branch, I could quickly see that their changes applied well to the 2.6.29.6 version (the last in the branch).

In order to better sort the changes michel.s had splat them into several patches
(patchs on e60-open project). After a few trials I build a series file allowing to apply those patches with quilt or better to import them to a git branch with git quiltimport. The order I choose allows to drop easily some patches (the last ones).

One particular point on those patches is that some include binary files:

  • fs/rfs/*.o a proprietary journaling layer over FAT. If you want my point ov vue, we don’t need that. After all we have free journaling file systems available and linux is able to mount something else than FAT over USB…
  • drivers/usb/gadget/file_storage.o also the corresponding .c file was removed, the BSD/GPL license from the original code allows a binary distribution (however I didn’t check if Alan Stern’s name appears in the doc) but I’d have liked that Samsung give that source code.

U-Boot

Before compiling the kernel, we need the mkimage utility from U-Boot. Here, Let’s build the U-Boot released by Samsung, and let’s just copy the tools/mkimage to a location in our PATH (that’s the only install method I could find).


make smdkc100_config 
make CROSS_COMPILE=arm-linux-gnueabi-

cp tools/mkimage ~/bin/

Building linux

For the config, one of the patches includes a .config. That file is a copy of config_rfs so even without the previous patch, we can get Samsung’s config.

Finally we can compile!


make CROSS_COMPILE=arm-linux-gnueabi- CFLAGS="-march=armv4t -mtune=cortex-a8" CXXFLAGS="-march=armv4t -mtune=cortex-a8" ARCH=arm uImage


We can then load our kernel by following The kernel testing howto from e60-open project. To load the kernel we will need the following command:


sudo dnw arch/arm/boot/uImage

That’it, and it works ! Well almost, the kernel cannot find his modules. This will not be a big deal for the ones included in the sources (but the subject of a next post) but the /lib/modules/max14540.ko and lib/modules/dhd.ko modules are not included in the sources while reporting a GPL license to the kernel.

Missing source code

The Samsung Open Source Release Center website has a contact form, but it does not seam to work (I even booted my netbook on windows to try with IE8 without success). After browsing the french e60 forum I found their email address and mailed them, no answer so far (not even automatic). Let’s wait …

Conclusion

We can compile a kernel for the e60 reader without using the cross tools from Samsung.
There still some work to load modules as the one on the reader are copiled for 2.6.29.4 and our kernel does not want to load them. (I’ve already done a few tests but that will be a next posts’ topic.)
But without the missing sources it will be hard for us to best use our e60 reader.

Update: I got an answer from Samsung, they updated the released archive. I still have to look at it.

First step in kernel development

I wanted to work on linux kernel from some time, but didn’t really know where to start. One day a wise man told me “a good way to learn is to do it! So get an USB device and write the driver for it.” I answered: “Well I didn’t thought of that, usually I’d use libusb for such cases.”

A USB device

Some days later, I didn’t find any nice device, but I thought, why not building it as well?
As I already told you, I’ve already hacked out an USB device: USBtinyISP. So I got back to the original code: usbtiny and I build myself a small device with 4 LED and 2 buttons:

My prototype's picture

I didn’t use and ATtiny, but an ATmega8 to keep more room for future improvements ;-) (The ATtiny2313 is already full with the USBtinyISP code).

And here is the schematic: (as picture, the gschem sources stay in git under the sch folder):

The schematic

Once the wiring done, some few lines of code based on the usbtiny sample, and that’s it: A firmware for the ATmega (in the root of the project).

Then I needed to test it, so back to the first idea, some code lines using libusb, available in the test, helped to improve the firmware ;-)

Everything’s OK, let’s write a driver.

The Linux driver

Well I just followed some tutorials:

Finaly looking at the usbled.c file in Linux sources to get some more updates.

This build a module that adds the files leds and keys in the device folder that Linux creates in /sys/bus/usb/.

That’s it! I don’t know if you learned something, but I did learn a lot! ;-)

All source code are available under GPL2 or GPL2+ on my gitweb: jvdg_usbgadget.git

As for the egocentric name, it’s just to avoid any name conflict. This has no mean to be integrated anywhere anyway. (The device uses an USB ID reserved to prototyping, so unusable for products…)

Time to put back software on the front page

I’ve been more on software recently, and I didn’t blog much…

I’m still maintaining openchrome Xorg driver, not much to do now that the latest upstream SVN version is on KiBi’s X autobuild system. Except waiting for the bugs to occur.

I also just requested to become DM to release the X Strike Force of the task of sponsoring me…

After a rather awkward first message (still sorry about that), I started working on webalizer’s debian package.
Nothing’s published yet, but this will come.

Finally I received an email from Axel Beckert about xrootconsole, well he already blogged about it, I accepted to co-maintain xrootconsole with him. More details on my xrootconsole page.

To conclude, after some month following the debian community, I’m starting to feel part of it!

Trial and errors with git branches

I’ve recently learned to use git (for my xorg adapted packages) and used it later for netsed.

In order to develop UDP in netsed, I had to try several stuff, my network programming experience in C is back to some school time, so this was really trial and errors. And here git really helps, all I had to do is create branches for each trial, so I don’t loose any tracks I’ve taken, then when I found the right way to do it, I could just merge or cherry pick from the branches (or even just copy past from gitk to my favorite editor gvim) and that was it !

Of course I can now delete the trial branches, but those were really helpful during development time.

This meant abusing of git commit --amend, git merge ( --squash ) and git cherry-pick commands, but well you cannot build a clean code without effort.

I should probably give an other look at git stash which seams to fill similar needs.

Taking over Netsed

Netsed, the network packet stream editor, is a program originally written by Michal Zalewski .

While the program idea is good, it’s implementation had some lack, and nobody seamed to care enough to fix it.

I did already hack it some years ago, and it appeared that my changes was fixing a debian RC bug (#586037) so I took netsed maintenance as one of my new projects!

For now only my changes and patches proposed by Mats Erik Andersson are integrated.

But I will start working on a test suite (still have to find the right tools for that, would ruby be nice ?), and of course implement UDP support.

Also I’d like to really thank Mats Erik Andersson and Tim Retout for their answers and support.

Resources:

WordPress and plugin upgrade

After yesterday’s trouble, I just upgraded all my plugins.

Gengo’s URI renaming scheme with language code at the end was leading to an infinite redirect (adding fr+en/ to the URI) so I had to disable it. But doing so breaks the existing URI on your bookmarks (if you had some) and on Google…
So I hacked gengo again so that if the URI ends with a language code, it is redirected to the basic URI.
A recent reading : Cool URIs don’t change is just about keeping the URI, here I’m redirecting, that’s not as good, but at least you wont get the 404 ;)

The link was on Peter Eisentraut’s Blog. I was reading his article about Remove and Purge. I was tempted to do the same, I even did for a few days. Then I read the comments, and ended using aptitude l~c view ;) . I was previously using synaptic only for purging residual configuration…

Hacking zenphoto for https admin

Trying to use zenphoto I found it does not have an option to have the admin tasks in https and the gallery in regular http.

WordPress is doing this and reading Rian’s article: SSL and Cookies in WordPress 2.6
I had a better idea on how it works.

Before coding, I also read How to Properly Provide Mixed HTTP and HTTPS Support from mikeperry’s blog.

And this is basically what I implemented.

For once the result of my work is not hosted on my blog but directly on zenphoto’s trac : The ticket with zenphoto patch to allow both http and https.

ANSI Color support for xrootconsole

Having the system log on a background transparent window on the desktop look nice and can be useful (USB key plug events, network connection events and so on).
One way is to use a terminal like aterm or Eterm for instance using the following command:


aterm -tr -bl -ib 0 -title log -name log +sb -geometry '140x16+0+791' -e bash -c "tail --follow=name /var/log/full.log | ccze" &

With the -title and -name option the window decoration can be removed at the window manager level. OK, this is nice.

But when using fluxbox desktop wheeling will not work over the log as it is a window not the desktop.

So I switched to xrootconsole, but it has no color support… not a big deal, I just hacked it in ;)

Here is a sample usage of the hacked xrootconsole, the important part is the -A parameter for ANSI to ccze as the default is to use curses:


tail -n 16 --follow=name /var/log/full.log | ccze -A | xrootconsole --wrap --bottomup -geometry 233x16+1+818 &

Continue reading

netsed

An old hack (2 years old  according to my subversion db !!)

This started with my 5.1 Yamaha audio amplifier, this device has network access to listen to netradios directly ! I wanted to hack it to play a personal netradio.

I configured my dhcp to have it report my server as gateway and used wireshark to listen how it was connecting the Internet. It appeared that the menu on the device was provided by XML streams.

I first did some DNS spoofing and placed on my apache server a fake XML file, the Yamaha amplifier couldn’t tell the difference and I could play some local mp3 files.

The next step was to have both the normal radios and some personal radios. That’s here netsed becomes useful. The idea was to filter the main menu XML to add an extra item that liks to a local XML page linking to personal radio.

I never get to the step where I setup an Icecast server however I got the extra menu working.

netsed did basically the job, but for some reason it was not closing connections to the http server so it generated several timeout errors, that’s basically what I fixed in the netsed code.

my Trac page about netsed