Building Kernel with cross-compiler and sharing through USB

Hi all,

finally I have launched myself to build a new kernel for my BeaglBone Black, as this is my first time, I have read lot of links and follow the steps proposed at some of them.
I have been able to cconfigure and compile the kernel, but there is no way to upload the kernel to target, BeagleBone Black. So, I can’t verify if it is working or not.

I’m going to explain all the steps I have done, and what I have tested in order to get your help.

BeagleBone Black Configuration:

  • Hardware: BeagleBone Black 4GB rev.C

  • OS: Debian 4.6.3-14

  • Kernel (current): 3.8.13-bone79

  • Internet connection: USB (‘USB0’)

Configure and Compile the Kernel: [Link]

  1. ARM Cross Compiler: arm-linux-gnueabihf-
  1. GIT → downloaded kernel 4.1
  1. Installed ‘lzop’ tool and ‘libssl-dev’.
  1. Downloaded U-Boot tools, made and installed (included ‘mkimage’ tool).
wget ftp://ftp.denx.de/pub/u-boot/u-boot-latest.tar.bz2
tar -xjf u-boot-latest.tar.bz2
cd into u-boot directory
make sandbox_defconfig tools-only
sudo install tools/mkimage /usr/local/bin

  1. Compiled the BeagleBone Black kernel.
git clone git://github.com/beagleboard/linux.git
cd linux
git checkout 4.1
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bb.org_defconfig 
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig   (To modify some features)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j4
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage dtbs LOADADDR=0x80008000 -j4
  1. Build kernel modules.
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules -j4
  1. Rootfs folder:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=/home/user/export/rootfs modules_install

Once, kernel is built, it is upload time. For such action, I have test both suggestions from link above, also another one.
Now, I will explain how I have tried to do it and the results, moreover my doubts.

Upload Kernel:

  • Way1 (brute force):
  • To be fast, ‘4.1.15’ modules were copied to ‘/lib/modules/4.1.15’ path.
  • uImage was copied from ‘arch/arm/boot’ on Host-PC to ‘/boot/uboot’ on BBB.
  • am335x-boneblack.dtb was copied from ‘arch/arm/boot/dts’ on Host-PC to ‘/boot/uboot/dtbs’ on BBB.
  • Then, BBB is rebooted, but BBB is halted at boot. The four leds are switched on permanently.
  • I have to restore the BBB with the SD Card.

Which is the right kernel image, uImage or zImage? I have compiled uImage but I saw at so many websites that the image to upload is zImage.

  • Way2 (tftp):

  • Created and configured tftp server on Host-PC.

  • Connected Serial-USB adapter to BBB’s serial port.

  • Opened uBoot console, and set ip variables, both ipaddr and serverip.

  • Added to ‘uEnv.txt’:

console=ttyO0, 115200n8
ipaddr=192.168.7.2
serverip=192.168.7.1
rootpath=/home/user/uboot/export/
netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=${ipaddr}:${serverip}:192.168.7.1:255.255.255.0:beaglebone:usb0:none:192.168.7.1
netboot=echo Booting from network ...; tftp ${loadaddr} ${bootfile}; tftp $(fdraddr} ${fdtfile}; run netargs; bootz ${loadaddr} - ${fdtaddr}
uenvcmd=run netboot
  • From here, no more steps worked. There is no USB connection at uBoot, so I can’t communicate with Host-PC

How can I solve the issue and send the kernel to BeagleBone?

Please, any hint or tip you can provide me it will be helpful.

KR!

Don't bother with "uImage".. Use the zImage...

Grab a 3.3v ftdi usb serial cable and actually watch the boot process,
unless you enjoy guessing what's going on..

Regards,

Hi,

I have done it from Windows with Open tftp, but the process failed.

tftpboot 0x80F80000 am335x-boneblack.dtb
tftpboot 0x80007FC0 uImage
setenv bootargs console=ttyO0,115200n8 root=/dev/mmcblk0p2 ro rootfstype=ext4 rootwait
bootm 0x80007FC0 - 0x80F80000

All works until last step which returns:

Wrong Ramdisk Image Format

Ramdisk image is corrupt or invalid

I have no reboot the BBB yet, but it is probably even if I repeat the process for zImage it will failed too.

