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!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
6,943 Views
Registered: ‎04-10-2016

How to set up a custom script when the system starts in Petalinux2015.4.

How to set up a custom script when the system starts in Petalinux2015.4.

I would like to make the system automatically complete some tasks when it starts, in the script defined. But I don't know where to write the script in petalinux2015.4

0 Kudos
4 Replies
Xilinx Employee
Xilinx Employee
6,917 Views
Registered: ‎08-01-2008

Re: How to set up a custom script when the system starts in Petalinux2015.4.

To have the PetaLinux build tools incorporate pre-build binary code, follow this general flow:

PetaLinux 2013.04 (and prior)

  1. Ensure that the root file system includes an interpreter for your script (e.g., Perl, Python, etc.).
  2. Use the petalinux-new-app to create an application. The new application will be located in ${PETALINUX}/software/user-apps/<APP>/. The -e option for petalinux-new-app will automatically select the application from menuconfig and will allow the application to be automatically built when the PetaLinux system is built.
  3. Place the scripts into ${PETALINUX}/software/user-apps/<APP>/
  4. Modify the makefile for the new application located inside ${PETALINUX}/software/user-apps/<APP>/.
    • Ensure that the all: and clean: sections of the makefile are empty.
    • Update the romfs: section to copy the scripts into ${PETALINUX}/software/petalinux-dist/romfs/.

Below is an example of the modifications:

{{{
all:
 
clean:
romfs:
     $(ROMFSINST) -d -p 0755 mystartup /etc/init.d/mystartup
     $(ROMFSINST) -s /etc/init.d/mystartup /etc/rcS.d/S99mystartup
}}}

Note: The scripts in /etc/rcS.d/ run in alphabetical order.

PetaLinux 2013.10 (and later)

  1. Ensure that the root filesystem includes an interpreter for your script (e.g., Perl, Python, etc.).
  2. Use petalinux-create -t apps -n <APP> to create an application.  The new application will be located in <PETALINUX_PROJECT_DIR>/components/apps/<APP>/. The --enable option for petalinux-create will automatically select the application from menuconfig and will allow the application to be automatically built when the PetaLinux system is built.
  3. Place the script(s) into <PETALINUX_PROJECT_DIR>/components/apps/<APP>/
  4. Modify the makefile for the new application located inside <PETALINUX_PROJECT_DIR>/components/apps/<APP>/.
    • Ensure that the all:, build:, and clean: sections of the makefile are empty.
    • Update the install:: section to copy the scripts into <PETALINUX_PROJECT_DIR>/build/linux/roofts/targetroot/.
Below is an example of the modifications:
all: build install
build: $(APP)
clean:
.PHONY: install image
install: $(APP)
 $(TARGETINST) -d -p 0755 mystartup /etc/init.d/mystartup
 $(TARGETINST) -s /etc/init.d/mystartup /etc/rc5.d/S99mystartup
Note: The scripts in /etc/rc5.d/ run in alphabetical order.
Thanks and Regards
Balkrishan
--------------------------------------------------------------------------------------------
Please mark the post as an answer "Accept as solution" in case it helped resolve your query.
Give kudos in case a post in case it guided to the solution.
Adventurer
Adventurer
6,783 Views
Registered: ‎04-10-2016

Re: How to set up a custom script when the system starts in Petalinux2015.4.

I've got help from you.Thank you very much.

0 Kudos
4,334 Views
Registered: ‎09-20-2016

Re: How to set up a custom script when the system starts in Petalinux2015.4.

Hi,

 

I'm using PetaLinux 2016.04 and trying to get a custom script to run on startup.

 

Following the steps below, in step 2 I create an app (which I later do see when I run petalinux-config - c rootfs).

 

It seems it doesn't get created in <PETALINUX_PROJECT_DIR>/components/apps/<APP> but in<PETALINUX_PROJECT_DIR>/project-spec/meta-user/recipes-apps/<APP>

 

I place the script I want to run at startup in here, then update the Makefile as in the example (not as in step 4, I don't see a /build/linux/rootfs/targetroot/ folder).

 

APP = boot-scripts-my

# Add any other object files to this list below
APP_OBJS = boot-scripts-my.o

all: build install

build: $(APP)

clean:
.PHONY: install image

install: $(APP)
	$(TARGETINST) -d -p 0755 mystartup /etc/init.d/mystartup
	$(TARGETINST) -s /etc/init.d/mystartup /etc/rc5.d/S99mystartup

$(APP): $(APP_OBJS)
	$(CC) $(LDFLAGS) -o $@ $(APP_OBJS) $(LDLIBS)

But after booting this (on Zedboard), I don't see any mystartup script file in any subfolder of /etc/, and no boot-scripts-my either. (I know the Makefile is being read when I do petalinux-build, as it complained originally about an error in that file, which I then fixed.)

0 Kudos
Moderator
Moderator
4,327 Views
Registered: ‎04-17-2011

Re: How to set up a custom script when the system starts in Petalinux2015.4.

As you are using 2016.4, it is based of Yocto and the steps have changed. Refer to pages 58-60 of the User Guide: https://www.xilinx.com/support/documentation/sw_manuals/xilinx2016_4/ug1144-petalinux-tools-reference-guide.pdf

This should get you moving in your attempt. Reply back if you need any help performing those steps.
Regards,
Debraj
----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------
0 Kudos