NFS rootfs for Wandboard - linux-kernel

My first time working on the Uboot and Serial Port. I am trying to mount my /nfsroot from my ubuntu host to the wandboard target so that I can boot up the board with TFTP in Kernel and NFS as rootfs.
Been getting error here and there and do not know what they mean.
Please advice.
This is the complete Error Log with root=/dev/nfs
This is the error I have when I try to mount the nfs to one of my SDCard's partition (mmcblk2p2). root=/dev/mmcblk2p2
It mounted but then devtmpfs return error mounting -2.
EXT3-fs (mmcblk2p2): error: couldn't mount because of unsupported optional features (240)
EXT2-fs (mmcblk2p2): error: couldn't mount because of unsupported optional features (244)
EXT4-fs (mmcblk2p2): recovery complete
EXT4-fs (mmcblk2p2): mounted filesystem with ordered data mode. Opts: (null)
VFS: Mounted root (ext4 filesystem) on device 179:2.
devtmpfs: error mounting -2
Freeing unused kernel memory: 328K (80d22000 - 80d74000)
Failed to execute /sbin/init (error -2). Attempting defaults...
Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
CPU1: stopping
And this is my printenv
=> printenv
baudrate=115200
boot_fdt=try
bootargs=console=ttymxc0,115200 root=/dev/mmcblk0p2 rw nfsroot=192.168.0.227:/nfsroot,v3,tcp
bootcmd=mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if run loadimage; then run mmcboot; else run netboot; fi; fi; else run netboot; fi
bootdelay=5
bootfile=zImage-wandboard-quad.bin
bootscript=echo Running bootscript from mmc ...; source
console=ttymxc0
ethact=FEC
ethaddr=00:1f:7b:b4:14:ce
ethprime=FEC
fdt_addr=0x18000000
fdt_file=zImage-imx6q-wandboard.dtb
fdt_high=0xffffffff
get_cmd=dhcp
image=zImage-wandboard-quad.bin
initrd_high=0xffffffff
ip_dyn=yes
loadaddr=0x12000000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
mmcargs=setenv bootargs console=${console},${baudrate} root=${mmcroot}; run videoargs
mmcboot=echo Booting from mmc ...; run mmcargs; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then bootz ${loadaddr} - ${fdt_addr}; else if test ${boot_fdt} = try; then bootz; e;
mmcdev=0
mmcpart=1
mmcroot=/dev/mmcblk2p2 rootwait rw
netargs=setenv bootargs console=${console},${baudrate} ${smp} root=/dev/mmcblk2p2 rw ip={ipaddr} nfsroot=${serverip}:${nfsroot},v3,tcp init=/sbin/init
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; ${get_cmd} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; th;
nfsroot=/nfsroot
script=boot.scr
serverip=192.168.0.227
splashpos=m,m
update_sd_firmware=if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if mmc dev ${mmcdev}; then if ${get_cmd} ${update_sd_firmware_filename}; then setexpr fw_sz ${filesize} /i
update_sd_firmware_filename=u-boot.imx
videoargs=setenv nextcon 0; if hdmidet; then setenv bootargs ${bootargs} video=mxcfb${nextcon}:dev=hdmi,1280x720M#60,if=RGB24; setenv fbmen fbmem=28M; setexpr nextcon ${nextcon} + 1; else echo - no HDMI mo}
Environment size: 2810/8188 bytes

