How To Set Up the Auto Boot Service for the Desktop Version of RK3399 SBC

The hardware platform of this article is based on Forlinx OK3399-C Single Board Computer(SBC). Other RK3399 products maybe different due to the different settings of each manufacturer, for reference only. Here mainly introduces how to set up the auto boot service for the Desktop version of Forlinx RK3399 Single Board Computer.

systemd reads the configuration under /etc/systemd/system by default. The files in this directory will be linked to the files under /lib/systemd/system/.

Execute ls /lib/systemd/system and you can see there are many boot scripts, including rc.local.service which need to modify

Open the script (create one if it doesn't exist):


# This file is part of systemd.## systemd is free software; you can redistribute it and/or modify it# under the terms of the GNU Lesser General Public License as published by# the Free Software Foundation; either version 2.1 of the License, or# (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by# systemd-rc-local-generator if /etc/rc.local is executable.[Unit]

Description=/etc/rc.local Compatibility

ConditionFileI>**ecutable=/etc/rc.local

After=network.target

[Service] Type=forking

ExecStart=/etc/rc.local start

TimeoutSec=0

RemainAfterExit=yes


Generally, the boot file is mainly divided into three parts

[Unit] part: boot Sequence and Dependencies

[Service] part: boot behavior, how to boot, boot type

[Install] part: Define how to install this configuration, that is, how to realize auto boot.

It shows the boot sequence of /etc/rc.local is behind network. However, obviously it lacks the Install part. Thus it does not define how to realize auto boot. So apparently this configuration is invalid. Therefore, need to add [Install] part after it:


[Install]

WantedBy=multi-user.target

Alias=rc-local.service


So the complete rc.local.service is like this:


[Unit]

Description=/etc/rc.local Compatibility

Documentation=man:systemd-rc-local-generator(8)

ConditionFileI>**ecutable=/etc/rc.local

After=network.target

[Service]

Type=forking

ExecStart=/etc/rc.local start

TimeoutSec=0

RemainAfterExit=yes

GuessMainPID=no

[Install]

WantedBy=multi-user.target

Alias=rc-local.service


Note: ubuntu-18.04 server version does not have /etc/rc.local by default. Need to create it yourself

sudo touch /etc/rc.local

Then write the boot script to /etc/rc.local. You can write some test scripts in it to verify if the scripts work.

echo "this just a test" > /usr/local/text.log

Remember to add execute permission:

sudo chmod +x /etc/rc.local

After this, it’s the last step. AS mentioned above, systemd reads the configuration under /etc/systemd/system by default, so it also need to create a soft link in /etc/systemd/system.

ln -s /lib/systemd/system/rc.local.service /etc/systemd/system/

Next, reboot system and check if there is /usr/local/text.log. If yes, the boot script is in effect.