<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.linux-xtensa.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jcmvbkbc</id>
	<title>Linux/Xtensa - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.linux-xtensa.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Jcmvbkbc"/>
	<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Special:Contributions/Jcmvbkbc"/>
	<updated>2026-05-05T01:06:46Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=792</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=792"/>
		<updated>2022-04-21T11:22:15Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update features by release section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
&lt;br /&gt;
Initial RAMFS is a CPIO archive that the kernel may use to populate a tmpfs and then use as a root file system.&lt;br /&gt;
It may be integrated into the kernel image (see kernel .config variable CONFIG_INITRAMFS_SOURCE) or loaded into memory separately by the bootloader. In the latter case its load address is passed to the kernel in the boot parameters block.&lt;br /&gt;
&lt;br /&gt;
When Buildroot is used to generate root file system it can produce cpio image.&lt;br /&gt;
When Buildroot is also used to build the kernel it can be directed to build the root file system into the kernel.&lt;br /&gt;
See Buildroot .config symbols BR2_TARGET_ROOTFS_CPIO and  BR2_TARGET_ROOTFS_INITRAMFS.&lt;br /&gt;
&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 5.19 ==&lt;br /&gt;
* support coprocessors on SMP.&lt;br /&gt;
* support protection faults on noMMU.&lt;br /&gt;
* support full tickless operation.&lt;br /&gt;
* KCSAN.&lt;br /&gt;
* hibernation.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.18 ==&lt;br /&gt;
* support compiler plugins (with gcc-12 and newer).&lt;br /&gt;
* support for kernel ABI selection.&lt;br /&gt;
* removed dependency on compiler&#039;s libgcc.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.16 ==&lt;br /&gt;
* support for cores without windowed registers.&lt;br /&gt;
* call0 ABI kernel.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.13 ==&lt;br /&gt;
* GDBIO semihosting.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.9 ==&lt;br /&gt;
* syscall audit.&lt;br /&gt;
* seccomp filter.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.6 ==&lt;br /&gt;
* exception vectors can be attached to the rest of the kernel or placed at specific address.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.5 ==&lt;br /&gt;
* eXecute In Place (XIP) kernel.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.4 ==&lt;br /&gt;
* support for call0 ABI userspace.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.3 ==&lt;br /&gt;
* &#039;virt&#039; board (sim with PCI, corresponding board model available in QEMU since v4.2).&lt;br /&gt;
&lt;br /&gt;
== Linux 5.2 ==&lt;br /&gt;
* support for cores with exclusive access option.&lt;br /&gt;
* basic support for cores with MPU.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.1 ==&lt;br /&gt;
* generic spinlock/rwlock.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.0 ==&lt;br /&gt;
* memtest.&lt;br /&gt;
* Jump labels.&lt;br /&gt;
* tracehook.&lt;br /&gt;
* syscall tracepoints.&lt;br /&gt;
* multiple coprocessor fixes.&lt;br /&gt;
* SMP fixes.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=791</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=791"/>
		<updated>2021-11-08T05:17:58Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update features by release section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
&lt;br /&gt;
Initial RAMFS is a CPIO archive that the kernel may use to populate a tmpfs and then use as a root file system.&lt;br /&gt;
It may be integrated into the kernel image (see kernel .config variable CONFIG_INITRAMFS_SOURCE) or loaded into memory separately by the bootloader. In the latter case its load address is passed to the kernel in the boot parameters block.&lt;br /&gt;
&lt;br /&gt;
When Buildroot is used to generate root file system it can produce cpio image.&lt;br /&gt;
When Buildroot is also used to build the kernel it can be directed to build the root file system into the kernel.&lt;br /&gt;
See Buildroot .config symbols BR2_TARGET_ROOTFS_CPIO and  BR2_TARGET_ROOTFS_INITRAMFS.&lt;br /&gt;
&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 5.16 ==&lt;br /&gt;
* support for cores without windowed registers&lt;br /&gt;
* call0 ABI kernel&lt;br /&gt;
&lt;br /&gt;
== Linux 5.13 ==&lt;br /&gt;
* GDBIO semihosting&lt;br /&gt;
&lt;br /&gt;
== Linux 5.9 ==&lt;br /&gt;
* syscall audit.&lt;br /&gt;
* seccomp filter.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.6 ==&lt;br /&gt;
* exception vectors can be attached to the rest of the kernel or placed at specific address.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.5 ==&lt;br /&gt;
* eXecute In Place (XIP) kernel.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.4 ==&lt;br /&gt;
* support for call0 ABI userspace.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.3 ==&lt;br /&gt;
* &#039;virt&#039; board (sim with PCI, corresponding board model available in QEMU since v4.2).&lt;br /&gt;
&lt;br /&gt;
== Linux 5.2 ==&lt;br /&gt;
* support for cores with exclusive access option.&lt;br /&gt;
* basic support for cores with MPU.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.1 ==&lt;br /&gt;
* generic spinlock/rwlock.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.0 ==&lt;br /&gt;
* memtest.&lt;br /&gt;
* Jump labels.&lt;br /&gt;
* tracehook.&lt;br /&gt;
* syscall tracepoints.&lt;br /&gt;
* multiple coprocessor fixes.&lt;br /&gt;
* SMP fixes.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=790</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=790"/>
		<updated>2020-08-06T18:31:18Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: fix typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
&lt;br /&gt;
Initial RAMFS is a CPIO archive that the kernel may use to populate a tmpfs and then use as a root file system.&lt;br /&gt;
It may be integrated into the kernel image (see kernel .config variable CONFIG_INITRAMFS_SOURCE) or loaded into memory separately by the bootloader. In the latter case its load address is passed to the kernel in the boot parameters block.&lt;br /&gt;
&lt;br /&gt;
When Buildroot is used to generate root file system it can produce cpio image.&lt;br /&gt;
When Buildroot is also used to build the kernel it can be directed to build the root file system into the kernel.&lt;br /&gt;
See Buildroot .config symbols BR2_TARGET_ROOTFS_CPIO and  BR2_TARGET_ROOTFS_INITRAMFS.&lt;br /&gt;
&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 5.9 ==&lt;br /&gt;
* syscall audit.&lt;br /&gt;
* seccomp filter.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.6 ==&lt;br /&gt;
* exception vectors can be attached to the rest of the kernel or placed at specific address.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.5 ==&lt;br /&gt;
* eXecute In Place (XIP) kernel.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.4 ==&lt;br /&gt;
* support for call0 ABI userspace.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.3 ==&lt;br /&gt;
* &#039;virt&#039; board (sim with PCI, corresponding board model available in QEMU since v4.2).&lt;br /&gt;
&lt;br /&gt;
== Linux 5.2 ==&lt;br /&gt;
* support for cores with exclusive access option.&lt;br /&gt;
* basic support for cores with MPU.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.1 ==&lt;br /&gt;
* generic spinlock/rwlock.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.0 ==&lt;br /&gt;
* memtest.&lt;br /&gt;
* Jump labels.&lt;br /&gt;
* tracehook.&lt;br /&gt;
* syscall tracepoints.&lt;br /&gt;
* multiple coprocessor fixes.&lt;br /&gt;
* SMP fixes.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=789</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=789"/>
		<updated>2020-08-06T18:09:45Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update features by release section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
&lt;br /&gt;
Initial RAMFS is a CPIO archive that the kernel may use to populate a tmpfs and then use as a root file system.&lt;br /&gt;
It may be integrated into the kernel image (see kernel .config variable CONFIG_INITRAMFS_SOURCE) or loaded into memory separately by the bootloader. In the latter case its load address is passed to the kernel in the boot parameters block.&lt;br /&gt;
&lt;br /&gt;
When Buildroot is used to generate root file system it can produce cpio image.&lt;br /&gt;
When Buildroot is also used to build the kernel it can be directed to build the root file system into the kernel.&lt;br /&gt;
See Buildroot .config symbols BR2_TARGET_ROOTFS_CPIO and  BR2_TARGET_ROOTFS_INITRAMFS.&lt;br /&gt;
&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 5.9 ==&lt;br /&gt;
* syscall audit.&lt;br /&gt;
* seccomp filter.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.6 ==&lt;br /&gt;
* exception vectors can be attached to the rest of the kernel or placed at specific address.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.5 ==&lt;br /&gt;
* eXecute In Place (XIP) kernel.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.4 ==&lt;br /&gt;
* support for call0 ABI userspace.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.3 ==&lt;br /&gt;
* &#039;virt&#039; board (sim with PCI, corresponding board model available in QEMU since v4.2).&lt;br /&gt;
&lt;br /&gt;
== Linux 5.2 ==&lt;br /&gt;
* support for cores with exclusive access option.&lt;br /&gt;
* basic support for cores with MPU.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.1 ==&lt;br /&gt;
* generic spinlock/rwlock.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.0 ==&lt;br /&gt;
* memtest.&lt;br /&gt;
* Jump lables.&lt;br /&gt;
* tracehook.&lt;br /&gt;
* syscall tracepoints.&lt;br /&gt;
* multiple coprocessor fixes.&lt;br /&gt;
* SMP fixes.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=788</id>
		<title>Instructions for building and booting Linux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=788"/>
		<updated>2019-08-30T01:21:05Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: building kernel on its own&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.&lt;br /&gt;