On the host (Ubuntu):
sudo apt-get install nfs-kernel-server
sudo mkdir /nfsroot
Add the /nfsroot directory to the /etc/exports file:
/nfsroot *(rw,sync,no_root_squash)
sudo /etc/init.d/nfs-common start or sudo /etc/init.d/nfs-kernel-server start
On the target (Wandboard):
Root filesystem on NFS must have been enabled when compiling the kernel (hopefully, it was, otherwise you'll need to recompile the Linux kernel)
Add root=/dev/nfs rw ip=target_IP nfsroot=NFS_server_IP>:/nfsroot/ to U-Boot's bootargs variable, where target_IP is the static IP address for the target and NFS_server_IP is the host IP address.

It turns out that I need to set the client IP parameter after I got the IP from DHCP. I thought that DHCP will handle all the IP configuration for the netboot arguments but I was wrong;
setenv ip 192.168.0.172:192.168.0.227::::eth0:on
setenv ipaddr 192.168.0.172
setenv netargs 'setenv bootargs console=${console},${baudrate} ${smp} root=/dev/nfs ip=${ipaddr} nfsroot=${serverip}:${nfsroot},v3,tcp'

Related

Kernel panic after ubi rootfs size increased

I'm currently working with LTIB tool to generate linux kernel 3.0.25, with u-boot-2009-08, for iMX6 solo core board.
I use mfg tool to flash. When I installed new packages, the rootfs size changed from 147 to 162MiB. Since then, I can't boot anymore, the ubi doesn't get attached.
I have a kernel panic with the following logs :
**UBI error: process_eb: bad image sequence number 1588612812 in PEB 720, expected 1344834100**
UBI error: ubi_attach_mtd_dev: failed to attach by scanning, error -22
UBI error: ubi_init: cannot attach mtd9
UBIFS error (pid 1): ubifs_mount: cannot open "ubi0:root", error -19
VFS: Cannot open root device "ubi0:root" or unknown-block(0,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
UBI error screenshot
Kernel Panic Screenshot
To get rid of this, I changed the u-boot mfg CONFIG_BOOTARGS as follows :
#define CONFIG_BOOTARGS "console=ttymxc1,115200 rdinit=/linuxrc mtdparts=gpmi-
nand:4m(boot),256k(bootenv),2m(splashscreen),10m(ramdisk),5m(kernel),5m(flasherkernel),256k(updater
),256k(flag1),256k(flag2),170m(rootfs),32m(userpart1),32m(userpart2),-(userpart)"\
Here's the ubinize.cfg :
[ubifs]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=170MiB
vol_type=dynamic
vol_name=root
vol_flags=autoresize
And the ubi generation commands :
sudo mkfs.ubifs -r $ROOTFS -m 4096 -e 253952 -c 1184 -o ubifs.img
sudo ubinize -o $BUILT_IMG/ubi.img -m 4096 -p 256KiB ubinize.cfg
And the flash commands :
$ flash_eraseall /dev/mtd9 # Erasing Rootfs partition
$ send" file="files/ubi.img # Sending Root filesystem
$ ubiformat /dev/mtd9 -f $FILE -s 4096 -O 4096 # Flashing Root Filesystem
Any idea ?
Thanks

fdt_addr not setup by U-Boot/first stage bootloader

I'm working on setting up U-Boot for our systems using raspberry pi 3B plus and cm3. (Though atm I'm working just with cm3. I'm confident the same applies to the 3B plus)
I got rid of the default bootcmd run distro_bootcmd and load a first stage boot script first_boot.scr which then loads and sources the respected boot.scr.
%EDIT%
In my answer I mentioned already that the failure description is wrong. I just checked the fdt_addr variable at the wrong time, thus leading me on the wrong path.
%EDIT%
As we already have machines out in the field I'm working on updating them. Here lies the problem. If I setup a fresh device with the new architecture everything works just fine. If I update and older system though, fdt_addr is not setup, thus the boot failes.
I can of course manually setup fdt_addt, but I want to understand what could be the reason for fdt_addr not being setup. As far as I could find, the first stage bootloader is responsible. So I imagine something is not beeing triggered.
Updating in our case describes simply copying the new images to the device, moving u-boot.bin and first_boot.scr to the boot partition and then changing the config.txt to start U-Boot not the kernel directly.
While setting up a fresh machine is pretty much the same just with formatting the device and placing the files in the exact same places.
bootcmd: load mmc 0:1 ${scriptaddr} /first_boot.scr; source ${scriptaddr}
env load #<- %EDIT%
if test "${boot_count}" > 4; then
echo "###Loading factory kernel bootscript###"
setenv boot_kernel 2;
load mmc 0:2 ${scriptaddr} images/factory/boot.scr;
source ${scriptaddr}
elif test "${boot_count}" > 2; then
echo "###Loading factory kernel bootscript###"
setenv boot_kernel 1;
load mmc 0:2 ${scriptaddr} images/previous/boot.scr;
source ${scriptaddr}
else
echo "###Loading current kernel bootscript###"
setenv boot_kernel 0;
load mmc 0:2 ${scriptaddr} images/latest/boot.scr;
source ${scriptaddr}
fi
if test "${boot_kernel}" = 2; then
echo "###Loading factory kernel###"
load mmc 0:2 ${kernel_addr_r} images/factory/Image;
load mmc 0:2 ${fdt_addr} images/factory/device_tree.dtb;
elif test "${boot_kernel}" = 1; then
echo "###Loading previous kernel###"
load mmc 0:2 ${kernel_addr_r} images/previous/Image;
load mmc 0:2 ${fdt_addr} images/previous/device_tree.dtb;
else
echo "###Loading current kernel###"
load mmc 0:2 ${kernel_addr_r} images/latest/Image;
load mmc 0:2 ${fdt_addr} images/latest/device_tree.dtb;
fi
setenv bootargs console=ttyAMA0,115200 printk.devkmsg=on usbcore.autosuspend=-1 fsck.mode=force fsck.repair=yes
env save
booti ${kernel_addr_r} - ${fdt_addr}
The culprit was a line I sadly left out in my example as I deemed it unimportant...
I work with the boot_count variable also in user land, for that reason I save my environment to the drive so I can interact with it via fw_saveenv.
Because of that I need to load the environment at the beginning of first_boot.scr.
But if you try to load with env load when there is no uboot.env file alot of the environment information is lost. So now I do a check for uboot.env and save if it is not present and load if so.
I described the problem wrong in my question though. I check the presence of fdt_addr before sourching first_boot.scr at times, thus getting lead on the wrong track.
if test -e mmc 0:1 uboot.env; then
echo "Loading env"
env load
else
echo "Saving default environment to file"
env save
fi
if test "${boot_count}" > 4; then
echo "###Loading factory kernel bootscript###"
setenv boot_kernel 2;
load mmc 0:2 ${scriptaddr} images/factory/boot.scr;
source ${scriptaddr}
elif test "${boot_count}" > 2; then
echo "###Loading factory kernel bootscript###"
setenv boot_kernel 1;
load mmc 0:2 ${scriptaddr} images/previous/boot.scr;
source ${scriptaddr}
else
echo "###Loading current kernel bootscript###"
setenv boot_kernel 0;
load mmc 0:2 ${scriptaddr} images/latest/boot.scr;
source ${scriptaddr}
fi

MIPS Linux kernel in qemu trips on initrd

I grabbed initrd and vmlinux (kernel 4.9.0) images from http://ftp.debian.org/debian/dists/Debian9.5/main/installer-mips/20170615+deb9u4/images/malta/netboot, installed and booted Qemu just fine:
$ qemu-system-mips -M malta -m 1G -hda ./debian-mips.qcow2 \
-initrd $initrd \
-kernel $vmlinux \
-append "nokaslr root=/dev/sda1" -nographic
Then I cross-compiled fresh kernel 4.18.0 using the same config as for 4.9.0, but this time Qemu fails to boot:
...
[ 4.036903] NET: Registered protocol family 17
[ 4.045894] rtc_cmos 70.rtc: setting system clock to 2018-07-23 02:26:58 UTC (1532312818)
[ 4.076247] Freeing unused kernel memory: 1528K
[ 4.076491] This architecture does not have kernel memory protection.
Loading, please wait...
starting version 232
[ 4.685538] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 4.703542] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 4.754874] random: udevadm: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... Begin: Waiting for suspend/resume device ... Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
...
done.
Gave up waiting for suspend/resume device
done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ...
done.
done.
Gave up waiting for root file system device. Common problems:
- Boot args (cat /proc/cmdline)
- Check rootdelay= (did the system wait long enough?)
- Missing modules (cat /proc/modules; ls /dev)
ALERT! /dev/sda1 does not exist. Dropping to a shell!
BusyBox v1.22.1 (Debian 1:1.22.0-19+b3) built-in shell (ash)
Enter 'help' for a list of built-in commands.
(initramfs)
I believe I have all the required drivers/hardware support compiled in, since I'm using the same .config file. Also, I mounted my qemu image, and did make modules_install in there, so the image does have the correct modules matching the kernel version.
UPDATE
So I enabled all the drivers under DeviceDrivers/ATA/ATAPI/MFM/RLL support (DEPRECATED) and DeviceDrivers/Serial ATA and Parallel ATA drivers (libata), rebuild the kernel, installed it in qemu image, booted up:
[ 4.437168] ata2.00: ATAPI: QEMU DVD-ROM, 2.5+, max UDMA/100
[ 4.442551] ata1.00: ATA-7: QEMU HARDDISK, 2.5+, max UDMA/100
[ 4.443553] ata1.00: 20971520 sectors, multi 16: LBA48
[ 4.478753] scsi 0:0:0:0: Direct-Access ATA QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5
[ 4.490907] sd 0:0:0:0: Attached scsi generic sg0 type 0
[ 4.498621] sd 0:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB)
[ 4.501629] sd 0:0:0:0: [sda] Write Protect is off
[ 4.508063] scsi 1:0:0:0: CD-ROM QEMU QEMU DVD-ROM 2.5+ PQ: 0 ANSI: 5
[ 4.518142] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 4.539178] sr 1:0:0:0: [sr0] scsi3-mmc drive: 4x/4x cd/rw xa/form2 tray
[ 4.540712] cdrom: Uniform CD-ROM driver Revision: 3.20
[ 4.564806] sr 1:0:0:0: Attached scsi generic sg1 type 5
[ 4.569555] sda: sda1 sda2 < sda5 >
[ 4.588040] sd 0:0:0:0: [sda] Attached SCSI disk
[ 5.102260] Freeing unused kernel memory: 1556K
[ 5.102988] This architecture does not have kernel memory protection.
Loading, please wait...
starting version 232
[ 7.297015] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 7.341169] random: systemd-udevd: uninitialized urandom read (16 bytes read)
[ 7.527445] random: udevadm: uninitialized urandom read (16 bytes read)
Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Will now check root file system ... fsck from util-linux 2.29.2
[/sbin/fsck.ext4 (1) -- /dev/sda1] fsck.ext4 -a -C0 /dev/sda1
/dev/sda1: clean, 29311/628320 files, 454566/2512640 blocks
done.
mount: mounting /dev/sda1 on /root failed: No such device
done.
Begin: Running /scripts/local-bottom ... done.
Begin: Running /scripts/init-bottom ... mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting /dev on /root/dev failed: No such file or directory
done.
mount: mounting /run on /root/run failed: No such file or directory
run-init: current directory on the same filesystem as the root: error 0
Target filesystem doesn't have requested /sbin/init.
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
run-init: current directory on the same filesystem as the root: error 0
No init found. Try passing init= bootarg.
What else is possibly going wrong here?
Thanks.
The kernel configuration has to include the following options for correct FS mount procedure :
a) Device Drivers/Serial ATA and Parallel ATA drivers (libata) -- CONFIG_ATA_SFF, CONFIG_ATA_BMDMA, CONFIG_ATA_PIIX
b) Device Drivers/Generic Driver Options -- CONFIG_DEVTMPFS

