JlimeToolchain

From Qi-Hardware
Jump to: navigation, search

Contents

[edit] Jlime Toolchain

Jlime Toolchain is a set of tools that allows you to compile code for Ben Nanonotes (or similar mipsel machines) If you develop or like building software for Ben Nanonote and Jlime, then you should install the Jlime Toolchain on your x86 PC.

As cross compiling on a x86 workstation is much faster than native compiling on the slow boxes, it is a good reason to install it and compile with it.

[edit] Download and Install

On the below example we will install the toolchain under /home/myuser/jlime-toolchain/ dir. But you can use any directory, just use whatever DIR you want with the commands.

Example:

# cd $HOME
cd /home/myuser
mkdir jlime-toolchain
cd jlime-toolchain
wget http://downloads.qi-hardware.com/jlime/toolchains/jlime-2010.1-2010.1-mipsel-linux-toolchain.tar.bz2
tar xvjf jlime-2010.1-2010.1-mipsel-linux-toolchain.tar.bz2 .
pwd
/home/myuser/jlime-toolchain/
wget http://downloads.qi-hardware.com/jlime/toolchains/opkg.conf
mv opkg.conf usr/local/jlime-2010.1/mipsel/mipsel-linux/etc/opkg.conf     # <-- PAY ATTENTION it is usr/... NO /usr/...
# EDIT usr/local/jlime-2010.1/mipsel/environment-setup
pwd
/home/myuser/jlime-toolchain
vim usr/local/jlime-2010.1/mipsel/environment-setup    # <-- Or vim /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/environment-setup

# EDIT every line with /usr/, and add as prefix the DIR where you installed toolchain
# FOR EXAMPLE, if you installed the toolchain like the commands above you should 
# have an environment-setup like this :
cat /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/environment-setup
export PATH=/home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/bin:$PATH
export LIBTOOL_SYSROOT_PATH=/home/myuser/jlime-toolchain/usr/mipsel-linux
export PKG_CONFIG_SYSROOT_DIR=/home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/mipsel-linux
export PKG_CONFIG_PATH=/home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/mipsel-linux/usr/lib/pkgconfig
export CONFIG_SITE=/home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/site-config
alias opkg='LD_LIBRARY_PATH=/home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/lib /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/bin/opkg-cl -f  /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel//etc/opkg-sdk.conf -o /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel'
alias opkg-target='LD_LIBRARY_PATH=/home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/lib /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/bin/opkg-cl  -f /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/mipsel-linux/etc/opkg.conf -o /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/mipsel-linux' 


[edit] Testing local opkg-target

With opkg-target you can install extra Jlime packages under your toolchain. It is useful, for example, to add libraries and headers you need to crosscompile your applications.

Example:

# TEST opkg for your toolchain
pwd
/home/myuser/jlime-toolchain
. usr/local/jlime-2010.1/mipsel/environment-setup    # <-- Or run : ". /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/environment-setup"
opkg-target update    # <-- Update the local packages database
# CHECK the proper name of the package to install
opkg-target list | grep -i libsdl-image
# INSTALL the headers and their dependences
opkg-target install libsdl-image-1.2-dev


[edit] Crosscompile

You have your hello.c, write a Makefile like this:

cat Makefile 
CC=mipsel-linux-gcc
CFLAGS=-Wall
 
hello:

Then, build hello with :

. /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/environment-setup    # <-- use the proper path to your toolchain
make

Warning!: you do not need to run ". /home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/environment-setup" every time you need to do something with your toolchain. Run it just once for every shell you use.

[edit] Building the Linux Kernel

Building Linux kernel for Nanonote or uboot is simpler than applications (yes, it is).

In order to build the kernel you do not need to run ". usr/local/jlime-2010.1/mipsel/environment-setup", so if you already did, then crosscompile the Linux kernel using another new shell, so you are sure that ". usr/local/jlime-2010.1/mipsel/environment-setup" was not ran.

Example to build the kernel :

# GO Linux Kernel source code
cd linux-for-nn/

# SET the PATH
export PATH=$PATH:/home/myuser/jlime-toolchain/usr/local/jlime-2010.1/mipsel/bin/
# MENUCONFIG AND BUILD
make ARCH=mips CROSS_COMPILE=mipsel-linux- clean
make ARCH=mips CROSS_COMPILE=mipsel-linux- menuconfig
make ARCH=mips CROSS_COMPILE=mipsel-linux- vmlinux.bin
# Get the set entry point for mkimage command (-e)
echo 0x$(mipsel-linux-nm vmlinux 2>/dev/null | grep " kernel_entry" | cut -f1 -d ' ')
cd arch/mips/boot
rm vmlinux.bin.gz uImage
gzip -9 vmlinux.bin
# You get the value for -e with the echo command above
mkimage -A mips -O linux -T kernel -C gzip -a 0x80010000 -e 0x80014240 -n 'MIPS' -d vmlinux.bin.gz uImage
# cp uImage to your nn system
Personal tools
Namespaces
Variants
Actions
Navigation
interactive
Toolbox
Print/export