Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

autostarting linux application at boot up

Status
Not open for further replies.

gary36

Full Member level 4
Joined
Mar 31, 2018
Messages
208
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,806
I have customized SBC from freescale. Comes with uboot and liunx kernel. The image was built with LTIB environment. I am given a task to build an linux application that runs at start up without user intervention. Any steps to do so.
 

It will depend on what distro you are working with, but most often you have to edit the file located at either /etc/rc.d/boot.local or /etc/rc.local and add the intended bash script there such as you would do by hand in the command line terminal.
 

... or (unlikely in an SBC at the moment) if it uses systemd, you need to write a small text file and tell the system to run it at boot time. There is a good tutorial at this web address:

The file is actually quite small, just a few lines and the example on that page is near the bottom.

Brian.
 

Hi

Just curious, where does this script file reside? SBC does not have a hard disk, just 8MB NOR flash and 128 MB NAND flash.
 

It should still have a filing system, in flash rather than on a physical disk but more or less the same structure.
If the SBC has a visual interface you should be able to type 'ls -a' to see the directories and files, if you have to ftp to access it, you can type 'nlist' to do the same.

Conventional start-up scripts are in the '/etc' directory from the root and the usual file name is 'rc.local'. Its a text file so easy to edit. Depending on the Linux version, you may have to use full path names to your script (include the whole file path from root) because the private user directory may not yet have been set up at that stage of booting.

systemd start up files are usually in '/etc/systemd/system' and have file names ending in '.service' but are again just text files.

Brian.
 

Hi betwixt
Some more clarification. Uboot comes with default flash driver that saves environmental variables. I guess same should be applicable to linux as well. Not sure if it is true. I see rootfs copies to RAM location and any editing will eventually save in RAM and not in flash. Now should I rebuild rootfs and kernel image ( will all the edits for auto start) and fuse to SBC to make it work? is it not possible otherwise?
 

To do modification of the boot scripts you have to change root file system and store it in the memory. On start-up compressed image of the root file system is loaded into ramdisk.
 

Hi filip,
I am facing a peculiar problem. I have written a custom device driver and I have built this a kernel component and flashed it. On execution of my application, everything runs fine until and hour, later which the system throws up a segmentation fault and exits the application. When I try to restart the SBC and run the application, it says that it cannot find the driver. I even searched in /dev directory and it does not list the same. I wonder, where the driver disappears. Any clues?
 

The first question that arises is: Did the above mentioned segmentation error occurred only after the installation of this device driver, or this occurred in any other occasion as well? It do not make much sense that the driver have been removed from the system, unless you have made some update/upgrade in the meantime, I guess, although it would not be at all inconceivable that your custom device driver is actually corrupting the system somehow. By that way, make sure that the system always reboots with an account having administrator privileges.
 

Hi Andre
Its mysterious because the application runs fine(with device driver) for some time and then the fault occurs. I have taken care of all privileges.
 

Segmentation fault, can be caused by multiple reasons. 1. you are allocating memory but you are not releasing it, so you ran out of memory, and get null pointer. 2. there is a problem with communication between your program and device driver, you are not checking for this condition, or driver returns unexpected result. 3. you corrupt memory, and that causes segmentation fault, etc. This can be debugged using gdbserver and gdb. As for driver it is located under /lib/modules/<kernel-version>. /dev directory contains special files, which are used to communicate with block or character drivers. In any case check if anything was displayed on the console (dmesg is the command).
 

Segmentation faults, as others have pointed out already, are due to memory errors. If the data segment(s) run into code segment (yes, such things do happen) you will get a segmentation fault.

Unfortunately the kernel will be unable to tell you more than that: because the program runs several steps before it crashes. Only solution is to go through your code with a debugger line by line...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top