Vanilla kernel build on Rasperry Pi 1 B+

Attempting to build mainline vanilla kernel (4.9) and boot on a Raspberry Pi 1 B+. Have followed instructions here. Currently boot hangs with the following output
Net: No ethernet found. starting USB...
USB0: Core Release: 2.80a
scanning bus 0 for devices... 3 USB Device(s) found
scanning usb for storage devices... 0 Starage Device(s) found
Hit any key to stap autoboot: 0
switch to partition #0, OK
mmc0 is current device
Scanning mmc 0:1
Found U-Boot script /boot.scr.uimg
reading /boot.scr.uimg 326 bytes read in 25 ms (12.7KiB/s)
## Exectuting script at 02000000 switch to partitions #0, OK
mmc0 is current device
reading ZImage
4064616 bytes read in 389 Ms (10MiB/s)
reading bcm2835-rpi-b-plus.dtb
7101 bytes read in 31 Ms (223.6KiB/s)
Kernel image # 0x1000000 [ 0x000000 _0x3e0568 ]
## Flattened Device Tree blob at 00000100
Booting using the fdt blob at 0x000100
Using Device Tree in place at 00000100, end 00004cbc
Starting kernel ...
boot.scr.uimg was built using mkimage from Ubuntu repositories
$ mkimage -V
mkimage version 2016.01+dfsg1-2ubuntu3
$ mkimage -A arm -O linux -T script -C none -n boot.scr -d boot.scr boot.scr.uimg
boot.scr is as listed in the instructions.
mmc dev 0
setenv fdtfile bcm2835-rpi-b-plus.dtb
setenv bootargs earlyprintk console=tty0 console=ttyAMA0 root=/dev/mmcblk0p2 rootwait
fatload mmc 0:1 ${kernel_addr_r} zImage
fatload mmc 0:1 ${fdt_addr_r} ${fdtfile}
bootz ${kernel_addr_r} - ${fdt_addr_r}

