UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Reply

Not able to config IP and other configuations over Linux OS boot for ZC702 Eval Board

Accepted Solution Solved
Visitor
Posts: 2
Registered: ‎02-12-2018
Accepted Solution

Not able to config IP and other configuations over Linux OS boot for ZC702 Eval Board

I have installed Linux OS on ZC702 by using petalinux-tools (v2017.3) and ZC702 BSP (v2017.3) and following Petalinux User Guide ug1144 

At final Stage I am adding BOOT.bin and image.ub in BOOT partition of SD Card.

The Board boots up with same image and i am able to assign IP address from DHCP server from my host machine for the first time power on and also I am able to access the root and its directories over ssh.

 

Then I update the script '/etc/network/interfaces' (referred this link) (on ZC702 root file system with "sudo" rights) for assigning static IP but on reboot it is not able to take that IP from this file and i have to assign IP address using DHCP Server again on boot..

 

Also I want to run my application on start which I am implementing over "crontab" feature.. 

 

Please advise how I can solve this and assign a IP on boot-up from this "interfaces" file and can keep the configuration sustain on boot of eval board and also in power-on/off states.

 

Thanks

 


Accepted Solutions
Adventurer
Posts: 84
Registered: ‎03-22-2016

Re: Not able to config IP and other configuations over Linux OS boot for ZC702 Eval Board

Petalinux is different from most Linux distributions. Normally, you install to a device, and then as you make changes they are written to your root filesystem. Package management, configuration, etc.

 

With Petalinux, you instead do all of your installation and configuration ahead of time, on the host machine. The end result is a root filesystem image that is intended to be loaded into a ramdisk on boot. While running, you can make changes, but as soon as you power off, those changes are gone. This is an intentional (and desirable) feature for embedded systems, but it can take some getting used to. The benefit is that you have something that can tolerate unclean shutdowns without any worry of filesystem corruption. And you don't have to think about modifying configuration on the device (especially convenient for devices you can't log into, or when there are hundreds of them).

 

Anyway, the point is, you need to make your changes on the host so that they end up in your BOOT.BIN and image.ub files. Petalinux includes some basic ability to modify network configuration using petalinux-config. If you want more configuration than that (such as a custom /etc/network/interfaces file), you'll need to add a custom "app" to your build. That app can copy any files you want into the running system.

 

I usually create an app called "customize", and include all the things that need to be customized for that particular project. In my most recent project, I have it loading an SSH key and an /etc/init.d startup script. In the startup script, I have it look for files on the SD card and use them to replace the ones in the root filesystem. It also looks for a bitfile and reprograms the fpga if it finds one. With this setup, I can make per-device changes on the SD without needing to generate new images.

 

customize.bb:

#
# This file is the customize recipe.
#

SUMMARY = "Simple customize application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://id_rsa.pub \
file://load-config \
"

inherit update-rc.d

# networking is at 01, so we have to get in before that
INITSCRIPT_NAME = "load-config"
INITSCRIPT_PARAMS = "defaults 00"

S = "${WORKDIR}"

do_install() {
install -d ${D}${sysconfdir}/init.d
install -d ${D}/home/root/.ssh

install -m 0755 ${S}/load-config ${D}${sysconfdir}/init.d/load-config
install -m 0600 ${S}/id_rsa.pub ${D}/home/root/.ssh/authorized_keys
}

${IMAGE_ROOTFS}/etc/inittab;"
FILES_${PN} += "/home/root/"

load-config:

#!/bin/sh
### BEGIN INIT INFO
# Provides:           load-config
# Required-Start      
# Required-Stop       
# Default-Start       S
# Default-Stop:       
# Short-Description:  Startup
### END INIT INFO

S=/mnt/sdcard
D=/etc/yourapplication
C=startup.sh

if [ "$1" != "start" ]; then
    exit 0
fi

# create directories/files
mkdir -p ${S}
mkdir -p ${D}

# mount the sd card
mount /dev/mmcblk0p1 ${S}

if [ -f ${S}/${C} ]; then
    echo "Running startup script"
    cp ${S}/${C} ${D}/${C}
    source ${D}/${C}
else
    echo "No startup script file found"
fi

