Official Guide to compile a kernel for Parallella

Forum about Parallella boot process, linux kernel, distros, SD-cards, etc.

Official Guide to compile a kernel for Parallella

Postby jimmystone » Wed Dec 23, 2015 11:52 am

Dear all,

Is there an official guide talk about how to compile Ubuntu kernel for Parallella?
Posts: 48
Joined: Tue Sep 24, 2013 12:09 pm

Re: Official Guide to compile a kernel for Parallella

Postby e97 » Thu Dec 24, 2015 1:10 am

Download kernel from git

Native compile on parallella:

1. make paralella_defconfig

a. If you want to make changes to the kernel config: make menuconfig

2. make -j2 (-V s for verbose output)

3. make modules

4. make modules_install

If you are cross compiling, it will mostly be the same but you will need to have and specify a CROSS_COMPILE toolchain as well as target ARCH.
Posts: 10
Joined: Sun Jul 19, 2015 1:56 am

Re: Official Guide to compile a kernel for Parallella

Postby frankbuss » Sun Aug 06, 2017 6:53 pm

Minor mistake, first step is "make parallella_defconfig" (note the additional L). Also for "make menuconfig", you need to install ncurses first: "sudo apt-get install libncurses-dev", if you want to compile it native on the platform from the latest Parabuntu release (2016.11 as of writing this). Also worth noting that the git repository is located at and that the branch is "parallella-linux-2016.11". No need to patch anything, the manual at ... -platform/ is outdated and should be deleted or changed to avoid confusion.

After this you don't have uImage. So another step is required:

5. make LOADADDR=0x8000 uImage

The uImage file is then located in "arch/arm/boot" and can be copied to /boot. Note that in the last official Parabuntu release, the boot partition is not mounted on start and you have to do this manually, or add it to /etc/fstab as I did (with the line "/dev/mmcblk0p1 /boot vfat defaults 0 0") and reboot.

And it is very useful to have a bigger filesystem, which can be done by deleting and creating the partition on the SD card first, to change it to a bigger partition, then using resize2fs. All from a host system. Might be possible from the platform itself, too, at least the Raspberry Pi can do this and it is just a simple option in their ncurses config program, without the need to do it all manually. But for the Linux kernel sources etc., you might want to store this on your host anyway, because SD cards can wear out or get damaged pretty fast. I use sshfs to mount a directory on my PC from the Parallella.

I just tried this on the Parallella device, with a network mounted filesystem and it needed several hours. Cross compiling on a PC with a local filesystem is much faster.

Maybe an official guide on the page would be useful instead of just linking to the github repository? Or at least add it to the github repository readme file?
Posts: 12
Joined: Mon Dec 17, 2012 3:22 am

Re: Official Guide to compile a kernel for Parallella

Postby frankbuss » Sat Aug 12, 2017 2:45 pm

I got my hopes up too soon. It worked after a "reboot" command, but after power down/power up, the new kernel crashed, see below. No idea what I did wrong. Maybe someone has a working "from scratch" recipe how to build the headless kernel from the Parabuntu distribution?

Unhandled fault: imprecise external abort (0x1406) at 0x00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: : 1406 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 0 PID: 6 Comm: kworker/u4:0 Not tainted 4.6.0+ #1
Hardware name: Xilinx Zynq Platform
Workqueue: deferwq deferred_probe_work_func
task: ef065640 ti: ef066000 task.ti: ef066000
PC is at elink_platform_probe+0x8b4/0xb08
LR is at arm_heavy_mb+0x24/0x4c
pc : [<c033af1c>] lr : [<c001bb10>] psr: 80000013
sp : ef067de0 ip : 00000238 fp : 00000001
r10: c0990808 r9 : c0990898 r8 : eea64c18
r7 : ef0c3a00 r6 : ef0c3a10 r5 : 00000000 r4 : eea64c10
r3 : deadbeef r2 : 006526d8 r1 : ef810bc0 r0 : 00000000
Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
Control: 18c5387d Table: 0000404a DAC: 00000051
Process kworker/u4:0 (pid: 6, stack limit = 0xef066210)
Stack: (0xef067de0 to 0xef068000)
7de0: ef0c6ec0 ef0c6ec0 eea64c10 00000000 eea64db0 eea64dcc ef067e04 dfffc0c8
7e00: eea67cd0 8e000000 3e000000 02000000 80000000 8fffffff ef834b18 00000200
7e20: 00000000 00000000 00000000 00000000 00000000 3fffffff ef834448 00000200
Posts: 12
Joined: Mon Dec 17, 2012 3:22 am

