Changes

Jump to: navigation, search

Embedded Linux tips and tricks

379 bytes removed, 10:46, 14 March 2022
no edit summary
__FORCETOC__ ==Introduction==This page provides examples and usage notes for common tasks/issues related to typical embedded Linux systems. ==How to write <code>.wic</code> image files to SD cards==[https://www.yoctoproject.org/ Yocto] build system can generate [https://www.yoctoproject.org/docs/2.4.2/dev-manual/dev-manual.html#creating-partitioned-images-using-wic <code>.wic</code> image files]. These files are usually written to SD cards to create bootable devices. The simplest way to write such images to SD cards is to use Edit the [https://www.balena.io/etcher/ Balena Etcher] tool, which is available for Linux, macOS, and Windows hosts. Using Etcher is straightforward, nonetheless many tutorials and examples are available on the Internet. Advanced users can also use the well-known [https://en.wikipedia.org/wiki/Dd_(Unix) file <code>dd</code>] utility. This tool should be avoided unless the user knows what they are doing. If the target device is not specified properly, <code>dd<etc/code> can wipe out all the data on a host's disk drive! For more details, see for instance [https:apt//opensource.com/article/18/7/how-use-dd-linux this article]. ==Setting up a Yocto prebuilt package repository for <code>apt</code>==Occasionally, it is convenient to set up the target for installing <code>.debconf</code> packages retrieved from a Yocto repository. The following example shows how to do that on an [[ORCA_SOM|ORCA SOM]]-based target.The repository used is located at http://yocto.dave.eu/imx-5.4.70-2.3.0/. The prebuilt packages were generated by Yocto Zeus, which was used to create the distro running on the target as well. ===Configuring the network subsystem===First of all, it is necessary to configure the target's network subsystem in order to access the Internet. In this example, a couple of <code>systemd</code> services are used for like this purpose, namely <code>systemd-networkd</code> and <code>systemd-resolved</code>. They were configured by following these steps. Disable the Connection Manager (ConnMan) sevice to prevent conflict issues:
<pre class="board-terminal">
APT::Architecture "arm64";
APT::Get::AllowUnauthenticated "true";
Acquire::Languages "none";
</pre>
Create Edit the configuration file for the network interface of interest (<code>eth1/etc/apt/sources.list.d/debian-10.list</code> in the example)like this:
<pre class="board-terminal">
root@desk-mx8mp:~# cat /etc/apt/sources.list.d/debian-10.list
deb [trusted=yes] http://yocto.dave.eu/imx-5.4.70-2.3.0/ all/
deb [trusted=yes] http://yocto.dave.eu/imx-5.4.70-2.3.0/ aarch64/
deb [trusted=yes] http://yocto.dave.eu/imx-5.4.70-2.3.0/ aarch64-mx8mp/
</pre>
Start <code>systemd-networkd</code> and <code>systemd-resolved</code>Execute the following commands:
<pre class="board-terminal">
root@desk-mx8mp:~# rm -rf /var/lib/apt/lists/*
root@desk-mx8mp:~# apt-get clean
root@orca:~# apt-get update
0% [Working]
Ign:1 http://yocto.dave.eu/imx-5.4.70-2.3.0 all/ InRelease
Ign:2 http://yocto.dave.eu/imx-5.4.70-2.3.0 aarch64/ InRelease
Ign:3 http://yocto.dave.eu/imx-5.4.70-2.3.0 aarch64-mx8mp/ InRelease
Get:4 http://yocto.dave.eu/imx-5.4.70-2.3.0 all/ Release [1213 B]
Get:5 http://yocto.dave.eu/imx-5.4.70-2.3.0 aarch64/ Release [1217 B]
Get:6 http://yocto.dave.eu/imx-5.4.70-2.3.0 aarch64-mx8mp/ Release [1223 B]
Ign:7 http://yocto.dave.eu/imx-5.4.70-2.3.0 all/ Release.gpg
Ign:8 http://yocto.dave.eu/imx-5.4.70-2.3.0 aarch64/ Release.gpg
Ign:9 http://yocto.dave.eu/imx-5.4.70-2.3.0 aarch64-mx8mp/ Release.gpg
Get:10 http://yocto.dave.eu/imx-5.4.70-2.3.0 all/ Packages [146 kB]
Get:11 http://yocto.dave.eu/imx-5.4.70-2.3.0 aarch64/ Packages [2848 kB]
Get:12 http://yocto.dave.eu/imx-5.4.70-2.3.0 aarch64-mx8mp/ Packages [283 kB]
Fetched 3280 kB in 6s (545 kB/s)
Reading package lists... Done
root@orca:~# sed -i 's/\.\//aarch64\//g' /var/lib/apt/lists/yocto.dave.eu_imx-5.4.70-2.3.0_aarch64_Packages
root@orca:~# sed -i 's/\.\//all\//g' /var/lib/apt/lists/yocto.dave.eu_imx-5.4.70-2.3.0_all_Packages
root@orca:~# sed -i 's/\.\//aarch64-mx8mp\//g' /var/lib/apt/lists/yocto.dave.eu_imx-5.4.70-2.3.0_aarch64-mx8mp_Packages
</pre>
Both services should be activeThe target is finally ready to install new packages. The following example shows for instance the installation of <code>vim</code>:
<pre class="board-terminal">
root@orca:~# systemctl status systemdsudo apt-networkdget install vim* systemd-networkdReading package lists...service - Network ServiceDoneBuilding dependency tree Loaded: loaded (/lib/systemd/system/systemd-networkdReading state information...service; enabled; vendor presetDoneThe following additional packages will be installed: enabled) Active: active (running) since Wed 2021 vim-common vim-help vim-syntax vim-12tutor vim-15 21:34vimrcThe following NEW packages will be installed:32 UTC; 18s ago Docs: man:systemd vim vim-common vim-help vim-syntax vim-networkd.service(8) Main PID: 534 (systemdtutor vim-network)vimrc Status: "Processing requests0 upgraded, 6 newly installed, 0 to remove and 20 not upgraded.Need to get 6584 kB of archives.After this operation, 0 B of additional disk space will be used." TasksDo you want to continue? [Y/n] YGet: 1 Memoryhttp: //yocto.dave.eu/imx-5.4.70-2.0M3.0 aarch64/ vim 8.1.1518-r0 [1051 kB] CGroupGet:2 http: /system/yocto.slicedave.eu/systemdimx-networkd5.4.service `70-534 2.3.0 aarch64/lib/systemd/systemdvim-networkd Dec 15 21:34:32 orca systemd[common 8.1]: Starting Network Service...Dec 15 21:34:32 orca systemd1518-networkdr0 [5342314 kB]: Enumeration completedDec 15 21Get:343 http:32 orca systemd[//yocto.dave.eu/imx-5.4.70-2.3.0 aarch64/ vim-help 8.1]: Started Network Service.Dec 15 21:34:32 orca systemd1518-networkdr0 [5341757 kB]: eth1: IPv6 successfully enabledDec 15 21Get:344 http:32 orca systemd//yocto.dave.eu/imx-5.4.70-networkd2.3.0 aarch64/ vim-syntax 8.1.1518-r0 [5341049 kB]: eth0: IPv6 successfully enabledDec 15 21Get:345 http:36 orca systemd//yocto.dave.eu/imx-5.4.70-2.3.0 aarch64/ vim-tutor 8.1.1518-networkdr0 [534411 kB]: eth1: Gained carrierDec 15 21Get:346 http:38 orca systemd//yocto.dave.eu/imx-networkd[534]: eth1: Gained IPv6LLDec 15 21:34:50 orca systemd5.4.70-2.3.0 aarch64/ vim-vimrc 8.1.1518-networkdr0 [5341596 B]: eth1: Configuredroot@orca:~# systemctl status systemd-resolvedFetched 6584 kB in 9s (660 kB/s)* systemd-resolvedSelecting previously unselected package vim.service - Network Name Resolution Loaded: loaded (Reading database ... 71726 files and directories currently installed.)Preparing to unpack .../lib/systemd/system/systemdvim_8.1.1518-resolvedr0_arm64.deb ...service; enabled; vendor preset: enabled) Active: active Unpacking vim (running8.1.1518-r0) since Wed 2021...Selecting previously unselected package vim-common.Preparing to unpack .../vim-12common_8.1.1518-15 21:34:32 UTC; 6s agor0_arm64.deb ... Docs: man:systemdUnpacking vim-resolved.servicecommon (8.1.1518-r0)... https:Selecting previously unselected package vim-help.Preparing to unpack ...//wwwvim-help_8.1.1518-r0_arm64.deb ..freedesktop.org/wiki/Software/systemd/resolved https://wwwUnpacking vim-help (8.freedesktop1.org/wiki/Software/systemd/writing1518-networkr0) ...Selecting previously unselected package vim-configuration-managerssyntax. https://wwwPreparing to unpack ..freedesktop.org/wiki/Software/systemd/writingvim-resolversyntax_8.1.1518-clientsr0_arm64.deb ... Main PID: 542 Unpacking vim-syntax (systemd8.1.1518-resolver0)...Selecting previously unselected package vim-tutor. Status: "Processing requestsPreparing to unpack .../vim-tutor_8.1.1518-r0_arm64.deb ..." Tasks: Unpacking vim-tutor (8.1.1518-r0) ... Memory: 1Selecting previously unselected package vim-vimrc.4M CGroup: Preparing to unpack .../systemvim-vimrc_8.1.slice/systemd1518-resolvedr0_arm64.deb ...service `Unpacking vim-542 /lib/systemd/systemdvimrc (8.1.1518-resolvedr0) ... Dec 15 21:34:32 orca systemd[Setting up vim (8.1]: Starting Network Name Resolution.1518-r0) ...Dec 15 21:34:32 orca systemdupdate-resolved[542]: Positive Trust Anchorsalternatives:Linking /bin/vi to /usr/bin/vim.vimDec 15 21:34:32 orca systemdupdate-resolved[542]alternatives: Linking /usr/bin/vim to /usr/bin/vim. IN DS 19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5vimDec 15 21:34:32 orca systemdupdate-resolved[542]alternatives: Linking /usr/bin/xxd to /usr/bin/xxd. IN DS 20326 vimSetting up vim-common (8 2 e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d.1.1518-r0) ...Dec 15 21:34:32 orca systemdSetting up vim-resolved[542]: Negative trust anchors: 10help (8.1.in1518-addrr0) .arpa 16.172.inSetting up vim-addrsyntax (8.arpa 171.172.in1518-addrr0) .arpa 18.172.inSetting up vim-addrtutor (8.arpa 191.1518-r0) .172.in-addr.arpa>Dec 15 21:34:32 orca systemdSetting up vim-resolved[542]: Using system hostname 'orca'vimrc (8.Dec 15 21:34:32 orca systemd[1]: Started Network Name Resolution.1518-r0) ...
</pre>
===Configuring <code>apt</code>===
4,650
edits

Navigation menu