# Load /etc files
if [ -d ${S}/etc ]; then
    echo "Loading /etc from SD"
    cp -rv ${S}/etc/* /etc/
fi

# if bitfile exists on SD card, program it
if [ -f ${S}/firmware.bin ]; then
    echo "Firmware file found, programming"
    mkdir -p /lib/firmware
    cp ${S}/firmware.bin /lib/firmware/
    rmmod yourmodule
    echo "Programming FPGA"
    echo firmware.bin > /sys/class/fpga_manager/fpga0/firmware
    modprobe yourmodule
fi

umount ${S}

# set hostname again, in case it changed
/etc/init.d/hostname.sh

exit 0

 

View solution in original post


All Replies
Adventurer
Posts: 84
Registered: ‎03-22-2016

Re: Not able to config IP and other configuations over Linux OS boot for ZC702 Eval Board

Petalinux is different from most Linux distributions. Normally, you install to a device, and then as you make changes they are written to your root filesystem. Package management, configuration, etc.

 

With Petalinux, you instead do all of your installation and configuration ahead of time, on the host machine. The end result is a root filesystem image that is intended to be loaded into a ramdisk on boot. While running, you can make changes, but as soon as you power off, those changes are gone. This is an intentional (and desirable) feature for embedded systems, but it can take some getting used to. The benefit is that you have something that can tolerate unclean shutdowns without any worry of filesystem corruption. And you don't have to think about modifying configuration on the device (especially convenient for devices you can't log into, or when there are hundreds of them).

 

Anyway, the point is, you need to make your changes on the host so that they end up in your BOOT.BIN and image.ub files. Petalinux includes some basic ability to modify network configuration using petalinux-config. If you want more configuration than that (such as a custom /etc/network/interfaces file), you'll need to add a custom "app" to your build. That app can copy any files you want into the running system.

 

I usually create an app called "customize", and include all the things that need to be customized for that particular project. In my most recent project, I have it loading an SSH key and an /etc/init.d startup script. In the startup script, I have it look for files on the SD card and use them to replace the ones in the root filesystem. It also looks for a bitfile and reprograms the fpga if it finds one. With this setup, I can make per-device changes on the SD without needing to generate new images.

 

customize.bb:

#
# This file is the customize recipe.
#

SUMMARY = "Simple customize application"
SECTION = "PETALINUX/apps"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

SRC_URI = "file://id_rsa.pub \
file://load-config \
"

inherit update-rc.d

# networking is at 01, so we have to get in before that
INITSCRIPT_NAME = "load-config"
INITSCRIPT_PARAMS = "defaults 00"

S = "${WORKDIR}"

do_install() {
install -d ${D}${sysconfdir}/init.d
install -d ${D}/home/root/.ssh

install -m 0755 ${S}/load-config ${D}${sysconfdir}/init.d/load-config
install -m 0600 ${S}/id_rsa.pub ${D}/home/root/.ssh/authorized_keys
}

${IMAGE_ROOTFS}/etc/inittab;"
FILES_${PN} += "/home/root/"

load-config:

#!/bin/sh
### BEGIN INIT INFO
# Provides:           load-config
# Required-Start      
# Required-Stop       
# Default-Start       S
# Default-Stop:       
# Short-Description:  Startup
### END INIT INFO

S=/mnt/sdcard
D=/etc/yourapplication
C=startup.sh

if [ "$1" != "start" ]; then
    exit 0
fi

# create directories/files
mkdir -p ${S}
mkdir -p ${D}

# mount the sd card
mount /dev/mmcblk0p1 ${S}

if [ -f ${S}/${C} ]; then
    echo "Running startup script"
    cp ${S}/${C} ${D}/${C}
    source ${D}/${C}
else
    echo "No startup script file found"
fi

# Load /etc files
if [ -d ${S}/etc ]; then
    echo "Loading /etc from SD"
    cp -rv ${S}/etc/* /etc/
fi

# if bitfile exists on SD card, program it
if [ -f ${S}/firmware.bin ]; then
    echo "Firmware file found, programming"
    mkdir -p /lib/firmware
    cp ${S}/firmware.bin /lib/firmware/
    rmmod yourmodule
    echo "Programming FPGA"
    echo firmware.bin > /sys/class/fpga_manager/fpga0/firmware
    modprobe yourmodule
fi

umount ${S}

# set hostname again, in case it changed
/etc/init.d/hostname.sh

exit 0