|
|
(73 intermediate revisions by 5 users not shown) |
Line 1: |
Line 1: |
| These instructions explain how to build a toolchain, root filesystem and kernel for Linux running on an Xtensa processor. These instructions apply specifically to the XTAV60 (LX60) board. They are based on a snapshot of work in progress.
| | This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup. |
|
| |
|
| Some general notes on these instructions:
| | = GNU/Linux on Xtensa = |
|
| |
|
| * They are a work in progress: the kernel and buildroot setup evolve, affecting this document. Hopefully it is kept up-to-date in a reasonably timely manner.
| | GNU is a collection of free software that provides POSIX environment. |
| | Linux is an operating system kernel. |
| | In order to boot GNU/Linux OS on Xtensa the following parts are needed: |
|
| |
|
| * The following was tested on an x86 machine running RedHat Enterprise Linux 4 (RHEL4) and Fedora Core 3 (FC3). It is expected to work on other Fedora releases (e.g. was tested on FC6) but to maintain host compatibility with Tensilica Tools, it is best to avoid Fedora releases beyond FC5. Other host distributions likely work but have not been tested. | | * a board with Xtensa core supported by Linux, or Xtensa simulator |
| | * bootable Linux kernel image |
| | * GNU software packaged in a form suitable for booting on Linux, the so called root file system |
| | * a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM |
|
| |
|
| * Lines prefixed with "sudo" need to be executed as root. The rest is best executed as a non-root user. (It is possible to install subversion and git as a non-root user if root access is an issue. How to do this isn't shown here.)
| | To build Linux image and root file system a toolchain correctly configured for used Xtensa core is needed. Toolchain configuration is performed by application of [[Toolchain_Overlay_File|Xtensa configuration overlay]]. Correct toolchain configuration is critical for building other pieces of software correctly. |
|
| |
|
| * Lines that set environment variables assume a Bourne compatible shell (e.g. /bin/sh or bash), but are easily adapted to other shells.
| | == Xtensa cores supported by Linux == |
|
| |
|
| * Instructions are assumed executed all in order (e.g. commands assume current directory and environment variables set earlier).
| | Official requirements for Xtensa core to run Linux are listed in the Xtensa OSKit Guide document. |
| | The absolute minimum set of options required to run Linux is windowed registers, exception option and one level-1 or medium level timer interrupt. |
| | * Full MMU option is required for full featured Linux kernel that includes process address space isolation, virtual memory and fork syscall. |
| | * Full MMU option, thread pointer option and conditional store option are required for running userspace with NPTL or TLS. |
|
| |
|
| | == Xtensa boards supported by Linux == |
|
| |
|
| | The following boards collectively referred as XTFPGA family are readily supported by Linux: Avnet LX60, LX110, LX200; Xilinx ML605, KC705. For board details/setup guide please see corresponding Board Guide or Board Prototyping Guide provided with Xtensa software release. |
|
| |
|
| == Ensure you have all needed packages installed on your system == | | == Xtensa simulators == |
|
| |
|
| === Install the ''Subversion'' source control tools ===
| | * Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS. |
| | * QEMU is a free system emulator capable of emulating any XTFPGA board or ISS. It can be configured to emulate any Xtensa core, but it does not currently support TIE extensions to the core architecture. Please see [[Xtensa_on_QEMU|this]] page for more details. |
|
| |
|
| First verify whether you already have Subversion installed. Try:
| | == Linux kernel == |
|
| |
|
| $ svn help
| | Linux kernel needs to be configured for the specific Xtensa core. For that reason Linux is usually configured and built separately from the userspace software. Please see [[Linux_Kernel|this]] page for more details. |
|
| |
|
| which should output a help page. If not,
| | == Root file system == |
| download and install the [http://subversion.tigris.org/ Subversion]
| |
| source control tools:
| |
|
| |
|
| $ sudo yum install subversion
| | Currently we support building GNU software and packaging it into root file system with the [[Buildroot]]. |
| | There are several types of root file system that Linux can boot with: |
|
| |
|
| This may install dependent packages (e.g. 'apr', etc).
| | === CPIO archive === |
| | * CPIO archive may be built into the kernel (so called 'built-in initramfs'), the resulting single image will contain both Linux and GNU software. It's easy to boot, but in order to change anything the kernel needs to be rebuilt. |
| | * CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It's harder to boot (two files instead of one), but easier to change. |
|
| |
|
| Documentation for Subversion is available online at http://svnbook.red-bean.com/
| | Both cases of CPIO use RAM for the root file system, so they're very fast. The downsides are that they take some time at startup to unpack, reserve some RAM (which may be an issue on low-memory boards like LX60) and are not persistent. |
| or by typing <code>svn help</code> at a shell prompt.
| |
|
| |
|
| === Download and install the <code>git</code> source control tools === | | === EXT2/3/4 file system image === |
| | EXT2/3/4 file system image may be used directly with ISS or QEMU through the Simulated block device Linux feature. Please see [[Linux_Kernel#ISS_platform|this]] chapter for more details. |
|
| |
|
| First determine whether you already have ''git'' installed. Try:
| | === TAR image === |
| | Tar image may be unpacked into a directory shared through NFS. Linux on XTFPGA boards and on QEMU can be configured to use NFS root file system. |
|
| |
|
| $ git
| | === UBIFS image === |
| | UBIFS image may be written directly to the daughterboard FLASH on XTFPGA boards. Please see [[Linux_Kernel#Rootfs_in_FLASH_.28UBIFS.29|this]] chapter for more details. |
|
| |
|
| which should output a help page. If instead ''git'' is not found,
| | == Bootloader == |
| download and install the ''git'' source control tools.
| | U-Boot can be used as a bootloader on XTFPGA boards. Please see [[U-Boot|this]] page for more details about installing it into the daughterboard FLASH. |
|
| |
|
| On FC6, you can just do the following | | == On-chip debugger == |
| (which installs documentation accessible with <code>man git</code>
| | On-chip debugger is good for debugging lowest level software: bootloader and Linux kernel itself. It also allows loading executable images into new board with empty FLASH. |
| or <code>git help</code>):
| | It consists of JTAG probe connected to the XTFPGA daughterboard (ML605 and KC705 daughterboards also have built-in JTAG chip), OCD monitor (xt-ocd) running on developer machine where the other end of JTAG probe is connected, and xt-gdb, the modified version of GNU debugger from the Xtensa software release. Please see Tensilica Debug User's Guide for more information about OCD setup and configuration. |
|
| |
|
| $ sudo yum install git
| | = Building GNU/Linux OS = |
| | In order to follow these instruction a build machine with GNU/Linux and a set of development tools (native binutils and gcc, make, wget, tar, ...) is needed. In the following example all software will be downloaded and built in the current directory. Xtensa tools used in the examples are installed into $XT_ROOT, tools release is $XT_RELEASE and selected core is $XT_CORE. |
|
| |
|
| On FC3, yum doesn't know about git, so you have to do something like:
| | == Prepare the overlay == |
| | Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location. |
| | Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable: |
| | $ '''cat > overlay-script''' |
| | '''....''' |
| | ^D |
| | $ '''chmod +x overlay-script''' |
|
| |
|
| $ cd /tmp
| | Run it and rename the resulting file: |
| $ lwp-download http://kernel.org/pub/software/scm/git/git-1.5.3.1.tar.bz2
| | $ '''./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz''' |
| $ tar xfj git-1.5.3.1.tar.bz2
| | $ '''mv xtensa-overlay.tar xtensa_${XT_CORE}.tar''' |
| $ cd git-1.5.3.1
| |
| $ make prefix=/usr/local all
| |
| $ sudo make prefix=/usr/local install
| |
|
| |
|
| and make sure <code>/usr/local/bin</code> is in your PATH. | | == Get, configure and build the toolchain and root file system == |
| This doesn't install git documentation. For that, you have
| | Get the buildroot git tree: |
| to build ''doc'' and ''info'' make targets, which require first
| | $ '''git clone git://git.buildroot.net/buildroot''' |
| installing other packages such as ''asciidoc'' and others.
| |
| However, for this example, documentation is not necessary.
| |
| You can find online docs such as a
| |
| [http://www.kernel.org/pub/software/scm/git/docs/tutorial.html tutorial]
| |
| and [http://www.kernel.org/pub/software/scm/git/docs/ manual pages].
| |
|
| |
|
| == Download buildroot and the Linux kernel ==
| | Check out some released version: |
| | $ '''git checkout 2014.11''' |
|
| |
|
| The following section describes how to download the very latest
| | Create build directory and configure it: |
| versions of buildroot and of the Linux kernel.
| | $ '''mkdir buildroot-build''' |
| | $ '''make -C buildroot O=$(pwd)/buildroot-build menuconfig''' |
|
| |
|
| You may also opt to download a specific snapshot of these sources
| | Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot. |
| and of this page that have been tested to work together,
| |
| instead of following the instructions below. In that case,
| |
| see the list of [[Buildroot_Snapshots]]. | |
|
| |
|
| === Download buildroot sources === | | Select 'Target Architecture' = Xtensa, 'Target Architecture Variant' = Custom Xtensa processor configuration, set 'Overlay file for custom configuration ' to the location of the overlay archive (it may be a path to a local file or an URL). |
|
| |
|
| Buildroot is used to build the toolchain and root filesystem.
| | Select toolchain options, packages to be built and final root file system image type. Select whether the kernel need to be built, kernel version and configuration. |
| First setup a work area:
| |
|
| |
|
| $ cd <workdir>
| | Build the toolchain, kernel and the root file system: |
| | $ '''make -C buildroot O=$(pwd)/buildroot-build''' |
|
| |
|
| where <workdir> is the path to an empty directory on a disk with
| | == The kernel may be built on its own == |
| at least 4 GB available space.
| | Get stable Linux release tree: |
| The following creates and populates the <workdir>/trunk directory:
| | $ '''wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz''' |
| | $ '''tar -xf linux-3.19.1.tar.xz''' |
|
| |
|
| $ svn co svn://linux-xtensa.org/var/svn/repos/buildroot/trunk/
| | Create variant directory for the specific core and copy core configuration files there: |
| | $ '''mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant''' |
| | $ '''cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant''' |
|
| |
|
| === Download Linux kernel sources === | | Create build directory and configure it: |
| | $ '''mkdir linux-build''' |
| | $ '''ARCH=xtensa CROSS_COMPILE=$(pwd)/buildroot-build/host/usr/bin/xtensa-buildroot-linux-uclibc- make -C linux-3.19.1 O=$(pwd)/linux-build menuconfig''' |
|
| |
|
| First you need to decide which kernel tree to work with.
| | Select 'Xtensa Processor Configuration' = Custom Xtensa processor configuration, set 'Xtensa Processor Custom Core Variant Name' to the contents of ${XT_CORE}. Select desired 'Xtensa System Type'. |
| (You can also download multiple kernel source trees of course.)
| |
|
| |
|
| At the time of writing, the <tt>xtensa-2.6.24</tt> tree is the most current.
| | Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux. |
|
| |
|
| The <tt>xtensa-2.6.24</tt> tree is based on the release candidate 2.6.24-rc''n'' kernel
| | Build the kernel: |
| from <tt>kernel.org</tt>.
| | $ '''ARCH=xtensa CROSS_COMPILE=$(pwd)/buildroot-build/host/usr/bin/xtensa-buildroot-linux-uclibc- make -C linux-3.19.1 O=$(pwd)/linux-build all''' |
|
| |
|
| The <tt>xtensa-devel</tt> tree contains the most recent changes but is not as stable.
| | = Booting GNU/Linux = |
| It also gets updated semi-regularly with the very latest Linux kernel tree from <tt>kernel.org</tt>.
| | TBD |
| '''Note:''' The <tt>xtensa-devel</tt> tree is about to be recreated from scratch; if you
| |
| have previously cloned this tree, you will have to clone it again once this happens to
| |
| avoid confusing git when pulling (from what would be a mismatching tree).
| |
| | |
| To get the stable tree into directory <dir> (which must not already exist):
| |
| | |
| $ cd <workdir>
| |
| $ git clone git://git.linux-xtensa.org/kernel/xtensa-2.6.24 <dir>
| |
| | |
| This creates and populates the <workdir>/<dir> directory. If <dir> is omitted, it defaults to <tt>xtensa-2.6.24</tt> (the last non-extension part of the cloned path).
| |
| | |
| Similarly, to get the development tree:
| |
| | |
| $ cd <workdir>
| |
| $ git clone git://git.linux-xtensa.org/kernel/xtensa-devel <dir>
| |
| | |
| Note that the latter <tt>xtensa-devel</tt> tree currently contains two branches:
| |
| '''master''' (the default branch checked out by the clone command above),
| |
| and '''testing'''.
| |
| ''Note: more branches will be added when the tree is recreated.''
| |
| Often, development
| |
| checkins are made to the '''testing''' branch before getting repackaged
| |
| and integrated over to the '''master''' branch some time later.
| |
| You can switch to another branch (within the cloned repository)
| |
| using the <tt>git-checkout</tt> command, for example:
| |
| | |
| $ git checkout testing
| |
| | |
| == Install any required processor specific overlay ==
| |
| | |
| This step is required if you are targeting a custom Xtensa processor.
| |
| If you use a Diamond 232L Standard Core, you can skip this step.
| |
| | |
| To configure buildroot and the kernel to use a custom Xtensa processor
| |
| configuration, you need to overlay a set of files customized for your
| |
| processor configuration onto toolchain sources (gcc, binutils, gdb, etc)
| |
| and the Linux kernel. This process has been automated using a script
| |
| located in the buildroot source tree.
| |
| For usage information, you can invoke it without arguments:
| |
| | |
| $ cd <workdir>
| |
| $ ./trunk/target/xtensa/xt-buildroot-overlay-install
| |
| | |
| which displays a help message similar to the following:
| |
| | |
| xt-buildroot-overlay-install version 1.1
| |
| Usage: xt-buildroot-overlay-install <parameters> [<options>]
| |
| Where <parameters> are:
| |
| -t file.tgz Specify path to the Xtensa Linux overlay tarball, typically
| |
| <xtensa_root>/xtensa-elf/src/linux/misc/linux-overlay.tar.gz
| |
| -b dir Path to the base of the buildroot source tree, in which
| |
| package specific overlay tarballs get installed.
| |
| -k dir Path to the base of the Linux kernel source tree, in which
| |
| the Linux kernel specific overlay gets installed.
| |
| -c config_name Name for the Xtensa processor configuration as it will be
| |
| known to the open source community. Must be a lowercase
| |
| identifier, starting with a letter, consisting of letters
| |
| and numbers and underscores, not ending with underscore
| |
| and not containing consecutive underscores. For examples:
| |
| dc232b , dc232b_be , mmubasele , fsf , s5000 .
| |
| -l long_name Long name for the Xtensa processor configuration, human-
| |
| readable with spaces etc allowed (must be quoted).
| |
| For example: 'Diamond 232L Standard Core Rev.B (LE)'
| |
| Try to keep it within approximately 40 characters.
| |
| And <options> are:
| |
| -f If package specific overlay tarballs already exist in
| |
| the destination source tree, overwrite them without asking.
| |
| --help Show this usage message.
| |
| | |
| Note that the Xtensa Linux overlay tarball MUST be obtained from an Xtensa
| |
| core package built using release RB-2008.3 or later. Until this release
| |
| becomes available (sometime in early 2008), the overlay tarball can be obtained
| |
| by providing Tensilica customer support with your processor configuration
| |
| and TIE (such as, .xcf and .tdb files); they should be able to generate it
| |
| for active customers.
| |
| | |
| Here is an example invocation of the overlay installation script:
| |
| | |
| $ ./trunk/target/xtensa/xt-buildroot-overlay-install -t blinkcore-linux-overlay.tar.gz \
| |
| -b ./trunk -k ./xtensa-devel -c superzip -l "ChipCorp SuperZIP Blink Accelerator Core"
| |
| | |
| The script extracts some relevant information from the overlay tarball,
| |
| presents it along with relevant parameters to the user, and prompts
| |
| for confirmation before proceeding.
| |
| | |
| The chosen processor name (-c option) must be unique among known Xtensa processors.
| |
| It is also probably wise to avoid names confusingly similar to other (non-Xtensa) processors.
| |
| If you expect at some point to contribute support for your custom processor to the
| |
| open-source community, this name will likely be long-lived.
| |
| (One way to contribute support for a custom processor might be to submit the overlay tarball
| |
| or files to the linux-xtensa.org maintainers.)
| |
| | |
| In the steps below, buildroot and the Linux kernel must be configured
| |
| (in their respective <code>''make menuconfig''</code> steps) to select
| |
| the <code>''custom''</code> Xtensa processor option.
| |
| This presents an extra configuration menu entry where you must provide
| |
| the name of the Xtensa processor. Set it to the same name
| |
| as was specified in the <code>-c</code> option above.
| |
| | |
| | |
| == Build a toolchain and root filesystem using buildroot ==
| |
| | |
| Note: for more details on generic buildroot topics not covered in this simple how-to,
| |
| see [http://buildroot.uclibc.org/ buildroot.uclibc.org].
| |
| | |
| === Configure buildroot ===
| |
| | |
| Note: You need the TERM environment variable properly set for curses
| |
| based tools to work.
| |
| | |
| The first time you configure buildroot, start with defaults for Xtensa processors:
| |
| | |
| $ cd <workdir>/trunk
| |
| $ cp target/xtensa/defconfig .config
| |
| $ make menuconfig
| |
| | |
| You should get a curses interface for configuring buildroot.
| |
| Make the following changes:
| |
| | |
| * Change '''Target Architecture Variant''' to desired Xtensa or Diamond core (e.g. '''dc232b''')
| |
| * Make any other desired changes (e.g. selecting additional packages)
| |
| * Exit and save the configuration
| |
| | |
| If later you want to change the buildroot configuration without losing
| |
| other changes made so far, just use ''make menuconfig'' by itself:
| |
| | |
| $ cd <workdir>/trunk
| |
| $ make menuconfig
| |
| | |
| === Configure uClibc ===
| |
| | |
| Apply the default uClibc configuration for Xtensa processors:
| |
| | |
| $ make uclibc-config
| |
| | |
| To further customize uClibc, you can then optionally configure it like this:
| |
| | |
| $ make uclibc-menuconfig
| |
| | |
| === Build buildroot ===
| |
| | |
| $ make
| |
| | |
| THIS WILL TAKE A LONG TIME (from 20 minutes to perhaps an hour or many,
| |
| depending on your system and on whether you enabled extra packages in
| |
| your buildroot configuration).
| |
| | |
| Wait patiently for build to complete. This builds an entire toolchain
| |
| as well as some basic packages, and constructs a root filesystem.
| |
| It might build many more packages if you selected them earlier with menuconfig.
| |
| | |
| ==== If Something Goes Wrong ====
| |
| | |
| Perhaps you missed some step above and the build fails. Or you're just switching to a different processor configuration, or making some change with unknown dependencies. Either way, you'll probably need to fix the error and/or make the change, and redo the whole build. The above 'make' command does not check many dependencies, so it will usually NOT rebuild things that depend on whatever you have fixed. Here's one possible sequence to retry the make without having to wipe out the 'trunk' directory tree completely and start again from the svn checkout.
| |
| | |
| $ rm -rf *build_xtensa* binaries
| |
| $ make uclibc-config
| |
| $ make
| |
| | |
| It should not be necessary to empty the 'dl' subdirectory, which contains tarballs downloaded from the Internet, or the .config file, which contains the buildroot configuration. Customizations to the uClibc configuration should have ended up getting saved in target/xtensa/uClibc.config , so hopefully are preserved by the above sequence.
| |
| | |
| == Build and Run a Linux Kernel on the XTAV60 or XTAV200 Board ==
| |
| | |
| References to the ''XTAV60 board'' refer to the combination of
| |
| the Avnet [http://www.em.avnet.com/tensilica1 LX60 (Xilinx) Development Board]
| |
| and a Tensilica provided FPGA bitstream containing a configured Tensilica
| |
| processor and basic peripheral IP. For more details, please refer to the
| |
| ''Tensilica Avnet LX60 (XT-AV60) Board User's Guide''.
| |
| | |
| Similarly, references to the ''XTAV200 board'' refers the combination of
| |
| the Avnet [http://www.em.avnet.com/tensilica2 LX200 (Xilinx) Development Board]
| |
| and a Tensilica provided FPGA bitstream containing a configured Tensilica
| |
| processor and basic peripheral IP. For more details, please refer to the
| |
| ''Tensilica Avnet LX200 (XT-AV200) Board User's Guide''.
| |
| | |
| | |
| === Configure the kernel ===
| |
| | |
| The kernel build is a two-step process: configure the kernel, and build it.
| |
| First, before we can do anything with the kernel, set your PATH to
| |
| point to the toolchain built using buildroot.
| |
| | |
| $ export PATH="''<workdir>''/trunk/build_xtensa_''<cname>''/staging_dir/usr/bin:$PATH"
| |
| | |
| where ''<cname>'' is the name of the Xtensa processor configuration you selected
| |
| when building the toolchain (e.g. <code>dc232b</code>).
| |
| | |
| Now setup a destination for kernel builds.
| |
| We usually like to have the build directory separate from
| |
| the source directory, so we use 'O=</destination/path>' in
| |
| kernel make commands. If you'll be routinely building multiple
| |
| configurations of the Linux kernel, it's good to have some
| |
| naming conventions for the build directory. For example,
| |
| to experiment with multiple target platforms but only one
| |
| processor configuration, we include just the platform name here:
| |
| | |
| $ mkdir build-xtav60
| |
| | |
| Let's start with the default kernel configuration for the Avnet board
| |
| (which works on both XTAV60 (LX60) and XTAV200 (LX200) boards)
| |
| as follows:
| |
| | |
| $ cd xtensa-devel
| |
| $ make O=../build-xtav60 ARCH=xtensa KBUILD_DEFCONFIG=lx60_defconfig defconfig
| |
| | |
| This configures the kernel using the default configuration found in
| |
| arch/xtensa/configs/lx60_defconfig.
| |
| | |
| NOTE: This kernel configuration has nothing to do with Xtensa
| |
| processor configuration. That comes next.
| |
| | |
| Let's now customize this a little bit to select the correct Xtensa processor
| |
| configuration, and to bundle the root filesystem into the kernel:
| |
| | |
| $ make O=../build-xtav60 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>''/trunk/binaries/uclibc/rootfs.xtensa_''<cname>''.cpio.gz
| |
| | |
| (Don't forget to replace ''<workdir>'' with the appropriate full path
| |
| and ''<cname>'' with your Xtensa processor configuration name.)
| |
| | |
| Under '''Processor type and features''',
| |
| make sure the '''Xtensa Processor Configuration''' is correct and matches
| |
| the processor configuration name you used to build the toolchain with buildroot
| |
| (for example, ''dc232b'' for Diamond 232L Rev.B).
| |
| The kernel build selects a toolchain and processor variant specific headers
| |
| based on this selection.
| |
| If the desired processor configuration does not appear explicitly in the list,
| |
| simply select '''Custom Xtensa processor configuration''' and enter the
| |
| processor configuration name (all lowercase) into the next menu parameter,
| |
| '''Xtensa Processor Custom Variant Name'''.
| |
| | |
| Exit menuconfig, saving your configuration changes.
| |
| | |
| Backup your configuration outside the build directory. For example:
| |
| | |
| $ cp ../build-xtav60/.config config.xtav60.saved
| |
| | |
| If you do a clean rebuild of the kernel (e.g. "rm -rf ../build-xtav60")
| |
| you can now configure it with simply:
| |
| $ mkdir ../build-xtav60 ; cp config.xtav60.saved ../build-xtav60/.config
| |
| Of course if you update the kernel, you'll probably again have to do:
| |
| $ make O=../build-xtav60 ARCH=xtensa menuconfig
| |
| and save a new copy of your configuration.
| |
| | |
| === Build the kernel ===
| |
| | |
| $ make O=../build-xtav60 ARCH=xtensa
| |
| | |
| The build will issue a few warnings which are normal.
| |
| Once complete, the bootable image is in:
| |
| <workdir>/build-xtav60/arch/xtensa/boot/Image.elf
| |
| and the uncompressed ELF file containing kernel symbols is in:
| |
| <workdir>/build-xtav60/vmlinux
| |
| There is also a RedBoot bootable image (if you use RedBoot) in:
| |
| <workdir>/build-xtav60/arch/xtensa/boot/zImage.redboot
| |
| | |
| === Install Xtensa Tools with the 232L (or selected) core ===
| |
| | |
| This can be done a a different machine than the one used so far,
| |
| as long as it has access to the <workdir> directory tree.
| |
| | |
| For this example, Xtensa Tools are only needed for downloading
| |
| the kernel over OCD using <code>xt-gdb</code>.
| |
| | |
| === Install and setup the Xtensa OCD Daemon ===
| |
| | |
| Setup and connect your JTAG probe, etc.
| |
| | |
| === Connect a terminal server ===
| |
| | |
| At 38400 bps 8N1 no flow control to the XTAV60 serial port.
| |
| | |
| === Optionally, setup networking ===
| |
| | |
| This step is optional.
| |
| | |
| Setup the board's MAC address using dipswitches
| |
| (see XTAV60 or XTAV200 board docs as appropriate)
| |
| and connect the board to a network that has a
| |
| DHCP server that will respond to that MAC address.
| |
| If you don't do this step, you'll simply not have network
| |
| access, and the boot process will take a minute or so longer
| |
| while the kernel times out waiting for a BOOTP response.
| |
| You can edit the kernel configuration and rebuild the kernel
| |
| to avoid using bootp (in particular, remove "ip=bootp" from
| |
| the kernel cmdline).
| |
| | |
| === Download and run the kernel ===
| |
| | |
| Reset the board (see board documentation).
| |
| | |
| Using Tensilica Tools, invoke:
| |
| | |
| $ xt-gdb <workdir>/build-xtav60/arch/xtensa/boot/Image.elf
| |
| | |
| (xt-gdb) target remote <ocdhost>:20000 0
| |
| (xt-gdb) reset
| |
| (xt-gdb) load
| |
| (xt-gdb) set $pc = &_ResetVector
| |
| (xt-gdb) symbol-file <workdir>/build-xtav60/vmlinux
| |
| (xt-gdb) c
| |
| | |
| where <ocdhost> is the IP address or DNS name of the machine
| |
| running the Xtensa OCD daemon. The Linux kernel should
| |
| start booting as soon as 'c' (continue) is executed.
| |
| | |
| You should eventually get a login prompt.
| |
| Just login as root (no password).
| |
| | |
| Try various Linux commands. Look at /bin, /sbin, /usr/bin,
| |
| etc to see what's available. Not all guaranteed to work,
| |
| but basic things like 'ls' and 'ping' seem to work fine.
| |
| | |
| Note: no need to setup an NFS or TFTP server. The filesystem
| |
| is contained within the kernel image. You may be able to mount
| |
| other filesystems over NFS though, if you wish, after booting.
| |
| | |
| == Build and Run a Linux Kernel on the Instruction Set Simulator (ISS) ==
| |
| | |
| You can build and run a Linux kernel in the Xtensa Instruction Set
| |
| Simulator (ISS). The following instructions have only been tried
| |
| with an ISS from release RB-2007.2 of Tensilica Tools. Bear in
| |
| mind that the XTAV60 port is likely much more stable than the ISS port
| |
| of Linux at this point in time.
| |
| | |
| Note: Depending on your host OS version, you may need to install
| |
| Tensilica Tools on a separate machine.
| |
| | |
| === Configure and Build the Kernel for ISS ===
| |
| | |
| Repeat all the same instructions as above for building the kernel for the
| |
| XTAV60 board, except that when initially configuring the kernel,
| |
| start from the ISS platform template instead:
| |
| | |
| $ mkdir build-iss
| |
| $ cd xtensa-devel
| |
| $ make O=../build-iss ARCH=xtensa KBUILD_DEFCONFIG=iss_defconfig defconfig
| |
| | |
| This configures the kernel using the default configuration found in
| |
| arch/xtensa/configs/iss_defconfig.
| |
| | |
| Also, when running menuconfig:
| |
| | |
| $ make O=../build-iss ARCH=xtensa menuconfig
| |
| | |
| in addition to setting up the initramfs filesystem, do the following.
| |
| Under '''Bus Options''', deselect '''PCI support'''.
| |
| Under '''Platform Options''', deselect '''Default bootloader kernel arguments'''.
| |
| | |
| | |
| Continue configuring and building the kernel as usual.
| |
| | |
| === Run the Kernel on ISS ===
| |
| | |
| Using Tensilica Tools, invoke:
| |
| | |
| $ 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
| |
| | |
| Wait patiently while Linux boots ... (maybe a minute)
| |
| | |
| Login as root (no password).
| |
| | |
| Note: Input via ISS is cooked, so everything typed gets echoed.
| |
| Also, time as reported by the kernel does not progress
| |
| according to true wall-clock time: it currently depends on
| |
| a simulated processor clock, which advances at various speeds
| |
| according to load.
| |
This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.
GNU/Linux on Xtensa
GNU is a collection of free software that provides POSIX environment.
Linux is an operating system kernel.
In order to boot GNU/Linux OS on Xtensa the following parts are needed:
- a board with Xtensa core supported by Linux, or Xtensa simulator
- bootable Linux kernel image
- GNU software packaged in a form suitable for booting on Linux, the so called root file system
- a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM
To build Linux image and root file system a toolchain correctly configured for used Xtensa core is needed. Toolchain configuration is performed by application of Xtensa configuration overlay. Correct toolchain configuration is critical for building other pieces of software correctly.
Xtensa cores supported by Linux
Official requirements for Xtensa core to run Linux are listed in the Xtensa OSKit Guide document.
The absolute minimum set of options required to run Linux is windowed registers, exception option and one level-1 or medium level timer interrupt.
- Full MMU option is required for full featured Linux kernel that includes process address space isolation, virtual memory and fork syscall.
- Full MMU option, thread pointer option and conditional store option are required for running userspace with NPTL or TLS.
Xtensa boards supported by Linux
The following boards collectively referred as XTFPGA family are readily supported by Linux: Avnet LX60, LX110, LX200; Xilinx ML605, KC705. For board details/setup guide please see corresponding Board Guide or Board Prototyping Guide provided with Xtensa software release.
Xtensa simulators
- Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.
- QEMU is a free system emulator capable of emulating any XTFPGA board or ISS. It can be configured to emulate any Xtensa core, but it does not currently support TIE extensions to the core architecture. Please see this page for more details.
Linux kernel
Linux kernel needs to be configured for the specific Xtensa core. For that reason Linux is usually configured and built separately from the userspace software. Please see this page for more details.
Root file system
Currently we support building GNU software and packaging it into root file system with the Buildroot.
There are several types of root file system that Linux can boot with:
CPIO archive
- CPIO archive may be built into the kernel (so called 'built-in initramfs'), the resulting single image will contain both Linux and GNU software. It's easy to boot, but in order to change anything the kernel needs to be rebuilt.
- CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It's harder to boot (two files instead of one), but easier to change.
Both cases of CPIO use RAM for the root file system, so they're very fast. The downsides are that they take some time at startup to unpack, reserve some RAM (which may be an issue on low-memory boards like LX60) and are not persistent.
EXT2/3/4 file system image
EXT2/3/4 file system image may be used directly with ISS or QEMU through the Simulated block device Linux feature. Please see this chapter for more details.
TAR image
Tar image may be unpacked into a directory shared through NFS. Linux on XTFPGA boards and on QEMU can be configured to use NFS root file system.
UBIFS image
UBIFS image may be written directly to the daughterboard FLASH on XTFPGA boards. Please see this chapter for more details.
Bootloader
U-Boot can be used as a bootloader on XTFPGA boards. Please see this page for more details about installing it into the daughterboard FLASH.
On-chip debugger
On-chip debugger is good for debugging lowest level software: bootloader and Linux kernel itself. It also allows loading executable images into new board with empty FLASH.
It consists of JTAG probe connected to the XTFPGA daughterboard (ML605 and KC705 daughterboards also have built-in JTAG chip), OCD monitor (xt-ocd) running on developer machine where the other end of JTAG probe is connected, and xt-gdb, the modified version of GNU debugger from the Xtensa software release. Please see Tensilica Debug User's Guide for more information about OCD setup and configuration.
Building GNU/Linux OS
In order to follow these instruction a build machine with GNU/Linux and a set of development tools (native binutils and gcc, make, wget, tar, ...) is needed. In the following example all software will be downloaded and built in the current directory. Xtensa tools used in the examples are installed into $XT_ROOT, tools release is $XT_RELEASE and selected core is $XT_CORE.
Prepare the overlay
Please see this page for overlay repacking script and details of the overlay source location.
Create conversion script by pasting this into the file overlay-script and making it executable:
$ cat > overlay-script
....
^D
$ chmod +x overlay-script
Run it and rename the resulting file:
$ ./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz
$ mv xtensa-overlay.tar xtensa_${XT_CORE}.tar
Get, configure and build the toolchain and root file system
Get the buildroot git tree:
$ git clone git://git.buildroot.net/buildroot
Check out some released version:
$ git checkout 2014.11
Create build directory and configure it:
$ mkdir buildroot-build
$ make -C buildroot O=$(pwd)/buildroot-build menuconfig
Please see this chapter for more details about configuring the Buildroot.
Select 'Target Architecture' = Xtensa, 'Target Architecture Variant' = Custom Xtensa processor configuration, set 'Overlay file for custom configuration ' to the location of the overlay archive (it may be a path to a local file or an URL).
Select toolchain options, packages to be built and final root file system image type. Select whether the kernel need to be built, kernel version and configuration.
Build the toolchain, kernel and the root file system:
$ make -C buildroot O=$(pwd)/buildroot-build
The kernel may be built on its own
Get stable Linux release tree:
$ wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz
$ tar -xf linux-3.19.1.tar.xz
Create variant directory for the specific core and copy core configuration files there:
$ mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant
$ cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant
Create build directory and configure it:
$ mkdir linux-build
$ ARCH=xtensa CROSS_COMPILE=$(pwd)/buildroot-build/host/usr/bin/xtensa-buildroot-linux-uclibc- make -C linux-3.19.1 O=$(pwd)/linux-build menuconfig
Select 'Xtensa Processor Configuration' = Custom Xtensa processor configuration, set 'Xtensa Processor Custom Core Variant Name' to the contents of ${XT_CORE}. Select desired 'Xtensa System Type'.
Please see this chapter for more details about configuring Linux.
Build the kernel:
$ ARCH=xtensa CROSS_COMPILE=$(pwd)/buildroot-build/host/usr/bin/xtensa-buildroot-linux-uclibc- make -C linux-3.19.1 O=$(pwd)/linux-build all
Booting GNU/Linux
TBD