Is there any way to check the kernel?

KR!

Now, I have followed these other steps.
I have built the kernel, uImage, and with the help of tftp uploaded it to BBB.

Then, with ‘bootm 0x80200000’ instruction, I forced the boot of the BBB with new kernel.

But the results is:

“spl_load_image_fat_os: error reading image args, err - -1”

I have followed all tutorials, step by step, and currently, I don’t know if the kernel is wrong, the file corrupted or what is going on.

Could anyone help me, please?

I use NFS all the time and this is what I have in uEnv.txt on my SDCard.

##Rename as: uEnv.txt to boot via nfs

uname_r=4.1.12-ti-r25

##https://www.kernel.org/doc/Documentation/filesystems/nfs/nfsroot.txt

##SERVER: sudo apt-get install tftpd-hpa
##SERVER: TFTP_DIRECTORY defined in /etc/default/tftpd-hpa
##SERVER: zImage/.dtb need to be located here:
##SERVER: TFTP_DIRECTORY/zImage
##SERVER: TFTP_DIRECTORY/dtbs/
.dtb

#cmdline=init=/lib/systemd/systemd
#cmdline=quiet init=/lib/systemd/systemd
#cmdline=ftrace=function_graph trace_buffer_size=100000 FTRACE
#cmdline=init=/lib/sysvinit/init

##client_ip needs to be set for u-boot to try booting via nfs

client_ip=10.100.116.105

#u-boot defaults: uncomment and override where needed

server_ip=10.100.116.100
gw_ip=10.100.116.1
netmask=255.255.255.0
#hostname=
#device=eth0
#autoconf=off
root_dir=/home/john/targetNFS
#nfs_options=,vers=3
#nfsrootfstype=ext4 rootwait fixrtc

dtb=am335x-boneblack.dtb

Follow these instructions to setup your SDCard:

https://www.eewiki.net/display/linuxonarm/BeagleBone+Black#BeagleBoneBlack-SetupmicroSDcard

On this same page you will find info on how to setup the kernel and rootfs. Start with something that works before trying to build your own u-boot and kernel.

Regards,
John

Thanks @jhon3909!!

That is a complete guide, but I don’t want to change the complete OS, just Kernel.
I will avoid the microSD option by the moment. In future, I am sure that in future I will make a fresh installation, so it will be helpful.

Here is the ouput I have got:

U-Boot# tftp 0x82000000 zImage

link up on port 0, speed 100, full duplex

Using cpsw device

TFTP from server 10.2.1.71; our IP address is 10.2.1.41

Filename ‘zImage’.

Load address: 0x82000000

Loading: #################################################################

#################################################################

#################################################################

#################################################################

#################################################################

#################################################################

#################################################################

#################################################################

##########

1.3 MiB/s

done

Bytes transferred = 7779368 (76b428 hex)

U-Boot# bootz 0x82000000 - 0x88000000

Kernel image @ 0x82000000 [ 0x000000 - 0x76b428 ]

## Flattened Device Tree blob at 88000000

Booting using the fdt blob at 0x88000000

reserving fdt memory region: addr=88000000 size=7000

reserving fdt memory region: addr=88080000 size=2d2a91

Using Device Tree in place at 88000000, end 8800a07f

Starting kernel …

U-Boot SPL 2014.04-00014-g47880f5 (Apr 22 2014 - 13:23:54)

reading args

spl_load_image_fat_os: error reading image args, err - -1

reading u-boot.img

reading u-boot.img

U-Boot 2014.04-00014-g47880f5 (Apr 22 2014 - 13:23:54)

I2C: ready

DRAM: 512 MiB

NAND: 0 MiB

MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1

*** Warning - readenv() failed, using default environment

Net: not set. Validating first E-fuse MAC

cpsw, usb_ether

Hit any key to stop autoboot: 0

gpio: pin 53 (gpio 53) value is 1

Card did not respond to voltage select!

mmc0(part 0) is current device

Card did not respond to voltage select!

gpio: pin 56 (gpio 56) value is 0

gpio: pin 55 (gpio 55) value is 0

gpio: pin 54 (gpio 54) value is 0

mmc1(part 0) is current device

gpio: pin 54 (gpio 54) value is 1