Re: Official Guide to compile a kernel for Parallella

Postby frankbuss » Sat Aug 12, 2017 6:42 pm

Ok, now it works, even after power cycling. I compared the kernel message output of the working version with my version, and it crashed at the Epiphany driver, which I then disabled. Might be useful to have this working, too, but for now I need only the FPGA. This is what I did:

Prerequisites: I updated my host system to Debian 9 (Stretch), because then the cross-compiler is just a package and I don't need to compile this myself. Cross-compiling is highly recommended, because it needs only minutes instead of hours. Then I installed everything I needed to cross-compile the kernel:

Code: Select all
sudo apt-get update
sudo apt-get install binutils-arm-linux-gnueabihf gcc-arm-linux-gnueabihf git fakeroot build-essential ncurses-dev libncurses5-dev libssl-dev bc u-boot-tools

You might need more, but the error messages should be self explanatory.

I got some strange problem like "ld cannot find" for "make menuconfig" later. After some hours googling and searching the problem, I added this to ~/.bashrc and logged in again:

Code: Select all

Then I found a script, which looked like it was used to build the official kernel: ...

It adds some config settings in addition to the parallella specific configs at the end of the file, which doesn't look right. I think the right way would be to change the default parallella config, or merge the config fragment from the Parabuntu repository with the script, as described here: ... ments.html

I think I have used mostly the same settings, just some debug settings are different and I included the UIO driver in the kernel and not as a module. And I added smbfs support, to mount a Windows file system or Samba server, which is useful to use my NAS from the Parallella system. Attached is the working .config file.

Then I cloned this version of the kernel:

Code: Select all
git clone -b parallella-linux-2016.11
cd parallella-linux

If you want to configure it yourself, do this:

Code: Select all
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000 parallella_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000 olddefconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000 menuconfig

At the end of these steps, you have a .config file. For a known working version use my .config file, which you can modify with the menuconfig step above. Then you can compile it like this:

Code: Select all
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000 uImage
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000 zynq-parallella-headless-noelink.dtb
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000 modules

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000 INSTALL_MOD_PATH=$MODULES_INSTALL_DIR modules_install
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- LOADADDR=0x8000 INSTALL_HDR_PATH=$HEADERS_INSTALL_DIR headers_install

The result files needs to be copied to the Parallella platform. I did it as described in the previous article, by mounting the boot partition on a running Parallella system, and mounting my host directory on the PC from the Parallella system with sshfs. Then I renamed the old modules directory "/lib/modules/4.6.0+" to "/lib/modules/4.6.0+.old", and /boot/uImage and /boot/devicetree.dtb, in case something goes wrong to make it easier to restore to the orignal version. Then copy it like this, from the Linux build directory:

Code: Select all
cp arch/arm/boot/uImage /boot/uImage
cp arch/arm/boot/dts/zynq-parallella-headless.dtb /boot/devicetree.dtb
cp -a modules/lib/modules/4.6.0+ /lib/modules/4.6.0+ (rename old before copy)

That's all, now you have your own headless Linux kernel without Epiphany support, and you can reboot it and start developing your own driver modules.

Driver development would be another article, just a quick tip: if you get "Unknown symbol _GLOBAL_OFFSET_TABLE_ (err 0)" in the syslog when trying to load your module with "insmod", as I got, then use the "-fno-pic" option for compiling, so something like this in your Makefile:

Code: Select all
make CFLAGS_MODULE=-fno-pic ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -C path-to-your-linux-sources/modules/lib/modules/4.6.0+/build M=$(PWD) modules

If something goes wrong and you want a clean directory, you don't need to clone it again, just do this:

Code: Select all
git reset --hard HEAD
git clean -fdx

Warning: This deletes all your new files in the directory and reverts all changes!

Maybe I just didn't found the right documentation, but this should be all much easier, like just a Vagrant or Docker image with everything working and working versions of the .config file for different configurations. Currently it is a big entry hurdle for newbies to start develop their own drivers, which is not too difficult if you manage to setup the build environment.
Linux config file
(23.65 KiB) Downloaded 3 times
Posts: 12
Joined: Mon Dec 17, 2012 3:22 am

Return to Linux/U-Boot

Who is online

Users browsing this forum: No registered users and 4 guests