Documentation:NGW/NewKernel

From AVRFreaks Wiki

Jump to: navigation, search

Contents

[edit] Creating and installing a new Kernel for the ATNGW100 with Buildroot

The following steps will allow show you how to generate a new kernel with customisations and install it via an SD card onto you NGW100. This example will you Buildroot to automate some of the kernel creation steps. The latest version of Buildroot for the Atmel AVR32 can be found here

This example uses Ubuntu on the host development PC.

This first step is to cross compile a kernel and filesystem on the host PC. We use Buildroot for this and the output of buildroot is generally a complete Linux filesystem and AVR32 specific Kernel and tools. The exact output can be altered to be just the kernel or specific files.

[edit] 1. Using Buildroot to create a new kernel

1.1 Download the Buildroot tarball from here.

              Buildroot requires the following dependencies and will complain if they are not present on the host system:
                    * C compiler (GCC)
                    * C++ compiler for Qtopia (G++)
                    * GNU make
                    * sed
                    * flex
                    * bison
                    * patch
                    * gettext
                    * libtool
                    * texinfo
                    * autoconf (version 2.13 and 2.61)
                    * automake
                    * ncurses library (development install)
                    * zlib library (development install)
                    * libacl library (development install)
                    * lzo2 library (development install)
                Any missing applications can be installed via your favourite package manager (apt-get, yum, rpm etc)


1.2 Untar it to an accessible directory (the home directory is fine)

             eg: untar xvf buildroot-avr32-v2.3.0.tar.bz2

1.3 Open a terminal and change directory to the newly created Buildroot directory

             i.e. cd /user/home/Buildroot-avr32v2.3.0

1.4 Use the Make program to set the configuration for the NGW100

             eg: make atngw100_defconfig
                
             Other useful Make commands include "make clean and make dist_clean" to remove previous binaries and output files. "Make source" will download and store all the packages that Make might need to build a kernel image.
             For a full list type "Make help" or look in the text file "Makefile"

1.5 (Optional) If you would like to change any configurations, Make has a curses based GUI you can navigate to include or exclude certain packages from the final build. To start this GUI type:

             make menuconfig

1.6 Once you have 'untarred'Buildroot and given it a configuration file to follow, you are ready to ask Buildroot to create the kernel and filesystem for you. The process will take a significant amount of time (up to several hours depending on machine capabilities) and is commenced by typing:

              make

[edit] Troubleshooting

Murphy's Law will always play its part when it comes to software development. The following are a few tips and tricks to overcome some of the hurdles users have faced using Buildroot to create kernel and filesystems for the NGW100.

[edit] Rebuilding just the kernel

By way of a useful trick, if you want to test a change to the kernel but do not want to do a full make each time, merely delete the uImage file from

 ./root/boot/uImage
 ./linux-2.6.27.6/arch/avr32/boot/images/uImage

under the project_build_avr32 directory and then run make again. Buildroot will detect the missing uImage file and generate it again, whilst not recompiling anything else.


[edit] 2. Installing the new kernel and filesystem on the SD Card

Link to "Boot From SD Card section of this Wiki

Please note that you need to be very careful when executing the mkfs command. You will most likely be the root user and this means if you choose the incorrect partition to "mkfs" you can easily wipe all data from the incorrect partition.

As a quick recap of those instructions, assuming the SD Card device is sdb, the steps are:

Run sfdisk to show which partition you are accessing:

 sfdisk -l /dev/sdb

Then make a filesystem on the SD Card device with the mkfs command:

 mkfs -t ext2 /dev/sdb1

Make a directory on the host as a mount point:

 mkdir /home/user/sdcard

Mount the SD Card block device at the mount point:

 mount /dev/sdb1 /home/user/sdcard

<Change directory to where you have the "*.tar.bz2" output of Buildroot, usually wihtin the "binaries" directory>

Untar the Buildroot created filesystem and kernel:

 tar xjf rootfs.avr32.tar.bz2 -C /user/home/sdcard

<At this point you should be able to list the files on the SD Card>

Now you need to alter the /etc/fstab so that the SD Card will be mounted by the NGW100 on boot

 nano /home/user/sdcard/etc/fstab  

 <You will need to add this line to the bottom of the file>
 /dev/mmcblk0p1  /               ext2            defaults        0       0



3.1 "Make stalls when trying to connect to www.mpfr.org"

Buildroot will try to download a patch file from www.mpfr.org even if "make source" has been run previously. It seems that sometimes www.mpfr.org cannot be reached easily to obtain the file "mpfr-2.3.0.patch. One solution is to manually search and download the file and place it in the "dl" directory under the directory where Buildroot is installed. This were Buildroot stores downloaded files, it can be "../src/dl" or "../dl" depending on which version of Buildroot is being used

[edit] AVR32 Studio

Buildroot creates a Toolchain as part of the make process that the host PC can use for developing binaries to execute on the target running the new Operating System.

As the saying goes, there is more than one way to skin a cat... Well there are many ways to have AVR32 Studio use the freshly built Toolchain.

The method I prefer is to create a small text file to launch AVR32 Studio that sets the correct PATH variable before launching AVR32 Studio. The contents should resemble:

 export PATH=$PATH:/home/user/buildroot-avr32-v2.3.0/build_avr32/staging_dir/bin
 /home/user/AVR32/avr32studio/avr32studio

This will place the needed binaries of the Toolchain, such as avr32-linux-gcc, on the PATH variable which makes those binaries accessible by AVR32 Studio. If later you update to a later version of Buildroot, you can just alter this one file to use the new Toolchain without disturbing any other Toolchain.

Personal tools