Linux-2.6.10 MIPS restarts after "Starting kernel ..."

I'm using old Linux-2.6.10 with ramdisk for MIPS arch. I was needed to enlarge my initrd for debug purposes. So, I did this. But with big initrd (~2.1MB) my board restarts faultly.
MY-BOARD # run bootnet
Using Board Eth. device
TFTP from server 192.168.1.10; our IP address is 192.168.1.1
Filename 'uImage'.
Load address: 0x80800000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
##################################################
done
Bytes transferred = 3247396 (318d24 hex)
## Booting image at 80800000 ...
Image Name: Linux-2.6.10 with ramdisk
Created: 2014-01-13 8:27:39 UTC
Image Type: MIPS Linux Kernel Image (gzip compressed)
Data Size: 3247332 Bytes = 3.1 MB
Load Address: 80100000
Entry Point: 8057b000
Verifying Checksum ... OK
Uncompressing Kernel Image ... OK
Starting kernel ...
Error: Boot failed!
My u-boot environment:
Type "printenv" to view boot options.
Hit any key to stop autoboot: 0
MY-BOARD # printenv
bootargs=console=ttyS0,115200 nofpu mem=30M root=/dev/ram0 rw
bootcmd=cp.b 0xad040000 0x80800000 0x400000; bootm 0x80800000
bootdelay=3
baudrate=115200
ethaddr=00:06:0D:00:00:00
ipaddr=192.168.1.1
serverip=192.168.1.10
preboot=echo; echo Type "printenv" to view boot options.; echo;
netmask=255.255.255.0
u-bootfile=u-boot.bin
prog-ub=run load-ub update-ub
load-ub=tftp 80504000 $(u-bootfile)
update-ub=protect off 1:0-4; cp.b AD000000 80500000 4000; cp.b AD03F000 8053F000 1000; erase 0xAD000000 0xAD03ffff; cp.b 80500000 AD000000 0x40000
imget=tftp 0x80800000 $(imname); erase 0xad000000 0xad7e0000; cp.b 0x80800000 0xad000000 $(filesize)
progkn=tftp 0x80800000 uImage; erase 0xad040000 0xad43ffff; cp.b 0x80800000 0xad040000 $(filesize)
progjffs=tftp 0x80800000 jffs; erase 0xad240000 0xad53ffff; cp.b 0x80800000
0xad240000 $(filesize)
bootnet=tftp 0x80800000 uImage; bootm 0x80800000
stdin=serial
stdout=serial
stderr=serial
ethact=Board Eth.
Environment size: 980/4092 bytes
MY-BOARD #
Does somebody know or remember how to fix this? I also use old U-Boot 1.1.2. U-Boot reaches "Starting kernel ..." and jump to the kernel entry point, theKernel() function. There is restart then ("Error: Boot failed!").
The kernel so old that it hasn't early_printk to debug itself. Imho, U-Boot is ok, and I miss some initrd option (I made all visible kernel .config). With small embedded initrd image (~700kB) Linux boot smoothly. In both cases initrd has the same size (8192K).
p.s.: I am sorry for imperfect English.

Resources