0

I'd like to automatically set the i.p address of usb port which is configured in cdc mode for my imx6 board.

I have tried manually setting the

I have also written a script to do this after boot. (after we login as root).

Both of them work but I'd like this to happen before the board asks for login prompt.

This was the content of the script

ifconfig usb0 192.168.100.100

placed in /etc/profile.d

I need to first login as root and then I can see the ip of usb0. Is it possible to have usb0's i.p set before login?

Sujay
  • 26
  • 1
  • 6

2 Answers2

1

I would create a meta-custom/recipes-core/systemd-conf/files/06-usb0.network file:

[Match]
Name=usb0

[Network]
Address=192.168.100.100/24

With meta-custom/recipes-core/systemd-conf/systemd-conf_%.bbappend recipe:

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += "file://06-usb0.network"

do_install_append() {
    install -d ${D}${sysconfdir}/systemd/network
    install -m 0644 ${WORKDIR}/06-usb0.network ${D}${sysconfdir}/systemd/network
}

FILES_${PN} += "${sysconfdir}/systemd/network/06-usb0.network"

Note: if you don't use latest Yocto release, it should be systemd-conf.bbappend instead of systemd-conf_%.bbappend

Nayfe
  • 2,130
  • 13
  • 18
  • what does_% stand for in systemd-conf_%.bbappend (I'm a novice so I'm not familiar with the jargon) – Sujay Nov 08 '19 at 10:01
  • `When you name an append file, you can use the "%" wildcard character to allow for matching recipe names.` see [mega manual](https://www.yoctoproject.org/docs/latest/mega-manual/mega-manual.html#ref-terms) – Nayfe Nov 08 '19 at 11:59
0

So I found a script /etc/rc.local

It was mentioned that the script does nothing so I guess that means I can modify it as I wish.

I just added

ifconfig usb0 192.168.100.100

at the start, and the usb i.p seem's to have set before login.

This however seems like a dirty solution, If there is a cleaner way please let me know.

Sujay
  • 26
  • 1
  • 6