&lt;br /&gt;
= GNU/Linux on Xtensa =&lt;br /&gt;
&lt;br /&gt;
GNU is a collection of free software that provides POSIX environment.&lt;br /&gt;
Linux is an operating system kernel.&lt;br /&gt;
In order to boot GNU/Linux OS on Xtensa the following parts are needed:&lt;br /&gt;
&lt;br /&gt;
* a board with Xtensa core supported by Linux, or Xtensa simulator&lt;br /&gt;
* bootable Linux kernel image&lt;br /&gt;
* GNU software packaged in a form suitable for booting on Linux, the so called root file system&lt;br /&gt;
* a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa cores supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
Official requirements for Xtensa core to run Linux are listed in the Xtensa OSKit Guide document.&lt;br /&gt;
The absolute minimum set of options required to run Linux is windowed registers, exception option and one level-1 or medium level timer interrupt.&lt;br /&gt;
* Full MMU option is required for full featured Linux kernel that includes process address space isolation, virtual memory and fork syscall.&lt;br /&gt;
* Full MMU option, thread pointer option and conditional store option are required for running userspace with NPTL or TLS.&lt;br /&gt;
&lt;br /&gt;
== Xtensa boards supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa simulators ==&lt;br /&gt;
&lt;br /&gt;
* Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Root file system ==&lt;br /&gt;
&lt;br /&gt;
Currently we support building GNU software and packaging it into root file system with the [[Buildroot]].&lt;br /&gt;
There are several types of root file system that Linux can boot with:&lt;br /&gt;
&lt;br /&gt;
=== CPIO archive ===&lt;br /&gt;
* CPIO archive may be built into the kernel (so called &#039;built-in initramfs&#039;), the resulting single image will contain both Linux and GNU software. It&#039;s easy to boot, but in order to change anything the kernel needs to be rebuilt.&lt;br /&gt;
* CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It&#039;s harder to boot (two files instead of one), but easier to change.&lt;br /&gt;
&lt;br /&gt;
Both cases of CPIO use RAM for the root file system, so they&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== EXT2/3/4 file system image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== TAR image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== UBIFS image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Bootloader ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== On-chip debugger ==&lt;br /&gt;
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.&lt;br /&gt;
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&#039;s Guide for more information about OCD setup and configuration.&lt;br /&gt;
&lt;br /&gt;
= Building GNU/Linux OS =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prepare the overlay ==&lt;br /&gt;
Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location.&lt;br /&gt;
Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable:&lt;br /&gt;
  $ &#039;&#039;&#039;cat &amp;gt; overlay-script&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;....&#039;&#039;&#039;&lt;br /&gt;
  ^D&lt;br /&gt;
  $ &#039;&#039;&#039;chmod +x overlay-script&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Run it and rename the resulting file:&lt;br /&gt;
  $ &#039;&#039;&#039;./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mv xtensa-overlay.tar xtensa_${XT_CORE}.tar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the toolchain and root file system ==&lt;br /&gt;
Get the buildroot git tree:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.buildroot.net/buildroot&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check out some released version:&lt;br /&gt;
  $ &#039;&#039;&#039;git checkout 2014.11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir buildroot-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build menuconfig&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot.&lt;br /&gt;
&lt;br /&gt;
Select &#039;Target Architecture&#039; = Xtensa, &#039;Target Architecture Variant&#039; = Custom Xtensa processor configuration, set &#039;Overlay file for custom configuration &#039; to the location of the overlay archive (it may be a path to a local file or an URL).&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Build the toolchain, kernel and the root file system:&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== The kernel may be built on its own ==&lt;br /&gt;
Get stable Linux release tree:&lt;br /&gt;
  $ &#039;&#039;&#039;wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;tar -xf linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create variant directory for the specific core and copy core configuration files there:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir linux-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Select &#039;Xtensa Processor Configuration&#039; = Custom Xtensa processor configuration, set &#039;Xtensa Processor Custom Core Variant Name&#039; to the contents of ${XT_CORE}. Select desired &#039;Xtensa System Type&#039;.&lt;br /&gt;
&lt;br /&gt;
Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux.&lt;br /&gt;
&lt;br /&gt;
Build the kernel:&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Booting GNU/Linux =&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=787</id>
		<title>Instructions for building and booting Linux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=787"/>
		<updated>2019-08-30T01:19:13Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: building kernel inside the buildroot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.&lt;br /&gt;
&lt;br /&gt;
= GNU/Linux on Xtensa =&lt;br /&gt;
&lt;br /&gt;
GNU is a collection of free software that provides POSIX environment.&lt;br /&gt;
Linux is an operating system kernel.&lt;br /&gt;
In order to boot GNU/Linux OS on Xtensa the following parts are needed:&lt;br /&gt;
&lt;br /&gt;
* a board with Xtensa core supported by Linux, or Xtensa simulator&lt;br /&gt;
* bootable Linux kernel image&lt;br /&gt;
* GNU software packaged in a form suitable for booting on Linux, the so called root file system&lt;br /&gt;
* a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa cores supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
Official requirements for Xtensa core to run Linux are listed in the Xtensa OSKit Guide document.&lt;br /&gt;
The absolute minimum set of options required to run Linux is windowed registers, exception option and one level-1 or medium level timer interrupt.&lt;br /&gt;
* Full MMU option is required for full featured Linux kernel that includes process address space isolation, virtual memory and fork syscall.&lt;br /&gt;
* Full MMU option, thread pointer option and conditional store option are required for running userspace with NPTL or TLS.&lt;br /&gt;
&lt;br /&gt;
== Xtensa boards supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa simulators ==&lt;br /&gt;
&lt;br /&gt;
* Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Root file system ==&lt;br /&gt;
&lt;br /&gt;
Currently we support building GNU software and packaging it into root file system with the [[Buildroot]].&lt;br /&gt;
There are several types of root file system that Linux can boot with:&lt;br /&gt;
&lt;br /&gt;
=== CPIO archive ===&lt;br /&gt;
* CPIO archive may be built into the kernel (so called &#039;built-in initramfs&#039;), the resulting single image will contain both Linux and GNU software. It&#039;s easy to boot, but in order to change anything the kernel needs to be rebuilt.&lt;br /&gt;
* CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It&#039;s harder to boot (two files instead of one), but easier to change.&lt;br /&gt;
&lt;br /&gt;
Both cases of CPIO use RAM for the root file system, so they&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== EXT2/3/4 file system image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== TAR image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== UBIFS image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Bootloader ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== On-chip debugger ==&lt;br /&gt;
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.&lt;br /&gt;
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&#039;s Guide for more information about OCD setup and configuration.&lt;br /&gt;
&lt;br /&gt;
= Building GNU/Linux OS =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prepare the overlay ==&lt;br /&gt;
Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location.&lt;br /&gt;
Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable:&lt;br /&gt;
  $ &#039;&#039;&#039;cat &amp;gt; overlay-script&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;....&#039;&#039;&#039;&lt;br /&gt;
  ^D&lt;br /&gt;
  $ &#039;&#039;&#039;chmod +x overlay-script&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Run it and rename the resulting file:&lt;br /&gt;
  $ &#039;&#039;&#039;./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mv xtensa-overlay.tar xtensa_${XT_CORE}.tar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the toolchain and root file system ==&lt;br /&gt;
Get the buildroot git tree:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.buildroot.net/buildroot&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check out some released version:&lt;br /&gt;
  $ &#039;&#039;&#039;git checkout 2014.11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir buildroot-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build menuconfig&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot.&lt;br /&gt;
&lt;br /&gt;
Select &#039;Target Architecture&#039; = Xtensa, &#039;Target Architecture Variant&#039; = Custom Xtensa processor configuration, set &#039;Overlay file for custom configuration &#039; to the location of the overlay archive (it may be a path to a local file or an URL).&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
Build the toolchain, kernel and the root file system:&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the Linux kernel ==&lt;br /&gt;
Get stable Linux release tree:&lt;br /&gt;
  $ &#039;&#039;&#039;wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;tar -xf linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create variant directory for the specific core and copy core configuration files there:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir linux-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Select &#039;Xtensa Processor Configuration&#039; = Custom Xtensa processor configuration, set &#039;Xtensa Processor Custom Core Variant Name&#039; to the contents of ${XT_CORE}. Select desired &#039;Xtensa System Type&#039;.&lt;br /&gt;
&lt;br /&gt;
Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux.&lt;br /&gt;
&lt;br /&gt;
Build the kernel:&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Booting GNU/Linux =&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=786</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=786"/>
		<updated>2019-08-30T00:52:42Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
&lt;br /&gt;
Initial RAMFS is a CPIO archive that the kernel may use to populate a tmpfs and then use as a root file system.&lt;br /&gt;
It may be integrated into the kernel image (see kernel .config variable CONFIG_INITRAMFS_SOURCE) or loaded into memory separately by the bootloader. In the latter case its load address is passed to the kernel in the boot parameters block.&lt;br /&gt;
&lt;br /&gt;
When Buildroot is used to generate root file system it can produce cpio image.&lt;br /&gt;
When Buildroot is also used to build the kernel it can be directed to build the root file system into the kernel.&lt;br /&gt;
See Buildroot .config symbols BR2_TARGET_ROOTFS_CPIO and  BR2_TARGET_ROOTFS_INITRAMFS.&lt;br /&gt;
&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 5.1 ==&lt;br /&gt;
* generic spinlock/rwlock.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.0 ==&lt;br /&gt;
* memtest.&lt;br /&gt;
* Jump lables.&lt;br /&gt;
* tracehook.&lt;br /&gt;
* syscall tracepoints.&lt;br /&gt;
* multiple coprocessor fixes.&lt;br /&gt;
* SMP fixes.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=785</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=785"/>
		<updated>2019-08-30T00:52:08Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update Rootfs in initial RAMFS&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
&lt;br /&gt;
Initial RAMFS is a CPIO archive that the kernel may use to populate a tmpfs and then use as a root file system.&lt;br /&gt;
It may be integrated into the kernel image (see .config variable CONFIG_INITRAMFS_SOURCE) or loaded into memory separately by the bootloader. In the latter case its load address is passed to the kernel in the boot parameters block.&lt;br /&gt;
&lt;br /&gt;
When Buildroot is used to generate root file system it can produce cpio image.&lt;br /&gt;
When Buildroot is also used to build the kernel it can be directed to build the root file system into the kernel.&lt;br /&gt;
See Buildroot .config symbols BR2_TARGET_ROOTFS_CPIO and  BR2_TARGET_ROOTFS_INITRAMFS.&lt;br /&gt;
&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 5.1 ==&lt;br /&gt;
* generic spinlock/rwlock.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.0 ==&lt;br /&gt;
* memtest.&lt;br /&gt;
* Jump lables.&lt;br /&gt;
* tracehook.&lt;br /&gt;
* syscall tracepoints.&lt;br /&gt;
* multiple coprocessor fixes.&lt;br /&gt;
* SMP fixes.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=784</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=784"/>
		<updated>2019-03-29T22:07:39Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update xtensa status&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 5.1 ==&lt;br /&gt;
* generic spinlock/rwlock.&lt;br /&gt;
&lt;br /&gt;
== Linux 5.0 ==&lt;br /&gt;
* memtest.&lt;br /&gt;
* Jump lables.&lt;br /&gt;
* tracehook.&lt;br /&gt;
* syscall tracepoints.&lt;br /&gt;
* multiple coprocessor fixes.&lt;br /&gt;
* SMP fixes.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=ABI_Interface&amp;diff=783</id>
		<title>ABI Interface</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=ABI_Interface&amp;diff=783"/>
		<updated>2018-11-10T01:17:58Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: fix ordinary call return value description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Argument Passing ==&lt;br /&gt;
&lt;br /&gt;
Arguments are passed in both registers and memory. The first six incoming arguments are stored in registers a2 through a7, and additional arguments are stored on the stack starting at the current stack pointer a1. Because Xtensa uses register windows that rotate during a function call, outgoing arguments that will become the incoming arguments must be stored to different register numbers. Depending on the call instruction and, thus, the rotation of the register window, the arguments are passed starting starting with register a(2+N), where N is the size of the window rotation. Therefore, the first argument in case of a &amp;lt;code&amp;gt;call4&amp;lt;/code&amp;gt; instruction is placed into a6, and for a &amp;lt;code&amp;gt;call8&amp;lt;/code&amp;gt; instruction into a10. Large arguments (8-bytes) are always passed in an even/odd register pair even if that means to omit a register for alignment. The return values are stored in a2 through a5 (so a function with return value occupying more than 2 registers may not be called with call12).&lt;br /&gt;
&lt;br /&gt;
           return addr  stack ptr       arg0, arg1, arg2, arg3, arg4, arg5&lt;br /&gt;
           -----------  ---------       ----------------------------------&lt;br /&gt;
             a0           a1              a2,   a3,   a4,   a5,   a6,   a7&lt;br /&gt;
 &lt;br /&gt;
 call4       a4           a5              a6,   a7,   a8,   a9,  a10,  a11&lt;br /&gt;
 call8       a8           a9             a10,  a11,  a12,  a13,  a14,  a15&lt;br /&gt;
 call12     a12          a13             a14,  a15   ---   ---   ---   --- &lt;br /&gt;
&lt;br /&gt;
== Syscall ABI ==&lt;br /&gt;
&lt;br /&gt;
Linux takes system-call arguments in registers. The ABI and Xtensa software conventions require the system-call number in a2. For improved efficiency, we try not to shift all parameters&lt;br /&gt;
one register up to maintain the original order. Register a2 is, therefore, moved to a6, a6 to a8, and a7 to a9, if the system call requires these arguments.&lt;br /&gt;
&lt;br /&gt;
 syscall number               arg0, arg1, arg2, arg3, arg4, arg5&lt;br /&gt;
 --------------               ----------------------------------&lt;br /&gt;
 a2                           a6,   a3,   a4,   a5,   a8,   a9&lt;br /&gt;
&lt;br /&gt;
Upon return, a2 contains the return value or error code. All other registers are preserved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TLS and NPTL implementation ==&lt;br /&gt;
&lt;br /&gt;
This is a description of the Xtensa-specific aspects of supporting thread-local storage (TLS). Originally developed by Sun, the implementation concept for TLS has been modified and generalized by Ulrich Drepper for Linux for a variety of platforms. [http://people.redhat.com/drepper/tls.pdf &amp;quot;ELF Handling for Thread-Local Storage&amp;quot;] provides background information and descriptions of the machine-independent aspects. Alex Oliva later developed an alternative and heavily optimized version for a Linux port to the FR-V processor and subsequently ported it to x86, x86_64, and ARM Linux systems. See also Oliva&#039;s implementation details for [http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt X86] and [http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-ARM.txt ARM].  The current status of this alternative approach is somewhat ambiguous: it has been accepted into GCC and Binutils but the glibc patches have not made it into the mainline tree, yet. As a new port, however, Xtensa can uses this optimized implementation without affecting legacy software. Although it would be convenient to share some of the platform-independent code, it is not required and will work regardless of whether those patches are ever accepted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Run-Time Handling of TLS ==&lt;br /&gt;
&lt;br /&gt;
The __tls_get_addr function has a different prototype with this approach:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;extern void *__tls_get_addr (tls_index *ti);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(This is actually the same prototype for __tls_get_addr that is used for most processors with the standard approach.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TLS Access Models ==&lt;br /&gt;
&lt;br /&gt;
The Initial Exec and Local Exec models are the same as with the standard approach and are not shown here.&lt;br /&gt;
&lt;br /&gt;
=== General Dynamic Model ===&lt;br /&gt;
&lt;br /&gt;
For the general dynamic model, the code sequence loads a function pointer and a single argument from the GOT and calls the function with that argument.  If the thread-local symbol is in the static TLS, the runtime linker will set the argument to the TLS offset and the function to a short routine that returns the offset plus the thread pointer.  Otherwise, the function is set to __tls_get_addr and the argument is a pointer to the tls_index structure holding the offset and module values.  This tls_index structure is dynamically allocated in a hash table by the runtime linker.&lt;br /&gt;
&lt;br /&gt;
This approach allows lazy relocation processing for TLS references, which should improve the start-up times.  The runtime linker can initialize the TLS function pointer in the GOT to a resolver function.  The details of this are presumably similar to other processors and are not yet specified for Xtensa.&lt;br /&gt;
&lt;br /&gt;
{| border=&#039;1&#039; cellspacing=&#039;0&#039; width=&#039;100%&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Location !! Code Sequence !! Initial Relocations !! Dynamic Relocations &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
 .literal&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
| &lt;br /&gt;
 .LC0&lt;br /&gt;
 .LC1&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (x)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (x)&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (x)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (x)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
 .text &lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|&lt;br /&gt;
 0x00  l32r   a8, .LC0&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  callx8 a8&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLS_FUNC (x)&lt;br /&gt;
 R_XTENSA_TLS_ARG (x)&lt;br /&gt;
 R_XTENSA_TLS_CALL (x)&lt;br /&gt;
|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The assembly syntax for this instruction sequence is:&lt;br /&gt;
&lt;br /&gt;
 movi   a8, x@TLSFUNC&lt;br /&gt;
 movi   a10, x@TLSARG&lt;br /&gt;
 callx8.tls a8, x@TLSCALL&lt;br /&gt;
&lt;br /&gt;
This relies on the assembler to relax the &amp;lt;code&amp;gt;movi&amp;lt;/code&amp;gt; instructions to &amp;lt;code&amp;gt;l32r&amp;lt;/code&amp;gt; instructions, so that both the literals and the instructions get the appropriate relocations.  The &amp;lt;code&amp;gt;callx8.tls&amp;lt;/code&amp;gt; assembler macro generates a &amp;lt;code&amp;gt;callx8&amp;lt;/code&amp;gt; instruction with an extra relocation specified by its second operand.&lt;br /&gt;
&lt;br /&gt;
=== Local Dynamic Model ===&lt;br /&gt;
&lt;br /&gt;
This model uses the same relocations and functions as the general dynamic model except that it references a special linker-defined _TLS_MODULE_BASE_ symbol which is set to the start of the local TLS space.&lt;br /&gt;
&lt;br /&gt;
{| border=&#039;1&#039; cellspacing=&#039;0&#039; width=&#039;100%&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Location !! Code Sequence !! Initial Relocations !! Dynamic Relocations&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
 .literal&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
| &lt;br /&gt;
 .LC0&lt;br /&gt;
 .LC1&lt;br /&gt;
 .LC2&lt;br /&gt;
 .LC3&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_DTPOFF (x)&lt;br /&gt;
 R_XTENSA_TLS_DTPOFF (y)&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
 .text &lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|&lt;br /&gt;
 0x00  l32r   a8, .LC0&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  callx8 a8&lt;br /&gt;
 ...&lt;br /&gt;
 0x09  l32r   a12, .LC2&lt;br /&gt;
 0x0c  add    a12, a12, a10&lt;br /&gt;
 ...&lt;br /&gt;
 0x0f  l32r   a13, .LC3&lt;br /&gt;
 0x12  add    a13, a13, a10&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLS_FUNC (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_CALL (_TLS_MODULE_BASE_)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The assembly syntax for this code sequence is:&lt;br /&gt;
&lt;br /&gt;
 movi   a8, _TLS_MODULE_BASE_@TLSFUNC&lt;br /&gt;
 movi   a10, _TLS_MODULE_BASE_@TLSARG&lt;br /&gt;
 callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL&lt;br /&gt;
 ...&lt;br /&gt;
 movi   a12, x@DTPOFF&lt;br /&gt;
 add    a12, a12, a10&lt;br /&gt;
 ...&lt;br /&gt;
 movi   a13, y@DTPOFF&lt;br /&gt;
 add    a13, a13, a10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Linker Optimizations ==&lt;br /&gt;
&lt;br /&gt;
=== General Dynamic -&amp;gt; Initial Exec ===&lt;br /&gt;
&lt;br /&gt;
{| border=&#039;1&#039; cellspacing=&#039;0&#039; width=&#039;100%&#039;&lt;br /&gt;
|-&lt;br /&gt;
|width=&#039;30%&#039;|&lt;br /&gt;
 .literal .LC0&lt;br /&gt;
 .literal .LC1&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 0x00  l32r   a8, .LC0&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  callx8 a8&lt;br /&gt;
|width=&#039;18%&#039;|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (x)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (x)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 R_XTENSA_TLS_FUNC (x)&lt;br /&gt;
 R_XTENSA_TLS_ARG (x)&lt;br /&gt;
 R_XTENSA_TLS_CALL (x)&lt;br /&gt;
| -&amp;gt;&lt;br /&gt;
|width=&#039;30%&#039;|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 .literal .LC1&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 0x00  rur    a8, THREADPTR&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  add    a10, a10, a8&lt;br /&gt;
|width=&#039;18%&#039;|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 R_XTENSA_TLS_TPOFF (x)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Local Dynamic -&amp;gt; Local Exec ===&lt;br /&gt;
&lt;br /&gt;
{| border=&#039;1&#039; cellspacing=&#039;0&#039; width=&#039;100%&#039;&lt;br /&gt;
|-&lt;br /&gt;
|width=&#039;30%&#039;|&lt;br /&gt;
 .literal .LC0&lt;br /&gt;
 .literal .LC1&lt;br /&gt;
 .literal .LC2&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 0x00  l32r   a8, .LC0&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  callx8 a8&lt;br /&gt;
 ...&lt;br /&gt;
 0x09  l32r   a12, .LC2&lt;br /&gt;
 0x0c  add    a12, a12, a10&lt;br /&gt;
|width=&#039;18%&#039;|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_DTPOFF (x)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 R_XTENSA_TLS_FUNC (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_CALL (_TLS_MODULE_BASE_)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
| -&amp;gt;&lt;br /&gt;
|width=&#039;30%&#039;|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 .literal .LC2&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 0x00  nop&lt;br /&gt;
 0x03  nop&lt;br /&gt;
 0x06  rur    a10, THREADPTR&lt;br /&gt;
 ...&lt;br /&gt;
 0x09  l32r   a12, .LC2&lt;br /&gt;
 0x0c  add    a12, a12, a10&lt;br /&gt;
|width=&#039;18%&#039;|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 R_XTENSA_TLS_TPOFF (x)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== New Xtensa ELF Definitions ==&lt;br /&gt;
&lt;br /&gt;
 .literal&lt;br /&gt;
 R_XTENSA_TLSDESC_FN&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG&lt;br /&gt;
 R_XTENSA_TLS_DTPOFF&lt;br /&gt;
 R_XTENSA_TLS_TPOFF&lt;br /&gt;
&lt;br /&gt;
 .text&lt;br /&gt;
 R_XTENSA_TLS_FUNC&lt;br /&gt;
 R_XTENSA_TLS_ARG&lt;br /&gt;
 R_XTENSA_TLS_CALL&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=ABI_Interface&amp;diff=782</id>
		<title>ABI Interface</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=ABI_Interface&amp;diff=782"/>
		<updated>2018-11-09T23:46:57Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: Fix syscall return value description.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Argument Passing ==&lt;br /&gt;
&lt;br /&gt;
Arguments are passed in both registers and memory. The first six incoming arguments are stored in registers a2 through a7, and additional arguments are stored on the stack starting at the current stack pointer a1. Because Xtensa uses register windows that rotate during a function call, outgoing arguments that will become the incoming arguments must be stored to different register numbers. Depending on the call instruction and, thus, the rotation of the register window, the arguments are passed starting starting with register a(2+N), where N is the size of the window rotation. Therefore, the first argument in case of a &amp;lt;code&amp;gt;call4&amp;lt;/code&amp;gt; instruction is placed into a6, and for a &amp;lt;code&amp;gt;call8&amp;lt;/code&amp;gt; instruction into a10. Large arguments (8-bytes) are always passed in an even/odd register pair even if that means to omit a register for alignment. The return values are stored in a2 through a7.&lt;br /&gt;
&lt;br /&gt;
           return addr  stack ptr       arg0, arg1, arg2, arg3, arg4, arg5&lt;br /&gt;
           -----------  ---------       ----------------------------------&lt;br /&gt;
             a0           a1              a2,   a3,   a4,   a5,   a6,   a7&lt;br /&gt;
 &lt;br /&gt;
 call4       a4           a5              a6,   a7,   a8,   a9,  a10,  a11&lt;br /&gt;
 call8       a8           a9             a10,  a11,  a12,  a13,  a14,  a15&lt;br /&gt;
 call12     a12          a13             a14,  a15   ---   ---   ---   --- &lt;br /&gt;
&lt;br /&gt;
== Syscall ABI ==&lt;br /&gt;
&lt;br /&gt;
Linux takes system-call arguments in registers. The ABI and Xtensa software conventions require the system-call number in a2. For improved efficiency, we try not to shift all parameters&lt;br /&gt;
one register up to maintain the original order. Register a2 is, therefore, moved to a6, a6 to a8, and a7 to a9, if the system call requires these arguments.&lt;br /&gt;
&lt;br /&gt;
 syscall number               arg0, arg1, arg2, arg3, arg4, arg5&lt;br /&gt;
 --------------               ----------------------------------&lt;br /&gt;
 a2                           a6,   a3,   a4,   a5,   a8,   a9&lt;br /&gt;
&lt;br /&gt;
Upon return, a2 contains the return value or error code. All other registers are preserved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TLS and NPTL implementation ==&lt;br /&gt;
&lt;br /&gt;
This is a description of the Xtensa-specific aspects of supporting thread-local storage (TLS). Originally developed by Sun, the implementation concept for TLS has been modified and generalized by Ulrich Drepper for Linux for a variety of platforms. [http://people.redhat.com/drepper/tls.pdf &amp;quot;ELF Handling for Thread-Local Storage&amp;quot;] provides background information and descriptions of the machine-independent aspects. Alex Oliva later developed an alternative and heavily optimized version for a Linux port to the FR-V processor and subsequently ported it to x86, x86_64, and ARM Linux systems. See also Oliva&#039;s implementation details for [http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-x86.txt X86] and [http://www.lsd.ic.unicamp.br/~oliva/writeups/TLS/RFC-TLSDESC-ARM.txt ARM].  The current status of this alternative approach is somewhat ambiguous: it has been accepted into GCC and Binutils but the glibc patches have not made it into the mainline tree, yet. As a new port, however, Xtensa can uses this optimized implementation without affecting legacy software. Although it would be convenient to share some of the platform-independent code, it is not required and will work regardless of whether those patches are ever accepted.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Run-Time Handling of TLS ==&lt;br /&gt;
&lt;br /&gt;
The __tls_get_addr function has a different prototype with this approach:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;extern void *__tls_get_addr (tls_index *ti);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(This is actually the same prototype for __tls_get_addr that is used for most processors with the standard approach.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== TLS Access Models ==&lt;br /&gt;
&lt;br /&gt;
The Initial Exec and Local Exec models are the same as with the standard approach and are not shown here.&lt;br /&gt;
&lt;br /&gt;
=== General Dynamic Model ===&lt;br /&gt;
&lt;br /&gt;
For the general dynamic model, the code sequence loads a function pointer and a single argument from the GOT and calls the function with that argument.  If the thread-local symbol is in the static TLS, the runtime linker will set the argument to the TLS offset and the function to a short routine that returns the offset plus the thread pointer.  Otherwise, the function is set to __tls_get_addr and the argument is a pointer to the tls_index structure holding the offset and module values.  This tls_index structure is dynamically allocated in a hash table by the runtime linker.&lt;br /&gt;
&lt;br /&gt;
This approach allows lazy relocation processing for TLS references, which should improve the start-up times.  The runtime linker can initialize the TLS function pointer in the GOT to a resolver function.  The details of this are presumably similar to other processors and are not yet specified for Xtensa.&lt;br /&gt;
&lt;br /&gt;
{| border=&#039;1&#039; cellspacing=&#039;0&#039; width=&#039;100%&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Location !! Code Sequence !! Initial Relocations !! Dynamic Relocations &lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
 .literal&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
| &lt;br /&gt;
 .LC0&lt;br /&gt;
 .LC1&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (x)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (x)&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (x)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (x)&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
 .text &lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|&lt;br /&gt;
 0x00  l32r   a8, .LC0&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  callx8 a8&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLS_FUNC (x)&lt;br /&gt;
 R_XTENSA_TLS_ARG (x)&lt;br /&gt;
 R_XTENSA_TLS_CALL (x)&lt;br /&gt;
|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The assembly syntax for this instruction sequence is:&lt;br /&gt;
&lt;br /&gt;
 movi   a8, x@TLSFUNC&lt;br /&gt;
 movi   a10, x@TLSARG&lt;br /&gt;
 callx8.tls a8, x@TLSCALL&lt;br /&gt;
&lt;br /&gt;
This relies on the assembler to relax the &amp;lt;code&amp;gt;movi&amp;lt;/code&amp;gt; instructions to &amp;lt;code&amp;gt;l32r&amp;lt;/code&amp;gt; instructions, so that both the literals and the instructions get the appropriate relocations.  The &amp;lt;code&amp;gt;callx8.tls&amp;lt;/code&amp;gt; assembler macro generates a &amp;lt;code&amp;gt;callx8&amp;lt;/code&amp;gt; instruction with an extra relocation specified by its second operand.&lt;br /&gt;
&lt;br /&gt;
=== Local Dynamic Model ===&lt;br /&gt;
&lt;br /&gt;
This model uses the same relocations and functions as the general dynamic model except that it references a special linker-defined _TLS_MODULE_BASE_ symbol which is set to the start of the local TLS space.&lt;br /&gt;
&lt;br /&gt;
{| border=&#039;1&#039; cellspacing=&#039;0&#039; width=&#039;100%&#039;&lt;br /&gt;
|-&lt;br /&gt;
! Location !! Code Sequence !! Initial Relocations !! Dynamic Relocations&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
 .literal&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
| &lt;br /&gt;
 .LC0&lt;br /&gt;
 .LC1&lt;br /&gt;
 .LC2&lt;br /&gt;
 .LC3&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_DTPOFF (x)&lt;br /&gt;
 R_XTENSA_TLS_DTPOFF (y)&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
| &lt;br /&gt;
 .text &lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|&lt;br /&gt;
 0x00  l32r   a8, .LC0&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  callx8 a8&lt;br /&gt;
 ...&lt;br /&gt;
 0x09  l32r   a12, .LC2&lt;br /&gt;
 0x0c  add    a12, a12, a10&lt;br /&gt;
 ...&lt;br /&gt;
 0x0f  l32r   a13, .LC3&lt;br /&gt;
 0x12  add    a13, a13, a10&lt;br /&gt;
|&lt;br /&gt;
 R_XTENSA_TLS_FUNC (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_CALL (_TLS_MODULE_BASE_)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The assembly syntax for this code sequence is:&lt;br /&gt;
&lt;br /&gt;
 movi   a8, _TLS_MODULE_BASE_@TLSFUNC&lt;br /&gt;
 movi   a10, _TLS_MODULE_BASE_@TLSARG&lt;br /&gt;
 callx8.tls a8, _TLS_MODULE_BASE_@TLSCALL&lt;br /&gt;
 ...&lt;br /&gt;
 movi   a12, x@DTPOFF&lt;br /&gt;
 add    a12, a12, a10&lt;br /&gt;
 ...&lt;br /&gt;
 movi   a13, y@DTPOFF&lt;br /&gt;
 add    a13, a13, a10&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Linker Optimizations ==&lt;br /&gt;
&lt;br /&gt;
=== General Dynamic -&amp;gt; Initial Exec ===&lt;br /&gt;
&lt;br /&gt;
{| border=&#039;1&#039; cellspacing=&#039;0&#039; width=&#039;100%&#039;&lt;br /&gt;
|-&lt;br /&gt;
|width=&#039;30%&#039;|&lt;br /&gt;
 .literal .LC0&lt;br /&gt;
 .literal .LC1&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 0x00  l32r   a8, .LC0&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  callx8 a8&lt;br /&gt;
|width=&#039;18%&#039;|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (x)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (x)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 R_XTENSA_TLS_FUNC (x)&lt;br /&gt;
 R_XTENSA_TLS_ARG (x)&lt;br /&gt;
 R_XTENSA_TLS_CALL (x)&lt;br /&gt;
| -&amp;gt;&lt;br /&gt;
|width=&#039;30%&#039;|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 .literal .LC1&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 0x00  rur    a8, THREADPTR&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  add    a10, a10, a8&lt;br /&gt;
|width=&#039;18%&#039;|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 R_XTENSA_TLS_TPOFF (x)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Local Dynamic -&amp;gt; Local Exec ===&lt;br /&gt;
&lt;br /&gt;
{| border=&#039;1&#039; cellspacing=&#039;0&#039; width=&#039;100%&#039;&lt;br /&gt;
|-&lt;br /&gt;
|width=&#039;30%&#039;|&lt;br /&gt;
 .literal .LC0&lt;br /&gt;
 .literal .LC1&lt;br /&gt;
 .literal .LC2&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 0x00  l32r   a8, .LC0&lt;br /&gt;
 0x03  l32r   a10, .LC1&lt;br /&gt;
 0x06  callx8 a8&lt;br /&gt;
 ...&lt;br /&gt;
 0x09  l32r   a12, .LC2&lt;br /&gt;
 0x0c  add    a12, a12, a10&lt;br /&gt;
|width=&#039;18%&#039;|&lt;br /&gt;
 R_XTENSA_TLSDESC_FN (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_DTPOFF (x)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 R_XTENSA_TLS_FUNC (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_ARG (_TLS_MODULE_BASE_)&lt;br /&gt;
 R_XTENSA_TLS_CALL (_TLS_MODULE_BASE_)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
| -&amp;gt;&lt;br /&gt;
|width=&#039;30%&#039;|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 .literal .LC2&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 0x00  nop&lt;br /&gt;
 0x03  nop&lt;br /&gt;
 0x06  rur    a10, THREADPTR&lt;br /&gt;
 ...&lt;br /&gt;
 0x09  l32r   a12, .LC2&lt;br /&gt;
 0x0c  add    a12, a12, a10&lt;br /&gt;
|width=&#039;18%&#039;|&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 R_XTENSA_TLS_TPOFF (x)&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
 &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== New Xtensa ELF Definitions ==&lt;br /&gt;
&lt;br /&gt;
 .literal&lt;br /&gt;
 R_XTENSA_TLSDESC_FN&lt;br /&gt;
 R_XTENSA_TLSDESC_ARG&lt;br /&gt;
 R_XTENSA_TLS_DTPOFF&lt;br /&gt;
 R_XTENSA_TLS_TPOFF&lt;br /&gt;
&lt;br /&gt;
 .text&lt;br /&gt;
 R_XTENSA_TLS_FUNC&lt;br /&gt;
 R_XTENSA_TLS_ARG&lt;br /&gt;
 R_XTENSA_TLS_CALL&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=UClinux&amp;diff=781</id>
		<title>UClinux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=UClinux&amp;diff=781"/>
		<updated>2018-04-24T20:56:00Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: uclinux support status update&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Toolchain with uClinux support =&lt;br /&gt;
&lt;br /&gt;
Xtensa uClinux userspace is based on bFLT executable file format.&lt;br /&gt;
&lt;br /&gt;
* gcc supports xtensa*-*-uclinux* targets starting with version 6.1.&lt;br /&gt;
&lt;br /&gt;
= Linux kernel with noMMU support =&lt;br /&gt;
&lt;br /&gt;
Linux kernel mainline supports noMMU configurations starting with version 3.19.&lt;br /&gt;
&lt;br /&gt;
= Buildroot with noMMU support =&lt;br /&gt;
&lt;br /&gt;
Buildroot mainline supports noMMU configurations starting with version 2016.05.&lt;br /&gt;
&lt;br /&gt;
= QEMU =&lt;br /&gt;
&lt;br /&gt;
QEMU supports nommu variants of all XTFPGA machines starting with version 2.12.&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=780</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=780"/>
		<updated>2018-04-24T20:39:55Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: drop special uclinux case&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=779</id>
		<title>Buildroot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=779"/>
		<updated>2018-04-24T20:38:56Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: move modern buildroot xtensa overlay configuration option to the top&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the steps to build a toolchain and root file system for a specific processor configuration based on the latest release of Buildroot. &lt;br /&gt;
&lt;br /&gt;
= Getting Buildroot and other prerequisites =&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate a cross-compilation toolchain, a root filesystem, linux kernel and the U-Boot bootloader.&lt;br /&gt;
== Getting Buildroot ==&lt;br /&gt;
Depending on whether buildroot tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest buildroot release archive: links in the Download section at http://buildroot.net/download.html&lt;br /&gt;
* mainline buildroot git tree: &amp;lt;code&amp;gt;git clone git://git.buildroot.net/buildroot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
== Xtensa core overlay file ==&lt;br /&gt;
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by buildroot. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of buildroot requires that the overlay file name has the format xtensa_&amp;lt;CORE_NAME&amp;gt;.tar, where CORE_NAME can be any user selected name.&lt;br /&gt;
&lt;br /&gt;
= Configuring and building Buildroot =&lt;br /&gt;
&lt;br /&gt;
The Buildroot may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree Buildroot configuration/building.&lt;br /&gt;
&lt;br /&gt;
For more information about Buildroot, please also read the documents provided by Buildroot under http://buildroot.net/docs.html.&lt;br /&gt;
&lt;br /&gt;
== Configuring the Buildroot ==&lt;br /&gt;
&lt;br /&gt;
Configuring the Buildroot creates build infrastructure and .config file in the build directory. .config file may be written from scratch or copied from the outside source. It&#039;s a good idea to run configuration after copying external or predefined config, as newer Buildroot releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to edit existing configuration or to create it from scratch run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* Target options submenu:&lt;br /&gt;
** BR2_xtensa: must be selected when building for Xtensa&lt;br /&gt;
** BR2_XTENSA_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
** release 2017.08 and newer:&lt;br /&gt;
*** BR2_XTENSA_OVERLAY_FILE: path to the overlay file. May be relative or absolute, may also be an URL.&lt;br /&gt;
** release 2017.05 and older:&lt;br /&gt;
*** BR2_XTENSA_CUSTOM_NAME: must specify custom core variant name. This name is used to derive configuration overlay file name.&lt;br /&gt;
*** BR2_XTENSA_OVERLAY_DIR: path to the directory with overlay file. May be relative to the Buildroot directory (specified as $(TOPDIR)/...) or the build directory (specified as $(BASE_DIR)/...)&lt;br /&gt;
* Toolchain submenu: select toolchain component versions and options. Many packages depend on presence of specific options, like IPv6 support or WCHAR support. Usually a package that cannot be built with current settings will indicate missing options in the menu.&lt;br /&gt;
* Target packages submenu: select individual packages and libraries that will be built and installed to the rootfs.&lt;br /&gt;
* Filesystem images submenu:&lt;br /&gt;
** BR2_TARGET_ROOTFS_CPIO: select to build CPIO image suitable for use as linux initramfs&lt;br /&gt;
** BR2_TARGET_ROOTFS_EXT2: select to build ext filesystem suitable for use with simulated block device&lt;br /&gt;
** BR2_TARGET_ROOTFS_TAR: select to build tar image, that may be unpacked and used for NFS root&lt;br /&gt;
&lt;br /&gt;
== Building buildroot ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039;&amp;lt;/code&amp;gt; to build the toolchain and root file system, or &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; toolchain&amp;lt;/code&amp;gt; to build only the toolchain.&lt;br /&gt;
&lt;br /&gt;
== Re-configuring and re-building Buildroot ==&lt;br /&gt;
&lt;br /&gt;
The Buildroot does not support uninstalling packages from its build directories. It also does not track dependencies between the built packages. The easiest way to make sure that deselected package is removed from the rootfs, or that changed toolchain option is applied to built packages is cleaning up build directory, leaving only .config in it and re-building everything from scratch.&lt;br /&gt;
&lt;br /&gt;
= Build Buildroot with Crosstool-NG =&lt;br /&gt;
&lt;br /&gt;
Using the Crosstool-NG toolchain allows to build a version of a Buildroot image based on GlibC instead of uClibc. In the current version, Buildroot cannot build Crosstool-NG for Xtensa directly, but can be configured to use it as an &#039;&#039;external&#039;&#039; toolchain. The first step is to build and install Crosstool-NG, so Buildroot can use it to compile the root file system. More information to build Crosstool-NG for Xtensa can be found under [[Crosstool-NG]]. Assuming Crosstool-NG is installed in &#039;ABSOLUTE_PATH_TO_XTOOLS&#039;, which is typically &amp;lt;code&amp;gt;$HOME/x-tools&amp;lt;/code&amp;gt;, you can make the following additional configurations changes in Buildroot:&lt;br /&gt;
&lt;br /&gt;
 Toolchain  ---&amp;gt;&lt;br /&gt;
   Toolchain type (External toolchain)&lt;br /&gt;
   Toolchain (Custom toolchain)&lt;br /&gt;
   Toolchain origin (Pre-installed toolchain)&lt;br /&gt;
   (ABSOLUTE_PATH_TO_XTOOLS) Toolchain path&lt;br /&gt;
   ($(ARCH)-unknown-linux-gnu) Toolchain prefix&lt;br /&gt;
   External toolchain C library (glibc/eglibc)&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== 2017.08 ==&lt;br /&gt;
* overlay overhaul: now overlay may be compressed, may have arbitrary name and may be specified as an URL&lt;br /&gt;
* overlay is applied to linux&lt;br /&gt;
* overlay is applied to U-Boot&lt;br /&gt;
&lt;br /&gt;
== 2017.05 ==&lt;br /&gt;
* build xtensa linux kernel uImage&lt;br /&gt;
&lt;br /&gt;
== 2016.05 ==&lt;br /&gt;
* support noMMU xtensa cores&lt;br /&gt;
&lt;br /&gt;
== 2014.11 ==&lt;br /&gt;
* fix &#039;dangerous relocation: call8: call target out of range&#039; linker bug&lt;br /&gt;
* fix &#039;Error: jump target out of range; no usable trampoline found&#039; and &#039;Error: operand 1 of &#039;j&#039; has out of range &#039; assembler bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.08 ==&lt;br /&gt;
* fix xtensa linker segfault on linking linux modules&lt;br /&gt;
&lt;br /&gt;
== 2014.05 ==&lt;br /&gt;
* fixes for building with -mtext-section-literals&lt;br /&gt;
* assembler trampolines (able to assemble files with jumps longer than 128K)&lt;br /&gt;
* fixes for &#039;dangerous relocation: call8: misaligned call target&#039; and &#039;dangerous relocation: overflow after relaxation&#039; linker bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.02 ==&lt;br /&gt;
* fix overlay application to gcc&lt;br /&gt;
&lt;br /&gt;
== 2012.11 ==&lt;br /&gt;
* xtensa in the Buildroot mainline&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=778</id>
		<title>Buildroot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=778"/>
		<updated>2018-04-24T20:35:17Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: drop special uclinux case&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the steps to build a toolchain and root file system for a specific processor configuration based on the latest release of Buildroot. &lt;br /&gt;
&lt;br /&gt;
= Getting Buildroot and other prerequisites =&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate a cross-compilation toolchain, a root filesystem, linux kernel and the U-Boot bootloader.&lt;br /&gt;
== Getting Buildroot ==&lt;br /&gt;
Depending on whether buildroot tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest buildroot release archive: links in the Download section at http://buildroot.net/download.html&lt;br /&gt;
* mainline buildroot git tree: &amp;lt;code&amp;gt;git clone git://git.buildroot.net/buildroot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
== Xtensa core overlay file ==&lt;br /&gt;
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by buildroot. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of buildroot requires that the overlay file name has the format xtensa_&amp;lt;CORE_NAME&amp;gt;.tar, where CORE_NAME can be any user selected name.&lt;br /&gt;
&lt;br /&gt;
= Configuring and building Buildroot =&lt;br /&gt;
&lt;br /&gt;
The Buildroot may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree Buildroot configuration/building.&lt;br /&gt;
&lt;br /&gt;
For more information about Buildroot, please also read the documents provided by Buildroot under http://buildroot.net/docs.html.&lt;br /&gt;
&lt;br /&gt;
== Configuring the Buildroot ==&lt;br /&gt;
&lt;br /&gt;
Configuring the Buildroot creates build infrastructure and .config file in the build directory. .config file may be written from scratch or copied from the outside source. It&#039;s a good idea to run configuration after copying external or predefined config, as newer Buildroot releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to edit existing configuration or to create it from scratch run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* Target options submenu:&lt;br /&gt;
** BR2_xtensa: must be selected when building for Xtensa&lt;br /&gt;
** BR2_XTENSA_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
** release 2017.05 and older:&lt;br /&gt;
*** BR2_XTENSA_CUSTOM_NAME: must specify custom core variant name. This name is used to derive configuration overlay file name.&lt;br /&gt;
*** BR2_XTENSA_OVERLAY_DIR: path to the directory with overlay file. May be relative to the Buildroot directory (specified as $(TOPDIR)/...) or the build directory (specified as $(BASE_DIR)/...)&lt;br /&gt;
** release 2017.08 and newer:&lt;br /&gt;
*** BR2_XTENSA_OVERLAY_FILE: path to the overlay file. May be relative or absolute, may also be an URL.&lt;br /&gt;
* Toolchain submenu: select toolchain component versions and options. Many packages depend on presence of specific options, like IPv6 support or WCHAR support. Usually a package that cannot be built with current settings will indicate missing options in the menu.&lt;br /&gt;
* Target packages submenu: select individual packages and libraries that will be built and installed to the rootfs.&lt;br /&gt;
* Filesystem images submenu:&lt;br /&gt;
** BR2_TARGET_ROOTFS_CPIO: select to build CPIO image suitable for use as linux initramfs&lt;br /&gt;
** BR2_TARGET_ROOTFS_EXT2: select to build ext filesystem suitable for use with simulated block device&lt;br /&gt;
** BR2_TARGET_ROOTFS_TAR: select to build tar image, that may be unpacked and used for NFS root&lt;br /&gt;
&lt;br /&gt;
== Building buildroot ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039;&amp;lt;/code&amp;gt; to build the toolchain and root file system, or &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; toolchain&amp;lt;/code&amp;gt; to build only the toolchain.&lt;br /&gt;
&lt;br /&gt;
== Re-configuring and re-building Buildroot ==&lt;br /&gt;
&lt;br /&gt;
The Buildroot does not support uninstalling packages from its build directories. It also does not track dependencies between the built packages. The easiest way to make sure that deselected package is removed from the rootfs, or that changed toolchain option is applied to built packages is cleaning up build directory, leaving only .config in it and re-building everything from scratch.&lt;br /&gt;
&lt;br /&gt;
= Build Buildroot with Crosstool-NG =&lt;br /&gt;
&lt;br /&gt;
Using the Crosstool-NG toolchain allows to build a version of a Buildroot image based on GlibC instead of uClibc. In the current version, Buildroot cannot build Crosstool-NG for Xtensa directly, but can be configured to use it as an &#039;&#039;external&#039;&#039; toolchain. The first step is to build and install Crosstool-NG, so Buildroot can use it to compile the root file system. More information to build Crosstool-NG for Xtensa can be found under [[Crosstool-NG]]. Assuming Crosstool-NG is installed in &#039;ABSOLUTE_PATH_TO_XTOOLS&#039;, which is typically &amp;lt;code&amp;gt;$HOME/x-tools&amp;lt;/code&amp;gt;, you can make the following additional configurations changes in Buildroot:&lt;br /&gt;
&lt;br /&gt;
 Toolchain  ---&amp;gt;&lt;br /&gt;
   Toolchain type (External toolchain)&lt;br /&gt;
   Toolchain (Custom toolchain)&lt;br /&gt;
   Toolchain origin (Pre-installed toolchain)&lt;br /&gt;
   (ABSOLUTE_PATH_TO_XTOOLS) Toolchain path&lt;br /&gt;
   ($(ARCH)-unknown-linux-gnu) Toolchain prefix&lt;br /&gt;
   External toolchain C library (glibc/eglibc)&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== 2017.08 ==&lt;br /&gt;
* overlay overhaul: now overlay may be compressed, may have arbitrary name and may be specified as an URL&lt;br /&gt;
* overlay is applied to linux&lt;br /&gt;
* overlay is applied to U-Boot&lt;br /&gt;
&lt;br /&gt;
== 2017.05 ==&lt;br /&gt;
* build xtensa linux kernel uImage&lt;br /&gt;
&lt;br /&gt;
== 2016.05 ==&lt;br /&gt;
* support noMMU xtensa cores&lt;br /&gt;
&lt;br /&gt;
== 2014.11 ==&lt;br /&gt;
* fix &#039;dangerous relocation: call8: call target out of range&#039; linker bug&lt;br /&gt;
* fix &#039;Error: jump target out of range; no usable trampoline found&#039; and &#039;Error: operand 1 of &#039;j&#039; has out of range &#039; assembler bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.08 ==&lt;br /&gt;
* fix xtensa linker segfault on linking linux modules&lt;br /&gt;
&lt;br /&gt;
== 2014.05 ==&lt;br /&gt;
* fixes for building with -mtext-section-literals&lt;br /&gt;
* assembler trampolines (able to assemble files with jumps longer than 128K)&lt;br /&gt;
* fixes for &#039;dangerous relocation: call8: misaligned call target&#039; and &#039;dangerous relocation: overflow after relaxation&#039; linker bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.02 ==&lt;br /&gt;
* fix overlay application to gcc&lt;br /&gt;
&lt;br /&gt;
== 2012.11 ==&lt;br /&gt;
* xtensa in the Buildroot mainline&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=777</id>
		<title>Instructions for building and booting Linux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=777"/>
		<updated>2018-04-24T20:33:45Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: drop special uclinux case&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.&lt;br /&gt;
&lt;br /&gt;
= GNU/Linux on Xtensa =&lt;br /&gt;
&lt;br /&gt;
GNU is a collection of free software that provides POSIX environment.&lt;br /&gt;
Linux is an operating system kernel.&lt;br /&gt;
In order to boot GNU/Linux OS on Xtensa the following parts are needed:&lt;br /&gt;
&lt;br /&gt;
* a board with Xtensa core supported by Linux, or Xtensa simulator&lt;br /&gt;
* bootable Linux kernel image&lt;br /&gt;
* GNU software packaged in a form suitable for booting on Linux, the so called root file system&lt;br /&gt;
* a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa cores supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
Official requirements for Xtensa core to run Linux are listed in the Xtensa OSKit Guide document.&lt;br /&gt;
The absolute minimum set of options required to run Linux is windowed registers, exception option and one level-1 or medium level timer interrupt.&lt;br /&gt;
* Full MMU option is required for full featured Linux kernel that includes process address space isolation, virtual memory and fork syscall.&lt;br /&gt;
* Full MMU option, thread pointer option and conditional store option are required for running userspace with NPTL or TLS.&lt;br /&gt;
&lt;br /&gt;
== Xtensa boards supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa simulators ==&lt;br /&gt;
&lt;br /&gt;
* Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Root file system ==&lt;br /&gt;
&lt;br /&gt;
Currently we support building GNU software and packaging it into root file system with the [[Buildroot]].&lt;br /&gt;
There are several types of root file system that Linux can boot with:&lt;br /&gt;
&lt;br /&gt;
=== CPIO archive ===&lt;br /&gt;
* CPIO archive may be built into the kernel (so called &#039;built-in initramfs&#039;), the resulting single image will contain both Linux and GNU software. It&#039;s easy to boot, but in order to change anything the kernel needs to be rebuilt.&lt;br /&gt;
* CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It&#039;s harder to boot (two files instead of one), but easier to change.&lt;br /&gt;
&lt;br /&gt;
Both cases of CPIO use RAM for the root file system, so they&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== EXT2/3/4 file system image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== TAR image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== UBIFS image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Bootloader ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== On-chip debugger ==&lt;br /&gt;
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.&lt;br /&gt;
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&#039;s Guide for more information about OCD setup and configuration.&lt;br /&gt;
&lt;br /&gt;
= Building GNU/Linux OS =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prepare the overlay ==&lt;br /&gt;
Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location.&lt;br /&gt;
Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable:&lt;br /&gt;
  $ &#039;&#039;&#039;cat &amp;gt; overlay-script&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;....&#039;&#039;&#039;&lt;br /&gt;
  ^D&lt;br /&gt;
  $ &#039;&#039;&#039;chmod +x overlay-script&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Run it and rename the resulting file:&lt;br /&gt;
  $ &#039;&#039;&#039;./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mv xtensa-overlay.tar xtensa_${XT_CORE}.tar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the toolchain and root file system ==&lt;br /&gt;
Get the buildroot git tree:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.buildroot.net/buildroot&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check out some released version:&lt;br /&gt;
  $ &#039;&#039;&#039;git checkout 2014.11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir buildroot-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build menuconfig&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot.&lt;br /&gt;
&lt;br /&gt;
Select &#039;Target Architecture&#039; = Xtensa, &#039;Target Architecture Variant&#039; = Custom Xtensa processor configuration, set &#039;Custom Xtensa processor configuration name&#039; to the contents of ${XT_CORE}, set &#039;Overlay directory for custom configuration&#039; = $(TOPDIR)/..&lt;br /&gt;
&lt;br /&gt;
Select toolchain options, packages to be built and final root file system image type.&lt;br /&gt;
&lt;br /&gt;
Build the toolchain and the root file system:&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the Linux kernel ==&lt;br /&gt;
Get stable Linux release tree:&lt;br /&gt;
  $ &#039;&#039;&#039;wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;tar -xf linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create variant directory for the specific core and copy core configuration files there:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir linux-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Select &#039;Xtensa Processor Configuration&#039; = Custom Xtensa processor configuration, set &#039;Xtensa Processor Custom Core Variant Name&#039; to the contents of ${XT_CORE}. Select desired &#039;Xtensa System Type&#039;.&lt;br /&gt;
&lt;br /&gt;
Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux.&lt;br /&gt;
&lt;br /&gt;
Build the kernel:&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Booting GNU/Linux =&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=776</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=776"/>
		<updated>2018-04-02T16:04:49Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add new features in 4.16&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* for experimental uClinux code see [[uClinux]].&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 4.16 ==&lt;br /&gt;
* KASAN.&lt;br /&gt;
* SSP.&lt;br /&gt;
* allocation of DMA buffers from high memory.&lt;br /&gt;
* support DMA_ATTR_NO_KERNEL_MAPPING.&lt;br /&gt;
* kernel is built with -mtext-section-literals and -mno-serialize-volatile.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=775</id>
		<title>Xtensa on QEMU</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=775"/>
		<updated>2018-03-09T17:55:32Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update core import script location&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Setting up and running Xtensa simulation on QEMU ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.qemu.org QEMU] is a free processor/machine emulator and virtualizer.&lt;br /&gt;
&lt;br /&gt;
Starting with version 1.0 QEMU offers [http://wiki.qemu.org/Features/Xtensa Xtensa architecture emulation].&lt;br /&gt;
DC232B, DC233C (LE) and fsf (BE) cores are supported on sim and LX60/LX200/ML605/KC705 platforms.&lt;br /&gt;
&lt;br /&gt;
== Getting and building QEMU ==&lt;br /&gt;
QEMU is developed using git. The main tree is located at git://git.qemu.org/qemu.git. Release tarballs and guest systems images are available at http://wiki.qemu.org/Download.&lt;br /&gt;
&lt;br /&gt;
This will make a copy of master QEMU repository, configure, build and install QEMU binaries for little-endian and big-endian targets:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.qemu.org/qemu.git&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir qemu-xtensa ; cd qemu-xtensa&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;../qemu/configure --prefix=`pwd`/root --target-list=xtensa-softmmu,xtensaeb-softmmu&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make install&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== QEMU options ==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Option !! Meaning !! Example&lt;br /&gt;
|-&lt;br /&gt;
| -M &amp;lt;machine-name&amp;gt;&lt;br /&gt;
| Emulate specific platform type. Use &#039;?&#039; to list all supported platform types.&lt;br /&gt;
| -M lx60&lt;br /&gt;
|-&lt;br /&gt;
| -cpu &amp;lt;core-name&amp;gt;&lt;br /&gt;
| Emulate specific core type. Use &#039;?&#039; to list all supported core types.&lt;br /&gt;
| -cpu dc232b&lt;br /&gt;
|-&lt;br /&gt;
| -m &amp;lt;memory size&amp;gt;&lt;br /&gt;
| Set emulated RAM size. M and G suffixes for mega- and gigabytes.&lt;br /&gt;
| -m 128M&lt;br /&gt;
|-&lt;br /&gt;
| -semihosting&lt;br /&gt;
| Enable SIMCALL instruction for the protection ring 0.&lt;br /&gt;
| -semihosting&lt;br /&gt;
|-&lt;br /&gt;
| -kernel &amp;lt;elf-image/uImage&amp;gt;&lt;br /&gt;
| Load elf-image or uImage and start emulation from its entry point. Note that image is loaded to virtual addresses it is linked for. For XTFPGA this option also chooses &#039;boot from SRAM&#039; mode, mapping SRAM to the System ROM region at physical address 0xFE000000.&lt;br /&gt;
| -kernel xtensa-2.6.29-smp/arch/xtensa/boot/Image.elf&lt;br /&gt;
|-&lt;br /&gt;
| -append &amp;lt;kernel arguments&amp;gt;&lt;br /&gt;
| (Not for sim) Wrap kernel arguments into the bootparameters block and pass pointer to it to the elf-image in a2.&lt;br /&gt;
| -append &#039;console=ttyS0 ip=dhcp root=/dev/nfs rw&#039;&lt;br /&gt;
|-&lt;br /&gt;
| -initrd &amp;lt;initrd-image&amp;gt;&lt;br /&gt;
| (Not for sim) Load initial RAM disk image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -initrd buildroot-build/images/rootfs.cpio&lt;br /&gt;
|-&lt;br /&gt;
| -dtb &amp;lt;Device-Tree-Blob&amp;gt;&lt;br /&gt;
| (Not for sim) Load DTB image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -dtb xtensa-build/arch/xtensa/boot/dts/kc705.dtb&lt;br /&gt;
|-&lt;br /&gt;
| -pflash &amp;lt;flash-image&amp;gt;&lt;br /&gt;
| (Not for sim) Mount flash-image as a system FLASH. Note that image size must match platform FLASH size (4MB for LX60, 16MB for LX200 and ML605, 128MB for KC705).&lt;br /&gt;
| -pflash u-boot.dc232b_xtav200.flash&lt;br /&gt;
|-&lt;br /&gt;
| -net nic,&amp;lt;nic-parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Set network interface parameters.&lt;br /&gt;
| -net nic,vlan=0&lt;br /&gt;
|-&lt;br /&gt;
| -net user,&amp;lt;SLIRP parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Use the user mode network stack. SLIRP parameters may be used to tune built-in DHCP and TFTP servers.&lt;br /&gt;
| -net user,vlan=0,tftp=.,hostname=dc232b-lx200&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== sim platform ==&lt;br /&gt;
&lt;br /&gt;
The sim platform is modelled after Tensilica ISS. It may run ELF images built for ISS, see e.g. [[Buildroot_Build_Instructions#Build_and_Run_a_Linux_Kernel_on_the_Instruction_Set_Simulator_(ISS)|Build and Run a Linux Kernel on the Instruction Set Simulator (ISS)]].&lt;br /&gt;
There&#039;s only SIMCALL external interface available for the sim machine. To avoid console interference with QEMU monitor, monitor should be disabled with -monitor null or moved to network interface with e.g. -monitor tcp::1236,telnet,server,nowait.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M sim -m 128M -semihosting -nographic -monitor null \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel sim-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since the QEMU doesn&#039;t manage terminal settings in semihosting mode, ^C and other terminal control codes interrupt QEMU instead of its guest. &#039;&#039;&#039;stty -echo -icanon -isig&#039;&#039;&#039; may be used to set up terminal to not echo input characters and not terminate QEMU.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA (LX60/LX200/ML605/KC705/...) platforms ==&lt;br /&gt;
&lt;br /&gt;
XTFPGA platform emulates system RAM, board-specific FPGA, UART, OpenCores 10/100 Mbit Ethernet MAC, National Semiconductors DP83848C 10/100 PHY and parallel FLASH.&lt;br /&gt;
The platform may boot from either SRAM (when -kernel option is specified, SRAM is mapped to the System ROM region and ELF image is loaded) or from FLASH.&lt;br /&gt;
&lt;br /&gt;
NFS root export record for user network (there&#039;s no way to specify root-path option for the QEMU builtin DHCP server. Unless kernel parameter &#039;nfsroot&#039; is given, you&#039;ll have to put the rootfs to /tftpboot/&amp;lt;hostname&amp;gt;):&lt;br /&gt;
  /tftpboot/      127.0.0.1(rw,no_root_squash,insecure)&lt;br /&gt;
&lt;br /&gt;
Booting linux image from SRAM (FLASH not mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel lx60-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting u-boot image from SRAM (empty FLASH image is created and mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;head -c 16M /dev/zero &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
In this scenario binary u-boot image may be downloaded from TFTP and copied to the FLASH as described [[U-Boot|here]].&lt;br /&gt;
&lt;br /&gt;
Alternatively FLASH image containing u-boot may be preformatted and QEMU may be booted from it:&lt;br /&gt;
  $ &#039;&#039;&#039;cat u-boot-xtensa.git/u-boot.bin.dc232b_xtav200 /dev/zero | head -c 16M &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
(Note that KC705 expects bootloader to be at the offset 0x06000000 in the FLASH, unlike the older boards that boot at offset 0).&lt;br /&gt;
&lt;br /&gt;
== Debugging with QEMU ==&lt;br /&gt;
=== GDB ===&lt;br /&gt;
There&#039;s builtin GDB server in the QEMU. -s command line switch activates it on the address 0.0.0.0:1234 (-gdb tcp:&amp;lt;ip&amp;gt;:&amp;lt;port&amp;gt; may be used instead of -s to change address and port to listen), -S switch stops QEMU at the first guest instruction waiting for &#039;continue&#039; command from gdb.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -M lx200 -nographic -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200 -s -S&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default xtensa gdb may only access unprivileged core registers. To allow access to all available registers ./gdb/xtensa-config.c needs to be modified, marking privileged registers as non-privileged. If [https://github.com/jcmvbkbc/xtensa-toolchain-build these scripts] are used to build the toolchain, the fixup-gdb.sh step does that.&lt;br /&gt;
&lt;br /&gt;
GDB breakpoints, watchpoints, single-stepping and other debugging features work as usual.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xtensa-dc232b-elf-gdb&#039;&#039;&#039;&lt;br /&gt;
  GNU gdb (GDB) 7.3.50.20110709-cvs&lt;br /&gt;
  Copyright (C) 2011 Free Software Foundation, Inc.&lt;br /&gt;
  License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;&lt;br /&gt;
  This is free software: you are free to change and redistribute it.&lt;br /&gt;
  There is NO WARRANTY, to the extent permitted by law.  Type &amp;quot;show copying&amp;quot;&lt;br /&gt;
  and &amp;quot;show warranty&amp;quot; for details.&lt;br /&gt;
  This GDB was configured as &amp;quot;--host=x86_64-unknown-linux-gnu --target=xtensa-dc232b-elf&amp;quot;.&lt;br /&gt;
  For bug reporting instructions, please see:&lt;br /&gt;
  &amp;lt;http://www.gnu.org/software/gdb/bugs/&amp;gt;.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;target remote 127.0.0.1:1234&#039;&#039;&#039;&lt;br /&gt;
  Remote debugging using 127.0.0.1:1234&lt;br /&gt;
  0xfe000000 in ?? ()&lt;br /&gt;
  (gdb) &#039;&#039;&#039;symbol-file u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
  Reading symbols from u-boot-xtensa.git/u-boot.dc232b_xtav200...done.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;x/10i $pc&#039;&#039;&#039;&lt;br /&gt;
  =&amp;gt; 0xfe000000 &amp;lt;_ResetVector&amp;gt;:   j       0xfe00000c &amp;lt;_ResetVector+12&amp;gt;&lt;br /&gt;
     0xfe000003 &amp;lt;_ResetVector+3&amp;gt;: break   0, 0&lt;br /&gt;
     0xfe000006 &amp;lt;_ResetVector+6&amp;gt;: excw&lt;br /&gt;
     0xfe000009 &amp;lt;_ResetVector+9&amp;gt;: .byte 0xff&lt;br /&gt;
     0xfe00000a &amp;lt;_ResetVector+10&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000b &amp;lt;_ResetVector+11&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000c &amp;lt;_ResetVector+12&amp;gt;:        l32r    a2, 0xfe000004 &amp;lt;_ResetVector+4&amp;gt;&lt;br /&gt;
     0xfe00000f &amp;lt;_ResetVector+15&amp;gt;:        jx      a2&lt;br /&gt;
     0xfe000012 &amp;lt;_ResetVector+18&amp;gt;:        ill&lt;br /&gt;
     0xfe000015 &amp;lt;_ResetVector+21&amp;gt;:        subx2   a0, a0, a0&lt;br /&gt;
  (gdb) &#039;&#039;&#039;si&#039;&#039;&#039;&lt;br /&gt;
  69      1:      l32r    a2, 2b&lt;br /&gt;
  (gdb)&lt;br /&gt;
&lt;br /&gt;
QEMU monitor commands may be invoked via gdb monitor command:&lt;br /&gt;
&lt;br /&gt;
  (gdb) &#039;&#039;&#039;monitor info mtree&#039;&#039;&#039;&lt;br /&gt;
  memory&lt;br /&gt;
  00000000-fffffffe (prio 0): system&lt;br /&gt;
    00000000-07ffffff (prio 0): lx60.dram&lt;br /&gt;
    f0000000-fdffffff (prio 0): lx60.io&lt;br /&gt;
      fd020000-fd02ffff (prio 0): lx60.fpga&lt;br /&gt;
      fd030000-fd030053 (prio 0): open_eth.regs&lt;br /&gt;
      fd030400-fd0307ff (prio 0): open_eth.desc&lt;br /&gt;
      fd050020-fd05003f (prio 0): serial&lt;br /&gt;
      fd800000-fd803fff (prio 0): open_eth.ram&lt;br /&gt;
    f8000000-f83fffff (prio 0): lx60.io.flash&lt;br /&gt;
    fe000000-fe01ffff (prio 0): lx60.sram&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
QEMU can log guest CPU state/opcode translation during execution. Invalid, reserved and not implemented opcodes, invalid conditions for certain opcodes, reserved/not implemented SR access, page table lookups, interrupt requests are all logged with this method. Logging may be enabled with -d&amp;lt;logging types&amp;gt; command line option, or with monitor command &#039;log &amp;lt;logging types&amp;gt;&#039;. By default logs go to the file /tmp/qemu.log. Verbose logging slows down execution significantly, it may be useful to control logging from GDB, enabling it via monitor command for the specific code blocks.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Logging type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| none&lt;br /&gt;
| disable logging&lt;br /&gt;
|-&lt;br /&gt;
| out_asm&lt;br /&gt;
| show generated host assembly code for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| in_asm&lt;br /&gt;
| show target assembly code for each compiled TB (not implemented for Xtensa)&lt;br /&gt;
|-&lt;br /&gt;
| op&lt;br /&gt;
| show micro ops for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| op_opt&lt;br /&gt;
| show micro ops after liveness analysis&lt;br /&gt;
|-&lt;br /&gt;
| int&lt;br /&gt;
| show interrupts/exceptions in short format&lt;br /&gt;
|-&lt;br /&gt;
| exec&lt;br /&gt;
| show trace before each executed TB&lt;br /&gt;
|-&lt;br /&gt;
| cpu&lt;br /&gt;
| show CPU state before block translation&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Extending QEMU ==&lt;br /&gt;
&lt;br /&gt;
Starting with QEMU-2.2 there&#039;s a script [https://github.com/OSLL/qemu-xtensa/blob/master/target/xtensa/import_core.sh qemu/target-xtensa/import_core.sh] that adds new core to QEMU from the xtensa configuration overlay.&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Setting_up_U-Boot&amp;diff=774</id>
		<title>Setting up U-Boot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Setting_up_U-Boot&amp;diff=774"/>
		<updated>2018-03-02T23:31:27Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: Blanked the page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=U-Boot&amp;diff=773</id>
		<title>U-Boot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=U-Boot&amp;diff=773"/>
		<updated>2018-03-02T23:30:13Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Under Construction - This page will describe the steps required to support a Xtensa processor configuration in U-Boot.&lt;br /&gt;
&lt;br /&gt;
== U-Boot Installation to XTFPGA boards (LX60, LX200, ML605, KC705) ==&lt;br /&gt;
&lt;br /&gt;
=== Loading initial image through xocd + xt-gdb ===&lt;br /&gt;
&lt;br /&gt;
   $ &#039;&#039;&#039;xt-gdb -n u-boot&#039;&#039;&#039;&lt;br /&gt;
   (xt-gdb) &#039;&#039;&#039;target remote localhost:20000 0&#039;&#039;&#039;&lt;br /&gt;
   (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
   (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
   (xt-gdb) &#039;&#039;&#039;continue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Flashing U-Boot image ===&lt;br /&gt;
&lt;br /&gt;
    U-Boot&amp;gt; &#039;&#039;&#039;protect off ...&#039;&#039;&#039;&lt;br /&gt;
    U-Boot&amp;gt; &#039;&#039;&#039;erase ...&#039;&#039;&#039;&lt;br /&gt;
    U-Boot&amp;gt; &#039;&#039;&#039;tftp u-boot.bin&#039;&#039;&#039;&lt;br /&gt;
    U-Boot&amp;gt; &#039;&#039;&#039;cp.b 2000000 F8000000 20000&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=772</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=772"/>
		<updated>2018-03-02T23:09:54Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: fix U-Boot page link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* for experimental uClinux code see [[uClinux]].&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[U-Boot|U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=771</id>
		<title>Instructions for building and booting Linux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=771"/>
		<updated>2018-03-02T23:09:01Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: fix U-Boot page link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.&lt;br /&gt;
&lt;br /&gt;
= GNU/Linux on Xtensa =&lt;br /&gt;
&lt;br /&gt;
GNU is a collection of free software that provides POSIX environment.&lt;br /&gt;
Linux is an operating system kernel.&lt;br /&gt;
In order to boot GNU/Linux OS on Xtensa the following parts are needed:&lt;br /&gt;
&lt;br /&gt;
* a board with Xtensa core supported by Linux, or Xtensa simulator&lt;br /&gt;
* bootable Linux kernel image&lt;br /&gt;
* GNU software packaged in a form suitable for booting on Linux, the so called root file system&lt;br /&gt;
* a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa cores supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
Official requirements for Xtensa core to run Linux are listed in the Xtensa OSKit Guide document.&lt;br /&gt;
The absolute minimum set of options required to run Linux is full MMU, debug option, windowed registers, one level-1 or medium level timer interrupt.&lt;br /&gt;
* See [[uClinux]] for experimental support of Xtensa cores without full MMU.&lt;br /&gt;
* Thread pointer option and conditional store option are required for running userspace with NPTL or TLS.&lt;br /&gt;
&lt;br /&gt;
== Xtensa boards supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa simulators ==&lt;br /&gt;
&lt;br /&gt;
* Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Root file system ==&lt;br /&gt;
&lt;br /&gt;
Currently we support building GNU software and packaging it into root file system with the [[Buildroot]].&lt;br /&gt;
There are several types of root file system that Linux can boot with:&lt;br /&gt;
&lt;br /&gt;
=== CPIO archive ===&lt;br /&gt;
* CPIO archive may be built into the kernel (so called &#039;built-in initramfs&#039;), the resulting single image will contain both Linux and GNU software. It&#039;s easy to boot, but in order to change anything the kernel needs to be rebuilt.&lt;br /&gt;
* CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It&#039;s harder to boot (two files instead of one), but easier to change.&lt;br /&gt;
&lt;br /&gt;
Both cases of CPIO use RAM for the root file system, so they&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== EXT2/3/4 file system image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== TAR image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== UBIFS image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Bootloader ==&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== On-chip debugger ==&lt;br /&gt;
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.&lt;br /&gt;
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&#039;s Guide for more information about OCD setup and configuration.&lt;br /&gt;
&lt;br /&gt;
= Building GNU/Linux OS =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prepare the overlay ==&lt;br /&gt;
Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location.&lt;br /&gt;
Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable:&lt;br /&gt;
  $ &#039;&#039;&#039;cat &amp;gt; overlay-script&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;....&#039;&#039;&#039;&lt;br /&gt;
  ^D&lt;br /&gt;
  $ &#039;&#039;&#039;chmod +x overlay-script&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Run it and rename the resulting file:&lt;br /&gt;
  $ &#039;&#039;&#039;./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mv xtensa-overlay.tar xtensa_${XT_CORE}.tar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the toolchain and root file system ==&lt;br /&gt;
Get the buildroot git tree:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.buildroot.net/buildroot&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check out some released version:&lt;br /&gt;
  $ &#039;&#039;&#039;git checkout 2014.11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir buildroot-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build menuconfig&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot.&lt;br /&gt;
&lt;br /&gt;
Select &#039;Target Architecture&#039; = Xtensa, &#039;Target Architecture Variant&#039; = Custom Xtensa processor configuration, set &#039;Custom Xtensa processor configuration name&#039; to the contents of ${XT_CORE}, set &#039;Overlay directory for custom configuration&#039; = $(TOPDIR)/..&lt;br /&gt;
&lt;br /&gt;
Select toolchain options, packages to be built and final root file system image type.&lt;br /&gt;
&lt;br /&gt;
Build the toolchain and the root file system:&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the Linux kernel ==&lt;br /&gt;
Get stable Linux release tree:&lt;br /&gt;
  $ &#039;&#039;&#039;wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;tar -xf linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create variant directory for the specific core and copy core configuration files there:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir linux-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Select &#039;Xtensa Processor Configuration&#039; = Custom Xtensa processor configuration, set &#039;Xtensa Processor Custom Core Variant Name&#039; to the contents of ${XT_CORE}. Select desired &#039;Xtensa System Type&#039;.&lt;br /&gt;
&lt;br /&gt;
Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux.&lt;br /&gt;
&lt;br /&gt;
Build the kernel:&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Booting GNU/Linux =&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=770</id>
		<title>Xtensa on QEMU</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=770"/>
		<updated>2018-03-02T23:07:20Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: fix u-boot page link and &amp;#039;extending qemu&amp;#039; section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Setting up and running Xtensa simulation on QEMU ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.qemu.org QEMU] is a free processor/machine emulator and virtualizer.&lt;br /&gt;
&lt;br /&gt;
Starting with version 1.0 QEMU offers [http://wiki.qemu.org/Features/Xtensa Xtensa architecture emulation].&lt;br /&gt;
DC232B, DC233C (LE) and fsf (BE) cores are supported on sim and LX60/LX200/ML605/KC705 platforms.&lt;br /&gt;
&lt;br /&gt;
== Getting and building QEMU ==&lt;br /&gt;
QEMU is developed using git. The main tree is located at git://git.qemu.org/qemu.git. Release tarballs and guest systems images are available at http://wiki.qemu.org/Download.&lt;br /&gt;
&lt;br /&gt;
This will make a copy of master QEMU repository, configure, build and install QEMU binaries for little-endian and big-endian targets:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.qemu.org/qemu.git&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir qemu-xtensa ; cd qemu-xtensa&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;../qemu/configure --prefix=`pwd`/root --target-list=xtensa-softmmu,xtensaeb-softmmu&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make install&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== QEMU options ==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Option !! Meaning !! Example&lt;br /&gt;
|-&lt;br /&gt;
| -M &amp;lt;machine-name&amp;gt;&lt;br /&gt;
| Emulate specific platform type. Use &#039;?&#039; to list all supported platform types.&lt;br /&gt;
| -M lx60&lt;br /&gt;
|-&lt;br /&gt;
| -cpu &amp;lt;core-name&amp;gt;&lt;br /&gt;
| Emulate specific core type. Use &#039;?&#039; to list all supported core types.&lt;br /&gt;
| -cpu dc232b&lt;br /&gt;
|-&lt;br /&gt;
| -m &amp;lt;memory size&amp;gt;&lt;br /&gt;
| Set emulated RAM size. M and G suffixes for mega- and gigabytes.&lt;br /&gt;
| -m 128M&lt;br /&gt;
|-&lt;br /&gt;
| -semihosting&lt;br /&gt;
| Enable SIMCALL instruction for the protection ring 0.&lt;br /&gt;
| -semihosting&lt;br /&gt;
|-&lt;br /&gt;
| -kernel &amp;lt;elf-image/uImage&amp;gt;&lt;br /&gt;
| Load elf-image or uImage and start emulation from its entry point. Note that image is loaded to virtual addresses it is linked for. For XTFPGA this option also chooses &#039;boot from SRAM&#039; mode, mapping SRAM to the System ROM region at physical address 0xFE000000.&lt;br /&gt;
| -kernel xtensa-2.6.29-smp/arch/xtensa/boot/Image.elf&lt;br /&gt;
|-&lt;br /&gt;
| -append &amp;lt;kernel arguments&amp;gt;&lt;br /&gt;
| (Not for sim) Wrap kernel arguments into the bootparameters block and pass pointer to it to the elf-image in a2.&lt;br /&gt;
| -append &#039;console=ttyS0 ip=dhcp root=/dev/nfs rw&#039;&lt;br /&gt;
|-&lt;br /&gt;
| -initrd &amp;lt;initrd-image&amp;gt;&lt;br /&gt;
| (Not for sim) Load initial RAM disk image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -initrd buildroot-build/images/rootfs.cpio&lt;br /&gt;
|-&lt;br /&gt;
| -dtb &amp;lt;Device-Tree-Blob&amp;gt;&lt;br /&gt;
| (Not for sim) Load DTB image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -dtb xtensa-build/arch/xtensa/boot/dts/kc705.dtb&lt;br /&gt;
|-&lt;br /&gt;
| -pflash &amp;lt;flash-image&amp;gt;&lt;br /&gt;
| (Not for sim) Mount flash-image as a system FLASH. Note that image size must match platform FLASH size (4MB for LX60, 16MB for LX200 and ML605, 128MB for KC705).&lt;br /&gt;
| -pflash u-boot.dc232b_xtav200.flash&lt;br /&gt;
|-&lt;br /&gt;
| -net nic,&amp;lt;nic-parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Set network interface parameters.&lt;br /&gt;
| -net nic,vlan=0&lt;br /&gt;
|-&lt;br /&gt;
| -net user,&amp;lt;SLIRP parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Use the user mode network stack. SLIRP parameters may be used to tune built-in DHCP and TFTP servers.&lt;br /&gt;
| -net user,vlan=0,tftp=.,hostname=dc232b-lx200&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== sim platform ==&lt;br /&gt;
&lt;br /&gt;
The sim platform is modelled after Tensilica ISS. It may run ELF images built for ISS, see e.g. [[Buildroot_Build_Instructions#Build_and_Run_a_Linux_Kernel_on_the_Instruction_Set_Simulator_(ISS)|Build and Run a Linux Kernel on the Instruction Set Simulator (ISS)]].&lt;br /&gt;
There&#039;s only SIMCALL external interface available for the sim machine. To avoid console interference with QEMU monitor, monitor should be disabled with -monitor null or moved to network interface with e.g. -monitor tcp::1236,telnet,server,nowait.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M sim -m 128M -semihosting -nographic -monitor null \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel sim-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since the QEMU doesn&#039;t manage terminal settings in semihosting mode, ^C and other terminal control codes interrupt QEMU instead of its guest. &#039;&#039;&#039;stty -echo -icanon -isig&#039;&#039;&#039; may be used to set up terminal to not echo input characters and not terminate QEMU.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA (LX60/LX200/ML605/KC705/...) platforms ==&lt;br /&gt;
&lt;br /&gt;
XTFPGA platform emulates system RAM, board-specific FPGA, UART, OpenCores 10/100 Mbit Ethernet MAC, National Semiconductors DP83848C 10/100 PHY and parallel FLASH.&lt;br /&gt;
The platform may boot from either SRAM (when -kernel option is specified, SRAM is mapped to the System ROM region and ELF image is loaded) or from FLASH.&lt;br /&gt;
&lt;br /&gt;
NFS root export record for user network (there&#039;s no way to specify root-path option for the QEMU builtin DHCP server. Unless kernel parameter &#039;nfsroot&#039; is given, you&#039;ll have to put the rootfs to /tftpboot/&amp;lt;hostname&amp;gt;):&lt;br /&gt;
  /tftpboot/      127.0.0.1(rw,no_root_squash,insecure)&lt;br /&gt;
&lt;br /&gt;
Booting linux image from SRAM (FLASH not mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel lx60-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting u-boot image from SRAM (empty FLASH image is created and mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;head -c 16M /dev/zero &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
In this scenario binary u-boot image may be downloaded from TFTP and copied to the FLASH as described [[U-Boot|here]].&lt;br /&gt;
&lt;br /&gt;
Alternatively FLASH image containing u-boot may be preformatted and QEMU may be booted from it:&lt;br /&gt;
  $ &#039;&#039;&#039;cat u-boot-xtensa.git/u-boot.bin.dc232b_xtav200 /dev/zero | head -c 16M &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
(Note that KC705 expects bootloader to be at the offset 0x06000000 in the FLASH, unlike the older boards that boot at offset 0).&lt;br /&gt;
&lt;br /&gt;
== Debugging with QEMU ==&lt;br /&gt;
=== GDB ===&lt;br /&gt;
There&#039;s builtin GDB server in the QEMU. -s command line switch activates it on the address 0.0.0.0:1234 (-gdb tcp:&amp;lt;ip&amp;gt;:&amp;lt;port&amp;gt; may be used instead of -s to change address and port to listen), -S switch stops QEMU at the first guest instruction waiting for &#039;continue&#039; command from gdb.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -M lx200 -nographic -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200 -s -S&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default xtensa gdb may only access unprivileged core registers. To allow access to all available registers ./gdb/xtensa-config.c needs to be modified, marking privileged registers as non-privileged. If [https://github.com/jcmvbkbc/xtensa-toolchain-build these scripts] are used to build the toolchain, the fixup-gdb.sh step does that.&lt;br /&gt;
&lt;br /&gt;
GDB breakpoints, watchpoints, single-stepping and other debugging features work as usual.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xtensa-dc232b-elf-gdb&#039;&#039;&#039;&lt;br /&gt;
  GNU gdb (GDB) 7.3.50.20110709-cvs&lt;br /&gt;
  Copyright (C) 2011 Free Software Foundation, Inc.&lt;br /&gt;
  License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;&lt;br /&gt;
  This is free software: you are free to change and redistribute it.&lt;br /&gt;
  There is NO WARRANTY, to the extent permitted by law.  Type &amp;quot;show copying&amp;quot;&lt;br /&gt;
  and &amp;quot;show warranty&amp;quot; for details.&lt;br /&gt;
  This GDB was configured as &amp;quot;--host=x86_64-unknown-linux-gnu --target=xtensa-dc232b-elf&amp;quot;.&lt;br /&gt;
  For bug reporting instructions, please see:&lt;br /&gt;
  &amp;lt;http://www.gnu.org/software/gdb/bugs/&amp;gt;.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;target remote 127.0.0.1:1234&#039;&#039;&#039;&lt;br /&gt;
  Remote debugging using 127.0.0.1:1234&lt;br /&gt;
  0xfe000000 in ?? ()&lt;br /&gt;
  (gdb) &#039;&#039;&#039;symbol-file u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
  Reading symbols from u-boot-xtensa.git/u-boot.dc232b_xtav200...done.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;x/10i $pc&#039;&#039;&#039;&lt;br /&gt;
  =&amp;gt; 0xfe000000 &amp;lt;_ResetVector&amp;gt;:   j       0xfe00000c &amp;lt;_ResetVector+12&amp;gt;&lt;br /&gt;
     0xfe000003 &amp;lt;_ResetVector+3&amp;gt;: break   0, 0&lt;br /&gt;
     0xfe000006 &amp;lt;_ResetVector+6&amp;gt;: excw&lt;br /&gt;
     0xfe000009 &amp;lt;_ResetVector+9&amp;gt;: .byte 0xff&lt;br /&gt;
     0xfe00000a &amp;lt;_ResetVector+10&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000b &amp;lt;_ResetVector+11&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000c &amp;lt;_ResetVector+12&amp;gt;:        l32r    a2, 0xfe000004 &amp;lt;_ResetVector+4&amp;gt;&lt;br /&gt;
     0xfe00000f &amp;lt;_ResetVector+15&amp;gt;:        jx      a2&lt;br /&gt;
     0xfe000012 &amp;lt;_ResetVector+18&amp;gt;:        ill&lt;br /&gt;
     0xfe000015 &amp;lt;_ResetVector+21&amp;gt;:        subx2   a0, a0, a0&lt;br /&gt;
  (gdb) &#039;&#039;&#039;si&#039;&#039;&#039;&lt;br /&gt;
  69      1:      l32r    a2, 2b&lt;br /&gt;
  (gdb)&lt;br /&gt;
&lt;br /&gt;
QEMU monitor commands may be invoked via gdb monitor command:&lt;br /&gt;
&lt;br /&gt;
  (gdb) &#039;&#039;&#039;monitor info mtree&#039;&#039;&#039;&lt;br /&gt;
  memory&lt;br /&gt;
  00000000-fffffffe (prio 0): system&lt;br /&gt;
    00000000-07ffffff (prio 0): lx60.dram&lt;br /&gt;
    f0000000-fdffffff (prio 0): lx60.io&lt;br /&gt;
      fd020000-fd02ffff (prio 0): lx60.fpga&lt;br /&gt;
      fd030000-fd030053 (prio 0): open_eth.regs&lt;br /&gt;
      fd030400-fd0307ff (prio 0): open_eth.desc&lt;br /&gt;
      fd050020-fd05003f (prio 0): serial&lt;br /&gt;
      fd800000-fd803fff (prio 0): open_eth.ram&lt;br /&gt;
    f8000000-f83fffff (prio 0): lx60.io.flash&lt;br /&gt;
    fe000000-fe01ffff (prio 0): lx60.sram&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
QEMU can log guest CPU state/opcode translation during execution. Invalid, reserved and not implemented opcodes, invalid conditions for certain opcodes, reserved/not implemented SR access, page table lookups, interrupt requests are all logged with this method. Logging may be enabled with -d&amp;lt;logging types&amp;gt; command line option, or with monitor command &#039;log &amp;lt;logging types&amp;gt;&#039;. By default logs go to the file /tmp/qemu.log. Verbose logging slows down execution significantly, it may be useful to control logging from GDB, enabling it via monitor command for the specific code blocks.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Logging type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| none&lt;br /&gt;
| disable logging&lt;br /&gt;
|-&lt;br /&gt;
| out_asm&lt;br /&gt;
| show generated host assembly code for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| in_asm&lt;br /&gt;
| show target assembly code for each compiled TB (not implemented for Xtensa)&lt;br /&gt;
|-&lt;br /&gt;
| op&lt;br /&gt;
| show micro ops for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| op_opt&lt;br /&gt;
| show micro ops after liveness analysis&lt;br /&gt;
|-&lt;br /&gt;
| int&lt;br /&gt;
| show interrupts/exceptions in short format&lt;br /&gt;
|-&lt;br /&gt;
| exec&lt;br /&gt;
| show trace before each executed TB&lt;br /&gt;
|-&lt;br /&gt;
| cpu&lt;br /&gt;
| show CPU state before block translation&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Extending QEMU ==&lt;br /&gt;
&lt;br /&gt;
Starting with QEMU-2.2 there&#039;s a script [https://github.com/OSLL/qemu-xtensa/blob/master/target-xtensa/import_core.sh qemu/target-xtensa/import_core.sh] that adds new core to QEMU from the xtensa configuration overlay.&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Setting_up_U-Boot&amp;diff=769</id>
		<title>Setting up U-Boot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Setting_up_U-Boot&amp;diff=769"/>
		<updated>2018-03-02T18:58:04Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: Replaced content with &amp;quot;== LX60, LX200, ML605, KC705 U-Boot Installation ==  === Loading initial image through xocd + xt-gdb ===     $ &amp;#039;&amp;#039;&amp;#039;xt-gdb -n u-boot&amp;#039;&amp;#039;&amp;#039;    (xt-gdb) &amp;#039;&amp;#039;&amp;#039;target remote localhos...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== LX60, LX200, ML605, KC705 U-Boot Installation ==&lt;br /&gt;
&lt;br /&gt;
=== Loading initial image through xocd + xt-gdb ===&lt;br /&gt;
&lt;br /&gt;
   $ &#039;&#039;&#039;xt-gdb -n u-boot&#039;&#039;&#039;&lt;br /&gt;
   (xt-gdb) &#039;&#039;&#039;target remote localhost:20000 0&#039;&#039;&#039;&lt;br /&gt;
   (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
   (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
   (xt-gdb) &#039;&#039;&#039;continue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Flashing U-Boot image ===&lt;br /&gt;
&lt;br /&gt;
    U-Boot&amp;gt; &#039;&#039;&#039;protect off ...&#039;&#039;&#039;&lt;br /&gt;
    U-Boot&amp;gt; &#039;&#039;&#039;erase ...&#039;&#039;&#039;&lt;br /&gt;
    U-Boot&amp;gt; &#039;&#039;&#039;tftp u-boot.bin&#039;&#039;&#039;&lt;br /&gt;
    U-Boot&amp;gt; &#039;&#039;&#039;cp.b 2000000 F8000000 20000&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=768</id>
		<title>Buildroot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=768"/>
		<updated>2017-07-28T21:51:38Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add latest features and document changed overlay location specifier&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the steps to build a toolchain and root file system for a specific processor configuration based on the latest release of Buildroot. &lt;br /&gt;
&lt;br /&gt;
= Getting Buildroot and other prerequisites =&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate a cross-compilation toolchain, a root filesystem, linux kernel and the U-Boot bootloader.&lt;br /&gt;
== Getting Buildroot ==&lt;br /&gt;
Depending on whether buildroot tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest buildroot release archive: links in the Download section at http://buildroot.net/download.html&lt;br /&gt;
* mainline buildroot git tree: &amp;lt;code&amp;gt;git clone git://git.buildroot.net/buildroot&amp;lt;/code&amp;gt;&lt;br /&gt;
* for the buildroot with uClinux support see [[uClinux]] &lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
== Xtensa core overlay file ==&lt;br /&gt;
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by buildroot. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of buildroot requires that the overlay file name has the format xtensa_&amp;lt;CORE_NAME&amp;gt;.tar, where CORE_NAME can be any user selected name.&lt;br /&gt;
&lt;br /&gt;
= Configuring and building Buildroot =&lt;br /&gt;
&lt;br /&gt;
The Buildroot may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree Buildroot configuration/building.&lt;br /&gt;
&lt;br /&gt;
For more information about Buildroot, please also read the documents provided by Buildroot under http://buildroot.net/docs.html.&lt;br /&gt;
&lt;br /&gt;
== Configuring the Buildroot ==&lt;br /&gt;
&lt;br /&gt;
Configuring the Buildroot creates build infrastructure and .config file in the build directory. .config file may be written from scratch or copied from the outside source. It&#039;s a good idea to run configuration after copying external or predefined config, as newer Buildroot releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to edit existing configuration or to create it from scratch run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* Target options submenu:&lt;br /&gt;
** BR2_xtensa: must be selected when building for Xtensa&lt;br /&gt;
** BR2_XTENSA_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
** release 2017.05 and older:&lt;br /&gt;
*** BR2_XTENSA_CUSTOM_NAME: must specify custom core variant name. This name is used to derive configuration overlay file name.&lt;br /&gt;
*** BR2_XTENSA_OVERLAY_DIR: path to the directory with overlay file. May be relative to the Buildroot directory (specified as $(TOPDIR)/...) or the build directory (specified as $(BASE_DIR)/...)&lt;br /&gt;
** release 2017.08 and newer:&lt;br /&gt;
*** BR2_XTENSA_OVERLAY_FILE: path to the overlay file. May be relative or absolute, may also be an URL.&lt;br /&gt;
* Toolchain submenu: select toolchain component versions and options. Many packages depend on presence of specific options, like IPv6 support or WCHAR support. Usually a package that cannot be built with current settings will indicate missing options in the menu.&lt;br /&gt;
* Target packages submenu: select individual packages and libraries that will be built and installed to the rootfs.&lt;br /&gt;
* Filesystem images submenu:&lt;br /&gt;
** BR2_TARGET_ROOTFS_CPIO: select to build CPIO image suitable for use as linux initramfs&lt;br /&gt;
** BR2_TARGET_ROOTFS_EXT2: select to build ext filesystem suitable for use with simulated block device&lt;br /&gt;
** BR2_TARGET_ROOTFS_TAR: select to build tar image, that may be unpacked and used for NFS root&lt;br /&gt;
&lt;br /&gt;
== Building buildroot ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039;&amp;lt;/code&amp;gt; to build the toolchain and root file system, or &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; toolchain&amp;lt;/code&amp;gt; to build only the toolchain.&lt;br /&gt;
&lt;br /&gt;
== Re-configuring and re-building Buildroot ==&lt;br /&gt;
&lt;br /&gt;
The Buildroot does not support uninstalling packages from its build directories. It also does not track dependencies between the built packages. The easiest way to make sure that deselected package is removed from the rootfs, or that changed toolchain option is applied to built packages is cleaning up build directory, leaving only .config in it and re-building everything from scratch.&lt;br /&gt;
&lt;br /&gt;
= Build Buildroot with Crosstool-NG =&lt;br /&gt;
&lt;br /&gt;
Using the Crosstool-NG toolchain allows to build a version of a Buildroot image based on GlibC instead of uClibc. In the current version, Buildroot cannot build Crosstool-NG for Xtensa directly, but can be configured to use it as an &#039;&#039;external&#039;&#039; toolchain. The first step is to build and install Crosstool-NG, so Buildroot can use it to compile the root file system. More information to build Crosstool-NG for Xtensa can be found under [[Crosstool-NG]]. Assuming Crosstool-NG is installed in &#039;ABSOLUTE_PATH_TO_XTOOLS&#039;, which is typically &amp;lt;code&amp;gt;$HOME/x-tools&amp;lt;/code&amp;gt;, you can make the following additional configurations changes in Buildroot:&lt;br /&gt;
&lt;br /&gt;
 Toolchain  ---&amp;gt;&lt;br /&gt;
   Toolchain type (External toolchain)&lt;br /&gt;
   Toolchain (Custom toolchain)&lt;br /&gt;
   Toolchain origin (Pre-installed toolchain)&lt;br /&gt;
   (ABSOLUTE_PATH_TO_XTOOLS) Toolchain path&lt;br /&gt;
   ($(ARCH)-unknown-linux-gnu) Toolchain prefix&lt;br /&gt;
   External toolchain C library (glibc/eglibc)&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== 2017.08 ==&lt;br /&gt;
* overlay overhaul: now overlay may be compressed, may have arbitrary name and may be specified as an URL&lt;br /&gt;
* overlay is applied to linux&lt;br /&gt;
* overlay is applied to U-Boot&lt;br /&gt;
&lt;br /&gt;
== 2017.05 ==&lt;br /&gt;
* build xtensa linux kernel uImage&lt;br /&gt;
&lt;br /&gt;
== 2016.05 ==&lt;br /&gt;
* support noMMU xtensa cores&lt;br /&gt;
&lt;br /&gt;
== 2014.11 ==&lt;br /&gt;
* fix &#039;dangerous relocation: call8: call target out of range&#039; linker bug&lt;br /&gt;
* fix &#039;Error: jump target out of range; no usable trampoline found&#039; and &#039;Error: operand 1 of &#039;j&#039; has out of range &#039; assembler bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.08 ==&lt;br /&gt;
* fix xtensa linker segfault on linking linux modules&lt;br /&gt;
&lt;br /&gt;
== 2014.05 ==&lt;br /&gt;
* fixes for building with -mtext-section-literals&lt;br /&gt;
* assembler trampolines (able to assemble files with jumps longer than 128K)&lt;br /&gt;
* fixes for &#039;dangerous relocation: call8: misaligned call target&#039; and &#039;dangerous relocation: overflow after relaxation&#039; linker bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.02 ==&lt;br /&gt;
* fix overlay application to gcc&lt;br /&gt;
&lt;br /&gt;
== 2012.11 ==&lt;br /&gt;
* xtensa in the Buildroot mainline&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=767</id>
		<title>Buildroot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=767"/>
		<updated>2017-07-27T00:40:00Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: We now can build linux and U-Boot as a part of buildroot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the steps to build a toolchain and root file system for a specific processor configuration based on the latest release of Buildroot. &lt;br /&gt;
&lt;br /&gt;
= Getting Buildroot and other prerequisites =&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate a cross-compilation toolchain, a root filesystem, linux kernel and the U-Boot bootloader.&lt;br /&gt;
== Getting Buildroot ==&lt;br /&gt;
Depending on whether buildroot tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest buildroot release archive: links in the Download section at http://buildroot.net/download.html&lt;br /&gt;
* mainline buildroot git tree: &amp;lt;code&amp;gt;git clone git://git.buildroot.net/buildroot&amp;lt;/code&amp;gt;&lt;br /&gt;
* for the buildroot with uClinux support see [[uClinux]] &lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
== Xtensa core overlay file ==&lt;br /&gt;
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by buildroot. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of buildroot requires that the overlay file name has the format xtensa_&amp;lt;CORE_NAME&amp;gt;.tar, where CORE_NAME can be any user selected name.&lt;br /&gt;
&lt;br /&gt;
= Configuring and building Buildroot =&lt;br /&gt;
&lt;br /&gt;
The Buildroot may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree Buildroot configuration/building.&lt;br /&gt;
&lt;br /&gt;
For more information about Buildroot, please also read the documents provided by Buildroot under http://buildroot.net/docs.html.&lt;br /&gt;
&lt;br /&gt;
== Configuring the Buildroot ==&lt;br /&gt;
&lt;br /&gt;
Configuring the Buildroot creates build infrastructure and .config file in the build directory. .config file may be written from scratch or copied from the outside source. It&#039;s a good idea to run configuration after copying external or predefined config, as newer Buildroot releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to edit existing configuration or to create it from scratch run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* Target options submenu:&lt;br /&gt;
** BR2_xtensa: must be selected when building for Xtensa&lt;br /&gt;
** BR2_XTENSA_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
** BR2_XTENSA_CUSTOM_NAME: must specify custom core variant name. This name is used to derive configuration overlay file name.&lt;br /&gt;
** BR2_XTENSA_OVERLAY_DIR: path to the directory with overlay file. May be relative to the Buildroot directory (specified as $(TOPDIR)/...) or the build directory (specified as $(BASE_DIR)/...)&lt;br /&gt;
* Toolchain submenu: select toolchain component versions and options. Many packages depend on presence of specific options, like IPv6 support or WCHAR support. Usually a package that cannot be built with current settings will indicate missing options in the menu.&lt;br /&gt;
* Target packages submenu: select individual packages and libraries that will be built and installed to the rootfs.&lt;br /&gt;
* Filesystem images submenu:&lt;br /&gt;
** BR2_TARGET_ROOTFS_CPIO: select to build CPIO image suitable for use as linux initramfs&lt;br /&gt;
** BR2_TARGET_ROOTFS_EXT2: select to build ext filesystem suitable for use with simulated block device&lt;br /&gt;
** BR2_TARGET_ROOTFS_TAR: select to build tar image, that may be unpacked and used for NFS root&lt;br /&gt;
&lt;br /&gt;
== Building buildroot ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039;&amp;lt;/code&amp;gt; to build the toolchain and root file system, or &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; toolchain&amp;lt;/code&amp;gt; to build only the toolchain.&lt;br /&gt;
&lt;br /&gt;
== Re-configuring and re-building Buildroot ==&lt;br /&gt;
&lt;br /&gt;
The Buildroot does not support uninstalling packages from its build directories. It also does not track dependencies between the built packages. The easiest way to make sure that deselected package is removed from the rootfs, or that changed toolchain option is applied to built packages is cleaning up build directory, leaving only .config in it and re-building everything from scratch.&lt;br /&gt;
&lt;br /&gt;
= Build Buildroot with Crosstool-NG =&lt;br /&gt;
&lt;br /&gt;
Using the Crosstool-NG toolchain allows to build a version of a Buildroot image based on GlibC instead of uClibc. In the current version, Buildroot cannot build Crosstool-NG for Xtensa directly, but can be configured to use it as an &#039;&#039;external&#039;&#039; toolchain. The first step is to build and install Crosstool-NG, so Buildroot can use it to compile the root file system. More information to build Crosstool-NG for Xtensa can be found under [[Crosstool-NG]]. Assuming Crosstool-NG is installed in &#039;ABSOLUTE_PATH_TO_XTOOLS&#039;, which is typically &amp;lt;code&amp;gt;$HOME/x-tools&amp;lt;/code&amp;gt;, you can make the following additional configurations changes in Buildroot:&lt;br /&gt;
&lt;br /&gt;
 Toolchain  ---&amp;gt;&lt;br /&gt;
   Toolchain type (External toolchain)&lt;br /&gt;
   Toolchain (Custom toolchain)&lt;br /&gt;
   Toolchain origin (Pre-installed toolchain)&lt;br /&gt;
   (ABSOLUTE_PATH_TO_XTOOLS) Toolchain path&lt;br /&gt;
   ($(ARCH)-unknown-linux-gnu) Toolchain prefix&lt;br /&gt;
   External toolchain C library (glibc/eglibc)&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== 2014.11 ==&lt;br /&gt;
* fix &#039;dangerous relocation: call8: call target out of range&#039; linker bug&lt;br /&gt;
* fix &#039;Error: jump target out of range; no usable trampoline found&#039; and &#039;Error: operand 1 of &#039;j&#039; has out of range &#039; assembler bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.08 ==&lt;br /&gt;
* fix xtensa linker segfault on linking linux modules&lt;br /&gt;
&lt;br /&gt;
== 2014.05 ==&lt;br /&gt;
* fixes for building with -mtext-section-literals&lt;br /&gt;
* assembler trampolines (able to assemble files with jumps longer than 128K)&lt;br /&gt;
* fixes for &#039;dangerous relocation: call8: misaligned call target&#039; and &#039;dangerous relocation: overflow after relaxation&#039; linker bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.02 ==&lt;br /&gt;
* fix overlay application to gcc&lt;br /&gt;
&lt;br /&gt;
== 2012.11 ==&lt;br /&gt;
* xtensa in the Buildroot mainline&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Toolchain_Overlay_File&amp;diff=766</id>
		<title>Toolchain Overlay File</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Toolchain_Overlay_File&amp;diff=766"/>
		<updated>2017-07-26T21:23:04Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: Update conversion script&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Overlay&#039;&#039; is a tar file that includes modified versions of processor configuration dependent files that are required by various toolchain tools, such as binutils, gcc, and gdb. The overlay described here has a specific layout and is intended for toolchain generators, such as buildroot, OpenADK or crosstool-NG. &lt;br /&gt;
&lt;br /&gt;
== Creating the overlay ==&lt;br /&gt;
&lt;br /&gt;
The overlay file shipped by Tensilica uses a flat directory structure, which is not suitable for buildroot or crosstool-NG at the moment. The file is part of the generated processor package, and can be found in the XtDevTools directory:&lt;br /&gt;
&lt;br /&gt;
 XtDevTools/install/build/$VERSION/$XTENSA_CORE/src/xtensa-config-overlay.tar.gz&lt;br /&gt;
&lt;br /&gt;
The following script converts this file and writes the modified version to xtensa-overlay.tar. Simply provide the path and name of the overlay provided by Tensilica when running the script:&lt;br /&gt;
&lt;br /&gt;
 ./make-overlay.sh $XTENSA_CORE path/to/xtensa-config-overlay.tar.gz .&lt;br /&gt;
&lt;br /&gt;
The file xtensa_$XTENSA_CORE.tar.gz created by the script can now be used to build buildroot or crosstool-NG. For more information how to configure those generators, please see [[Buildroot]] or [[crosstool-NG]].&lt;br /&gt;
&lt;br /&gt;
(Note that there is also a similar overlay file in the generated processor package provided by Tensilica, but it has a different directory layout and is not suitable for the script provided below. It can be found under .../$XTENSA_CORE/xtensa-elf/src/linux/misc/linux-overlay.tar.gz)&lt;br /&gt;
&lt;br /&gt;
== Conversion Script ==&lt;br /&gt;
&lt;br /&gt;
https://github.com/foss-xtensa/xtensa-config/blob/master/make-overlay.sh&lt;br /&gt;
&lt;br /&gt;
== Example Files ==&lt;br /&gt;
&lt;br /&gt;
The following files are the original and generated overlay file for the DC_D_233L processor.&lt;br /&gt;
&lt;br /&gt;
* http://www.linux-xtensa.org/pub/xtensa-config-overlay.tar.gz - Original overlay file provided by Tensilica&lt;br /&gt;
* http://www.linux-xtensa.org/pub/xtensa-overlay.tgz - : Generated overlay file, applicable to buildroot and crosstool-NG&lt;br /&gt;
&lt;br /&gt;
== Ready to go overlay archives (can be used with buildroot and OpenADK) ==&lt;br /&gt;
&lt;br /&gt;
https://github.com/jcmvbkbc/xtensa-toolchain-build/tree/master/overlays&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=764</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=764"/>
		<updated>2016-10-11T00:37:42Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* for experimental uClinux code see [[uClinux]].&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[Setting_up_U-Boot|Setting up U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable KSEG physical memory address and kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=763</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=763"/>
		<updated>2016-10-11T00:05:19Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update kernel features for 4.9&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* for experimental uClinux code see [[uClinux]].&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[Setting_up_U-Boot|Setting up U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 4.9 ==&lt;br /&gt;
* New kernel memory layouts: with 256MBytes and 512MBytes of low memory.&lt;br /&gt;
* Configurable kernel load address.&lt;br /&gt;
* Custom sysmem boot time memory allocator is replaced with memblock.&lt;br /&gt;
* KMEMLEAK.&lt;br /&gt;
* reserved-memory DT node.&lt;br /&gt;
* Cadence Configurable System Platform (CSP).&lt;br /&gt;
&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Boot_Loader&amp;diff=762</id>
		<title>Boot Loader</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Boot_Loader&amp;diff=762"/>
		<updated>2016-09-16T01:11:18Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update status of U-Boot port&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Boot Loaders ==&lt;br /&gt;
&lt;br /&gt;
The [http://en.wikipedia.org/wiki/Bootloader bootstrap loader or boot loader] is a small program running on a computer or device after power-on to load the operating system. Most boot loaders today provide additional features that allow to upgrade the firmware and access the system for troubleshooting.&lt;br /&gt;
&lt;br /&gt;
== U-Boot &amp;lt;small&amp;gt;([[U-Boot|build instructions for Xtensa]])&amp;lt;/small&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
U-Boot is one of the most popular boot loaders for Linux. It has a very complete [http://www.denx.de/wiki/U-Boot Project Page] as well as an nice introduction available [http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Introduction-to-Das-UBoot-the-universal-open-source-bootloader/ here]. A very complete U-Boot manual is also available [http://www.denx.de/wiki/DULG/Manual here].&lt;br /&gt;
&lt;br /&gt;
As of release v2016.09 xtensa support is available in the U-Boot mainline.&lt;br /&gt;
&lt;br /&gt;
== RedBoot ==&lt;br /&gt;
&lt;br /&gt;
Tensilica has also ported [http://sourceware.org/redboot/ RedBoot] for the Xtensa architecture. A RedBoot binary targeting the XTAV60 (LX60) or XTAV200 (LX200) emulation board is usually provided after generating an FPGA bitstream for one of these boards.  See the relevant board documentation from Tensilica for more details such as usage and supported features.  For more information and to request sources, please contact [http://www.tensilica.com/ Tensilica] directly.  For an example of how to boot the Linux kernel using RedBoot on the LX60 or LX200 boards, see [[RedBoot Example]].&lt;br /&gt;
&lt;br /&gt;
A source tarball for RedBoot with support for the Xtensa architecture is available [http://linux-xtensa.org/pub/redboot/redboot1.3.1-RB2007.2.tgz here].  For more details, see the tarball&#039;s [http://linux-xtensa.org/pub/redboot/redboot1.3.1-RB2007.2/README.txt README.txt] file.&lt;br /&gt;
&lt;br /&gt;
== Host-Side Loading via OCD ==&lt;br /&gt;
&lt;br /&gt;
An alternative to boot loaders is an external (e.g. &#039;&#039;&amp;quot;host-side&amp;quot;&#039;&#039;) loading mechanism.&lt;br /&gt;
&lt;br /&gt;
One common way to load a Linux kernel is to use debugging interfaces such as On-Chip Debug (OCD).  For example, Tensilica Tools GDB (xt-gdb) can connect to a target Xtensa processor using OCD via the Xtensa OCD Daemon.  It can then load and execute a Linux RAM image (Image.elf or vmlinux) onto the target using standard GDB commands.  See [[Buildroot_Build_Instructions#Download_and_run_the_kernel|Download and Run the Kernel]] for an example.&lt;br /&gt;
&lt;br /&gt;
== Linux Kernel Self-Boot Image ==&lt;br /&gt;
&lt;br /&gt;
It is possible to adapt the kernel build scripts for the Xtensa architecture to create a self-booting image. That is, a Linux kernel image that includes a Reset handler and can be either burned in ROM or Flash or downloaded to the target using another mechanism such as OCD.  &#039;&#039;&#039;&#039;&#039;Note:  This has not yet been implemented.&#039;&#039;&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Toolchain_and_Embedded_Distributions&amp;diff=761</id>
		<title>Toolchain and Embedded Distributions</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Toolchain_and_Embedded_Distributions&amp;diff=761"/>
		<updated>2016-09-07T07:56:15Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update status of xtensa support in crosstool-NG&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== [[Toolchain Overlay File]] ==&lt;br /&gt;
&lt;br /&gt;
Because Xtensa is a configurable and extensible processor architecture that allows to define additional registers and instructions, the toolchain is the main software component that usually needs to be adapted for a specific Xtensa processor configuration. Tensilica provides a small set of configuration files in form of an &#039;&#039;overlay&#039;&#039; that replace the versions in the toolchain sources. The [[Toolchain Overlay File]] is a version of that &#039;&#039;overlay&#039;&#039; provided by Tensilica with a specific format required for crosstool-NG and buildroot. A script to convert the &#039;&#039;overlay&#039;&#039; provided by Tensilica can be found under [[Toolchain Overlay File]]&lt;br /&gt;
&lt;br /&gt;
== Start from scratch with FSF/OSS sources ==&lt;br /&gt;
&lt;br /&gt;
Creating a toolchain and bootable root file system starting from sources is certainly the most challenging approach. It usually requires additional patches and sometimes matching versions of sources. While support for Xtensa is integrated in most toolchain tools, they must be patches for a specific Xtensa processor configuration. The &#039;&#039;overlay&#039;&#039; metioned above includes a necessary set of configuration files together with information explaining the process to patch the toolchain sources.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning:&#039;&#039;&#039; cross compilers running on 64bit hosts are known to produce broken code. For some more details see the [http://lists.linux-xtensa.org/pipermail/linux-xtensa/Week-of-Mon-20130715/001140.html explanation] of Chris Zankel.&lt;br /&gt;
&lt;br /&gt;
== [http://crosstool-ng.org/ crosstool-NG] &amp;lt;small&amp;gt;([[crosstool-NG|build instructions for Xtensa]])&amp;lt;/small&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
crosstool-NG (http://crosstool-ng.org/) provides a system to build a complete toolchain. It supports various C-libraries (Multilib, uClibc, glibc, and eglibc), but can also be used to build a &#039;bare&#039; toolchain. Starting with release 1.22.0 the mainline crosstool-NG repository includes support for Xtensa. The process of patching the toolchain and other architecture specific software is fully automated using the [[Toolchain Overlay File]]. More information for building a toolchain for Xtensa using crosstool-NG can be found [[crosstool-NG|here]].&lt;br /&gt;
&lt;br /&gt;
== [http://www.buildroot.org BuildRoot] &amp;lt;small&amp;gt;([[Buildroot|build instructions for Xtensa]])&amp;lt;/small&amp;gt; ==&lt;br /&gt;
&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a cross-compilation toolchain and root file system for your target Linux system. The Xtensa architecture is fully supported in the official tree, including support for specific processor configuration using the [[Toolchain Overlay File]]. For build instructions, see [[Buildroot]].&lt;br /&gt;
&lt;br /&gt;
== [http://www.openadk.org OpenADK] ==&lt;br /&gt;
&lt;br /&gt;
OpenADK is a set of Makefiles and patches that makes it easy to generate a cross-compilation toolchain and root file system for your target Linux system. The Xtensa architecture is fully supported, including support for specific processor configuration using the [[Toolchain Overlay File]]. At the moment only Qemu emulation (dc232b,dc233c) targets are available. New configuration can be simply added.&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=760</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=760"/>
		<updated>2016-03-27T01:18:37Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: Update Features by release for 4.4 and 4.6&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* for experimental uClinux code see [[uClinux]].&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[Setting_up_U-Boot|Setting up U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
== Linux 4.6 ==&lt;br /&gt;
* Hardware breakpoints/watchpoints.&lt;br /&gt;
* ioremap for memory outside KIO region.&lt;br /&gt;
* Big endian: serial, network, i2c work.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.4 ==&lt;br /&gt;
* DMA to high memory.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Toolchain_Overlay_File&amp;diff=759</id>
		<title>Toolchain Overlay File</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Toolchain_Overlay_File&amp;diff=759"/>
		<updated>2015-12-18T15:43:55Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: Patch gdb/xtensa-config.c file during overlay repacking. See https://sourceware.org/ml/gdb-patches/2015-04/msg00698.html for the reference&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;Overlay&#039;&#039; is a tar file that includes modified versions of processor configuration dependent files that are required by various toolchain tools, such as binutils, gcc, and gdb. The overlay described here has a specific layout and is intended for toolchain generators, such as buildroot, OpenADK or crosstool-NG. &lt;br /&gt;
&lt;br /&gt;
== Creating the overlay ==&lt;br /&gt;
&lt;br /&gt;
The overlay file shipped by Tensilica uses a flat directory structure, which is not suitable for buildroot or crosstool-NG at the moment. The file is part of the generated processor package, and can be found in the XtDevTools directory:&lt;br /&gt;
&lt;br /&gt;
 XtDevTools/install/build/$VERSION/$XTENSA_CORE/src/xtensa-config-overlay.tar.gz&lt;br /&gt;
&lt;br /&gt;
The following script converts this file and writes the modified version to xtensa-overlay.tar. Simply provide the path and name of the overlay provided by Tensilica when running the script:&lt;br /&gt;
&lt;br /&gt;
 ./script xtensa-config-overlay.tar.gz&lt;br /&gt;
&lt;br /&gt;
The file xtensa-overlay.tar created by the script can now be used to build buildroot or crosstool-NG. For more information how to configure those generators, please see [[Buildroot]] or [[crosstool-NG]].&lt;br /&gt;
&lt;br /&gt;
(Note that there is also a similar overlay file in the generated processor package provided by Tensilica, but it has a different directory layout and is not suitable for the script provided below. It can be found under .../$XTENSA_CORE/xtensa-elf/src/linux/misc/linux-overlay.tar.gz)&lt;br /&gt;
&lt;br /&gt;
== Conversion Script ==&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 if [ $# -ne 1 ]; then&lt;br /&gt;
  echo &amp;quot;Error: No overlay file specified&amp;quot;&lt;br /&gt;
  exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 if [ $1 == &amp;quot;xtensa-overlay.tar&amp;quot; ]; then&lt;br /&gt;
  echo &amp;quot;Error: Input file must be named other than &#039;xtensa-overlay.tar&#039;&amp;quot;&lt;br /&gt;
  exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 if [ ! -f $1 ]; then&lt;br /&gt;
  echo &amp;quot;Error: Overlay file $1 not found&amp;quot;&lt;br /&gt;
  exit 1&lt;br /&gt;
 fi&lt;br /&gt;
 TMPDIR=`mktemp -d`&lt;br /&gt;
 tar xzf $1 -C $TMPDIR&lt;br /&gt;
 mkdir -p $TMPDIR/overlay/binutils/bfd $TMPDIR/overlay/binutils/ld \&lt;br /&gt;
          $TMPDIR/overlay/binutils/include $TMPDIR/overlay/gcc/include \&lt;br /&gt;
          $TMPDIR/overlay/gdb/bfd $TMPDIR/overlay/gdb/gdb/regformats \&lt;br /&gt;
          $TMPDIR/overlay/gdb/gdb/gdbserver $TMPDIR/overlay/gdb/include&lt;br /&gt;
 mv $TMPDIR/binutils/xtensa-config.h $TMPDIR/overlay/binutils/include&lt;br /&gt;
 mv $TMPDIR/binutils/xtensa-modules.c $TMPDIR/overlay/binutils/bfd&lt;br /&gt;
 mv $TMPDIR/gcc/xtensa-config.h $TMPDIR/overlay/gcc/include&lt;br /&gt;
 sed -e &#039;0,/#include/s/#include/#include &amp;quot;defs.h&amp;quot;\n#include/&#039; -i $TMPDIR/gdb/xtensa-config.c&lt;br /&gt;
 mv $TMPDIR/gdb/xtensa-config.c $TMPDIR/overlay/gdb/gdb&lt;br /&gt;
 mv $TMPDIR/gdb/xtensa-config.h $TMPDIR/overlay/gdb/include&lt;br /&gt;
 mv $TMPDIR/gdb/xtensa-modules.c $TMPDIR/overlay/gdb/bfd&lt;br /&gt;
 mv $TMPDIR/gdb/xtensa-xtregs.c $TMPDIR/overlay/gdb/gdb/gdbserver&lt;br /&gt;
 mv $TMPDIR/gdb/reg-xtensa.dat $TMPDIR/overlay/gdb/gdb/regformats&lt;br /&gt;
 tar cf xtensa-overlay.tar -C $TMPDIR/overlay/ binutils gcc gdb&lt;br /&gt;
 rm -fr $TMPDIR&lt;br /&gt;
&lt;br /&gt;
== Example Files ==&lt;br /&gt;
&lt;br /&gt;
The following files are the original and generated overlay file for the DC_D_233L processor.&lt;br /&gt;
&lt;br /&gt;
* http://www.linux-xtensa.org/pub/xtensa-config-overlay.tar.gz - Original overlay file provided by Tensilica&lt;br /&gt;
* http://www.linux-xtensa.org/pub/xtensa-overlay.tgz - : Generated overlay file, applicable to buildroot and crosstool-NG&lt;br /&gt;
&lt;br /&gt;
== Ready to go overlay archives (can be used with buildroot and OpenADK) ==&lt;br /&gt;
&lt;br /&gt;
https://github.com/jcmvbkbc/xtensa-toolchain-build/tree/master/overlays&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=758</id>
		<title>Xtensa on QEMU</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=758"/>
		<updated>2015-11-26T13:10:30Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: specify better stty options for sim&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Setting up and running Xtensa simulation on QEMU ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.qemu.org QEMU] is a free processor/machine emulator and virtualizer.&lt;br /&gt;
&lt;br /&gt;
Starting with version 1.0 QEMU offers [http://wiki.qemu.org/Features/Xtensa Xtensa architecture emulation].&lt;br /&gt;
DC232B, DC233C (LE) and fsf (BE) cores are supported on sim and LX60/LX200/ML605/KC705 platforms.&lt;br /&gt;
&lt;br /&gt;
== Getting and building QEMU ==&lt;br /&gt;
QEMU is developed using git. The main tree is located at git://git.qemu.org/qemu.git. Release tarballs and guest systems images are available at http://wiki.qemu.org/Download.&lt;br /&gt;
&lt;br /&gt;
This will make a copy of master QEMU repository, configure, build and install QEMU binaries for little-endian and big-endian targets:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.qemu.org/qemu.git&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir qemu-xtensa ; cd qemu-xtensa&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;../qemu/configure --prefix=`pwd`/root --target-list=xtensa-softmmu,xtensaeb-softmmu&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make install&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== QEMU options ==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Option !! Meaning !! Example&lt;br /&gt;
|-&lt;br /&gt;
| -M &amp;lt;machine-name&amp;gt;&lt;br /&gt;
| Emulate specific platform type. Use &#039;?&#039; to list all supported platform types.&lt;br /&gt;
| -M lx60&lt;br /&gt;
|-&lt;br /&gt;
| -cpu &amp;lt;core-name&amp;gt;&lt;br /&gt;
| Emulate specific core type. Use &#039;?&#039; to list all supported core types.&lt;br /&gt;
| -cpu dc232b&lt;br /&gt;
|-&lt;br /&gt;
| -m &amp;lt;memory size&amp;gt;&lt;br /&gt;
| Set emulated RAM size. M and G suffixes for mega- and gigabytes.&lt;br /&gt;
| -m 128M&lt;br /&gt;
|-&lt;br /&gt;
| -semihosting&lt;br /&gt;
| Enable SIMCALL instruction for the protection ring 0.&lt;br /&gt;
| -semihosting&lt;br /&gt;
|-&lt;br /&gt;
| -kernel &amp;lt;elf-image/uImage&amp;gt;&lt;br /&gt;
| Load elf-image or uImage and start emulation from its entry point. Note that image is loaded to virtual addresses it is linked for. For XTFPGA this option also chooses &#039;boot from SRAM&#039; mode, mapping SRAM to the System ROM region at physical address 0xFE000000.&lt;br /&gt;
| -kernel xtensa-2.6.29-smp/arch/xtensa/boot/Image.elf&lt;br /&gt;
|-&lt;br /&gt;
| -append &amp;lt;kernel arguments&amp;gt;&lt;br /&gt;
| (Not for sim) Wrap kernel arguments into the bootparameters block and pass pointer to it to the elf-image in a2.&lt;br /&gt;
| -append &#039;console=ttyS0 ip=dhcp root=/dev/nfs rw&#039;&lt;br /&gt;
|-&lt;br /&gt;
| -initrd &amp;lt;initrd-image&amp;gt;&lt;br /&gt;
| (Not for sim) Load initial RAM disk image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -initrd buildroot-build/images/rootfs.cpio&lt;br /&gt;
|-&lt;br /&gt;
| -dtb &amp;lt;Device-Tree-Blob&amp;gt;&lt;br /&gt;
| (Not for sim) Load DTB image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -dtb xtensa-build/arch/xtensa/boot/dts/kc705.dtb&lt;br /&gt;
|-&lt;br /&gt;
| -pflash &amp;lt;flash-image&amp;gt;&lt;br /&gt;
| (Not for sim) Mount flash-image as a system FLASH. Note that image size must match platform FLASH size (4MB for LX60, 16MB for LX200 and ML605, 128MB for KC705).&lt;br /&gt;
| -pflash u-boot.dc232b_xtav200.flash&lt;br /&gt;
|-&lt;br /&gt;
| -net nic,&amp;lt;nic-parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Set network interface parameters.&lt;br /&gt;
| -net nic,vlan=0&lt;br /&gt;
|-&lt;br /&gt;
| -net user,&amp;lt;SLIRP parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Use the user mode network stack. SLIRP parameters may be used to tune built-in DHCP and TFTP servers.&lt;br /&gt;
| -net user,vlan=0,tftp=.,hostname=dc232b-lx200&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== sim platform ==&lt;br /&gt;
&lt;br /&gt;
The sim platform is modelled after Tensilica ISS. It may run ELF images built for ISS, see e.g. [[Buildroot_Build_Instructions#Build_and_Run_a_Linux_Kernel_on_the_Instruction_Set_Simulator_(ISS)|Build and Run a Linux Kernel on the Instruction Set Simulator (ISS)]].&lt;br /&gt;
There&#039;s only SIMCALL external interface available for the sim machine. To avoid console interference with QEMU monitor, monitor should be disabled with -monitor null or moved to network interface with e.g. -monitor tcp::1236,telnet,server,nowait.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M sim -m 128M -semihosting -nographic -monitor null \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel sim-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since the QEMU doesn&#039;t manage terminal settings in semihosting mode, ^C and other terminal control codes interrupt QEMU instead of its guest. &#039;&#039;&#039;stty -echo -icanon -isig&#039;&#039;&#039; may be used to set up terminal to not echo input characters and not terminate QEMU.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA (LX60/LX200/ML605/KC705/...) platforms ==&lt;br /&gt;
&lt;br /&gt;
XTFPGA platform emulates system RAM, board-specific FPGA, UART, OpenCores 10/100 Mbit Ethernet MAC, National Semiconductors DP83848C 10/100 PHY and parallel FLASH.&lt;br /&gt;
The platform may boot from either SRAM (when -kernel option is specified, SRAM is mapped to the System ROM region and ELF image is loaded) or from FLASH.&lt;br /&gt;
&lt;br /&gt;
NFS root export record for user network (there&#039;s no way to specify root-path option for the QEMU builtin DHCP server. Unless kernel parameter &#039;nfsroot&#039; is given, you&#039;ll have to put the rootfs to /tftpboot/&amp;lt;hostname&amp;gt;):&lt;br /&gt;
  /tftpboot/      127.0.0.1(rw,no_root_squash,insecure)&lt;br /&gt;
&lt;br /&gt;
Booting linux image from SRAM (FLASH not mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel lx60-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting u-boot image from SRAM (empty FLASH image is created and mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;head -c 16M /dev/zero &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
In this scenario binary u-boot image may be downloaded from TFTP and copied to the FLASH as described [[Setting_up_U-Boot|here]].&lt;br /&gt;
&lt;br /&gt;
Alternatively FLASH image containing u-boot may be preformatted and QEMU may be booted from it:&lt;br /&gt;
  $ &#039;&#039;&#039;cat u-boot-xtensa.git/u-boot.bin.dc232b_xtav200 /dev/zero | head -c 16M &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
(Note that KC705 expects bootloader to be at the offset 0x06000000 in the FLASH, unlike the older boards that boot at offset 0).&lt;br /&gt;
&lt;br /&gt;
== Debugging with QEMU ==&lt;br /&gt;
=== GDB ===&lt;br /&gt;
There&#039;s builtin GDB server in the QEMU. -s command line switch activates it on the address 0.0.0.0:1234 (-gdb tcp:&amp;lt;ip&amp;gt;:&amp;lt;port&amp;gt; may be used instead of -s to change address and port to listen), -S switch stops QEMU at the first guest instruction waiting for &#039;continue&#039; command from gdb.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -M lx200 -nographic -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200 -s -S&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default xtensa gdb may only access unprivileged core registers. To allow access to all available registers ./gdb/xtensa-config.c needs to be modified, marking privileged registers as non-privileged. If [https://github.com/jcmvbkbc/xtensa-toolchain-build these scripts] are used to build the toolchain, the fixup-gdb.sh step does that.&lt;br /&gt;
&lt;br /&gt;
GDB breakpoints, watchpoints, single-stepping and other debugging features work as usual.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xtensa-dc232b-elf-gdb&#039;&#039;&#039;&lt;br /&gt;
  GNU gdb (GDB) 7.3.50.20110709-cvs&lt;br /&gt;
  Copyright (C) 2011 Free Software Foundation, Inc.&lt;br /&gt;
  License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;&lt;br /&gt;
  This is free software: you are free to change and redistribute it.&lt;br /&gt;
  There is NO WARRANTY, to the extent permitted by law.  Type &amp;quot;show copying&amp;quot;&lt;br /&gt;
  and &amp;quot;show warranty&amp;quot; for details.&lt;br /&gt;
  This GDB was configured as &amp;quot;--host=x86_64-unknown-linux-gnu --target=xtensa-dc232b-elf&amp;quot;.&lt;br /&gt;
  For bug reporting instructions, please see:&lt;br /&gt;
  &amp;lt;http://www.gnu.org/software/gdb/bugs/&amp;gt;.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;target remote 127.0.0.1:1234&#039;&#039;&#039;&lt;br /&gt;
  Remote debugging using 127.0.0.1:1234&lt;br /&gt;
  0xfe000000 in ?? ()&lt;br /&gt;
  (gdb) &#039;&#039;&#039;symbol-file u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
  Reading symbols from u-boot-xtensa.git/u-boot.dc232b_xtav200...done.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;x/10i $pc&#039;&#039;&#039;&lt;br /&gt;
  =&amp;gt; 0xfe000000 &amp;lt;_ResetVector&amp;gt;:   j       0xfe00000c &amp;lt;_ResetVector+12&amp;gt;&lt;br /&gt;
     0xfe000003 &amp;lt;_ResetVector+3&amp;gt;: break   0, 0&lt;br /&gt;
     0xfe000006 &amp;lt;_ResetVector+6&amp;gt;: excw&lt;br /&gt;
     0xfe000009 &amp;lt;_ResetVector+9&amp;gt;: .byte 0xff&lt;br /&gt;
     0xfe00000a &amp;lt;_ResetVector+10&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000b &amp;lt;_ResetVector+11&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000c &amp;lt;_ResetVector+12&amp;gt;:        l32r    a2, 0xfe000004 &amp;lt;_ResetVector+4&amp;gt;&lt;br /&gt;
     0xfe00000f &amp;lt;_ResetVector+15&amp;gt;:        jx      a2&lt;br /&gt;
     0xfe000012 &amp;lt;_ResetVector+18&amp;gt;:        ill&lt;br /&gt;
     0xfe000015 &amp;lt;_ResetVector+21&amp;gt;:        subx2   a0, a0, a0&lt;br /&gt;
  (gdb) &#039;&#039;&#039;si&#039;&#039;&#039;&lt;br /&gt;
  69      1:      l32r    a2, 2b&lt;br /&gt;
  (gdb)&lt;br /&gt;
&lt;br /&gt;
QEMU monitor commands may be invoked via gdb monitor command:&lt;br /&gt;
&lt;br /&gt;
  (gdb) &#039;&#039;&#039;monitor info mtree&#039;&#039;&#039;&lt;br /&gt;
  memory&lt;br /&gt;
  00000000-fffffffe (prio 0): system&lt;br /&gt;
    00000000-07ffffff (prio 0): lx60.dram&lt;br /&gt;
    f0000000-fdffffff (prio 0): lx60.io&lt;br /&gt;
      fd020000-fd02ffff (prio 0): lx60.fpga&lt;br /&gt;
      fd030000-fd030053 (prio 0): open_eth.regs&lt;br /&gt;
      fd030400-fd0307ff (prio 0): open_eth.desc&lt;br /&gt;
      fd050020-fd05003f (prio 0): serial&lt;br /&gt;
      fd800000-fd803fff (prio 0): open_eth.ram&lt;br /&gt;
    f8000000-f83fffff (prio 0): lx60.io.flash&lt;br /&gt;
    fe000000-fe01ffff (prio 0): lx60.sram&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
QEMU can log guest CPU state/opcode translation during execution. Invalid, reserved and not implemented opcodes, invalid conditions for certain opcodes, reserved/not implemented SR access, page table lookups, interrupt requests are all logged with this method. Logging may be enabled with -d&amp;lt;logging types&amp;gt; command line option, or with monitor command &#039;log &amp;lt;logging types&amp;gt;&#039;. By default logs go to the file /tmp/qemu.log. Verbose logging slows down execution significantly, it may be useful to control logging from GDB, enabling it via monitor command for the specific code blocks.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Logging type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| none&lt;br /&gt;
| disable logging&lt;br /&gt;
|-&lt;br /&gt;
| out_asm&lt;br /&gt;
| show generated host assembly code for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| in_asm&lt;br /&gt;
| show target assembly code for each compiled TB (not implemented for Xtensa)&lt;br /&gt;
|-&lt;br /&gt;
| op&lt;br /&gt;
| show micro ops for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| op_opt&lt;br /&gt;
| show micro ops after liveness analysis&lt;br /&gt;
|-&lt;br /&gt;
| int&lt;br /&gt;
| show interrupts/exceptions in short format&lt;br /&gt;
|-&lt;br /&gt;
| exec&lt;br /&gt;
| show trace before each executed TB&lt;br /&gt;
|-&lt;br /&gt;
| cpu&lt;br /&gt;
| show CPU state before block translation&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Extending QEMU ==&lt;br /&gt;
&lt;br /&gt;
Starting with QEMU-2.2 there&#039;s a script [https://github.com/OSLL/qemu-xtensa/blob/master/target-xtensa/import_core.sh qemu/target-xtensa/import_core.sh] that adds new core to QEMU from the xtensa configuration overlay.&lt;br /&gt;
&lt;br /&gt;
To manually extend QEMU with new xtensa core an appropriate XtensaConfig structure must be registered. This structure may be mostly automatically filled in from the overlay data, see mainline commits [http://jcmvbkbc.spb.ru/git/?p=dumb/qemu-xtensa.git;a=commitdiff;h=53add759be1a39063cfc52ca2a6d0fcdd1091697 53add759be1a39063cfc52ca2a6d0fcdd1091697] (target-xtensa: add dc232b core) and [http://jcmvbkbc.spb.ru/git/?p=dumb/qemu-xtensa.git;a=commitdiff;h=935f7a2b428f71a40e985f09955bccaaf09518fa 935f7a2b428f71a40e985f09955bccaaf09518fa] (target-xtensa: add fsf core) for example:&lt;br /&gt;
* target-xtensa/core-&amp;lt;core name&amp;gt;/core-isa.h is a copy of config/core.h from xtensa-config-overlay.tar.gz;&lt;br /&gt;
* target-xtensa/core-&amp;lt;core name&amp;gt;/gdb-config.c is made from gdb/xtensa-config.c from xtensa-config-overlay.tar.gz, only rmap entries for PC, A*, AR*, SR*, UR* are retained;&lt;br /&gt;
* XtensaConfig::gdb_regmap::num_regs is the total number of rmap entries in the gdb-config.c;&lt;br /&gt;
* XtensaConfig::gdb_regmap::num_core_regs is the number of contiguous non-privileged ((flags &amp;amp; 1) == 0) rmap entries in the gdb-config.c.&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Crosstool-NG&amp;diff=757</id>
		<title>Crosstool-NG</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Crosstool-NG&amp;diff=757"/>
		<updated>2015-11-19T03:04:00Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update ct-ng status&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
Crosstool-NG provides a system to build a complete toolchain. It supports various C-libraries (newlib, uClibc, glibc, and eglibc), but can also be used to build a toolchain without a C-library. The following paragraphs describe the steps to build a toolchain tailored for an Xtensa configuration. &lt;br /&gt;
&lt;br /&gt;
== Configure and build Crosstool-NG ==&lt;br /&gt;
&lt;br /&gt;
Starting with release 1.22.0 the mainline crosstool-NG repository includes support for Xtensa. Using tip of the cloned git tree for work is not always a good idea, unless you need the latest mainline changes using official releases (marked by tags) would give more predictable results. &lt;br /&gt;
&lt;br /&gt;
 git clone https://github.com/crosstool-ng/crosstool-ng.git&lt;br /&gt;
 git checkout crosstool-ng-1.22.0&lt;br /&gt;
&lt;br /&gt;
=== Build ct-ng ===&lt;br /&gt;
&lt;br /&gt;
ct-ng is similar to the command &#039;make&#039; for other projects, and is used to configure and build the toolchain. Since we cloned it from the repository, its build system is not configured yet, use ./bootstrap script to create it:&lt;br /&gt;
&lt;br /&gt;
 ./bootstrap&lt;br /&gt;
&lt;br /&gt;
The next step is to configure ct-ng for your system. The default installation path is /usr/local/ but can be overwritten with the --prefix option. It is also possible to configure ct-ng for use without installation with --enable-local configure option:&lt;br /&gt;
&lt;br /&gt;
 ./configure --enable-local&lt;br /&gt;
&lt;br /&gt;
Finally, run &#039;make&#039; to build ct-ng (and &#039;make install&#039; to install it if needed):&lt;br /&gt;
&lt;br /&gt;
 make&lt;br /&gt;
&lt;br /&gt;
=== Xtensa core overlay file ===&lt;br /&gt;
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by the crosstool-NG. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of crosstool-NG requires that the overlay file name has the format xtensa_&amp;lt;CORE_NAME&amp;gt;.tar, where CORE_NAME can be any user selected name.&lt;br /&gt;
&lt;br /&gt;
== Building a &#039;bare&#039; toolchain without a C-library ==&lt;br /&gt;
&lt;br /&gt;
=== Configure the toolchain ===&lt;br /&gt;
&lt;br /&gt;
The first step is to configure the toolchain:&lt;br /&gt;
&lt;br /&gt;
 ./ct-ng menuconfig&lt;br /&gt;
&lt;br /&gt;
Make the following changes (---&amp;gt; means to enter the sub-menu). We are assuming that the overlay tar image (xtensa_&amp;lt;CORE_NAME&amp;gt;.tar) has been copied to ABSOLUTE_PATH_TO_OVERLAY.&lt;br /&gt;
 &lt;br /&gt;
 Target options  ---&amp;gt;                                         &lt;br /&gt;
 Target Architecture (xtensa) &lt;br /&gt;
 Target Architecture Variant (Custom Xtensa processor configuration)&lt;br /&gt;
 (CORE_NAME) Custom Xtensa process configuration file name&lt;br /&gt;
 (ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  &lt;br /&gt;
&lt;br /&gt;
 C-library  ---&amp;gt;                                              &lt;br /&gt;
 C library (none)&lt;br /&gt;
&lt;br /&gt;
The default directory for the created toolchain is $HOME/x-tools, but can be configured under &#039;Paths and misc options&#039;:&lt;br /&gt;
&lt;br /&gt;
 Paths and misc options  ---&amp;gt;&lt;br /&gt;
 (${HOME}/x-tools/${CT_TARGET}) Prefix directory&lt;br /&gt;
&lt;br /&gt;
=== Build and install the toolchain ===&lt;br /&gt;
&lt;br /&gt;
Finally, build and install the toolchain. &lt;br /&gt;
&lt;br /&gt;
 ./ct-ng build&lt;br /&gt;
&lt;br /&gt;
=== Test it ===&lt;br /&gt;
&lt;br /&gt;
 export PATH=$PATH:$HOME/x-tools/xtensa-unknown-linux-gnu/bin&lt;br /&gt;
 xtensa-unknown-linux-gnu-gcc t.c&lt;br /&gt;
&lt;br /&gt;
== Building uClibc-ng based toolchain ==&lt;br /&gt;
&lt;br /&gt;
=== Configure the toolchain ===&lt;br /&gt;
&lt;br /&gt;
Similar to the &#039;bare&#039; version above, the first step is to configure crosstool-NG. Simply run&lt;br /&gt;
&lt;br /&gt;
 ./ct-ng menuconfig&lt;br /&gt;
&lt;br /&gt;
and make the following changes (---&amp;gt; means to enter the sub-menu).&lt;br /&gt;
&lt;br /&gt;
 Paths and misc options ---&amp;gt;&lt;br /&gt;
 [*] Try features marked as EXPERIMENTAL&lt;br /&gt;
&lt;br /&gt;
 Target options  ---&amp;gt;                                         &lt;br /&gt;
 Target Architecture (xtensa) &lt;br /&gt;
 Target Architecture Variant (Custom Xtensa processor configuration)&lt;br /&gt;
 (CORE_NAME) Custom Xtensa process configuration name&lt;br /&gt;
 (ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  &lt;br /&gt;
&lt;br /&gt;
 Operating system ---&amp;gt;&lt;br /&gt;
 Target OS (linux)&lt;br /&gt;
&lt;br /&gt;
 C-library  ---&amp;gt;                                              &lt;br /&gt;
 C library (uClibc)&lt;br /&gt;
&lt;br /&gt;
=== Build and install the toolchain ===&lt;br /&gt;
&lt;br /&gt;
Finally, build and install the toolchain.&lt;br /&gt;
&lt;br /&gt;
 ./ct-ng build&lt;br /&gt;
&lt;br /&gt;
== Building a &#039;glibc&#039; based toolchain &#039;&#039;(experimental)&#039;&#039; ==&lt;br /&gt;
&lt;br /&gt;
NOTE THAT THE REPOSITORY IS CURRENTLY NOT AVAILABLE.&lt;br /&gt;
&lt;br /&gt;
The glibc port is experimental at the moment and also not part of the main repository yet. A version for Xtensa can be found on linux-xtensa.org, so you can clone it from there:&lt;br /&gt;
&lt;br /&gt;
 git clone git://.../git/glibc&lt;br /&gt;
&lt;br /&gt;
=== Configure the toolchain ===&lt;br /&gt;
&lt;br /&gt;
Similar to the &#039;bare&#039; version above, the first step is to configure crosstool-NG. Simply run&lt;br /&gt;
&lt;br /&gt;
 ./ct-ng menuconfig&lt;br /&gt;
&lt;br /&gt;
and make the following changes (---&amp;gt; means to enter the sub-menu).&lt;br /&gt;
&lt;br /&gt;
 Paths and misc options ---&amp;gt;&lt;br /&gt;
 [*] Try features marked as EXPERIMENTAL&lt;br /&gt;
&lt;br /&gt;
 Target options  ---&amp;gt;                                         &lt;br /&gt;
 Target Architecture (xtensa) &lt;br /&gt;
 Target Architecture Variant (Custom Xtensa processor configuration)&lt;br /&gt;
 (CORE_NAME) Custom Xtensa process configuration name&lt;br /&gt;
 (ABSOLUTE_PATH_TO_OVERLAY) Full path to custom Xtensa processor configurations  &lt;br /&gt;
&lt;br /&gt;
 C-library  ---&amp;gt;                                              &lt;br /&gt;
 C library (glibc)&lt;br /&gt;
 glibc version (Custom glibc)&lt;br /&gt;
 (ABSOLUTE_PATH_TO_glibc-2.17) Full path to custom glibc source&lt;br /&gt;
 (ports) Extra addons&lt;br /&gt;
&lt;br /&gt;
=== Build and install the toolchain ===&lt;br /&gt;
&lt;br /&gt;
Finally, build and install the toolchain.&lt;br /&gt;
&lt;br /&gt;
 ./ct-ng build&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=UClinux&amp;diff=756</id>
		<title>UClinux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=UClinux&amp;diff=756"/>
		<updated>2015-10-06T03:39:07Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add clone commands&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Toolchain with uClinux support =&lt;br /&gt;
&lt;br /&gt;
Xtensa uClinux userspace is based on bFLT executable file format.&lt;br /&gt;
&lt;br /&gt;
* gcc patch that adds xtensa*-*-uclinux* is [https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e3c15dbe1c4cd63d906eb67c1c607cc4fab6b329 committed] into gcc-6.0 development branch and will be first released with gcc-6.1.&lt;br /&gt;
* elf2flt patch that adds Xtensa support is [http://cgit.openadk.org/cgi/cgit/elf2flt.git/commit/?id=17a2cf8c28cf13b85939b2553b8a87b16d88c94e committed into this] elf2flt repository.&lt;br /&gt;
&lt;br /&gt;
= Linux kernel with noMMU support =&lt;br /&gt;
&lt;br /&gt;
Linux branch with noMMU support patches, sample core and sample configuration: https://github.com/jcmvbkbc/linux-xtensa/commits/xtensa-nommu&lt;br /&gt;
&lt;br /&gt;
The following command may be used to clone that tree and switch to xtensa-nommu branch: &amp;lt;code&amp;gt;git clone -b xtensa-nommu git://github.com/jcmvbkbc/linux-xtensa.git&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The patches will likely appear in Linux v4.4&lt;br /&gt;
&lt;br /&gt;
= Buildroot with noMMU support =&lt;br /&gt;
&lt;br /&gt;
Buildroot branch with gcc and elf2flt patches, sample overlay and configuration: https://github.com/jcmvbkbc/buildroot/commits/xtensa-nommu&lt;br /&gt;
&lt;br /&gt;
The following command may be used to clone that tree and switch to xtensa-nommu branch: &amp;lt;code&amp;gt;git clone -b xtensa-nommu git://github.com/jcmvbkbc/buildroot.git&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= uClinux distribution for Xtensa =&lt;br /&gt;
&lt;br /&gt;
In progress&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=755</id>
		<title>Buildroot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=755"/>
		<updated>2015-10-06T03:34:35Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add uclinux link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the steps to build a toolchain and root file system for a specific processor configuration based on the latest release of Buildroot. &lt;br /&gt;
&lt;br /&gt;
= Getting Buildroot and other prerequisites =&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate a cross-compilation toolchain and a root filesystem. Building linux kernel and bootloader for arbitrary Xtensa core with the Buildroot is currently not supported.&lt;br /&gt;
== Getting Buildroot ==&lt;br /&gt;
Depending on whether buildroot tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest buildroot release archive: links in the Download section at http://buildroot.net/download.html&lt;br /&gt;
* mainline buildroot git tree: &amp;lt;code&amp;gt;git clone git://git.buildroot.net/buildroot&amp;lt;/code&amp;gt;&lt;br /&gt;
* for the buildroot with uClinux support see [[uClinux]] &lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
== Xtensa core overlay file ==&lt;br /&gt;
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by buildroot. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of buildroot requires that the overlay file name has the format xtensa_&amp;lt;CORE_NAME&amp;gt;.tar, where CORE_NAME can be any user selected name.&lt;br /&gt;
&lt;br /&gt;
= Configuring and building Buildroot =&lt;br /&gt;
&lt;br /&gt;
The Buildroot may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree Buildroot configuration/building.&lt;br /&gt;
&lt;br /&gt;
For more information about Buildroot, please also read the documents provided by Buildroot under http://buildroot.net/docs.html.&lt;br /&gt;
&lt;br /&gt;
== Configuring the Buildroot ==&lt;br /&gt;
&lt;br /&gt;
Configuring the Buildroot creates build infrastructure and .config file in the build directory. .config file may be written from scratch or copied from the outside source. It&#039;s a good idea to run configuration after copying external or predefined config, as newer Buildroot releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to edit existing configuration or to create it from scratch run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* Target options submenu:&lt;br /&gt;
** BR2_xtensa: must be selected when building for Xtensa&lt;br /&gt;
** BR2_XTENSA_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
** BR2_XTENSA_CUSTOM_NAME: must specify custom core variant name. This name is used to derive configuration overlay file name.&lt;br /&gt;
** BR2_XTENSA_OVERLAY_DIR: path to the directory with overlay file. May be relative to the Buildroot directory (specified as $(TOPDIR)/...) or the build directory (specified as $(BASE_DIR)/...)&lt;br /&gt;
* Toolchain submenu: select toolchain component versions and options. Many packages depend on presence of specific options, like IPv6 support or WCHAR support. Usually a package that cannot be built with current settings will indicate missing options in the menu.&lt;br /&gt;
* Target packages submenu: select individual packages and libraries that will be built and installed to the rootfs.&lt;br /&gt;
* Filesystem images submenu:&lt;br /&gt;
** BR2_TARGET_ROOTFS_CPIO: select to build CPIO image suitable for use as linux initramfs&lt;br /&gt;
** BR2_TARGET_ROOTFS_EXT2: select to build ext filesystem suitable for use with simulated block device&lt;br /&gt;
** BR2_TARGET_ROOTFS_TAR: select to build tar image, that may be unpacked and used for NFS root&lt;br /&gt;
&lt;br /&gt;
== Building buildroot ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039;&amp;lt;/code&amp;gt; to build the toolchain and root file system, or &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; toolchain&amp;lt;/code&amp;gt; to build only the toolchain.&lt;br /&gt;
&lt;br /&gt;
== Re-configuring and re-building Buildroot ==&lt;br /&gt;
&lt;br /&gt;
The Buildroot does not support uninstalling packages from its build directories. It also does not track dependencies between the built packages. The easiest way to make sure that deselected package is removed from the rootfs, or that changed toolchain option is applied to built packages is cleaning up build directory, leaving only .config in it and re-building everything from scratch.&lt;br /&gt;
&lt;br /&gt;
= Build Buildroot with Crosstool-NG =&lt;br /&gt;
&lt;br /&gt;
Using the Crosstool-NG toolchain allows to build a version of a Buildroot image based on GlibC instead of uClibc. In the current version, Buildroot cannot build Crosstool-NG for Xtensa directly, but can be configured to use it as an &#039;&#039;external&#039;&#039; toolchain. The first step is to build and install Crosstool-NG, so Buildroot can use it to compile the root file system. More information to build Crosstool-NG for Xtensa can be found under [[Crosstool-NG]]. Assuming Crosstool-NG is installed in &#039;ABSOLUTE_PATH_TO_XTOOLS&#039;, which is typically &amp;lt;code&amp;gt;$HOME/x-tools&amp;lt;/code&amp;gt;, you can make the following additional configurations changes in Buildroot:&lt;br /&gt;
&lt;br /&gt;
 Toolchain  ---&amp;gt;&lt;br /&gt;
   Toolchain type (External toolchain)&lt;br /&gt;
   Toolchain (Custom toolchain)&lt;br /&gt;
   Toolchain origin (Pre-installed toolchain)&lt;br /&gt;
   (ABSOLUTE_PATH_TO_XTOOLS) Toolchain path&lt;br /&gt;
   ($(ARCH)-unknown-linux-gnu) Toolchain prefix&lt;br /&gt;
   External toolchain C library (glibc/eglibc)&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== 2014.11 ==&lt;br /&gt;
* fix &#039;dangerous relocation: call8: call target out of range&#039; linker bug&lt;br /&gt;
* fix &#039;Error: jump target out of range; no usable trampoline found&#039; and &#039;Error: operand 1 of &#039;j&#039; has out of range &#039; assembler bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.08 ==&lt;br /&gt;
* fix xtensa linker segfault on linking linux modules&lt;br /&gt;
&lt;br /&gt;
== 2014.05 ==&lt;br /&gt;
* fixes for building with -mtext-section-literals&lt;br /&gt;
* assembler trampolines (able to assemble files with jumps longer than 128K)&lt;br /&gt;
* fixes for &#039;dangerous relocation: call8: misaligned call target&#039; and &#039;dangerous relocation: overflow after relaxation&#039; linker bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.02 ==&lt;br /&gt;
* fix overlay application to gcc&lt;br /&gt;
&lt;br /&gt;
== 2012.11 ==&lt;br /&gt;
* xtensa in the Buildroot mainline&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=754</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=754"/>
		<updated>2015-10-06T03:30:51Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add uclinux link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* for experimental uClinux code see [[uClinux]].&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[Setting_up_U-Boot|Setting up U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=UClinux&amp;diff=753</id>
		<title>UClinux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=UClinux&amp;diff=753"/>
		<updated>2015-10-06T03:28:20Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: create page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Experimental uClinux support =&lt;br /&gt;
&lt;br /&gt;
== Toolchain with uClinux support ==&lt;br /&gt;
&lt;br /&gt;
Xtensa uClinux userspace is based on bFLT executable file format.&lt;br /&gt;
&lt;br /&gt;
* gcc patch that adds xtensa*-*-uclinux* is [https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=e3c15dbe1c4cd63d906eb67c1c607cc4fab6b329 committed] into gcc-6.0 development branch and will be first released with gcc-6.1.&lt;br /&gt;
* elf2flt patch that adds Xtensa support is [http://cgit.openadk.org/cgi/cgit/elf2flt.git/commit/?id=17a2cf8c28cf13b85939b2553b8a87b16d88c94e committed into this] elf2flt repository.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel with noMMU support ==&lt;br /&gt;
&lt;br /&gt;
Linux branch with noMMU support patches, sample core and sample configuration: https://github.com/jcmvbkbc/linux-xtensa/commits/xtensa-nommu&lt;br /&gt;
&lt;br /&gt;
The patches will likely appear in Linux v4.4&lt;br /&gt;
&lt;br /&gt;
== Buildroot with noMMU support ==&lt;br /&gt;
&lt;br /&gt;
Buildroot branch with gcc and elf2flt patches, sample overlay and configuration: https://github.com/jcmvbkbc/buildroot/commits/xtensa-nommu&lt;br /&gt;
&lt;br /&gt;
== uClinux distribution for Xtensa ==&lt;br /&gt;
&lt;br /&gt;
In progress&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=752</id>
		<title>Instructions for building and booting Linux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=752"/>
		<updated>2015-10-06T03:17:50Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add &amp;#039;cores supported by linux&amp;#039;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.&lt;br /&gt;
&lt;br /&gt;
= GNU/Linux on Xtensa =&lt;br /&gt;
&lt;br /&gt;
GNU is a collection of free software that provides POSIX environment.&lt;br /&gt;
Linux is an operating system kernel.&lt;br /&gt;
In order to boot GNU/Linux OS on Xtensa the following parts are needed:&lt;br /&gt;
&lt;br /&gt;
* a board with Xtensa core supported by Linux, or Xtensa simulator&lt;br /&gt;
* bootable Linux kernel image&lt;br /&gt;
* GNU software packaged in a form suitable for booting on Linux, the so called root file system&lt;br /&gt;
* a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa cores supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
Official requirements for Xtensa core to run Linux are listed in the Xtensa OSKit Guide document.&lt;br /&gt;
The absolute minimum set of options required to run Linux is full MMU, debug option, windowed registers, one level-1 or medium level timer interrupt.&lt;br /&gt;
* See [[uClinux]] for experimental support of Xtensa cores without full MMU.&lt;br /&gt;
* Thread pointer option and conditional store option are required for running userspace with NPTL or TLS.&lt;br /&gt;
&lt;br /&gt;
== Xtensa boards supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa simulators ==&lt;br /&gt;
&lt;br /&gt;
* Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Root file system ==&lt;br /&gt;
&lt;br /&gt;
Currently we support building GNU software and packaging it into root file system with the [[Buildroot]].&lt;br /&gt;
There are several types of root file system that Linux can boot with:&lt;br /&gt;
&lt;br /&gt;
=== CPIO archive ===&lt;br /&gt;
* CPIO archive may be built into the kernel (so called &#039;built-in initramfs&#039;), the resulting single image will contain both Linux and GNU software. It&#039;s easy to boot, but in order to change anything the kernel needs to be rebuilt.&lt;br /&gt;
* CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It&#039;s harder to boot (two files instead of one), but easier to change.&lt;br /&gt;
&lt;br /&gt;
Both cases of CPIO use RAM for the root file system, so they&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== EXT2/3/4 file system image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== TAR image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== UBIFS image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Bootloader ==&lt;br /&gt;
U-Boot can be used as a bootloader on XTFPGA boards. Please see [[Setting_up_U-Boot|this]] page for more details about installing it into the daughterboard FLASH.&lt;br /&gt;
&lt;br /&gt;
== On-chip debugger ==&lt;br /&gt;
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.&lt;br /&gt;
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&#039;s Guide for more information about OCD setup and configuration.&lt;br /&gt;
&lt;br /&gt;
= Building GNU/Linux OS =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prepare the overlay ==&lt;br /&gt;
Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location.&lt;br /&gt;
Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable:&lt;br /&gt;
  $ &#039;&#039;&#039;cat &amp;gt; overlay-script&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;....&#039;&#039;&#039;&lt;br /&gt;
  ^D&lt;br /&gt;
  $ &#039;&#039;&#039;chmod +x overlay-script&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Run it and rename the resulting file:&lt;br /&gt;
  $ &#039;&#039;&#039;./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mv xtensa-overlay.tar xtensa_${XT_CORE}.tar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the toolchain and root file system ==&lt;br /&gt;
Get the buildroot git tree:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.buildroot.net/buildroot&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check out some released version:&lt;br /&gt;
  $ &#039;&#039;&#039;git checkout 2014.11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir buildroot-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build menuconfig&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot.&lt;br /&gt;
&lt;br /&gt;
Select &#039;Target Architecture&#039; = Xtensa, &#039;Target Architecture Variant&#039; = Custom Xtensa processor configuration, set &#039;Custom Xtensa processor configuration name&#039; to the contents of ${XT_CORE}, set &#039;Overlay directory for custom configuration&#039; = $(TOPDIR)/..&lt;br /&gt;
&lt;br /&gt;
Select toolchain options, packages to be built and final root file system image type.&lt;br /&gt;
&lt;br /&gt;
Build the toolchain and the root file system:&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the Linux kernel ==&lt;br /&gt;
Get stable Linux release tree:&lt;br /&gt;
  $ &#039;&#039;&#039;wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;tar -xf linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create variant directory for the specific core and copy core configuration files there:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir linux-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Select &#039;Xtensa Processor Configuration&#039; = Custom Xtensa processor configuration, set &#039;Xtensa Processor Custom Core Variant Name&#039; to the contents of ${XT_CORE}. Select desired &#039;Xtensa System Type&#039;.&lt;br /&gt;
&lt;br /&gt;
Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux.&lt;br /&gt;
&lt;br /&gt;
Build the kernel:&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Booting GNU/Linux =&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Status_of_the_Xtensa_Port&amp;diff=751</id>
		<title>Status of the Xtensa Port</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Status_of_the_Xtensa_Port&amp;diff=751"/>
		<updated>2015-10-06T02:00:13Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add ltrace to debug section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page provides additional information for software support for the Xtensa architecture. While most applications are written architecture independent, development tools and operating systems must be ported to a new processor architecture. Support for the Xtensa architecture has already been integrated in most Open Source software projects. Development trees that feed to the respective mainline repository and for new development can be found in local [http://git.linux-xtensa.org GIT] repositories. &lt;br /&gt;
&lt;br /&gt;
=== Toolchain: Compiler (GCC) and various binary utilities (binutils) ===&lt;br /&gt;
&lt;br /&gt;
All GNU toolchain tools are maintained in OpenSource and can be downloaded from the respective locations.&lt;br /&gt;
* Binutils: http://www.gnu.org/software/binutils/&lt;br /&gt;
* GCC: http://gcc.gnu.org/&lt;br /&gt;
&lt;br /&gt;
Additional information to patch these sources for a specific Xtensa processor configuration can be found under [[Toolchain and Embedded Distributions]].&lt;br /&gt;
&lt;br /&gt;
=== C-Libraries: Glibc, uClibc and uClibc-ng ===&lt;br /&gt;
&lt;br /&gt;
Xtensa has long been part of uClibc, however, there are a lot of bug fixes pending for the next release (0.9.33.3). Support for the Native Posix Thread Library (NTPL) is under development and is expected to be part of the following release. The spin-off uClibc-ng project already contains the experimental NPTL support. Development for Glibc with NPTL (older thread libraries are not supported by Glibc anymore) is also current under way. A development tree can be found in this [https://github.com/czankel/xtensa-glibc GIT] repository.&lt;br /&gt;
* uClibc: http://www.uclibc.org/&lt;br /&gt;
* GlibC: http://www.gnu.org/software/libc/&lt;br /&gt;
* uClibc-ng: http://www.uclibc-ng.org/&lt;br /&gt;
&lt;br /&gt;
=== Debugging ===&lt;br /&gt;
&lt;br /&gt;
GDB is maintained in OpenSource and support for Xtensa in other debugging tools was maintained as patches in local buildroot repositories, and are currently updated and pushed to the respective main repositories.&lt;br /&gt;
* GDB: http://www.gnu.org/software/gdb/&lt;br /&gt;
* strace: http://sourceforge.net/projects/strace/&lt;br /&gt;
* ltrace: http://ltrace.alioth.debian.org/&lt;br /&gt;
&lt;br /&gt;
=== Linux kernel ===&lt;br /&gt;
&lt;br /&gt;
Xtensa has been part of the official Linux kernel tree since 2.6.13, however, a lot of patches were maintained in a local stable tree for a long time, and are currently ported to the latest kernel tree. Features, such as large memory support and cache aliasing should be expected to hit the kernel in the 3.10/3.11 time frame. The latest version can be found at https://www.kernel.org/.&lt;br /&gt;
&lt;br /&gt;
=== Toolchain creation tools and embedded distributions (crosstool-NG, buildroot, etc) ===&lt;br /&gt;
&lt;br /&gt;
Xtensa is supported by buildroot, which can be downloaded from http://www.buildroot.net. Support for crosstool-NG has not been pushed into the official tree yet. A version can be downloaded from local [http://git.linux-xtensa.org GIT] repositories. Additional information to configure these tools for a specific Xtensa processor configuration can be found under [[Toolchain and Embedded Distributions]].&lt;br /&gt;
* Buildroot: http://www.buildroot.net&lt;br /&gt;
* Crosstool-NG: http://crosstool-ng.org/&lt;br /&gt;
* OpenADK: http://www.openadk.org/&lt;br /&gt;
&lt;br /&gt;
=== Other Projects ===&lt;br /&gt;
&lt;br /&gt;
The following list are additional projects that are architecture specific, or that have architecture specific components with additional information how to compile them for Xtensa.&lt;br /&gt;
&lt;br /&gt;
* [[LibFFI]] - LibFFI is a library that provides an interface to execute low-level functions. It is mostly used by scripting or higher-level languages, such as Python, Dalvik, etc.&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=750</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=750"/>
		<updated>2015-09-25T17:39:41Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update linux features list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[Setting_up_U-Boot|Setting up U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== Linux 4.3 ==&lt;br /&gt;
* Hardware perf counters and perf support.&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=749</id>
		<title>Xtensa on QEMU</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=749"/>
		<updated>2015-07-20T21:39:33Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add ML605/KC705 to the list of platforms&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Setting up and running Xtensa simulation on QEMU ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.qemu.org QEMU] is a free processor/machine emulator and virtualizer.&lt;br /&gt;
&lt;br /&gt;
Starting with version 1.0 QEMU offers [http://wiki.qemu.org/Features/Xtensa Xtensa architecture emulation].&lt;br /&gt;
DC232B, DC233C (LE) and fsf (BE) cores are supported on sim and LX60/LX200/ML605/KC705 platforms.&lt;br /&gt;
&lt;br /&gt;
== Getting and building QEMU ==&lt;br /&gt;
QEMU is developed using git. The main tree is located at git://git.qemu.org/qemu.git. Release tarballs and guest systems images are available at http://wiki.qemu.org/Download.&lt;br /&gt;
&lt;br /&gt;
This will make a copy of master QEMU repository, configure, build and install QEMU binaries for little-endian and big-endian targets:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.qemu.org/qemu.git&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir qemu-xtensa ; cd qemu-xtensa&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;../qemu/configure --prefix=`pwd`/root --target-list=xtensa-softmmu,xtensaeb-softmmu&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make install&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== QEMU options ==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Option !! Meaning !! Example&lt;br /&gt;
|-&lt;br /&gt;
| -M &amp;lt;machine-name&amp;gt;&lt;br /&gt;
| Emulate specific platform type. Use &#039;?&#039; to list all supported platform types.&lt;br /&gt;
| -M lx60&lt;br /&gt;
|-&lt;br /&gt;
| -cpu &amp;lt;core-name&amp;gt;&lt;br /&gt;
| Emulate specific core type. Use &#039;?&#039; to list all supported core types.&lt;br /&gt;
| -cpu dc232b&lt;br /&gt;
|-&lt;br /&gt;
| -m &amp;lt;memory size&amp;gt;&lt;br /&gt;
| Set emulated RAM size. M and G suffixes for mega- and gigabytes.&lt;br /&gt;
| -m 128M&lt;br /&gt;
|-&lt;br /&gt;
| -semihosting&lt;br /&gt;
| Enable SIMCALL instruction for the protection ring 0.&lt;br /&gt;
| -semihosting&lt;br /&gt;
|-&lt;br /&gt;
| -kernel &amp;lt;elf-image/uImage&amp;gt;&lt;br /&gt;
| Load elf-image or uImage and start emulation from its entry point. Note that image is loaded to virtual addresses it is linked for. For XTFPGA this option also chooses &#039;boot from SRAM&#039; mode, mapping SRAM to the System ROM region at physical address 0xFE000000.&lt;br /&gt;
| -kernel xtensa-2.6.29-smp/arch/xtensa/boot/Image.elf&lt;br /&gt;
|-&lt;br /&gt;
| -append &amp;lt;kernel arguments&amp;gt;&lt;br /&gt;
| (Not for sim) Wrap kernel arguments into the bootparameters block and pass pointer to it to the elf-image in a2.&lt;br /&gt;
| -append &#039;console=ttyS0 ip=dhcp root=/dev/nfs rw&#039;&lt;br /&gt;
|-&lt;br /&gt;
| -initrd &amp;lt;initrd-image&amp;gt;&lt;br /&gt;
| (Not for sim) Load initial RAM disk image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -initrd buildroot-build/images/rootfs.cpio&lt;br /&gt;
|-&lt;br /&gt;
| -dtb &amp;lt;Device-Tree-Blob&amp;gt;&lt;br /&gt;
| (Not for sim) Load DTB image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -dtb xtensa-build/arch/xtensa/boot/dts/kc705.dtb&lt;br /&gt;
|-&lt;br /&gt;
| -pflash &amp;lt;flash-image&amp;gt;&lt;br /&gt;
| (Not for sim) Mount flash-image as a system FLASH. Note that image size must match platform FLASH size (4MB for LX60, 16MB for LX200 and ML605, 128MB for KC705).&lt;br /&gt;
| -pflash u-boot.dc232b_xtav200.flash&lt;br /&gt;
|-&lt;br /&gt;
| -net nic,&amp;lt;nic-parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Set network interface parameters.&lt;br /&gt;
| -net nic,vlan=0&lt;br /&gt;
|-&lt;br /&gt;
| -net user,&amp;lt;SLIRP parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Use the user mode network stack. SLIRP parameters may be used to tune built-in DHCP and TFTP servers.&lt;br /&gt;
| -net user,vlan=0,tftp=.,hostname=dc232b-lx200&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== sim platform ==&lt;br /&gt;
&lt;br /&gt;
The sim platform is modelled after Tensilica ISS. It may run ELF images built for ISS, see e.g. [[Buildroot_Build_Instructions#Build_and_Run_a_Linux_Kernel_on_the_Instruction_Set_Simulator_(ISS)|Build and Run a Linux Kernel on the Instruction Set Simulator (ISS)]].&lt;br /&gt;
There&#039;s only SIMCALL external interface available for the sim machine. To avoid console interference with QEMU monitor, monitor should be disabled with -monitor null or moved to network interface with e.g. -monitor tcp::1236,telnet,server,nowait.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M sim -m 128M -semihosting -nographic -monitor null \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel sim-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since the QEMU doesn&#039;t manage terminal settings in semihosting mode, ^C and other terminal control codes interrupt QEMU instead of its guest. stty raw may be used to set up terminal not to terminate QEMU.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA (LX60/LX200/ML605/KC705/...) platforms ==&lt;br /&gt;
&lt;br /&gt;
XTFPGA platform emulates system RAM, board-specific FPGA, UART, OpenCores 10/100 Mbit Ethernet MAC, National Semiconductors DP83848C 10/100 PHY and parallel FLASH.&lt;br /&gt;
The platform may boot from either SRAM (when -kernel option is specified, SRAM is mapped to the System ROM region and ELF image is loaded) or from FLASH.&lt;br /&gt;
&lt;br /&gt;
NFS root export record for user network (there&#039;s no way to specify root-path option for the QEMU builtin DHCP server. Unless kernel parameter &#039;nfsroot&#039; is given, you&#039;ll have to put the rootfs to /tftpboot/&amp;lt;hostname&amp;gt;):&lt;br /&gt;
  /tftpboot/      127.0.0.1(rw,no_root_squash,insecure)&lt;br /&gt;
&lt;br /&gt;
Booting linux image from SRAM (FLASH not mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel lx60-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting u-boot image from SRAM (empty FLASH image is created and mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;head -c 16M /dev/zero &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
In this scenario binary u-boot image may be downloaded from TFTP and copied to the FLASH as described [[Setting_up_U-Boot|here]].&lt;br /&gt;
&lt;br /&gt;
Alternatively FLASH image containing u-boot may be preformatted and QEMU may be booted from it:&lt;br /&gt;
  $ &#039;&#039;&#039;cat u-boot-xtensa.git/u-boot.bin.dc232b_xtav200 /dev/zero | head -c 16M &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
(Note that KC705 expects bootloader to be at the offset 0x06000000 in the FLASH, unlike the older boards that boot at offset 0).&lt;br /&gt;
&lt;br /&gt;
== Debugging with QEMU ==&lt;br /&gt;
=== GDB ===&lt;br /&gt;
There&#039;s builtin GDB server in the QEMU. -s command line switch activates it on the address 0.0.0.0:1234 (-gdb tcp:&amp;lt;ip&amp;gt;:&amp;lt;port&amp;gt; may be used instead of -s to change address and port to listen), -S switch stops QEMU at the first guest instruction waiting for &#039;continue&#039; command from gdb.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -M lx200 -nographic -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200 -s -S&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default xtensa gdb may only access unprivileged core registers. To allow access to all available registers ./gdb/xtensa-config.c needs to be modified, marking privileged registers as non-privileged. If [https://github.com/jcmvbkbc/xtensa-toolchain-build these scripts] are used to build the toolchain, the fixup-gdb.sh step does that.&lt;br /&gt;
&lt;br /&gt;
GDB breakpoints, watchpoints, single-stepping and other debugging features work as usual.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xtensa-dc232b-elf-gdb&#039;&#039;&#039;&lt;br /&gt;
  GNU gdb (GDB) 7.3.50.20110709-cvs&lt;br /&gt;
  Copyright (C) 2011 Free Software Foundation, Inc.&lt;br /&gt;
  License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;&lt;br /&gt;
  This is free software: you are free to change and redistribute it.&lt;br /&gt;
  There is NO WARRANTY, to the extent permitted by law.  Type &amp;quot;show copying&amp;quot;&lt;br /&gt;
  and &amp;quot;show warranty&amp;quot; for details.&lt;br /&gt;
  This GDB was configured as &amp;quot;--host=x86_64-unknown-linux-gnu --target=xtensa-dc232b-elf&amp;quot;.&lt;br /&gt;
  For bug reporting instructions, please see:&lt;br /&gt;
  &amp;lt;http://www.gnu.org/software/gdb/bugs/&amp;gt;.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;target remote 127.0.0.1:1234&#039;&#039;&#039;&lt;br /&gt;
  Remote debugging using 127.0.0.1:1234&lt;br /&gt;
  0xfe000000 in ?? ()&lt;br /&gt;
  (gdb) &#039;&#039;&#039;symbol-file u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
  Reading symbols from u-boot-xtensa.git/u-boot.dc232b_xtav200...done.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;x/10i $pc&#039;&#039;&#039;&lt;br /&gt;
  =&amp;gt; 0xfe000000 &amp;lt;_ResetVector&amp;gt;:   j       0xfe00000c &amp;lt;_ResetVector+12&amp;gt;&lt;br /&gt;
     0xfe000003 &amp;lt;_ResetVector+3&amp;gt;: break   0, 0&lt;br /&gt;
     0xfe000006 &amp;lt;_ResetVector+6&amp;gt;: excw&lt;br /&gt;
     0xfe000009 &amp;lt;_ResetVector+9&amp;gt;: .byte 0xff&lt;br /&gt;
     0xfe00000a &amp;lt;_ResetVector+10&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000b &amp;lt;_ResetVector+11&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000c &amp;lt;_ResetVector+12&amp;gt;:        l32r    a2, 0xfe000004 &amp;lt;_ResetVector+4&amp;gt;&lt;br /&gt;
     0xfe00000f &amp;lt;_ResetVector+15&amp;gt;:        jx      a2&lt;br /&gt;
     0xfe000012 &amp;lt;_ResetVector+18&amp;gt;:        ill&lt;br /&gt;
     0xfe000015 &amp;lt;_ResetVector+21&amp;gt;:        subx2   a0, a0, a0&lt;br /&gt;
  (gdb) &#039;&#039;&#039;si&#039;&#039;&#039;&lt;br /&gt;
  69      1:      l32r    a2, 2b&lt;br /&gt;
  (gdb)&lt;br /&gt;
&lt;br /&gt;
QEMU monitor commands may be invoked via gdb monitor command:&lt;br /&gt;
&lt;br /&gt;
  (gdb) &#039;&#039;&#039;monitor info mtree&#039;&#039;&#039;&lt;br /&gt;
  memory&lt;br /&gt;
  00000000-fffffffe (prio 0): system&lt;br /&gt;
    00000000-07ffffff (prio 0): lx60.dram&lt;br /&gt;
    f0000000-fdffffff (prio 0): lx60.io&lt;br /&gt;
      fd020000-fd02ffff (prio 0): lx60.fpga&lt;br /&gt;
      fd030000-fd030053 (prio 0): open_eth.regs&lt;br /&gt;
      fd030400-fd0307ff (prio 0): open_eth.desc&lt;br /&gt;
      fd050020-fd05003f (prio 0): serial&lt;br /&gt;
      fd800000-fd803fff (prio 0): open_eth.ram&lt;br /&gt;
    f8000000-f83fffff (prio 0): lx60.io.flash&lt;br /&gt;
    fe000000-fe01ffff (prio 0): lx60.sram&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
QEMU can log guest CPU state/opcode translation during execution. Invalid, reserved and not implemented opcodes, invalid conditions for certain opcodes, reserved/not implemented SR access, page table lookups, interrupt requests are all logged with this method. Logging may be enabled with -d&amp;lt;logging types&amp;gt; command line option, or with monitor command &#039;log &amp;lt;logging types&amp;gt;&#039;. By default logs go to the file /tmp/qemu.log. Verbose logging slows down execution significantly, it may be useful to control logging from GDB, enabling it via monitor command for the specific code blocks.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Logging type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| none&lt;br /&gt;
| disable logging&lt;br /&gt;
|-&lt;br /&gt;
| out_asm&lt;br /&gt;
| show generated host assembly code for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| in_asm&lt;br /&gt;
| show target assembly code for each compiled TB (not implemented for Xtensa)&lt;br /&gt;
|-&lt;br /&gt;
| op&lt;br /&gt;
| show micro ops for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| op_opt&lt;br /&gt;
| show micro ops after liveness analysis&lt;br /&gt;
|-&lt;br /&gt;
| int&lt;br /&gt;
| show interrupts/exceptions in short format&lt;br /&gt;
|-&lt;br /&gt;
| exec&lt;br /&gt;
| show trace before each executed TB&lt;br /&gt;
|-&lt;br /&gt;
| cpu&lt;br /&gt;
| show CPU state before block translation&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Extending QEMU ==&lt;br /&gt;
&lt;br /&gt;
Starting with QEMU-2.2 there&#039;s a script [https://github.com/OSLL/qemu-xtensa/blob/master/target-xtensa/import_core.sh qemu/target-xtensa/import_core.sh] that adds new core to QEMU from the xtensa configuration overlay.&lt;br /&gt;
&lt;br /&gt;
To manually extend QEMU with new xtensa core an appropriate XtensaConfig structure must be registered. This structure may be mostly automatically filled in from the overlay data, see mainline commits [http://jcmvbkbc.spb.ru/git/?p=dumb/qemu-xtensa.git;a=commitdiff;h=53add759be1a39063cfc52ca2a6d0fcdd1091697 53add759be1a39063cfc52ca2a6d0fcdd1091697] (target-xtensa: add dc232b core) and [http://jcmvbkbc.spb.ru/git/?p=dumb/qemu-xtensa.git;a=commitdiff;h=935f7a2b428f71a40e985f09955bccaaf09518fa 935f7a2b428f71a40e985f09955bccaaf09518fa] (target-xtensa: add fsf core) for example:&lt;br /&gt;
* target-xtensa/core-&amp;lt;core name&amp;gt;/core-isa.h is a copy of config/core.h from xtensa-config-overlay.tar.gz;&lt;br /&gt;
* target-xtensa/core-&amp;lt;core name&amp;gt;/gdb-config.c is made from gdb/xtensa-config.c from xtensa-config-overlay.tar.gz, only rmap entries for PC, A*, AR*, SR*, UR* are retained;&lt;br /&gt;
* XtensaConfig::gdb_regmap::num_regs is the total number of rmap entries in the gdb-config.c;&lt;br /&gt;
* XtensaConfig::gdb_regmap::num_core_regs is the number of contiguous non-privileged ((flags &amp;amp; 1) == 0) rmap entries in the gdb-config.c.&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=748</id>
		<title>Xtensa on QEMU</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Xtensa_on_QEMU&amp;diff=748"/>
		<updated>2015-07-20T21:24:51Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: fix &amp;#039;extending QEMU&amp;#039; paragraph&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Setting up and running Xtensa simulation on QEMU ==&lt;br /&gt;
&lt;br /&gt;
[http://wiki.qemu.org QEMU] is a free processor/machine emulator and virtualizer.&lt;br /&gt;
&lt;br /&gt;
Starting with version 1.0 QEMU offers [http://wiki.qemu.org/Features/Xtensa Xtensa architecture emulation].&lt;br /&gt;
DC232B, DC233C (LE) and fsf (BE) cores are supported on sim and LX60/LX200 platforms.&lt;br /&gt;
&lt;br /&gt;
== Getting and building QEMU ==&lt;br /&gt;
QEMU is developed using git. The main tree is located at git://git.qemu.org/qemu.git. Release tarballs and guest systems images are available at http://wiki.qemu.org/Download.&lt;br /&gt;
&lt;br /&gt;
This will make a copy of master QEMU repository, configure, build and install QEMU binaries for little-endian and big-endian targets:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.qemu.org/qemu.git&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir qemu-xtensa ; cd qemu-xtensa&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;../qemu/configure --prefix=`pwd`/root --target-list=xtensa-softmmu,xtensaeb-softmmu&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make install&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== QEMU options ==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Option !! Meaning !! Example&lt;br /&gt;
|-&lt;br /&gt;
| -M &amp;lt;machine-name&amp;gt;&lt;br /&gt;
| Emulate specific platform type. Use &#039;?&#039; to list all supported platform types.&lt;br /&gt;
| -M lx60&lt;br /&gt;
|-&lt;br /&gt;
| -cpu &amp;lt;core-name&amp;gt;&lt;br /&gt;
| Emulate specific core type. Use &#039;?&#039; to list all supported core types.&lt;br /&gt;
| -cpu dc232b&lt;br /&gt;
|-&lt;br /&gt;
| -m &amp;lt;memory size&amp;gt;&lt;br /&gt;
| Set emulated RAM size. M and G suffixes for mega- and gigabytes.&lt;br /&gt;
| -m 128M&lt;br /&gt;
|-&lt;br /&gt;
| -semihosting&lt;br /&gt;
| Enable SIMCALL instruction for the protection ring 0.&lt;br /&gt;
| -semihosting&lt;br /&gt;
|-&lt;br /&gt;
| -kernel &amp;lt;elf-image/uImage&amp;gt;&lt;br /&gt;
| Load elf-image or uImage and start emulation from its entry point. Note that image is loaded to virtual addresses it is linked for. For XTFPGA this option also chooses &#039;boot from SRAM&#039; mode, mapping SRAM to the System ROM region at physical address 0xFE000000.&lt;br /&gt;
| -kernel xtensa-2.6.29-smp/arch/xtensa/boot/Image.elf&lt;br /&gt;
|-&lt;br /&gt;
| -append &amp;lt;kernel arguments&amp;gt;&lt;br /&gt;
| (Not for sim) Wrap kernel arguments into the bootparameters block and pass pointer to it to the elf-image in a2.&lt;br /&gt;
| -append &#039;console=ttyS0 ip=dhcp root=/dev/nfs rw&#039;&lt;br /&gt;
|-&lt;br /&gt;
| -initrd &amp;lt;initrd-image&amp;gt;&lt;br /&gt;
| (Not for sim) Load initial RAM disk image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -initrd buildroot-build/images/rootfs.cpio&lt;br /&gt;
|-&lt;br /&gt;
| -dtb &amp;lt;Device-Tree-Blob&amp;gt;&lt;br /&gt;
| (Not for sim) Load DTB image and pass its location to kernel in the bootparameters block.&lt;br /&gt;
| -dtb xtensa-build/arch/xtensa/boot/dts/kc705.dtb&lt;br /&gt;
|-&lt;br /&gt;
| -pflash &amp;lt;flash-image&amp;gt;&lt;br /&gt;
| (Not for sim) Mount flash-image as a system FLASH. Note that image size must match platform FLASH size (4MB for LX60, 16MB for LX200, 32MB for ML605, 128MB for KC705).&lt;br /&gt;
| -pflash u-boot.dc232b_xtav200.flash&lt;br /&gt;
|-&lt;br /&gt;
| -net nic,&amp;lt;nic-parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Set network interface parameters.&lt;br /&gt;
| -net nic,vlan=0&lt;br /&gt;
|-&lt;br /&gt;
| -net user,&amp;lt;SLIRP parameters&amp;gt;&lt;br /&gt;
| (Not for sim) Use the user mode network stack. SLIRP parameters may be used to tune built-in DHCP and TFTP servers.&lt;br /&gt;
| -net user,vlan=0,tftp=.,hostname=dc232b-lx200&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== sim platform ==&lt;br /&gt;
&lt;br /&gt;
The sim platform is modelled after Tensilica ISS. It may run ELF images built for ISS, see e.g. [[Buildroot_Build_Instructions#Build_and_Run_a_Linux_Kernel_on_the_Instruction_Set_Simulator_(ISS)|Build and Run a Linux Kernel on the Instruction Set Simulator (ISS)]].&lt;br /&gt;
There&#039;s only SIMCALL external interface available for the sim machine. To avoid console interference with QEMU monitor, monitor should be disabled with -monitor null or moved to network interface with e.g. -monitor tcp::1236,telnet,server,nowait.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M sim -m 128M -semihosting -nographic -monitor null \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel sim-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Since the QEMU doesn&#039;t manage terminal settings in semihosting mode, ^C and other terminal control codes interrupt QEMU instead of its guest. stty raw may be used to set up terminal not to terminate QEMU.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA (LX60/LX200/ML605/KC705/...) platforms ==&lt;br /&gt;
&lt;br /&gt;
XTFPGA platform emulates system RAM, board-specific FPGA, UART, OpenCores 10/100 Mbit Ethernet MAC, National Semiconductors DP83848C 10/100 PHY and parallel FLASH.&lt;br /&gt;
The platform may boot from either SRAM (when -kernel option is specified, SRAM is mapped to the System ROM region and ELF image is loaded) or from FLASH.&lt;br /&gt;
&lt;br /&gt;
NFS root export record for user network (there&#039;s no way to specify root-path option for the QEMU builtin DHCP server. Unless kernel parameter &#039;nfsroot&#039; is given, you&#039;ll have to put the rootfs to /tftpboot/&amp;lt;hostname&amp;gt;):&lt;br /&gt;
  /tftpboot/      127.0.0.1(rw,no_root_squash,insecure)&lt;br /&gt;
&lt;br /&gt;
Booting linux image from SRAM (FLASH not mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel lx60-2.6.29-smp/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting u-boot image from SRAM (empty FLASH image is created and mapped):&lt;br /&gt;
  $ &#039;&#039;&#039;head -c 16M /dev/zero &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
In this scenario binary u-boot image may be downloaded from TFTP and copied to the FLASH as described [[Setting_up_U-Boot|here]].&lt;br /&gt;
&lt;br /&gt;
Alternatively FLASH image containing u-boot may be preformatted and QEMU may be booted from it:&lt;br /&gt;
  $ &#039;&#039;&#039;cat u-boot-xtensa.git/u-boot.bin.dc232b_xtav200 /dev/zero | head -c 16M &amp;gt; lx200.flash&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -cpu dc232b -M lx200 -m 96M -nographic \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 -pflash lx200.flash&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
(Note that KC705 expects bootloader to be at the offset 0x06000000 in the FLASH, unlike the older boards that boot at offset 0).&lt;br /&gt;
&lt;br /&gt;
== Debugging with QEMU ==&lt;br /&gt;
=== GDB ===&lt;br /&gt;
There&#039;s builtin GDB server in the QEMU. -s command line switch activates it on the address 0.0.0.0:1234 (-gdb tcp:&amp;lt;ip&amp;gt;:&amp;lt;port&amp;gt; may be used instead of -s to change address and port to listen), -S switch stops QEMU at the first guest instruction waiting for &#039;continue&#039; command from gdb.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;qemu-system-xtensa -M lx200 -nographic -pflash lx200.flash \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-net nic,vlan=0 -net user,vlan=0,tftp=.,hostname=dc232b-lx200 \&#039;&#039;&#039;&lt;br /&gt;
    &#039;&#039;&#039;-kernel u-boot-xtensa.git/u-boot.dc232b_xtav200 -s -S&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
By default xtensa gdb may only access unprivileged core registers. To allow access to all available registers ./gdb/xtensa-config.c needs to be modified, marking privileged registers as non-privileged. If [https://github.com/jcmvbkbc/xtensa-toolchain-build these scripts] are used to build the toolchain, the fixup-gdb.sh step does that.&lt;br /&gt;
&lt;br /&gt;
GDB breakpoints, watchpoints, single-stepping and other debugging features work as usual.&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xtensa-dc232b-elf-gdb&#039;&#039;&#039;&lt;br /&gt;
  GNU gdb (GDB) 7.3.50.20110709-cvs&lt;br /&gt;
  Copyright (C) 2011 Free Software Foundation, Inc.&lt;br /&gt;
  License GPLv3+: GNU GPL version 3 or later &amp;lt;http://gnu.org/licenses/gpl.html&amp;gt;&lt;br /&gt;
  This is free software: you are free to change and redistribute it.&lt;br /&gt;
  There is NO WARRANTY, to the extent permitted by law.  Type &amp;quot;show copying&amp;quot;&lt;br /&gt;
  and &amp;quot;show warranty&amp;quot; for details.&lt;br /&gt;
  This GDB was configured as &amp;quot;--host=x86_64-unknown-linux-gnu --target=xtensa-dc232b-elf&amp;quot;.&lt;br /&gt;
  For bug reporting instructions, please see:&lt;br /&gt;
  &amp;lt;http://www.gnu.org/software/gdb/bugs/&amp;gt;.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;target remote 127.0.0.1:1234&#039;&#039;&#039;&lt;br /&gt;
  Remote debugging using 127.0.0.1:1234&lt;br /&gt;
  0xfe000000 in ?? ()&lt;br /&gt;
  (gdb) &#039;&#039;&#039;symbol-file u-boot-xtensa.git/u-boot.dc232b_xtav200&#039;&#039;&#039;&lt;br /&gt;
  Reading symbols from u-boot-xtensa.git/u-boot.dc232b_xtav200...done.&lt;br /&gt;
  (gdb) &#039;&#039;&#039;x/10i $pc&#039;&#039;&#039;&lt;br /&gt;
  =&amp;gt; 0xfe000000 &amp;lt;_ResetVector&amp;gt;:   j       0xfe00000c &amp;lt;_ResetVector+12&amp;gt;&lt;br /&gt;
     0xfe000003 &amp;lt;_ResetVector+3&amp;gt;: break   0, 0&lt;br /&gt;
     0xfe000006 &amp;lt;_ResetVector+6&amp;gt;: excw&lt;br /&gt;
     0xfe000009 &amp;lt;_ResetVector+9&amp;gt;: .byte 0xff&lt;br /&gt;
     0xfe00000a &amp;lt;_ResetVector+10&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000b &amp;lt;_ResetVector+11&amp;gt;:        .byte 0xff&lt;br /&gt;
     0xfe00000c &amp;lt;_ResetVector+12&amp;gt;:        l32r    a2, 0xfe000004 &amp;lt;_ResetVector+4&amp;gt;&lt;br /&gt;
     0xfe00000f &amp;lt;_ResetVector+15&amp;gt;:        jx      a2&lt;br /&gt;
     0xfe000012 &amp;lt;_ResetVector+18&amp;gt;:        ill&lt;br /&gt;
     0xfe000015 &amp;lt;_ResetVector+21&amp;gt;:        subx2   a0, a0, a0&lt;br /&gt;
  (gdb) &#039;&#039;&#039;si&#039;&#039;&#039;&lt;br /&gt;
  69      1:      l32r    a2, 2b&lt;br /&gt;
  (gdb)&lt;br /&gt;
&lt;br /&gt;
QEMU monitor commands may be invoked via gdb monitor command:&lt;br /&gt;
&lt;br /&gt;
  (gdb) &#039;&#039;&#039;monitor info mtree&#039;&#039;&#039;&lt;br /&gt;
  memory&lt;br /&gt;
  00000000-fffffffe (prio 0): system&lt;br /&gt;
    00000000-07ffffff (prio 0): lx60.dram&lt;br /&gt;
    f0000000-fdffffff (prio 0): lx60.io&lt;br /&gt;
      fd020000-fd02ffff (prio 0): lx60.fpga&lt;br /&gt;
      fd030000-fd030053 (prio 0): open_eth.regs&lt;br /&gt;
      fd030400-fd0307ff (prio 0): open_eth.desc&lt;br /&gt;
      fd050020-fd05003f (prio 0): serial&lt;br /&gt;
      fd800000-fd803fff (prio 0): open_eth.ram&lt;br /&gt;
    f8000000-f83fffff (prio 0): lx60.io.flash&lt;br /&gt;
    fe000000-fe01ffff (prio 0): lx60.sram&lt;br /&gt;
&lt;br /&gt;
=== Logging ===&lt;br /&gt;
&lt;br /&gt;
QEMU can log guest CPU state/opcode translation during execution. Invalid, reserved and not implemented opcodes, invalid conditions for certain opcodes, reserved/not implemented SR access, page table lookups, interrupt requests are all logged with this method. Logging may be enabled with -d&amp;lt;logging types&amp;gt; command line option, or with monitor command &#039;log &amp;lt;logging types&amp;gt;&#039;. By default logs go to the file /tmp/qemu.log. Verbose logging slows down execution significantly, it may be useful to control logging from GDB, enabling it via monitor command for the specific code blocks.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Logging type !! Meaning&lt;br /&gt;
|-&lt;br /&gt;
| none&lt;br /&gt;
| disable logging&lt;br /&gt;
|-&lt;br /&gt;
| out_asm&lt;br /&gt;
| show generated host assembly code for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| in_asm&lt;br /&gt;
| show target assembly code for each compiled TB (not implemented for Xtensa)&lt;br /&gt;
|-&lt;br /&gt;
| op&lt;br /&gt;
| show micro ops for each compiled TB&lt;br /&gt;
|-&lt;br /&gt;
| op_opt&lt;br /&gt;
| show micro ops after liveness analysis&lt;br /&gt;
|-&lt;br /&gt;
| int&lt;br /&gt;
| show interrupts/exceptions in short format&lt;br /&gt;
|-&lt;br /&gt;
| exec&lt;br /&gt;
| show trace before each executed TB&lt;br /&gt;
|-&lt;br /&gt;
| cpu&lt;br /&gt;
| show CPU state before block translation&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Extending QEMU ==&lt;br /&gt;
&lt;br /&gt;
Starting with QEMU-2.2 there&#039;s a script [https://github.com/OSLL/qemu-xtensa/blob/master/target-xtensa/import_core.sh qemu/target-xtensa/import_core.sh] that adds new core to QEMU from the xtensa configuration overlay.&lt;br /&gt;
&lt;br /&gt;
To manually extend QEMU with new xtensa core an appropriate XtensaConfig structure must be registered. This structure may be mostly automatically filled in from the overlay data, see mainline commits [http://jcmvbkbc.spb.ru/git/?p=dumb/qemu-xtensa.git;a=commitdiff;h=53add759be1a39063cfc52ca2a6d0fcdd1091697 53add759be1a39063cfc52ca2a6d0fcdd1091697] (target-xtensa: add dc232b core) and [http://jcmvbkbc.spb.ru/git/?p=dumb/qemu-xtensa.git;a=commitdiff;h=935f7a2b428f71a40e985f09955bccaaf09518fa 935f7a2b428f71a40e985f09955bccaaf09518fa] (target-xtensa: add fsf core) for example:&lt;br /&gt;
* target-xtensa/core-&amp;lt;core name&amp;gt;/core-isa.h is a copy of config/core.h from xtensa-config-overlay.tar.gz;&lt;br /&gt;
* target-xtensa/core-&amp;lt;core name&amp;gt;/gdb-config.c is made from gdb/xtensa-config.c from xtensa-config-overlay.tar.gz, only rmap entries for PC, A*, AR*, SR*, UR* are retained;&lt;br /&gt;
* XtensaConfig::gdb_regmap::num_regs is the total number of rmap entries in the gdb-config.c;&lt;br /&gt;
* XtensaConfig::gdb_regmap::num_core_regs is the number of contiguous non-privileged ((flags &amp;amp; 1) == 0) rmap entries in the gdb-config.c.&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=747</id>
		<title>Linux Kernel</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Linux_Kernel&amp;diff=747"/>
		<updated>2015-06-25T04:13:02Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: update linux features list&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Getting linux kernel sources =&lt;br /&gt;
Now that linux mainline has up-to-date xtensa support kernel.org is the primary place to go for xtensa linux.&lt;br /&gt;
Depending on whether kernel tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest linux release archive: &#039;mainline&#039; at the https://www.kernel.org/ points to it. May be buggy though.&lt;br /&gt;
* latest stable release archive: &#039;stable&#039; at the https://www.kernel.org/ points to it. The best choice usually.&lt;br /&gt;
* mainline linux git tree: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
* stable linux git tree: https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/ . Use git clone with one of the URLs at that page to clone it.&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
= Adding specific processor configuration =&lt;br /&gt;
Note that the Xtensa port of Linux uses the terminology &#039;&#039;variant&#039;&#039; to describe a processor configuration. The steps involved adding a processor configuration are:&lt;br /&gt;
&lt;br /&gt;
# Create a new directory for the processor &#039;&#039;variant&#039;&#039; and copy a set of configuration files that describes the processor to that directory.&lt;br /&gt;
# When configuring the kernel set .config variable CONFIG_XTENSA_VARIANT_CUSTOM_NAME to the name of used variant.&lt;br /&gt;
&lt;br /&gt;
All processor configuration specific sources and header files are located in arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039; for source files, and arch/xtensa/variants/&#039;&#039;variant-name&#039;&#039;/include/variant for header files. The include directory typically contains at least the following three files that describe the processor configuration:&lt;br /&gt;
&lt;br /&gt;
* tie.h - describing custom defined TIE registers&lt;br /&gt;
* tie-asm.h - macros to access additional TIE registers&lt;br /&gt;
* core.h - describing various processor configurations, such as cache sizes, register options, etc.&lt;br /&gt;
&lt;br /&gt;
All processor configurations provide a set of these files as part of the &#039;&#039;overlay&#039;&#039; provided by Tensilica.&lt;br /&gt;
&lt;br /&gt;
If we want to add another processor, we have to create the following directory and copy the three configurations file to that directory:&lt;br /&gt;
&lt;br /&gt;
 mkdir -p arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
 cp tie.h tie-asm.h core.h arch/xtensa/variants/MyCore/include/variant&lt;br /&gt;
&lt;br /&gt;
= Configuring and building the kernel =&lt;br /&gt;
To build the kernel a toolchain for the target variant is needed: gcc (it doesn&#039;t need to have libc) and binutils. Currently the kernel can not be built with xcc. The toolchain may be built with [[crosstool-NG]] or [[buildroot]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Define CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; environment variable to specify cross-compiler to be used. &#039;&#039;cross-compiler-spec&#039;&#039; is a path to cross-compiler binaries plus cross-compiler name up to its last component (e.g. if your cross-compiler is /opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-gcc then specify &#039;&#039;&#039;CROSS_COMPILE=/opt/xtensa/tools/fsf/bin/xtensa-fsf-elf-&#039;&#039;&#039; to use it).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The kernel may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree kernel configuration/building.&lt;br /&gt;
&lt;br /&gt;
== Configuring the kernel ==&lt;br /&gt;
Configuring the kernel creates build infrastructure and .config file in the build directory. .config file may be written from scratch, copied from the outside source or taken from a predefined configuration and edited. For a list of predefined configurations see contents of directory arch/xtensa/configs. It&#039;s a good idea to run configuration after copying external or predefined config, as newer kernel releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to use predefined .config run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; &#039;&#039;predefined_config_name&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
* to edit existing configuration run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_CUSTOM_NAME: must specify custom core variant name&lt;br /&gt;
* CONFIG_XTENSA_VARIANT_MMU: if set to &#039;N&#039; will build noMMU kernel even when core variant actually supports MMU. Should always be set for MMUv2 cores.&lt;br /&gt;
* CONFIG_HAVE_SMP: must always be set correctly, as presence of MX interrupt distributor affects external interrupts numbering.&lt;br /&gt;
* CONFIG_INITIALIZE_XTENSA_MMU_INSIDE_VMLINUX: controls whether uImage will reinitialize memory mapping. Should be set for noMMU and MMUv3 cores, unless MMU is fully initialized by uBoot. Ignored for MMUv2 cores. Has no effect for Image.elf, as it has to initialize MMU either in reset vector or in vmlinux.&lt;br /&gt;
* XTENSA_PLATFORM_*: must specify target platform. xtensa currently does not support multiplatform kernels.&lt;br /&gt;
* CONFIG_CMDLINE: default kernel command line. Gets overridden by command line specified in the device tree (built-in or externally loaded) or passed from the bootloader.&lt;br /&gt;
* BUILTIN_DTB: default kernel device tree. Only used when device tree is not supplied by the bootloader.&lt;br /&gt;
&lt;br /&gt;
* CONFIG_DEVTMPFS: enables kernel self-maintained /dev filesystem.&lt;br /&gt;
* CONFIG_SERIAL_OF_PLATFORM: enables UART driver that may be instantiated from the device tree.&lt;br /&gt;
* CONFIG_LD_NO_RELAX: disables link-time relaxation at kernel build. This is useful against linker relaxation bugs and currently speeds up the build significantly.&lt;br /&gt;
&lt;br /&gt;
== Building the kernel ==&lt;br /&gt;
&lt;br /&gt;
* to build kernel and modules run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; all&#039;&#039;&#039;&lt;br /&gt;
* to build only the kernel run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; zImage&#039;&#039;&#039;&lt;br /&gt;
* to install kernel modules into &#039;&#039;modules-dir&#039;&#039; run &#039;&#039;&#039;ARCH=xtensa CROSS_COMPILE=&#039;&#039;cross-compiler-spec&#039;&#039; INSTALL_MOD_PATH=&#039;&#039;modules-dir&#039;&#039; make O=&#039;&#039;build-dir-path&#039;&#039; modules_install&#039;&#039;&#039;&lt;br /&gt;
* all commands supported by kernel build system may be listed with &#039;&#039;&#039;ARCH=xtensa make help&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The resulting binaries are located relatively to the &#039;&#039;build-dir-path&#039;&#039;:&lt;br /&gt;
* vmlinux: kernel ELF image, useful for debugging.&lt;br /&gt;
* arch/xtensa/boot/Image.elf: kernel with reset vector handler, may be used with xt-ocd or QEMU.&lt;br /&gt;
* arch/xtensa/boot/uImage: kernel image for uBoot, may as well be used with QEMU.&lt;br /&gt;
&lt;br /&gt;
Built modules are located in their respective directories. &lt;br /&gt;
&lt;br /&gt;
= Booting the kernel =&lt;br /&gt;
== ISS platform ==&lt;br /&gt;
Kernels built for ISS are only bootable on Xtensa ISS (xt-run) or on QEMU. Neither xt-run nor QEMU can pass parameters to the ISS kernel, so normally it should have everything built-in: kernel command line and possibly initramfs. The easiest way to generate initramfs cpio archive is by setting BR2_TARGET_ROOTFS_CPIO to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
The kernel can also be configured to use simdisk, which is a host file with a file system image for the guest: see kernel configuration parameters CONFIG_BLK_DEV_SIMDISK and CONFIG_SIMDISK0_FILENAME. If CONFIG_SIMDISK0_FILENAME is a relative path it is relative to the current directory of the running simulator. The easiest way to generate file system image is by setting BR2_TARGET_ROOTFS_EXT2 to y in the buildroot configuration.&lt;br /&gt;
&lt;br /&gt;
Running linux in Xtensa ISS:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-run --turbo --memlimit=128 &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
Since xt-run doesn&#039;t manage terminal settings, ^C and other terminal control codes interrupt xt-run instead of its guest. &#039;&#039;&#039;stty raw&#039;&#039;&#039; may be used to set up terminal not to terminate xt-run.&lt;br /&gt;
&lt;br /&gt;
Running linux in QEMU: see [[Xtensa_on_QEMU#sim_platform|QEMU reference]] page.&lt;br /&gt;
&lt;br /&gt;
== XTFPGA platform ==&lt;br /&gt;
XTFPGA is a collective name for FPGA boards capable of running Xtensa bitstream: LX60, LX110, LX200, ML605 and KC705.&lt;br /&gt;
&lt;br /&gt;
Kernels built for XTFPGA may be booted on FPGA board and on QEMU (see [[Xtensa_on_QEMU#XTFPGA_.28LX60.2FLX200.2FML605.2FKC705.2F....29_platforms|QEMU reference]] page on how to do it).&lt;br /&gt;
&lt;br /&gt;
There are two supported ways of booting linux on FPGA board: with xt-ocd and with uBoot.&lt;br /&gt;
&lt;br /&gt;
=== Booting with xt-ocd ===&lt;br /&gt;
To use xt-ocd Xtensa tools need to be installed, boot from flash disabled on the board (refer to the specific board prototyping guide for the location of corresponding DIP switch), JTAG probe connected to the board and topology.xml file set up. Please refer to the Tensilica On Chip Debugging Guide (onchip_debug_guide.pdf) for the list of supported probes and setup instructions.&lt;br /&gt;
&lt;br /&gt;
Sample topology.xml for the KC705 daughterboard built-in USB JTAG probe and single core bitstream:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;configuration&amp;gt;&lt;br /&gt;
  &amp;lt;controller id=&#039;Controller0&#039; module=&#039;ft2232&#039; probe=&#039;Dual RS232-HS&#039; speed=&#039;10MHz&#039; examine=&#039;1&#039;/&amp;gt;&lt;br /&gt;
  &amp;lt;driver id=&#039;XtensaDriver0&#039; module=&#039;xtensa&#039; step-intr=&#039;mask,stepover,setps&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;chain controller=&#039;Controller0&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;tap id=&#039;TAP0&#039; irwidth=&#039;5&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/chain&amp;gt;&lt;br /&gt;
  &amp;lt;system module=&#039;jtag&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;component id=&#039;Component0&#039; tap=&#039;TAP0&#039; config=&#039;trax&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/system&amp;gt;&lt;br /&gt;
  &amp;lt;device id=&#039;Xtensa0&#039; component=&#039;Component0&#039; driver=&#039;XtensaDriver0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;application id=&#039;GDBStub&#039; module=&#039;gdbstub&#039; port=&#039;22000&#039;&amp;gt;&lt;br /&gt;
    &amp;lt;target device=&#039;Xtensa0&#039; /&amp;gt;&lt;br /&gt;
  &amp;lt;/application&amp;gt;&lt;br /&gt;
&amp;lt;/configuration&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Running xt-ocd:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-ocd -c topology.xml&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Booting kernel on XTFPGA boards with xt-ocd + xt-gdb:&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb --xtensa-core=&#039;&#039;xtensa-core-name&#039;&#039; &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target remote &#039;&#039;xt-ocd-address-and-port&#039;&#039; &#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;reset&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;load&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;c&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Booting with uBoot ===&lt;br /&gt;
Please see [[Setting_up_U-Boot|Setting up U-Boot]] page for instructions on installing uBoot onto the board.&lt;br /&gt;
&lt;br /&gt;
uBoot can load kernel uImage from FLASH or from the network via TFTP.&lt;br /&gt;
==== Loading kernel from FLASH ====&lt;br /&gt;
Kernel may be stored as raw data in a separate FLASH partition, or it may be stored in a FLASH file system and loaded as a file.&lt;br /&gt;
The following steps load kernel from UBIFS volume on a FLASH partition:&lt;br /&gt;
* make sure that mtdparts environment variable is set correctly. If it&#039;s not, use &#039;mtdparts default&#039; command to reset MTD partitions configuration to default, or &#039;mtdparts add&#039; to add partitions manually. Example of correct default settings for KC705:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;mtdparts&#039;&#039;&#039;&lt;br /&gt;
  &lt;br /&gt;
  device nor0 &amp;lt;f0000000.flash&amp;gt;, # parts = 4&lt;br /&gt;
   #: name                size            offset          mask_flags&lt;br /&gt;
   0: data                0x06000000      0x00000000      0&lt;br /&gt;
   1: boot loader area    0x00800000      0x06000000      0&lt;br /&gt;
   2: kernel image        0x017e0000      0x06800000      0&lt;br /&gt;
   3: boot environment    0x00020000      0x07fe0000      0&lt;br /&gt;
  &lt;br /&gt;
  active partition: nor0,0 - (data) 0x06000000 @ 0x00000000&lt;br /&gt;
  &lt;br /&gt;
  defaults:&lt;br /&gt;
  mtdids  : nor0=f0000000.flash&lt;br /&gt;
  mtdparts: mtdparts=f0000000.flash:0x06000000(data),0x00800000(boot loader area),0x017e0000(kernel image),0x00020000(boot environment)&lt;br /&gt;
&lt;br /&gt;
* attach MTD partition to UBI with &#039;ubi part &#039;&#039;mtd-partition-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubi part &#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBI: attaching mtd1 to ubi0&lt;br /&gt;
  UBI: physical eraseblock size:   131072 bytes (128 KiB)&lt;br /&gt;
  UBI: logical eraseblock size:    130944 bytes&lt;br /&gt;
  UBI: smallest flash I/O unit:    1&lt;br /&gt;
  UBI: VID header offset:          64 (aligned 64)&lt;br /&gt;
  UBI: data offset:                128&lt;br /&gt;
  UBI: attached mtd1 to ubi0&lt;br /&gt;
  UBI: MTD device name:            &amp;quot;mtd=0&amp;quot;&lt;br /&gt;
  UBI: MTD device size:            96 MiB&lt;br /&gt;
  UBI: number of good PEBs:        768&lt;br /&gt;
  UBI: number of bad PEBs:         0&lt;br /&gt;
  UBI: max. allowed volumes:       128&lt;br /&gt;
  UBI: wear-leveling threshold:    4096&lt;br /&gt;
  UBI: number of internal volumes: 1&lt;br /&gt;
  UBI: number of user volumes:     1&lt;br /&gt;
  UBI: available PEBs:             0&lt;br /&gt;
  UBI: total number of reserved PEBs: 768&lt;br /&gt;
  UBI: number of PEBs reserved for bad PEB handling: 0&lt;br /&gt;
  UBI: max/mean erase counter: 8/4&lt;br /&gt;
&lt;br /&gt;
* mount UBI volume that contains kernel uImage with &#039;ubifsmount ubi:&#039;&#039;volume-name&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsmount ubi:&#039;&#039;data&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
  UBIFS: mounted UBI device 0, volume 0, name &amp;quot;data&amp;quot;&lt;br /&gt;
  UBIFS: mounted read-only&lt;br /&gt;
  UBIFS: file system size:   98731776 bytes (96417 KiB, 94 MiB, 754 LEBs)&lt;br /&gt;
  UBIFS: journal size:       4975872 bytes (4859 KiB, 4 MiB, 38 LEBs)&lt;br /&gt;
  UBIFS: media format:       w4/r0 (latest is w4/r0)&lt;br /&gt;
  UBIFS: default compressor: LZO&lt;br /&gt;
  UBIFS: reserved for root:  4879407 bytes (4765 KiB)&lt;br /&gt;
&lt;br /&gt;
* load kernel image from the mounted file system with &#039;ubifsload &#039;&#039;address&#039;&#039; &#039;&#039;path-to-uImage&#039;&#039;&#039;:&lt;br /&gt;
  U-Boot&amp;gt; &#039;&#039;&#039;ubifsload 0x02000000 uImage&#039;&#039;&#039;&lt;br /&gt;
  Loading file &#039;uImage&#039; to addr 0x02000000 with size 2850403 (0x002b7e63)...&lt;br /&gt;
  Done&lt;br /&gt;
&lt;br /&gt;
==== Loading kernel from TFTP ====&lt;br /&gt;
In order for uBoot to be able to load uImage, device tree blob and initramfs they need to be copied somewhere under the tftproot and network must be configured in uBoot.&lt;br /&gt;
&lt;br /&gt;
= Rootfs =&lt;br /&gt;
== Rootfs in initial RAMFS ==&lt;br /&gt;
== Rootfs over NFS ==&lt;br /&gt;
== Rootfs in FLASH (UBIFS) ==&lt;br /&gt;
The easiest way to generate UBIFS image is by setting BR2_TARGET_ROOTFS_UBIFS to y in the buildroot config. Buildroot will also need the following file system parameters, that can be queried with mtdinfo tool:&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_LEBSIZE: logical erase block (LEB) size (130944 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MINIOSIZE: minimum I/O unit size (1 for this device)&lt;br /&gt;
* BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT: maximum logical eraseblock count (this device has 768, 764 are usable, as reported by ubiattach).&lt;br /&gt;
&lt;br /&gt;
  # &#039;&#039;&#039;mtdinfo -a -u&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Count of MTD devices:           4&lt;br /&gt;
Present MTD devices:            mtd0, mtd1, mtd2, mtd3&lt;br /&gt;
Sysfs interface supported:      yes&lt;br /&gt;
&lt;br /&gt;
mtd0&lt;br /&gt;
Name:                           data&lt;br /&gt;
Type:                           nor&lt;br /&gt;
Eraseblock size:                131072 bytes, 128.0 KiB&lt;br /&gt;
Amount of eraseblocks:          768 (100663296 bytes, 96.0 MiB)&lt;br /&gt;
Minimum input/output unit size: 1 byte&lt;br /&gt;
Sub-page size:                  1 byte&lt;br /&gt;
Character device major/minor:   90:0&lt;br /&gt;
Bad blocks are allowed:         false&lt;br /&gt;
Device is writable:             true&lt;br /&gt;
Default UBI VID header offset:  64&lt;br /&gt;
Default UBI data offset:        128&lt;br /&gt;
Default UBI LEB size:           130944 bytes, 127.9 KiB&lt;br /&gt;
Maximum UBI volumes count:      128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To format FLASH partition and put UBIFS image into it the following command sequence may be used:&lt;br /&gt;
* run ubiformat:&lt;br /&gt;
  # &#039;&#039;&#039;ubiformat /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  ubiformat: mtd0 (nor), size 100663296 bytes (96.0 MiB), 768 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 1 bytes&lt;br /&gt;
  libscan: scanning eraseblock 767 -- 100 % complete  &lt;br /&gt;
  ubiformat: 768 eraseblocks have valid erase counter, mean value is 2&lt;br /&gt;
  ubiformat: formatting eraseblock 767 -- 100 % complete  &lt;br /&gt;
* attach formatted device to UBI (this will create /dev/ubi0 device):&lt;br /&gt;
  # &#039;&#039;&#039;ubiattach -p /dev/mtd0&#039;&#039;&#039;&lt;br /&gt;
  UBI device number 0, total 768 LEBs (100564992 bytes, 95.9 MiB), available 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB)&lt;br /&gt;
* create UBI volumes on formatted device (this will create /dev/ubi0_0 device, AKA ubi0:rootfs):&lt;br /&gt;
  # &#039;&#039;&#039;ubimkvol /dev/ubi0 -m -N rootfs&#039;&#039;&#039;&lt;br /&gt;
  Set volume size to 100041216&lt;br /&gt;
  Volume ID 0, size 764 LEBs (100041216 bytes, 95.4 MiB), LEB size 130944 bytes (127.9 KiB), dynamic, name &amp;quot;rootfs&amp;quot;, alignment 1&lt;br /&gt;
* put UBI rootfs image so that xtensa linux could access it (in this example kernel is booted with NFS root and UBI image goes to /mnt/rootfs.ubifs)&lt;br /&gt;
* run ubiupdatevol to copy file system image to the specific UBI volume:&lt;br /&gt;
  # &#039;&#039;&#039;ubiupdatevol /dev/ubi0_0 /mnt/rootfs.ubifs&#039;&#039;&#039;&lt;br /&gt;
* now the volume may be mounted:&lt;br /&gt;
  # &#039;&#039;&#039;mount -t ubifs /dev/ubi0_0 /mnt&#039;&#039;&#039;&lt;br /&gt;
* to use that volume as rootfs add the following parameters to the kernel command line (note that 0 in the &#039;ubi.mtd=0&#039; is the number of mtd partition to bind to ubi0, and &#039;rootfs&#039; in the ubi0:rootfs below is the volume name):&lt;br /&gt;
  ubi.mtd=0 root=ubi0:rootfs rootfstype=ubifs&lt;br /&gt;
&lt;br /&gt;
Further reading:&lt;br /&gt;
* http://www.linux-mtd.infradead.org/doc/ubifs.html&lt;br /&gt;
* http://www.linux-mtd.infradead.org/faq/ubifs.html&lt;br /&gt;
* https://www.kernel.org/doc/Documentation/filesystems/ubifs.txt&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== Linux 4.1 ==&lt;br /&gt;
* ALSA playback driver for XTFPGA.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.19 ==&lt;br /&gt;
* noMMU.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.17 ==&lt;br /&gt;
* Highmem on cores with aliasing cache.&lt;br /&gt;
* New (simpler) method of configuring for specific core variant.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.16 ==&lt;br /&gt;
* Stability: xtensa linux may be rebuilt natively.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.15 ==&lt;br /&gt;
* Highmem.&lt;br /&gt;
* KC705 board.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.14 ==&lt;br /&gt;
* SMP.&lt;br /&gt;
* Futex.&lt;br /&gt;
* register spilling overhaul.&lt;br /&gt;
* OpenCores ethernet works when connected to gigabit network.&lt;br /&gt;
* c67x00 USB host is usable on XTFPGA.&lt;br /&gt;
* TAP network works in ISS.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.12 ==&lt;br /&gt;
* Kernel preemption.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.11 ==&lt;br /&gt;
* Multihit exceptions fixed.&lt;br /&gt;
* Static function tracer.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.10 ==&lt;br /&gt;
* MMUv3 cores.&lt;br /&gt;
* Lockdep/stack tracing.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.9 ==&lt;br /&gt;
* TLS (THREADPTR register).&lt;br /&gt;
* Oprofile.&lt;br /&gt;
* ISS simdisk.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.8 ==&lt;br /&gt;
* Device trees.&lt;br /&gt;
* uImage generation.&lt;br /&gt;
* IRQ subsystem overhaul (IRQ domains, medium-priority interrupts).&lt;br /&gt;
* XTFPGA boards.&lt;br /&gt;
* s32c1i-based atomic/bit operations and spinlocks.&lt;br /&gt;
&lt;br /&gt;
== Linux 3.7 ==&lt;br /&gt;
* Overall architecture port overhaul, mainline is alive again, builds and runs.&lt;br /&gt;
* There were dragons prior to that release.&lt;br /&gt;
&lt;br /&gt;
= Kernel loadable modules using FLIX with L32R =&lt;br /&gt;
&lt;br /&gt;
The kernel module loader (for the Xtensa architecture) supports only the limited set of relocations needed for module loading.  This includes, for example, relocation of literals referenced by L32R instructions.  This loader is not given specific information about any custom TIE configured in the processor, and thus is currently not able to relocate L32R instructions encoded in a FLIX bundle.&lt;br /&gt;
&lt;br /&gt;
To ensure kernel modules load properly, they need to avoid L32R instructions within FLIX instruction bundles.&lt;br /&gt;
   &lt;br /&gt;
Existing kernel code does not generate such instructions, so it is not susceptible.&lt;br /&gt;
However, it is possible to generate FLIX instructions using assembly code, or using the Tensilica XCC compiler.  In the case of assembly code, simply avoid using L32R or MOVI instructions within a FLIX instruction bundle, unless a MOVI is known to fit without expanding (&amp;quot;relaxing&amp;quot;) into an L32R instruction.  In the case of XCC, pass the -mno-flix to the compiler (xt-xcc) to avoid generating FLIX bundles.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;:  The use of Tensilica software tools (including XCC) for Linux development is described in the &#039;&#039;Tensilica OSKit Guide&#039;&#039;, available from Tensilica.&lt;br /&gt;
&lt;br /&gt;
== Debugging Kernel Loadable Modules ==&lt;br /&gt;
&lt;br /&gt;
Debugging loadable modules isn&#039;t easy, a few pointers mentioned here might save you some time.  There is a mechanism that Amit Kalie mentioned on his KGDB webpage on loading the module symbols into gdb while loading a module [http://kgdb.linsyssoft.com/initmodule.htm Debuging init_module].&lt;br /&gt;
&lt;br /&gt;
The [http://linux.about.com/od/commands/l/blcmdl8_insmod.htm &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; command] has a &amp;lt;tt&amp;gt;&#039;&#039;--map&#039;&#039;&amp;lt;/tt&amp;gt;&lt;br /&gt;
option that dumps the module component offsets needed by Amit&#039;s approach.&lt;br /&gt;
Unfortunately the initial Xtensa buildroot snapshots have a version of &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; that doesn&#039;t provide this option. Also, while debugging the kernel it&#039;s not convenient to run &amp;lt;tt&amp;gt;insmod&amp;lt;/tt&amp;gt; on the console of the target. &lt;br /&gt;
&lt;br /&gt;
A workaround to this problem is to hack the kernel &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; file and enable debugging. &lt;br /&gt;
&lt;br /&gt;
    #if 1&lt;br /&gt;
    #define DEBUGP printk&lt;br /&gt;
    #else&lt;br /&gt;
    #define DEBUGP(fmt , a...)&lt;br /&gt;
    #endif&lt;br /&gt;
&lt;br /&gt;
This will enable &amp;lt;tt&amp;gt;module.c&amp;lt;/tt&amp;gt; to print the module section addresses. You then just list them in the gdb &amp;lt;tt&amp;gt;add-symbol-file&amp;lt;/tt&amp;gt; command using that command&#039;s section (&amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt;) options. &lt;br /&gt;
Note that the &amp;lt;tt&amp;gt;.text&amp;lt;/tt&amp;gt; section is specified without using the &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option:  its address is given alone before any &amp;lt;tt&amp;gt;&#039;&#039;-s&#039;&#039;&amp;lt;/tt&amp;gt; option.&lt;br /&gt;
&lt;br /&gt;
    final section addresses:                  [Kernel Console Log/Output]&lt;br /&gt;
        0xc02a9098 .note.gnu.build-id&lt;br /&gt;
        0xc02b1000 .init.literal&lt;br /&gt;
        0xc02a7000 .text&lt;br /&gt;
        0xc02b11d8 .init.text&lt;br /&gt;
        0xc02a90bc .rodata&lt;br /&gt;
        0xc02a92c4 .rodata.str1.4&lt;br /&gt;
        0xc02ac27c .data&lt;br /&gt;
        0xc02ac640 __param&lt;br /&gt;
        0xc02ac668 .gnu.linkonce.this_module&lt;br /&gt;
        0xc02ac76c .bss&lt;br /&gt;
        0xc02aaf0c .symtab&lt;br /&gt;
        0xc02ab8fc .strtab&lt;br /&gt;
&lt;br /&gt;
    add-symbol-file /export/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/ctlmeth.ko   \&lt;br /&gt;
        0xc02a7000                           \&lt;br /&gt;
        -s .data 0xc02ac27c                  \&lt;br /&gt;
        -s .init.text 0xc02b11d8             \&lt;br /&gt;
        -s .bss 0xc02ac76c                   \&lt;br /&gt;
        -s .init.literal 0xc02b1000          \&lt;br /&gt;
        -s  .rodata 0xc02a90bc&lt;br /&gt;
&lt;br /&gt;
You likely want to compile your modules unoptimized and unstripped to facilitate debugging and provide the path to the module source to gdb with the &amp;lt;tt&amp;gt;dir&amp;lt;/tt&amp;gt; command.&lt;br /&gt;
For example:&lt;br /&gt;
    dir /home/pdelaney/src/Transwitch/a2000_src/a2000_src/Linux_atlanta/ctlm-cpe/drivers/ctlmeth/&lt;br /&gt;
&lt;br /&gt;
== Debugging on ISS ==&lt;br /&gt;
&lt;br /&gt;
  $ &#039;&#039;&#039;xt-gdb &#039;&#039;build-dir-path&#039;&#039;/arch/xtensa/boot/Image.elf&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;target sim --turbo --memlimit=128&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;symbol-file &#039;&#039;build-dir-path&#039;&#039;/vmlinux&#039;&#039;&#039;&lt;br /&gt;
  (xt-gdb) &#039;&#039;&#039;run&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=746</id>
		<title>Instructions for building and booting Linux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=746"/>
		<updated>2015-03-12T18:58:23Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.&lt;br /&gt;
&lt;br /&gt;
= GNU/Linux on Xtensa =&lt;br /&gt;
&lt;br /&gt;
GNU is a collection of free software that provides POSIX environment.&lt;br /&gt;
Linux is an operating system kernel.&lt;br /&gt;
In order to boot GNU/Linux OS on Xtensa the following parts are needed:&lt;br /&gt;
&lt;br /&gt;
* a board with Xtensa core supported by Linux, or Xtensa simulator&lt;br /&gt;
* bootable Linux kernel image&lt;br /&gt;
* GNU software packaged in a form suitable for booting on Linux, the so called root file system&lt;br /&gt;
* a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa boards supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa simulators ==&lt;br /&gt;
&lt;br /&gt;
* Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Root file system ==&lt;br /&gt;
&lt;br /&gt;
Currently we support building GNU software and packaging it into root file system with the [[Buildroot]].&lt;br /&gt;
There are several types of root file system that Linux can boot with:&lt;br /&gt;
&lt;br /&gt;
=== CPIO archive ===&lt;br /&gt;
* CPIO archive may be built into the kernel (so called &#039;built-in initramfs&#039;), the resulting single image will contain both Linux and GNU software. It&#039;s easy to boot, but in order to change anything the kernel needs to be rebuilt.&lt;br /&gt;
* CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It&#039;s harder to boot (two files instead of one), but easier to change.&lt;br /&gt;
&lt;br /&gt;
Both cases of CPIO use RAM for the root file system, so they&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== EXT2/3/4 file system image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== TAR image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== UBIFS image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Bootloader ==&lt;br /&gt;
U-Boot can be used as a bootloader on XTFPGA boards. Please see [[Setting_up_U-Boot|this]] page for more details about installing it into the daughterboard FLASH.&lt;br /&gt;
&lt;br /&gt;
== On-chip debugger ==&lt;br /&gt;
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.&lt;br /&gt;
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&#039;s Guide for more information about OCD setup and configuration.&lt;br /&gt;
&lt;br /&gt;
= Building GNU/Linux OS =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prepare the overlay ==&lt;br /&gt;
Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location.&lt;br /&gt;
Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable:&lt;br /&gt;
  $ &#039;&#039;&#039;cat &amp;gt; overlay-script&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;....&#039;&#039;&#039;&lt;br /&gt;
  ^D&lt;br /&gt;
  $ &#039;&#039;&#039;chmod +x overlay-script&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Run it and rename the resulting file:&lt;br /&gt;
  $ &#039;&#039;&#039;./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mv xtensa-overlay.tar xtensa_${XT_CORE}.tar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the toolchain and root file system ==&lt;br /&gt;
Get the buildroot git tree:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.buildroot.net/buildroot&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check out some released version:&lt;br /&gt;
  $ &#039;&#039;&#039;git checkout 2014.11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir buildroot-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build menuconfig&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot.&lt;br /&gt;
&lt;br /&gt;
Select &#039;Target Architecture&#039; = Xtensa, &#039;Target Architecture Variant&#039; = Custom Xtensa processor configuration, set &#039;Custom Xtensa processor configuration name&#039; to the contents of ${XT_CORE}, set &#039;Overlay directory for custom configuration&#039; = $(TOPDIR)/..&lt;br /&gt;
&lt;br /&gt;
Select toolchain options, packages to be built and final root file system image type.&lt;br /&gt;
&lt;br /&gt;
Build the toolchain and the root file system:&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the Linux kernel ==&lt;br /&gt;
Get stable Linux release tree:&lt;br /&gt;
  $ &#039;&#039;&#039;wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;tar -xf linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create variant directory for the specific core and copy core configuration files there:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir linux-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Select &#039;Xtensa Processor Configuration&#039; = Custom Xtensa processor configuration, set &#039;Xtensa Processor Custom Core Variant Name&#039; to the contents of ${XT_CORE}. Select desired &#039;Xtensa System Type&#039;.&lt;br /&gt;
&lt;br /&gt;
Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux.&lt;br /&gt;
&lt;br /&gt;
Build the kernel:&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Booting GNU/Linux =&lt;br /&gt;
TBD&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=745</id>
		<title>Instructions for building and booting Linux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=745"/>
		<updated>2015-03-12T18:57:23Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: fix typos&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.&lt;br /&gt;
&lt;br /&gt;
= GNU/Linux on Xtensa =&lt;br /&gt;
&lt;br /&gt;
GNU is a collection of free software that provides POSIX environment.&lt;br /&gt;
Linux is an operating system kernel.&lt;br /&gt;
In order to boot GNU/Linux OS on Xtensa the following parts are needed:&lt;br /&gt;
&lt;br /&gt;
* a board with Xtensa core supported by Linux, or Xtensa simulator&lt;br /&gt;
* bootable Linux kernel image&lt;br /&gt;
* GNU software packaged in a form suitable for booting on Linux, the so called root file system&lt;br /&gt;
* a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa boards supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa simulators ==&lt;br /&gt;
&lt;br /&gt;
* Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.&lt;br /&gt;
* 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.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Root file system ==&lt;br /&gt;
&lt;br /&gt;
Currently we support building GNU software and packaging it into root file system with the [[Buildroot]].&lt;br /&gt;
There are several types of root file system that Linux can boot with:&lt;br /&gt;
&lt;br /&gt;
=== CPIO archive ===&lt;br /&gt;
* CPIO archive may be built into the kernel (so called &#039;built-in initramfs&#039;), the resulting single image will contain both Linux and GNU software. It&#039;s easy to boot, but in order to change anything the kernel needs to be rebuilt.&lt;br /&gt;
* CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It&#039;s harder to boot (two files instead of one), but easier to change.&lt;br /&gt;
&lt;br /&gt;
Both cases of CPIO use RAM for the root file system, so they&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== EXT2/3/4 file system image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== TAR image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== UBIFS image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Bootloader ==&lt;br /&gt;
U-Boot can be used as a bootloader on XTFPGA boards. Please see [[Setting_up_U-Boot|this]] page for more details about installing it into the daughterboard FLASH.&lt;br /&gt;
&lt;br /&gt;
== On-chip debugger ==&lt;br /&gt;
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.&lt;br /&gt;
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&#039;s Guide for more information about OCD setup and configuration.&lt;br /&gt;
&lt;br /&gt;
= Building GNU/Linux OS =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prepare the overlay ==&lt;br /&gt;
Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location.&lt;br /&gt;
Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable:&lt;br /&gt;
  $ &#039;&#039;&#039;cat &amp;gt; overlay-script&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;....&#039;&#039;&#039;&lt;br /&gt;
  ^D&lt;br /&gt;
  $ &#039;&#039;&#039;chmod +x overlay-script&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Run it and rename the resulting file:&lt;br /&gt;
  $ &#039;&#039;&#039;./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mv xtensa-overlay.tar xtensa_${XT_CORE}.tar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the toolchain and root file system ==&lt;br /&gt;
Get the buildroot git tree:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.buildroot.net/buildroot&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check out some released version:&lt;br /&gt;
  $ &#039;&#039;&#039;git checkout 2014.11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir buildroot-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build menuconfig&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot.&lt;br /&gt;
&lt;br /&gt;
Select &#039;Target Architecture&#039; = Xtensa, &#039;Target Architecture Variant&#039; = Custom Xtensa processor configuration, set &#039;Custom Xtensa processor configuration name&#039; to the contents of ${XT_CORE}, set &#039;Overlay directory for custom configuration&#039; = $(TOPDIR)/..&lt;br /&gt;
&lt;br /&gt;
Select toolchain options, packages to be built and final root file system image type.&lt;br /&gt;
&lt;br /&gt;
Build the toolchain and the root file system:&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the Linux kernel ==&lt;br /&gt;
Get stable Linux release tree:&lt;br /&gt;
  $ &#039;&#039;&#039;wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;tar -xf linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create variant directory for the specific core and copy core configuration files there:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir linux-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Select &#039;Xtensa Processor Configuration&#039; = Custom Xtensa processor configuration, set &#039;Xtensa Processor Custom Core Variant Name&#039; to the contents of ${XT_CORE}. Select desired &#039;Xtensa System Type&#039;.&lt;br /&gt;
&lt;br /&gt;
Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux.&lt;br /&gt;
&lt;br /&gt;
Build the kernel:&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=744</id>
		<title>Instructions for building and booting Linux</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Instructions_for_building_and_booting_Linux&amp;diff=744"/>
		<updated>2015-03-12T18:52:26Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: Rewrite the page, overview and building parts.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes what parts are necessary in order to run GNU/Linux OS on Xtensa, their interaction and setup.&lt;br /&gt;
&lt;br /&gt;
= GNU/Linux on Xtensa =&lt;br /&gt;
&lt;br /&gt;
GNU is a collection of free software that provides POSIX environment.&lt;br /&gt;
Linux is an operating system kernel.&lt;br /&gt;
In order to boot GNU/Linux OS on Xtensa the following parts are needed:&lt;br /&gt;
&lt;br /&gt;
* a board with Xtensa core supported by Linux, or Xtensa simulator&lt;br /&gt;
* bootable Linux kernel image&lt;br /&gt;
* GNU software packaged in a form suitable for booting on Linux, the so called root file system&lt;br /&gt;
* a bootloader or on-chip debugger capable of loading Linux kernel image into the board RAM&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa boards supported by Linux ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Xtensa simulators ==&lt;br /&gt;
&lt;br /&gt;
* Xtensa software provides Instruction Set Simulator (xt-run) capable of running Linux configured for ISS.&lt;br /&gt;
* QEMU is a free system emulator capable of emulating any XTFPGA board. 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.&lt;br /&gt;
&lt;br /&gt;
== Linux kernel ==&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Root file system ==&lt;br /&gt;
&lt;br /&gt;
Currently we support building GNU software and packaging it into root file system with the [[Buildroot]].&lt;br /&gt;
There are several types of root file system that Linux can boot with:&lt;br /&gt;
&lt;br /&gt;
=== CPIO archive ===&lt;br /&gt;
* CPIO archive may be built into the kernel (so called &#039;built-in initramfs&#039;), the resulting signle image will contain both Linux and GNU software. It&#039;s easy to boot, but in order to change anything the kernel needs to be rebuilt.&lt;br /&gt;
* CPIO archive may also be loaded separately from the kernel, but used in the same way as the built-in initramfs. It&#039;s harder to boot (two files instead of one), but easier to change.&lt;br /&gt;
&lt;br /&gt;
Both cases of CPIO use RAM for the root file system, so they&#039;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.&lt;br /&gt;
&lt;br /&gt;
=== EXT2/3/4 file system image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== TAR image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
=== UBIFS image ===&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Bootloader ==&lt;br /&gt;
U-Boot can be used as a bootloader on XTFPGA boards. Please see [[Setting_up_U-Boot|this]] page for more details about installing it into the daughterboard FLASH.&lt;br /&gt;
&lt;br /&gt;
== On-chip debugger ==&lt;br /&gt;
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.&lt;br /&gt;
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&#039;s Guide for more information about OCD setup and configuration.&lt;br /&gt;
&lt;br /&gt;
= Building GNU/Linux OS =&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== Prepare the overlay ==&lt;br /&gt;
Please see [[Toolchain_Overlay_File|this]] page for overlay repacking script and details of the overlay source location.&lt;br /&gt;
Create conversion script by pasting [[Toolchain_Overlay_File#Conversion_Script|this]] into the file overlay-script and making it executable:&lt;br /&gt;
  $ &#039;&#039;&#039;cat &amp;gt; overlay-script&#039;&#039;&#039;&lt;br /&gt;
  &#039;&#039;&#039;....&#039;&#039;&#039;&lt;br /&gt;
  ^D&lt;br /&gt;
  $ &#039;&#039;&#039;chmod +x overlay-script&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Run it and rename the resulting file:&lt;br /&gt;
  $ &#039;&#039;&#039;./overlay-script ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/src/xtensa-config-overlay.tar.gz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;mv xtensa-overlay.tar xtensa_${XT_CORE}.tar&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the toolchain and root file system ==&lt;br /&gt;
Get the buildroot git tree:&lt;br /&gt;
  $ &#039;&#039;&#039;git clone git://git.buildroot.net/buildroot&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Check out some released version:&lt;br /&gt;
  $ &#039;&#039;&#039;git checkout 2014.11&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir buildroot-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=$(pwd)/buildroot-build menuconfig&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Please see [[Buildroot#Configuring_and_building_Buildroot|this]] chapter for more details about configuring the Buildroot.&lt;br /&gt;
&lt;br /&gt;
Select &#039;Target Architecture&#039; = Xtensa, &#039;Target Architecture Variant&#039; = Custom Xtensa processor configuration, set &#039;Custom Xtensa processor configuration name&#039; to the contents of ${XT_CORE}, set &#039;Overlay directory for custom configuration&#039; = $(TOPDIR)/..&lt;br /&gt;
&lt;br /&gt;
Select toolchain options, packages to be built and final root file system image type.&lt;br /&gt;
&lt;br /&gt;
Build the toolchain and the root file system:&lt;br /&gt;
  $ &#039;&#039;&#039;make -C buildroot O=`pwd`/buildroot-build&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Get, configure and build the Linux kernel ==&lt;br /&gt;
Get stable Linux release tree:&lt;br /&gt;
  $ &#039;&#039;&#039;wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;tar -xf linux-3.19.1.tar.xz&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create variant directory for the specific core and copy core configuration files there:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir -p linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;cp ${XT_ROOT}/XtDevTools/install/builds/${XT_RELEASE}-linux/${XT_CORE}/config/*.h linux-3.19.1/arch/xtensa/variants/${XT_CORE}/include/variant&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create build directory and configure it:&lt;br /&gt;
  $ &#039;&#039;&#039;mkdir linux-build&#039;&#039;&#039;&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Select &#039;Xtensa Processor Configuration&#039; = Custom Xtensa processor configuration, set &#039;Xtensa Processor Custom Core Variant Name&#039; to the contents of ${XT_CORE}. Select desired &#039;Xtensa System Type&#039;.&lt;br /&gt;
&lt;br /&gt;
Please see [[Linux_Kernel#Configuring_the_kernel|this]] chapter for more details about configuring Linux.&lt;br /&gt;
&lt;br /&gt;
Build the kernel:&lt;br /&gt;
  $ &#039;&#039;&#039;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&#039;&#039;&#039;&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=743</id>
		<title>Buildroot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=743"/>
		<updated>2015-03-12T14:54:55Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: add &amp;#039;features by release&amp;#039; for the Buildroot&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the steps to build a toolchain and root file system for a specific processor configuration based on the latest release of Buildroot. &lt;br /&gt;
&lt;br /&gt;
= Getting Buildroot and other prerequisites =&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate a cross-compilation toolchain and a root filesystem. Building linux kernel and bootloader for arbitrary Xtensa core with the Buildroot is currently not supported.&lt;br /&gt;
== Getting Buildroot ==&lt;br /&gt;
Depending on whether buildroot tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest buildroot release archive: links in the Download section at http://buildroot.net/download.html&lt;br /&gt;
* mainline buildroot git tree: &amp;lt;code&amp;gt;git clone git://git.buildroot.net/buildroot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
== Xtensa core overlay file ==&lt;br /&gt;
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by buildroot. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of buildroot requires that the overlay file name has the format xtensa_&amp;lt;CORE_NAME&amp;gt;.tar, where CORE_NAME can be any user selected name.&lt;br /&gt;
&lt;br /&gt;
= Configuring and building Buildroot =&lt;br /&gt;
&lt;br /&gt;
The Buildroot may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree Buildroot configuration/building.&lt;br /&gt;
&lt;br /&gt;
For more information about Buildroot, please also read the documents provided by Buildroot under http://buildroot.net/docs.html.&lt;br /&gt;
&lt;br /&gt;
== Configuring the Buildroot ==&lt;br /&gt;
&lt;br /&gt;
Configuring the Buildroot creates build infrastructure and .config file in the build directory. .config file may be written from scratch or copied from the outside source. It&#039;s a good idea to run configuration after copying external or predefined config, as newer Buildroot releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to edit existing configuration or to create it from scratch run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* Target options submenu:&lt;br /&gt;
** BR2_xtensa: must be selected when building for Xtensa&lt;br /&gt;
** BR2_XTENSA_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
** BR2_XTENSA_CUSTOM_NAME: must specify custom core variant name. This name is used to derive configuration overlay file name.&lt;br /&gt;
** BR2_XTENSA_OVERLAY_DIR: path to the directory with overlay file. May be relative to the Buildroot directory (specified as $(TOPDIR)/...) or the build directory (specified as $(BASE_DIR)/...)&lt;br /&gt;
* Toolchain submenu: select toolchain component versions and options. Many packages depend on presence of specific options, like IPv6 support or WCHAR support. Usually a package that cannot be built with current settings will indicate missing options in the menu.&lt;br /&gt;
* Target packages submenu: select individual packages and libraries that will be built and installed to the rootfs.&lt;br /&gt;
* Filesystem images submenu:&lt;br /&gt;
** BR2_TARGET_ROOTFS_CPIO: select to build CPIO image suitable for use as linux initramfs&lt;br /&gt;
** BR2_TARGET_ROOTFS_EXT2: select to build ext filesystem suitable for use with simulated block device&lt;br /&gt;
** BR2_TARGET_ROOTFS_TAR: select to build tar image, that may be unpacked and used for NFS root&lt;br /&gt;
&lt;br /&gt;
== Building buildroot ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039;&amp;lt;/code&amp;gt; to build the toolchain and root file system, or &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; toolchain&amp;lt;/code&amp;gt; to build only the toolchain.&lt;br /&gt;
&lt;br /&gt;
== Re-configuring and re-building Buildroot ==&lt;br /&gt;
&lt;br /&gt;
The Buildroot does not support uninstalling packages from its build directories. It also does not track dependencies between the built packages. The easiest way to make sure that deselected package is removed from the rootfs, or that changed toolchain option is applied to built packages is cleaning up build directory, leaving only .config in it and re-building everything from scratch.&lt;br /&gt;
&lt;br /&gt;
= Build Buildroot with Crosstool-NG =&lt;br /&gt;
&lt;br /&gt;
Using the Crosstool-NG toolchain allows to build a version of a Buildroot image based on GlibC instead of uClibc. In the current version, Buildroot cannot build Crosstool-NG for Xtensa directly, but can be configured to use it as an &#039;&#039;external&#039;&#039; toolchain. The first step is to build and install Crosstool-NG, so Buildroot can use it to compile the root file system. More information to build Crosstool-NG for Xtensa can be found under [[Crosstool-NG]]. Assuming Crosstool-NG is installed in &#039;ABSOLUTE_PATH_TO_XTOOLS&#039;, which is typically &amp;lt;code&amp;gt;$HOME/x-tools&amp;lt;/code&amp;gt;, you can make the following additional configurations changes in Buildroot:&lt;br /&gt;
&lt;br /&gt;
 Toolchain  ---&amp;gt;&lt;br /&gt;
   Toolchain type (External toolchain)&lt;br /&gt;
   Toolchain (Custom toolchain)&lt;br /&gt;
   Toolchain origin (Pre-installed toolchain)&lt;br /&gt;
   (ABSOLUTE_PATH_TO_XTOOLS) Toolchain path&lt;br /&gt;
   ($(ARCH)-unknown-linux-gnu) Toolchain prefix&lt;br /&gt;
   External toolchain C library (glibc/eglibc)&lt;br /&gt;
&lt;br /&gt;
= Features by release =&lt;br /&gt;
&lt;br /&gt;
== 2014.11 ==&lt;br /&gt;
* fix &#039;dangerous relocation: call8: call target out of range&#039; linker bug&lt;br /&gt;
* fix &#039;Error: jump target out of range; no usable trampoline found&#039; and &#039;Error: operand 1 of &#039;j&#039; has out of range &#039; assembler bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.08 ==&lt;br /&gt;
* fix xtensa linker segfault on linking linux modules&lt;br /&gt;
&lt;br /&gt;
== 2014.05 ==&lt;br /&gt;
* fixes for building with -mtext-section-literals&lt;br /&gt;
* assembler trampolines (able to assemble files with jumps longer than 128K)&lt;br /&gt;
* fixes for &#039;dangerous relocation: call8: misaligned call target&#039; and &#039;dangerous relocation: overflow after relaxation&#039; linker bugs&lt;br /&gt;
&lt;br /&gt;
== 2014.02 ==&lt;br /&gt;
* fix overlay application to gcc&lt;br /&gt;
&lt;br /&gt;
== 2012.11 ==&lt;br /&gt;
* xtensa in the Buildroot mainline&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
	<entry>
		<id>http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=742</id>
		<title>Buildroot</title>
		<link rel="alternate" type="text/html" href="http://wiki.linux-xtensa.org/index.php?title=Buildroot&amp;diff=742"/>
		<updated>2015-03-12T13:20:32Z</updated>

		<summary type="html">&lt;p&gt;Jcmvbkbc: Add the Buildroot instructions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page describes the steps to build a toolchain and root file system for a specific processor configuration based on the latest release of Buildroot. &lt;br /&gt;
&lt;br /&gt;
= Getting Buildroot and other prerequisites =&lt;br /&gt;
Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate a cross-compilation toolchain and a root filesystem. Building linux kernel and bootloader for arbitrary Xtensa core with the Buildroot is currently not supported.&lt;br /&gt;
== Getting Buildroot ==&lt;br /&gt;
Depending on whether buildroot tree with full history is needed for development or not either release tarball should be downloaded or git tree cloned.&lt;br /&gt;
* latest buildroot release archive: links in the Download section at http://buildroot.net/download.html&lt;br /&gt;
* mainline buildroot git tree: &amp;lt;code&amp;gt;git clone git://git.buildroot.net/buildroot&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Using tip of the cloned git tree for work is usually a bad idea, basing development branches on known releases (marked by tags) would give more predictable results.&lt;br /&gt;
&lt;br /&gt;
== Xtensa core overlay file ==&lt;br /&gt;
The overlay file includes patches for toolchain tools, such as compiler, assembler, and debugger, that are required to support a specific Xtensa processor configuration. Tensilica provides such an overlay as part of the processor download, however, it needs to be reformatted to match the specific format required by buildroot. For a script to convert the overlay file, and additional information, please go to [[Toolchain Overlay File]]. The current version of buildroot requires that the overlay file name has the format xtensa_&amp;lt;CORE_NAME&amp;gt;.tar, where CORE_NAME can be any user selected name.&lt;br /&gt;
&lt;br /&gt;
= Configuring and building Buildroot =&lt;br /&gt;
&lt;br /&gt;
The Buildroot may be built in the same directory as its source (in-tree) or in a separate directory (out-of-tree). Building out-of-tree is usually cleaner and involves less actions when several configurations need to be built.&lt;br /&gt;
Adding parameter O=&#039;&#039;build-dir-path&#039;&#039; to make controls out-of-tree Buildroot configuration/building.&lt;br /&gt;
&lt;br /&gt;
For more information about Buildroot, please also read the documents provided by Buildroot under http://buildroot.net/docs.html.&lt;br /&gt;
&lt;br /&gt;
== Configuring the Buildroot ==&lt;br /&gt;
&lt;br /&gt;
Configuring the Buildroot creates build infrastructure and .config file in the build directory. .config file may be written from scratch or copied from the outside source. It&#039;s a good idea to run configuration after copying external or predefined config, as newer Buildroot releases may have added/removed or changed configuration parameters and the config file may need to be updated.&lt;br /&gt;
&lt;br /&gt;
* to use external .config just copy it to the build directory&lt;br /&gt;
* to edit existing configuration or to create it from scratch run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; menuconfig&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To search for a specific configuration item in curses interface use &#039;/&#039;.&lt;br /&gt;
The following configuration parameters are important/interesting/worth checking:&lt;br /&gt;
* Target options submenu:&lt;br /&gt;
** BR2_xtensa: must be selected when building for Xtensa&lt;br /&gt;
** BR2_XTENSA_CUSTOM: must be set when a custom core variant is used&lt;br /&gt;
** BR2_XTENSA_CUSTOM_NAME: must specify custom core variant name. This name is used to derive configuration overlay file name.&lt;br /&gt;
** BR2_XTENSA_OVERLAY_DIR: path to the directory with overlay file. May be relative to the Buildroot directory (specified as $(TOPDIR)/...) or the build directory (specified as $(BASE_DIR)/...)&lt;br /&gt;
* Toolchain submenu: select toolchain component versions and options. Many packages depend on presence of specific options, like IPv6 support or WCHAR support. Usually a package that cannot be built with current settings will indicate missing options in the menu.&lt;br /&gt;
* Target packages submenu: select individual packages and libraries that will be built and installed to the rootfs.&lt;br /&gt;
* Filesystem images submenu:&lt;br /&gt;
** BR2_TARGET_ROOTFS_CPIO: select to build CPIO image suitable for use as linux initramfs&lt;br /&gt;
** BR2_TARGET_ROOTFS_EXT2: select to build ext filesystem suitable for use with simulated block device&lt;br /&gt;
** BR2_TARGET_ROOTFS_TAR: select to build tar image, that may be unpacked and used for NFS root&lt;br /&gt;
&lt;br /&gt;
== Building buildroot ==&lt;br /&gt;
&lt;br /&gt;
Run &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039;&amp;lt;/code&amp;gt; to build the toolchain and root file system, or &amp;lt;code&amp;gt;make O=&#039;&#039;build-dir-path&#039;&#039; toolchain&amp;lt;/code&amp;gt; to build only the toolchain.&lt;br /&gt;
&lt;br /&gt;
== Re-configuring and re-building Buildroot ==&lt;br /&gt;
&lt;br /&gt;
The Buildroot does not support uninstalling packages from its build directories. It also does not track dependencies between the built packages. The easiest way to make sure that deselected package is removed from the rootfs, or that changed toolchain option is applied to built packages is cleaning up build directory, leaving only .config in it and re-building everything from scratch.&lt;br /&gt;
&lt;br /&gt;
= Build Buildroot with Crosstool-NG =&lt;br /&gt;
&lt;br /&gt;
Using the Crosstool-NG toolchain allows to build a version of a Buildroot image based on GlibC instead of uClibc. In the current version, Buildroot cannot build Crosstool-NG for Xtensa directly, but can be configured to use it as an &#039;&#039;external&#039;&#039; toolchain. The first step is to build and install Crosstool-NG, so Buildroot can use it to compile the root file system. More information to build Crosstool-NG for Xtensa can be found under [[Crosstool-NG]]. Assuming Crosstool-NG is installed in &#039;ABSOLUTE_PATH_TO_XTOOLS&#039;, which is typically &amp;lt;code&amp;gt;$HOME/x-tools&amp;lt;/code&amp;gt;, you can make the following additional configurations changes in Buildroot:&lt;br /&gt;
&lt;br /&gt;
 Toolchain  ---&amp;gt;&lt;br /&gt;
   Toolchain type (External toolchain)&lt;br /&gt;
   Toolchain (Custom toolchain)&lt;br /&gt;
   Toolchain origin (Pre-installed toolchain)&lt;br /&gt;
   (ABSOLUTE_PATH_TO_XTOOLS) Toolchain path&lt;br /&gt;
   ($(ARCH)-unknown-linux-gnu) Toolchain prefix&lt;br /&gt;
   External toolchain C library (glibc/eglibc)&lt;/div&gt;</summary>
		<author><name>Jcmvbkbc</name></author>
	</entry>
</feed>