Hello,
I'm using yocto linux 5.4.70-2.3.1 on MEK board (I.MX8QM). By default eth0 is configured to use dhcp. How can I change this to a static IP address that would be set permanently (remains through reboots) ?
I tried various things I could find on the web but no luck so far...
Thanks,
Solved! Go to Solution.
ok, I found the proper way of doing it. The Yocto distribution I have seems to use systemd.
So I didn't even need to change any thing on the boot command line, all I had to do is to create a file /etc/systemd/network/20-wired.network with following content:
[Match]
Name=eth0
[Network]
Address=192.168.1.12/24
Hello,
You may find it helpful to refer to the following thread where this has already been discussed: https://community.nxp.com/t5/i-MX-Processors/change-IP-address-static-DHCP/td-p/243273
Hope it helps!
BR,
Ivan.
Hello,
Following the thread you pointed me to, I tried to remove "ip=dhcp" from the uboot "netargs" variable so it is now:
netargs=setenv bootargs console=${console},${baudrate} earlycon root=/dev/nfs nfsroot=${serverip}:${nfsroot},v3,tcp
Then I created an /etc/network/interfaces file containing my static ip configuration. If I then do an ifdown/ifup, the ethernet interface is up with the right static IP address.
If I then restart the board, the ethernet is still not getting configured with the static IP and my /etc/network/interfaces file is then empty... (gets kind of reset to empty somehow during the boot process ?...)
Any other idea ?
For info here is my boot command line:
=> printenv
auth_os=auth_cntr ${cntr_addr}
baudrate=115200
board_name=MEK
board_rev=iMX8QM
boot_fdt=try
boot_os=booti ${loadaddr} - ${fdt_addr};
bootcmd=mmc dev ${mmcdev}; if mmc rescan; then if run loadbootscript; then run bootscript; else if test ${sec_boot} = yes; then if run loadcntr; then run mmcboot; else run netboot; fi; else if run loadimage; then run mmcboot; else run netboot; fi; fi; fi; else booti ${loadaddr} - ${fdt_addr}; fi
bootcmd_mfg=run mfgtool_args;if iminfo ${initrd_addr}; then if test ${tee} = yes; then bootm ${tee_addr} ${initrd_addr} ${fdt_addr}; else booti ${loadaddr} ${initrd_addr} ${fdt_addr}; fi; else echo "Run fastboot ..."; fastboot auto; fi;
bootdelay=1
bootscript=echo Running bootscript from mmc ...; source
cntr_addr=0x98000000
cntr_file=os_cntr_signed.bin
commit_atf=f1d7187
commit_mkimage=8947fea3
commit_scfw=11102b55
commit_secofw=d63fdb21
console=ttyLP0
dom0fdt_file=imx8qm-mek-dom0.dtb
domu-android-auto=no
emmc_dev=0
eth1addr=00:04:9f:06:d0:93
ethact=ethernet@5b040000
ethaddr=00:04:9f:06:d0:92
ethprime=eth0
fastboot_dev=mmc0
fdt_addr=0x83000000
fdt_file=imx8qm-mek.dtb
fdt_high=0xffffffffffffffff
fdtcontroladdr=fae0aab0
hdp_addr=0x9c000000
hdp_file=hdmitxfw.bin
hdprx_addr=0x9c800000
hdprx_file=hdmirxfw.bin
image=Image
initrd_addr=0x83100000
initrd_high=0xffffffffffffffff
jh_mmcboot=setenv fdt_file imx8qm-mek-root.dtb;setenv boot_os 'scu_rm dtb ${fdt_addr}; booti ${loadaddr} - ${fdt_addr};'; run mmcboot;
jh_netboot=setenv fdt_file imx8qm-mek-root.dtb;setenv boot_os 'scu_rm dtb ${fdt_addr}; booti ${loadaddr} - ${fdt_addr};'; run netboot;
kboot=booti
loadaddr=0x80280000
loadbootscript=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};
loadcntr=fatload mmc ${mmcdev}:${mmcpart} ${cntr_addr} ${cntr_file}
loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}
loadhdp=fatload mmc ${mmcdev}:${mmcpart} ${hdp_addr} ${hdp_file}
loadhdprx=fatload mmc ${mmcdev}:${mmcpart} ${hdprx_addr} ${hdprx_file}
loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}
loadm4image_0=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${m4_0_image}
loadm4image_1=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${m4_1_image}
m4_0_image=m4_0.bin
m4_1_image=m4_1.bin
m4boot_0=run loadm4image_0; dcache flush; bootaux ${loadaddr} 0
m4boot_1=run loadm4image_1; dcache flush; bootaux ${loadaddr} 1
mfgtool_args=setenv bootargs console=${console},${baudrate} rdinit=/linuxrc clk_ignore_unused
mmcargs=setenv bootargs console=${console},${baudrate} earlycon root=${mmcroot}
mmcautodetect=yes
mmcboot=echo Booting from mmc ...; if run loadhdp; then; hdp load ${hdp_addr}; fi;run mmcargs; if test ${sec_boot} = yes; then if run auth_os; then run boot_os; else echo ERR: failed to authenticate; fi; else if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if run loadfdt; then run boot_os; else echo WARN: Cannot load the DT; fi; else echo wait for boot; fi;fi;
mmcdev=0
mmcpart=1
mmcroot=/dev/mmcblk0p2 rootwait rw
nandfit_part=yes
netargs=setenv bootargs console=ttyLP0,115200 earlycon root=/dev/nfs nfsroot=:,v3,tcp
netboot=echo Booting from net ...; run netargs; if test ${ip_dyn} = yes; then setenv get_cmd dhcp; else setenv get_cmd tftp; fi; if ${get_cmd} ${hdp_addr} ${hdp_file}; then; hdp load ${hdp_addr}; fi;if test ${sec_boot} = yes; then ${get_cmd} ${cntr_addr} ${cntr_file}; if run auth_os; then run boot_os; else echo ERR: failed to authenticate; fi; else ${get_cmd} ${loadaddr} ${image}; if test ${boot_fdt} = yes || test ${boot_fdt} = try; then if ${get_cmd} ${fdt_addr} ${fdt_file}; then run boot_os; else echo WARN: Cannot load the DT; fi; else booti; fi;fi;
script=boot.scr
sd_dev=1
sec_boot=no
serial#=1004880e828bc82d
soc_type=imx8qm
splashimage=0x9e000000
xenboot_common=${get_cmd} ${loadaddr} xen;${get_cmd} ${fdt_addr} ${dom0fdt_file};if ${get_cmd} ${hdp_addr} ${hdp_file}; then; hdp load ${hdp_addr}; fi;${get_cmd} ${xenlinux_addr} ${image};fdt addr ${fdt_addr};fdt resize 256;fdt set /chosen/module@0 reg <0x00000000 ${xenlinux_addr} 0x00000000 0x${filesize}>; fdt set /chosen/module@0 bootargs "${bootargs} ${xenlinux_bootargs}"; if test ${domu-android-auto} = yes; then; fdt set /domu/doma android-auto <1>;fdt rm /gpio@5d090000 power-domains;fi;setenv bootargs ${xenhyper_bootargs};booti ${loadaddr} - ${fdt_addr};
xenhyper_bootargs=console=dtuart dom0_mem=2048M dom0_max_vcpus=2 dom0_vcpus_pin=true hmp-unsafe=true
xenlinux_addr=0x9e000000
xenlinux_bootargs=
xenlinux_console=hvc0 earlycon=xen
xenmmcboot=setenv get_cmd "fatload mmc ${mmcdev}:${mmcpart}";setenv console ${xenlinux_console};run mmcargs;run xenboot_common;
xennetboot=setenv get_cmd dhcp;setenv console ${xenlinux_console};run netargs;run xenboot_common;
Environment size: 4692/8188 bytes
I could fix the issue with the file content being erased. This is probably due to some cache being not flushed to the device before I reset the board. If I restart the board with the command "reboot" instead of pressing the reset button, the content of the file remains. But still my interface doesn't get the IP config. My file /etc/network/interface has following content:
auto eth0
iface eth0 inet static
address 192.168.0.12
netmask 255.255.255.0
ifconfig gives me the following after startup:
eth0 Link encap:Ethernet HWaddr 00:04:9F:06:D0:92
inet6 addr: fe80::204:9fff:fe06:d092/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:222 errors:0 dropped:0 overruns:0 frame:0
TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21862 (21.3 KiB) TX bytes:4427 (4.3 KiB)
During startup I see following being printed:
[ 10.730401] fec 5b040000.ethernet eth0: Link is Up - 1Gbps/Full - flow control off
[ 10.738050] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
I could get the interface configured with the static IP set in /etc/network/interfaces by adding to /etc/rc.local the following line:
ifup eth0
I don't know why this is not called by some other script during the boot process... It works but kind of sounds like a dirty hack to me... I'm wondering if the recent yocto distributions are not using some other system than this /etc/network/interfaces to bring up the interfaces during the boot process....
ok, I found the proper way of doing it. The Yocto distribution I have seems to use systemd.
So I didn't even need to change any thing on the boot command line, all I had to do is to create a file /etc/systemd/network/20-wired.network with following content:
[Match]
Name=eth0
[Network]
Address=192.168.1.12/24