SD/MMC found on device 1

reading uEnv.txt

1547 bytes read in 7 ms (215.8 KiB/s)

gpio: pin 55 (gpio 55) value is 1

Loaded environment from uEnv.txt

Importing environment from mmc …

Checking if uenvcmd is set …

gpio: pin 56 (gpio 56) value is 1

Running uenvcmd …

reading zImage

5644336 bytes read in 314 ms (17.1 MiB/s)

reading initrd.img

2960017 bytes read in 173 ms (16.3 MiB/s)

reading /dtbs/am335x-boneblack.dtb

26118 bytes read in 12 ms (2.1 MiB/s)

Kernel image @ 0x82000000 [ 0x000000 - 0x562030 ]

## Flattened Device Tree blob at 88000000

Booting using the fdt blob at 0x88000000

Using Device Tree in place at 88000000, end 88009605

Starting kernel …

Uncompressing Linux… done, booting the kernel.

[ 0.378017] omap2_mbox_probe: platform not supported

[ 0.533724] tps65217-bl tps65217-bl: no platform data provided

[ 0.597092] bone-capemgr bone_capemgr.9: slot #0: No cape found

[ 0.634199] bone-capemgr bone_capemgr.9: slot #1: No cape found

[ 0.671307] bone-capemgr bone_capemgr.9: slot #2: No cape found

[ 0.708416] bone-capemgr bone_capemgr.9: slot #3: No cape found

[ 0.726896] omap_hsmmc mmc.5: of_parse_phandle_with_args of ‘reset’ failed

[ 0.761472] pinctrl-single 44e10800.pinmux: pin 44e10854 already requested by 44e10800.pinmux; cannot claim for gpio-leds.8

[ 0.773150] pinctrl-single 44e10800.pinmux: pin-21 (gpio-leds.8) status -22

[ 0.780451] pinctrl-single 44e10800.pinmux: could not request pin 21 on device pinctrl-single

Loading, please wait…

[ 1.067327] bone-capemgr bone_capemgr.9: failed to load firmware ‘BB-SPI0-01-00A0.dtbo’

[ 1.075800] bone-capemgr bone_capemgr.9: loader: failed to load slot-7 BB-SPI0-01:00A0 (prio 0)

[ 1.198848] hub 1-0:1.0: unable to enumerate USB device on port 1

[ 1.323607] tilcdc 4830e000.fb: Not sure which CEA mode to set, leaving as DVI

[ 1.400647] bone-capemgr bone_capemgr.9: slot #6: BB-BONELT-HDMIN conflict P8.45 (#5:BB-BONELT-HDMI)

[ 1.410426] bone-capemgr bone_capemgr.9: slot #6: Failed verification

[ 1.417314] bone-capemgr bone_capemgr.9: loader: failed to load slot-6 BB-BONELT-HDMIN:00A0 (prio 2)

Scanning for Btrfs filesystems

systemd-fsck[234]: rootfs: clean, 97876/230144 files, 606202/919296 blocks

[ 10.707751] libphy: PHY 4a101000.mdio:01 not found

[ 10.713034] net eth0: phy 4a101000.mdio:01 not found on slave 1

Debian GNU/Linux 7 beaglebone ttyO0

default username:password is [debian:temppwd]

Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

The IP Address for eth0 is: 10.2.1.41

The IP Address for usb0 is: 192.168.7.2

beaglebone login: [ 13.431203] tilcdc 4830e000.fb: timeout waiting for framedone

[ 18.827691] tilcdc 4830e000.fb: timeout waiting for framedone

U-Boot SPL 2014.04-00014-g47880f5 (Apr 22 2014 - 13:23:54)-B

oot 2014.04-00014-g47880f5 (Apr 22 2014 - 13:23:54)

I2C: ready

DRAM: 512 MiB

NAND: 0 MiB

MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1

*** Warning - readenv() failed, using default environmenU-Boot SPL 2014.04-00014-g47880f5 (Apr 22 2014 - 13:23:54)

reading args

spl_load_image_fat_os: error reading image args, err - -1

reading u-boot.img

reading u-boot.img

U-Boot 2014.04-00014-g47880f5 (Apr 22 2014 - 13:23:54)

I2C: ready

DRAM: 512 MiB

