Tool/software: Linux
Dear,
How do i set IP address permanently in sitara linux (kernel space)? So that i can communicate to other system via ethernet after power on.
Regards,
Winiston.P
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Linux
Dear,
How do i set IP address permanently in sitara linux (kernel space)? So that i can communicate to other system via ethernet after power on.
Regards,
Winiston.P
Hi Winiston,
There are 2 ways to set static IP address of your device.
1. Set IP via bootargs:
You should stop booting in u-boot prompt.
Execute 'printenv' command and find bootargs variable. If 'ip=dhcp' presents or there is noting set for 'ip' edit bootargs so that ip={ ipaddr }:{ serverip }:{ gatewayip }:{ netmask }:{ hostname }::off, where you set ipaddr, serverip, gatewayip, netmask, and hostname to desired values.
Then save configuration using 'saveenv' command.
2. Set IP in Linux:
Open /etc/network/interfaces on the rootfs in a text editor.
Comment out 'iface eth0 inet dhcp' by adding a '#' in front of it if it presents.
Then add your desired settings:
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
network 192.168.1.0
gateway 192.168.1.1
dns-nameserver XXX.XXX.XXX.XXX
Save the file and reboot.
To be sure to avoid overlapping of opposite configurations execute both steps.
BR
Tsvetolin Shulev
Dear,
I have tried both the options. But ip address did not set permanently. My "printenv" output attached below.
U-Boot# printenv
arch=arm
args_mmc=run finduuid;setenv bootargs console=${console} ${optargs} root=PARTUUID=${uuid} rw rootfstype=${mmcrootfstype}
baudrate=115200
board=am43xx
board_name=AM43__GP
board_rev=v1.4
bootargs=console=ttyO0,115200n8 root=/dev/nfs nfsroot=:/export/rootfs,nolock rw ip=static
bootcmd=run findfdt; run mmcboot;run usbboot;run nandboot;
bootdelay=1
bootdir=/boot
bootenv=uEnv.txt
bootfile=zImage
bootm_size=0x10000000
bootpart=0:2
console=ttyO0,115200n8
cpu=armv7
dfu_alt_info_emmc=MLO raw 0x100 0x100 mmcpart 0;u-boot.img raw 0x300 0x1000 mmcpart 0
dfu_alt_info_mmc=boot part 0 1;rootfs part 0 2;MLO fat 0 1;spl-os-args fat 0 1;spl-os-image fat 0 1;u-boot.img fat 0 1;uEnv.txt fat 0 1
dfu_alt_info_ram=kernel ram 0x80200000 0x4000000;fdt ram 0x80f80000 0x80000;ramdisk ram 0x81000000 0x4000000
dfu_bufsiz=0x10000
eth1addr=a0:f6:fd:60:41:a3
ethact=cpsw
ethaddr=a0:f6:fd:60:41:a1
fdt_addr_r=0x88000000
fdtaddr=0x88000000
fdtfile=undefined
findfdt=if test $board_name = AM43EPOS; then setenv fdtfile am43x-epos-evm.dtb; fi; if test $board_name = AM43__GP; then setenv fdtfile am437x-gp-evm.dtb; fi; if test $b
finduuid=part uuid mmc 0:2 uuid
importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
kernel_addr_r=0x82000000
loadaddr=0x82000000
loadbootenv=load ${devtype} ${devnum} ${loadaddr} ${bootenv}
loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/${fdtfile}
loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
loadramdisk=load ${devtype} ${devnum} ${rdaddr} ramdisk.gz
mmcboot=mmc dev ${mmcdev}; setenv devnum ${mmcdev}; setenv devtype mmc; if mmc rescan; then echo SD/MMC found on device ${devnum};if run loadbootenv; then echo Loaded en;
mmcdev=0
mmcrootfstype=ext4 rootwait
mtdids=nand0=nand.0
mtdparts=mtdparts=nand.0:256k(NAND.SPL),256k(NAND.SPL.backup1),256k(NAND.SPL.backup2),256k(NAND.SPL.backup3),512k(NAND.u-boot-spl-os),1m(NAND.u-boot),256k(NAND.u-boot-en)
nandargs=setenv bootargs console=${console} ${optargs} root=${nandroot} rootfstype=${nandrootfstype}
nandboot=echo Booting from nand ...; run nandargs; nand read ${fdtaddr} NAND.u-boot-spl-os; nand read ${loadaddr} NAND.kernel; bootz ${loadaddr} - ${fdtaddr}
nandroot=ubi0:rootfs rw ubi.mtd=NAND.file-system,4096
nandrootfstype=ubifs rootwait=1
netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
netboot=echo Booting from network ...; setenv autoload no; dhcp; run netloadimage; run netloadfdt; run netargs; bootz ${loadaddr} - ${fdtaddr}
netloadfdt=tftp ${fdtaddr} ${fdtfile}
netloadimage=tftp ${loadaddr} ${bootfile}
nfsopts=nolock
partitions=uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}
ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}
ramdisk_addr_r=0x88080000
ramroot=/dev/ram0 rw
ramrootfstype=ext2
rdaddr=0x88080000
rootpath=/export/rootfs
soc=am33xx
static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
stderr=serial
stdin=serial
stdout=serial
usbargs=setenv bootargs console=${console} ${optargs} root=${usbroot} rootfstype=${usbrootfstype}
usbboot=setenv devnum ${usbdev}; setenv devtype usb; usb start ${usbdev}; if usb dev ${usbdev}; then if run loadbootenv; then echo Loaded environment from ${bootenv};runi
usbdev=0
usbnet_devaddr=a0:f6:fd:60:41:a3
usbroot=/dev/sda2 rw
usbrootfstype=ext4 rootwait
vendor=ti
ver=U-Boot 2015.07-00114-gf8d68d1-dirty (Sep 12 2016 - 14:28:40 +0530)
Environment size: 4384/65532 bytes
U-Boot
i entered from the uboot as given below
ip={ 192.168.1.10 }:{ 192.168.1.1}:{192.168.1.1}:{255.255.255.0}:{futura}::off
saveenv
and i edited in "/etc/network/interfaces" as you said in the previous mail. But ip address did not set permanently.
How do i resolve this issue?
Regards,
Winiston.P
Winiston,
The issue for the configuration described in my previous post is that the interface does not become up after reboot.
You should try manually to execute 'ifup eth0' and the check whether the configuration is applied.
If it is OK you should add in the init script 'ifup eth0'. There are the step which works on my board:
1. Go to /lib/systemd/system folder and create a file named myinit.service with content:
[Unit] Description=Myinit scripts [Service] ExecStart=/etc/init.d/myinitscript.sh [Install] WantedBy=multi-user.target
2. Go to /etc/init.d/ folder and create a file named myinitscript.sh with content:
#!/bin/sh echo "My script doing ifup eth0\n" ifdown eth0 sleep 3 ifup eth0
3. Make the script executable:
chmod a+x myinitscript.sh
4. Enable and start the myinit.service:
systemctl unmask myinit.service systemctl enable myinit.service systemctl start myinit.service
5. Reboot the device and check IP config (ifconfig).
BR
Tsvetolin Shulev
Dear Tsvetolin,
I followed your guideline and succeeded to set ip address permanently. Thanks a lot .
Regards,
Winiston.P