OK… If you are same SBC enthusiast as me and not familiar with Linux kernel editing to throw out things from it to speed-up booting process here is my quick and in most time acceptable solution of the problem witch costs 0$ and 0 lines of kernel edit . Just some hours spend around systemd services.
First of all, the basic idea is not to delete everything from OS to decrease boot time. The idea is to put Your program launch after and before some OS services in boot process. The sequence of service starting is shown here.
The basic OS functionality comes with sysinit.target loaded. You still can be missing some drivers (like SPI) so keep it in mind and wait for necessary drivers to start (with some bash script for example) but UART, GPIO and filesystem are available to interact.
To add your program (for example /usr/myprogram) as a service you should:
-
sudo su
if you are not root
-
Create a service file. For example nano /etc/systemd/system/myserw.service
:
[Unit]
Description=MyService
DefaultDependencies=no
[Service]
Type=simple
ExecStart=/usr/myprogram
[Install]
WantedBy=sysinit.target
-
chmod +x /etc/systemd/system/myserw.service
-
systemctl enable myserw.service
creates symlink
-
systemctl daemon-reload
-
systemctl status myserw.service
Now you should see some info about your service working.
-
reboot
and if your app can blink a LED - try to measure time between boot process starts and led turned on and be ready to be nicely surprised. If your program did not start at booting process systemctl status myserw.service
should give you info about the problem occur.
PS: You should read about systemd service creation to be more flexible with your project needs.
Result: my C++ project on beagle board witch boots about 120! seconds till network up, now starts after 31 second after power up. Its almost 4 times faster!!!
I will try described method on radxa zero and will share the results.
And it would be nice if someone can help to solve 2 annoying things in raxda booting process:
- 2 seconds delay on U-boot.
- raid6 benchmark on kernel start. (1 second)
In general it waist 3 seconds and it cannot be skipped by systemd .
Post created.
UPD. Problems solved:
Fix 1. u-boot 2 sec delay.
Fix 2. raid6 bench - 1 sec delay.