linux-kernelbeagleboneblacku-bootbeagleboard

NFS mounting while booting Linux kernel on BeagleBone


I am trying to mount NFS while booting my beaglebone board. I use ethernet over usb on board. I have done this steps:

  1. Setup uboot settings:
=> env default -f -a
=> setenv ipaddr 192.168.0.100
=> setenv serverip 192.168.0.1
=> setenv ethact usb_ether
=> setenv usbnet_devaddr f8:dc:7a:00:00:02
=> setenv usbnet_hostaddr f8:dc:7a:00:00:01
=> setenv bootcmd 'tftp 0x81000000 zImage; tftp 0x82000000 am335x-boneblack.dtb; bootz 0x81000000 - 0x82000000'
=> saveenv
  1. Setup interface on workstation:
nmcli con add type ethernet ifname enxf8dc7a000001 ip4 192.168.0.1/24
  1. Setup /etc/exports file on workstation:
/home/anisyan/proj/learn-embedded-linux/linux-kernel-labs/modules/nfsroot/ 192.168.0.100(rw,no_root_squash,no_subtree_check)
  1. Try ping the host from uboot (It's alive):
=> ping 192.168.0.1
using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC f8:dc:7a:00:00:02
HOST MAC f8:dc:7a:00:00:01
RNDIS ready
musb-hdrc: peripheral reset irq lost!
high speed config #2: 2 mA, Ethernet Gadget, using RNDIS
USB RNDIS network up!
Using usb_ether device
host 192.168.0.1 is alive

But I can't use nfs command in uboot. It generates the error:

=> nfs

Warning: usb_ether using MAC address from ROM
using musb-hdrc, OUT ep1out IN ep1in STATUS ep2in
MAC f8:dc:7a:00:00:02
HOST MAC f8:dc:7a:00:00:01
RNDIS ready
musb-hdrc: peripheral reset irq lost!
high speed config #2: 2 mA, Ethernet Gadget, using RNDIS
USB RNDIS network up!
Using usb_ether device
File transfer via NFS from server 192.168.0.1; our IP address is 192.168.0.100
Filename 'zImage/�zImage'.
Load address: 0x82000000
Loading: *** ERROR: Cannot mount
  1. setup kernel bootargs:
setenv bootargs root=/dev/nfs rw ip=192.168.0.100:::::usb0 console=ttyO0,115200n8 g_ether.dev_addr=f8:dc:7a:00:00:02 g_ether.host_addr=f8:dc:7a:00:00:01 nfsroot=192.168.0.1:/home/anisyan/proj/learn-embedded-linux/linux-kernel-labs/modules/nfsroot/ ,nfsvers=3

And my kernel generates the error while mounting FS:

------
[    2.545318] omap_i2c 4819c000.i2c: bus 2 rev0.11 at 100 kHz
[    2.570464] hctosys: unable to open rtc device (rtc0)
[  111.202637] VFS: Unable to mount root fs via NFS, trying floppy.
[  111.209241] VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
[  111.216571] Please append a correct "root=" boot option; here are the available partitions:
[  111.225000] 0100           65536 ram0 
[  111.225004]  (driver?)
[  111.231133] 0101           65536 ram1 
[  111.231135]  (driver?)
[  111.237282] 0102           65536 ram2 
[  111.237284]  (driver?)
[  111.243425] 0103           65536 ram3 
[  111.243427]  (driver?)
[  111.249552] 0104           65536 ram4 
[  111.249554]  (driver?)
[  111.255696] 0105           65536 ram5 
[  111.255698]  (driver?)
[  111.261823] 0106           65536 ram6 
[  111.261825]  (driver?)
[  111.267966] 0107           65536 ram7 
[  111.267968]  (driver?)
[  111.274107] 0108           65536 ram8 
[  111.274110]  (driver?)
[  111.280236] 0109           65536 ram9 
[  111.280239]  (driver?)
[  111.286389] 010a           65536 ram10 
[  111.286392]  (driver?)
[  111.292620] 010b           65536 ram11 
[  111.292622]  (driver?)
[  111.298834] 010c           65536 ram12 
[  111.298836]  (driver?)
[  111.305064] 010d           65536 ram13 
[  111.305066]  (driver?)
[  111.311277] 010e           65536 ram14 
[  111.311280]  (driver?)
[  111.317507] 010f           65536 ram15 
[  111.317510]  (driver?)
[  111.323745] b300        15267840 mmcblk0 
[  111.323749]  driver: mmcblk
[  111.330574]   b301          101376 mmcblk0p1 614bbe6e-01
[  111.330577] 
[  111.337416]   b302        15164416 mmcblk0p2 614bbe6e-02
[  111.337418] 
[  111.344260] b310         3735552 mmcblk1 
[  111.344262]  driver: mmcblk
[  111.351084]   b311         3731456 mmcblk1p1 18ac3061-01
[  111.351086] 
[  111.357929] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
[  111.366232] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.5.0-rc6 #1
[  111.372435] Hardware name: Generic AM33XX (Flattened Device Tree)
[  111.378595] [<c03128b4>] (unwind_backtrace) from [<c030cb64>] (show_stack+0x10/0x14)
[  111.386385] [<c030cb64>] (show_stack) from [<c0eeaf70>] (dump_stack+0xc0/0xd4)
[  111.393651] [<c0eeaf70>] (dump_stack) from [<c0347d90>] (panic+0x110/0x328)
[  111.400654] [<c0347d90>] (panic) from [<c1601484>] (mount_block_root+0x184/0x234)
[  111.408173] [<c1601484>] (mount_block_root) from [<c160179c>] (mount_root+0x124/0x140)
[  111.416124] [<c160179c>] (mount_root) from [<c1601934>] (prepare_namespace+0x17c/0x1b8)
[  111.424167] [<c1601934>] (prepare_namespace) from [<c0f02c3c>] (kernel_init+0x8/0x10c)
[  111.432122] [<c0f02c3c>] (kernel_init) from [<c03010e8>] (ret_from_fork+0x14/0x2c)
[  111.439721] Exception stack(0xdb0b1fb0 to 0xdb0b1ff8)
[  111.444794] 1fa0:                                     00000000 00000000 00000000 00000000
[  111.453007] 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
[  111.461218] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000
[  111.467876] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0) ]---

Could anyone help me please with it?

UPD: I can mount NFS from uboot console(just for network test) with help

=> nfs 0x81000000 192.168.0.1:/mnt/share/file

Then I downloaded my kernel image and DTB with help TFTP and run boot from uboot.

I have thought that the kernel should setup eternet-over-usb device and then mount nfs. I added this flags to kernek config for it:

CONFIG_USB_GADGET=y
CONFIG_USB_MUSB_HDRC=y
CONFIG_USB_MUSB_GADGET=y
CONFIG_USB_MUSB_DSPS=y
CONFIG_AM335X_PHY_USB=y
CONFIG_USB_ETH=y
CONFIG_ROOT_NFS=y 

But I still get error during booting.


Solution

  • I have solved this problem:

    1. I should't edit the .config file by hand. I should do it only with help make menuconfig, because any CONFIG_* flag can have some dependies. make menuconfig can resolve it.

    2. We can explicitly point the init program in the bootargs:

    init=/absolete/path/to/init/program