NAND: 0 MiB

MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1

*** Warning - readenv() failed, using default environmen

Debian GNU/Linux 7 beaglebone ttyO0

default username:password is [debian:temppwd]

Support/FAQ: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian

The IP Address for eth0 is: 10.2.1.41

The IP Address for usb0 is: 192.168.7.2

beaglebone login: U-Boo tftp 0x82000000 zImage from server 10.2.

1.71; our IP address is 10.2.1.41

Filename ‘zImage’.

Load address: 0x82000000

##########

1.3 MiB/s

done

Bytes transferred = 7779368 (76b428 hex)

U-Boot# bootz 0x82000000 - 0x88000000

Kernel image @ 0x82000000 [ 0x000000 - 0x76b428 ]

## Flattened Device Tree blob at 88000000

Booting using the fdt blob at 0x88000000

reserving fdt memory region: addr=88000000 size=7000

reserving fdt memory region: addr=88080000 size=2d2a91

Using Device Tree in place at 88000000, end 8800a07f

Starting kernel …

U-Boot SPL 2014.04-00014-g47880f5 (Apr 22 2014 - 13:23:54)

reading args

spl_load_image_fat_os: error reading image args, err - -1

reading u-boot.img

reading u-boot.img

U-Boot 2014.04-00014-g47880f5 (Apr 22 2014 - 13:23:54)

I2C: ready

DRAM: 512 MiB

NAND: 0 MiB

MMC: OMAP SD/MMC: 0, OMAP SD/MMC: 1

*** Warning - readenv() failed, using default environment

Reached this point, I want to sum up:

  • Install cross-compiler.

  • Get uBoot: ftp:://ftp.denx.de/pub//u-boot/u-boot-latest.tar.bz2

  • Get kernel from: git://github.com/beagleboard/linux

  • Build the kernel and modules (make … uImage dtbs LOADDADDR=0x80008000).

  • Copy the modules to: /lib/modules

  • Create tftp server in host-pc.

  • Launch uBoot on BBB (use serial port).

  • Configure @ips.

  • Transfer zImage: tftpboot 0x82000000.

  • Boot from new kernel: bootz 0x82000000 - 0x88000000.

These steps from above didn’t work too.

Can anyone explain the concrete steps that must be done to build and transfer the kernel, please?

What about the files needed to make it works? (/lib/modules; am335x-bobeblack.dtb; uImage; zImage)

I always solve these types of problems with a process of elimination. Start with an SDCard that works and then using the same u-boot, move the kernel and DTB to your TFTP folder and copy the complete rootfs to your NFS folder. Check that your TFTP and NFS are working correctly. If you are using systemd, you need to disable dbus from managing eth0 or you boot will fail.

In /lib/systemd/system/connman.service, add -I eth0 to the connmand line

Regards,
John

Following this tutorial, kernel downloading could be started, but there have been some errors during the installation and finally it fails.

U-Boot# bootz ${loadaddr} - ${fdtaddr}

Kernel image @ 0x82000000 [ 0x000000 - 0x699998 ]

## Flattened Device Tree blob at 88000000

Booting using the fdt blob at 0x88000000

Using Device Tree in place at 88000000, end 880107cb

Starting kernel …

[ 2.908603] omap_voltage_late_init: Voltage driver support not added

[ 2.917509] cpu cpu0: cpu0 clock notifier not ready, retry

[ 3.012702] bone_capemgr bone_capemgr: slot #0: No cape found

[ 3.072698] bone_capemgr bone_capemgr: slot #1: No cape found

[ 3.132785] bone_capemgr bone_capemgr: slot #2: No cape found

[ 3.192726] bone_capemgr bone_capemgr: slot #3: No cape found

INIT: version 2.88 booting

[info] Using makefile-style concurrent boot in runlevel S.

findfs: unable to resolve ‘UUID=61bb86ef-f3ee-4afd-8e29-80179407225b’

[ ok ] Starting the hotplug events dispatcher: udevd.

[ ok ] Synthesizing the initial hotplug events…done.

[ ok ] Waiting for /dev to be fully populated…done.

[ ok ] Setting preliminary keymap…done.

[ ok ] Setting parameters of disc: (none).

[ ok ] Activating swap…done.

