g_multi not loading at boot

Hi,

I have installed a custom Debian using the steps on eewiki. I have downloaded the beaglebone-black-g-ether-load.sh script to load g_ether, and finally I have created a systemd service to load it as follows:

[Unit]
Description=Generic BeagleBone Black at boot time
Requires=systemd-journald.socket basic.target
After=local-fs.target systemd-journald.socket basic.target

[Service]
Type=simple
ExecStart=/opt/scripts/beaglebone-black-g-ether-load.sh
StandardOutput=journal
Restart=no

[Install]
WantedBy=multi-user.target

When booting the service outputs an error when loading the g_multi module:

may 22 12:54:57 beaglebone beaglebone-black-g-ether-load.sh[185]: cpsw.0: 7C:66:9D:46:4B:43
may 22 12:54:57 beaglebone beaglebone-black-g-ether-load.sh[185]: cpsw.1: 7C:66:9D:46:4B:45
may 22 12:54:57 beaglebone beaglebone-black-g-ether-load.sh[185]: modprobe: ERROR: could not insert ‘g_multi’: No such device

I have seen that there is another discussion related to this problem, but the difference in this case is that it load after login in the system and executing the script by hand.

I can’t figure out what is the difference between both cases and why it doesn’t work on boot.

More information:

root@beaglebone:~# printenv
XDG_SESSION_ID=1
TERM=xterm
SHELL=/bin/bash
USER=root
MAIL=/var/mail/root
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/root
LANG=en_US.UTF-8
SHLVL=1
HOME=/root
LOGNAME=root
XDG_RUNTIME_DIR=/run/user/0
_=/usr/bin/printenv

Modules before loading:

root@beaglebone:~# lsmod
Module Size Used by
musb_dsps 8465 0
musb_hdrc 76896 1 musb_dsps
pruss_remoteproc 12702 0
ti_am335x_adc 4766 0
kfifo_buf 1941 1 ti_am335x_adc
industrialio 34965 2 ti_am335x_adc,kfifo_buf
musb_am335x 1075 0
uio_pdrv_genirq 2824 0
uio 7008 1 uio_pdrv_genirq
usb_f_mass_storage 34731 0
usb_f_rndis 17807 0
u_ether 9436 1 usb_f_rndis
libcomposite 38883 2 usb_f_rndis,usb_f_mass_storage

And after loading:

root@beaglebone:/opt/scripts# lsmod
Module Size Used by
usb_f_acm 5695 1
u_serial 9655 1 usb_f_acm
usb_f_ecm 7901 1
g_multi 3226 0
musb_dsps 8465 0
musb_hdrc 76896 1 musb_dsps
pruss_remoteproc 12702 0
ti_am335x_adc 4766 0
kfifo_buf 1941 1 ti_am335x_adc
industrialio 34965 2 ti_am335x_adc,kfifo_buf
musb_am335x 1075 0
uio_pdrv_genirq 2824 0
uio 7008 1 uio_pdrv_genirq
usb_f_mass_storage 34731 2 g_multi
usb_f_rndis 17807 2 g_multi
u_ether 9436 3 usb_f_ecm,usb_f_rndis,g_multi
libcomposite 38883 5 usb_f_acm,usb_f_ecm,usb_f_rndis,g_multi,usb_f_mass_storage

Any idea why this is happening ?

Yeap, you have a race condition between:

musb_hdrc & g_multi

The easy fix is to build-in musb_hdrc.

Otherwise verify musb_hdrc has been loaded before you modprobe g_multi

Regards,

Thank you Robert for your fast answer,

And how does the official scripts manage to avoid the race condition ?

I have been looking at generic-boot-script.sh that is loaded at init and to am335x_evm.sh (after loading SOC.sh). I tried to replicate the same behaviour but just writing a replacemente service file for generic-boot-script,calling directly to the beaglebone-black-g-ether-load.sh script. I’m using the same ti kernel from your repository.

I tried adding musb_hdrc on the initramfs, but i’m no sure if it’s the correct way to go. I’m still trying to learn how all the boot process works.

Best regards,

Easy...

https://github.com/RobertCNelson/ti-linux-kernel-dev/commit/91b44dd618b6a4f0d44aa00a18e6195292fd4c0d

moved CONFIG_USB_MUSB_HDRC to be built-in..

Regards,

Ok, I compiled a new version of the kernel with that modification and it’s working now.

Thank you :slight_smile: