+ Post New Thread
Results 1 to 12 of 12
  1. #1
    Member level 5
    Points: 707, Level: 5

    Join Date
    Mar 2018
    Posts
    88
    Helped
    0 / 0
    Points
    707
    Level
    5

    autostarting linux application at boot up

    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.

  2. #2
    Super Moderator
    Points: 29,579, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,839
    Helped
    1114 / 1114
    Points
    29,579
    Level
    41
    Blog Entries
    9

    Re: autostarting linux application at boot up

    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.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  3. #3
    Super Moderator
    Points: 80,991, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,276
    Helped
    4433 / 4433
    Points
    80,991
    Level
    69

    Re: autostarting linux application at boot up

    ... 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:
    https://learn.adafruit.com/running-p...ling-a-service
    The file is actually quite small, just a few lines and the example on that page is near the bottom.

    Brian.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



  4. #4
    Member level 5
    Points: 707, Level: 5

    Join Date
    Mar 2018
    Posts
    88
    Helped
    0 / 0
    Points
    707
    Level
    5

    Re: autostarting linux application at boot up

    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.



    •   AltAdvertisement

        
       

  5. #5
    Super Moderator
    Points: 80,991, Level: 69
    Achievements:
    7 years registered
    Awards:
    2nd Helpful Member
    betwixt's Avatar
    Join Date
    Jul 2009
    Location
    Aberdyfi, West Wales, UK
    Posts
    13,276
    Helped
    4433 / 4433
    Points
    80,991
    Level
    69

    Re: autostarting linux application at boot up

    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.
    PLEASE - no friends requests or private emails, I simply don't have time to reply to them all.
    It's better to share your questions and answers on Edaboard so we can all benefit from each others experiences.



    •   AltAdvertisement

        
       

  6. #6
    Member level 5
    Points: 707, Level: 5

    Join Date
    Mar 2018
    Posts
    88
    Helped
    0 / 0
    Points
    707
    Level
    5

    Re: autostarting linux application at boot up

    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?



  7. #7
    Full Member level 3
    Points: 1,280, Level: 8

    Join Date
    Apr 2017
    Posts
    171
    Helped
    35 / 35
    Points
    1,280
    Level
    8

    Re: autostarting linux application at boot up

    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.



  8. #8
    Member level 5
    Points: 707, Level: 5

    Join Date
    Mar 2018
    Posts
    88
    Helped
    0 / 0
    Points
    707
    Level
    5

    Re: autostarting linux application at boot up

    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?



  9. #9
    Super Moderator
    Points: 29,579, Level: 41
    andre_teprom's Avatar
    Join Date
    Nov 2006
    Location
    Brazil
    Posts
    8,839
    Helped
    1114 / 1114
    Points
    29,579
    Level
    41
    Blog Entries
    9

    Re: autostarting linux application at boot up

    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.
    --------------------------------------------------------------------------------------------------
    Part of the world that you live in, You are the part that you're giving ( Renaissance )



    •   AltAdvertisement

        
       

  10. #10
    Member level 5
    Points: 707, Level: 5

    Join Date
    Mar 2018
    Posts
    88
    Helped
    0 / 0
    Points
    707
    Level
    5

    Re: autostarting linux application at boot up

    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.



  11. #11
    Full Member level 3
    Points: 4,634, Level: 16

    Join Date
    Apr 2001
    Location
    California, USA
    Posts
    188
    Helped
    25 / 25
    Points
    4,634
    Level
    16

    Re: autostarting linux application at boot up

    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).



  12. #12
    Advanced Member level 5
    Points: 17,084, Level: 31
    Achievements:
    7 years registered

    Join Date
    Nov 2012
    Posts
    3,128
    Helped
    770 / 770
    Points
    17,084
    Level
    31

    Re: autostarting linux application at boot up

    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...



--[[ ]]--