OpenWrt Forum Archive

Topic: Problem with startup script

The content of this topic has been archived on 17 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I've added a startup script to /etc/init.d/ directory

#!/bin/sh /etc/rc.common

START=100


start() {
        echo "HELLO FROM SCRIPT"
        echo 7 > /sys/class/gpio/export
        echo "out" > /sys/class/gpio/gpio7/direction
        echo 1 > /sys/class/gpio/gpio7/value

        insmod fbtft >> /tmp/log.txt
        insmod fb_ili9341 >> /tmp/log.txt
        insmod fbtft_device name=tm022hdh26 busnum=32 >> /tmp/log.txt

        mkfifo /tmp/myfifo


        hello&
        nano-X&


}

stop() {
        killall -9 hello
        rmmod fbtft_device
        rmmod fb_ili9341
        rmmod fbtft
}

After reboot, the hello application is running perfectly but the modules that should get loaded by insmod were not loaded. When I run the stop() function of the script it says:
module is not loaded
module is not loaded
module is not loaded

If I run start() again the modules are loaded correctly and the apps run OK.

Why can't I get the modules to load at startup ? The script clearly runs at startup since the hello app is running.

Thanks,
Bogdan

bogdanul2003 wrote:

START=100

Try START=95 (or something like 45)
I have doubts about "100", as I think that it may get evaluated as "10". All the needed services might not yet be initialised at that point.

(I am not sure if more than 2 digits can be used. You might check in /etc/rc.d directory how the 100 has got applied to a symlink there. At least based on old documentation, the running order of scripts is evaluated by alphabetic order, so 100 is before 11 in any case. http://wiki.openwrt.org/doc/techref/initscripts )

(Last edited by hnyman on 27 Apr 2015, 19:34)

I've tried with START=95 and I get the same result. After complete boot there is not trace of loading the modules in dmesg either.
I've also tried to put the full path /usr/sbin/insmod but no luck.

Is there a way to log the output of the insmod commands and see it after complete boot?

'dmesg' shows the kernel log, and 'logread' the normal system log.
You should see there results from insmod commands.
Or errors like:
Fri Mar 13 03:07:24 2015 daemon.err insmod: module is already loaded - cls_u32
Fri Mar 13 03:07:24 2015 daemon.err insmod: module is already loaded - em_u32
Fri Mar 13 03:07:24 2015 daemon.err insmod: module is already loaded - act_connmark

After boot I don't see any logs. When I run the script by hand this is what I find in the logs

Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3339.660000] fbtft_device:  SPI devices registered:
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3339.660000] fbtft_device:      m25p80 spi0.0 25000kHz 8 bits mode=0x00
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3339.670000] fbtft_device:  'fb' Platform devices registered:
Tue Apr 28 16:44:16 2015 kern.err kernel: [ 3339.670000] fbtft_device:    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!222
Tue Apr 28 16:44:16 2015 kern.err kernel: [ 3339.680000] pdata.sck:20 pdata.mosi:21 pdata.miso:18 spi->chip_select:19
Tue Apr 28 16:44:16 2015 kern.err kernel: [ 3339.680000] spi->modalias:fb_ili9341, spi->max_speed_hz:32000000, spi->bus_num:32, spi->mode:0
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3340.310000] graphics fb0: fb_ili9341 frame buffer, 240x320, 150 KiB video memory, 16 KiB DMA buffer memory, fps=20, spi32.19 at 32 MHz
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3340.310000] fbtft_device:  GPIOS used by 'tm022hdh26':
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3340.310000] fbtft_device:    'reset' = GPIO26
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3340.310000] fbtft_device:    'dc' = GPIO22
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3340.310000] fbtft_device:  SPI devices registered:
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3340.310000] fbtft_device:      m25p80 spi0.0 25000kHz 8 bits mode=0x00
Tue Apr 28 16:44:16 2015 kern.info kernel: [ 3340.310000] fbtft_device:      fb_ili9341 spi32.19 32000kHz 8 bits mode=0x00

It is weird that I see no errors in the log but I also can't find this stuff after boot.

Is there another way to load those modules? Especially the module that needs some parameters.

I've solved this by calling insmod from the hello application which can be opened at startup by the script, otherwise it wouldn't work.

The discussion might have continued from here.