[…] Checking root file system…fsck from util-linux 2.20.1

rootfs: clean, 95464/230144 files, 591755/919296 blocks

done.

[ ok ] Cleaning up temporary files… /tmp.

[info] Loading kernel module mt7601Usta.

libkmod: ERROR …/libkmod/libkmod.c:554 kmod_search_moddep: could not open moddep file '/lib/modules/4.1.16-bone18/modules.dep.bin’

[ ok ] Activating lvm and md swap…done.

[…] Checking file systems…fsck from util-linux 2.20.1

done.

[ ok ] Mounting local filesystems…done.

[ ok ] Activating swapfile swap…done.

[ ok ] Cleaning up temporary files…

[ ok ] Setting kernel variables …done.

[ ok ] Configuring network interfaces…done.

[ 12.196117] libphy: PHY 4a101000.mdio:01 not found

[ 12.200934] net eth0: phy 4a101000.mdio:01 not found on slave 1

[ ok ] Cleaning up temporary files…

[ ok ] Setting up ALSA…done (none loaded).

[info] Setting console screen modes.

setterm: cannot (un)set powersave mode: Inappropriate ioctl for device

[info] Skipping font and keymap setup (handled by console-setup).

[ ok ] Setting up console font and keymap…done.

[ ok ] Setting up X socket directories… /tmp/.X11-unix /tmp/.ICE-unix.

INIT: Entering runlevel: 2

[info] Using makefile-style concurrent boot in runlevel 2.

Wed Apr 23 20:20:00 UTC 2014

[ ok ] Starting enhanced syslogd: rsyslogd.

[…] Starting ACPI services…RTNETLINK1 answers: No such file or directory

acpid: error talking to the kernel via netlink

. ok

[…] Starting web server: apache2apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName

. ok

[ ok ] Starting periodic command scheduler: cron.

[ ok ] Starting system message bus: dbus.

[ ok ] Starting Avahi mDNS/DNS-SD Daemon: avahi-daemon.

[ ok ] Starting Light Display Manager: lightdm.

[ ok ] Loading cpufreq kernel modules…done (none).

[ ok ] CPUFreq Utilities: Setting ondemand CPUFreq governor…CPU0…done.

saned disabled; edit /etc/default/saned

Starting very small Busybox based DHCP server: Starting /usr/sbin/udhcpd…

udhcpd.

[ ok ] Starting OpenBSD Secure Shell server: sshd.

[…] Starting Network connection manager: wicd[…] Starting Remote Deskto[ ok tocol server : xrdp sesman.

. ok

/etc/rc.local: 14: /etc/rc.local: cannot create /sys/devices/bone_capemgr1/slots: Directory nonexistent

[FAIL] startpar: service(s) returned failure: rc.local … failed!

INIT: Id “T0” respawning too fast: disabled for 5 minutes

Why this installation fails? Should I create a directory before launch it? Or maybe it something about modules compilation?

KR!

libkmod: ERROR …/libkmod/libkmod.c:554 kmod_search_moddep: could not open moddep file '/lib/modules/4.1.16-bone18/modules.dep.bin’

This error has been fixed after copying the ‘4.1.16-bone18’ modules to ‘/lib/modules’ path.

/etc/rc.local: 14: /etc/rc.local: cannot create /sys/devices/bone_capemgr1/slots: Directory nonexistent

[FAIL] startpar: service(s) returned failure: rc.local … failed!

This is still happening. What can I do to solve this issue?

Hi,

I have just commented both lines, and the process goes well until console starts to show:

INIT: Id “T0” respawning too fast: disabled for 5 minutes

Then, the process enters into an infinite loop showing message every 5 minutes.

What process is T0? And how can I solved this?

KR!

That's getty... serial console access..

by default 4.1.x is configured for /dev/ttySx while your rootfs is
looking for /dev/ttyOx..

Regards,

Hi,

this is my original ‘/etc/inittab’ file:

T0:23:respawn:/sbin/getty -L ttyO0 115200 vt102

Could I modify any file of my system (BBB)? Or may I need to re-built the kernel?

KR!

T0:23:respawn:/sbin/getty -L ttyS0 115200 vt102

Regards,

Finally… it works!!!

Thanks Robert!!!