Linux Porting On Xtensa Processors

These instructions explain how I build the toolchain, root filesystem and kernel for Linux running on an Xtensa ISS. Most of these works follow the guide from the official Linux Xtensa porting document.
Host environment

  • Ubuntu 8.04 LTS
  • gcc version 4.2.4

Download buildroot and the Linux kernel

This porting work uses snapshots tar ball from official Linux Xtensa website linux-xtensa-20080711.tar.gz. I have unzipped the source code and make the top directory as the <workdir>.

tar -zxvf linux-xtensa-20080711.tar.gz

<workdir>/
         /buildroot
         /linux

Install any required processor specific overlay

This step is required because I am targeting a custom Xtensa processor.

cd <workdir>
./buildroot/target/xtensa/xt-buildroot-overlay-install \
    -t <HOME>/xtensa_RB-2008.4/XtDevTools/install/builds/RB-2008.4-linux/linuxcpu/src/xtensa-config-overlay.tar.gz \
    -b ./buildroot -k ./linux -c linuxcpu -l "Xtensa core for Linux"

Build a toolchain and root filesystem using buildroot

Configure buildroot

$ cd <workdir>/buildroot
$ ./target/xtensa/setup-config linuxcpu

Build buildroot

$ make

Build and Run a Linux Kernel on the Instruction Set Simulator (ISS)

Configure and Build the Kernel for ISS

$ export PATH="<workdir>/buildroot/build_xtensa_linuxcpu/staging_dir/usr/bin:$PATH"

$ mkdir build-iss
$ cd linux
$ make O=../build-iss ARCH=xtensa KBUILD_DEFCONFIG=iss_defconfig defconfig

Also, when running menuconfig:

$ make O=../build-iss ARCH=xtensa  menuconfig

Under General setup, make sure the Initial RAM filesystem and RAM disk (initramfs/initrd) support entry is enabled. Underneath that, edit Initramfs source file(s), and enter the path to the cpio formatted root filesystem generated by buildroot:
<workdir>/buildroot/binaries/uclibc/rootfs.xtensa_<cname>.cpio.gz

Under Bus Options, deselect PCI support. Under Platform Options, deselect Default bootloader kernel arguments.
Attention:
You need also select: Processor type and features -> Xtensa Processor Configuration (Custom Xtensa processor configuration) -> (X) Custom Xtensa processor configuration
After you select this flag, please make sure that <workdir>/linux/include/asm-xtensa/variant-linuxcpu/ exists.
Put the linuxcpu as the correct core name. These files are important for following kernel compilation.

Compile the kernel

Compile the linux kernel for your xtensa platform.

$ make O=../build-iss ARCH=xtensa CROSS_COMPILE=xtensa_linuxcpu-linux-uclibc-

Run the Kernel on ISS

$ xt-gdb <workdir>/build-iss/arch/xtensa/boot/Image.elf
(xt-gdb) target sim --turbo
(xt-gdb) symbol-file <workdir>/build-iss/vmlinux
(xt-gdb) run

Problems and errors

( XTCORE::bcopyToHost ) *WARNING* no translation available for virtual address 20004000 at ring 1

This line appears time to time. Though it does not stop the execution, there are something wrong with this porting work.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License