Cross-Compiling for MSSII with Ubuntu

Introduction

At the moment, there is no native compiler for the MSSII, so it's not possible to "make" directly on the MSSII. However, a solution to get our favorite applications running on the MSSII exists. It's called "cross-compiling". The aim of cross-compilation is compiling for one platform (eg MSSII) on another platform (Ubuntu in this article). This article will explain you how to easily get a compiling environment under Scratchbox and then build binaries for MSSII.

Installing Scratchbox

First, we need to install Scratchbox to easily get a cross-compilation environment. I don't know if the Scratchbox version available on default Ubuntu repositories is matching for MSSII, but there is one package in those repositories. Personnally, I used debian repositories provided on the official Scratchbox website. To add Scratchbox repository to packet manager in Ubuntu, first click this menu :

System > Administration > Software source

There, add the following repository line :

deb http://scratchbox.org/debian stable main

After validating, you will need to install Scratchbox packages. Here is a list of needed packages for MSSII :

  • scratchbox-core and it's dependencies,
  • scratchbox-devkit-cputransp,
  • scratchbox-libs,
  • scratchbox-toolchain-cs2005q3.2-glibc2.5-arm.

This is okay for the install part, now we need to configure scratchbox.

Configuring Scratchbox 

If you are running Ubuntu Hardy Heron, you need to enter two commands in a terminal in order to avoid an error when starting Scratchbox :

echo 0 | sudo tee /proc/sys/vm/vdso_enabled

echo 4096 | sudo tee /proc/sys/vm/mmap_min_addr

Then, you will have to create a group and user for scratchbox (in order to replicate a /home structure when emulating the environment). First, we will create a new group called "users" :

/scratchbox/sbin/sbox_configure yes users

Then create a new user called "userx" in the group "user" :

/scratchbox/sbin/sbox_adduser userx yes

Afterwards, we need to choose which processor to emulate with Scratchbox, setting up a "target". First, start Scratchbox :

scratchbox

Your shell prompt should change to "scratchbox@your_machine". Next, enter the menu typing the following command : 

sb-menu

Scratchbox menu will appear. There, tou need to choose the following menus :

  • Setup, then <NEW>
  • Enter "MSSII" for the target's name,
  • Choose "cs2005q3.2-glibc2.5-arm" for the compiler,
  • Add "cputransp" devkit,
  • Choose "qemu-arm-0.8.2-sb2" when asked for the CPU-transparency method,
  • Say "NO" to "Do you wish to extract a rootstrap on the target ?",
  • "YES" to install files then "OK" to validate the selected files (C library, /etc, ...),
  • Say "YES" to select the target.

You now have a working development environment. You just need to know where are located the files on your hardrive and on the scratchbox environment.

Paths

Your home directory in Scratchbox environment is located at the following path on your real environment :

/scratchbox/users/userx/home/userx/

If you compile libraries (".a") and get include files (".h"), you need to put them in the following directories in order to get them found by GCC :

/usr/lib/

/usr/include/

Conclusion

Using this method, I managed to compile the latest vsftpd (v2.0.6) with SSL support by first compiling the OpenSSL library and then vsftpd with SSL directive.