Build kernel
Let me explain why the existing images are not suitable. Their main problem is that they are compiled on the old 3.4 kernel, and this immediately imposes a maximum of 4 on the compiler and ubuntu 12.04, I don’t remember exactly 14.04. So it turns out that if you want to use the latest software and libraries, you will have to recompile the last kernel. Of course, you can remove the restriction on compiling not less than version 5 of gcc in the source code and correct the code so that it is assembled under version 4, but this is still a hemorrhoid. Not to mention the fact that in our case the graphic part of the linux is superfluous.
To start with kernel.org, we download the 4.14.57 kernel at that time, it was the last stable version.
In the folder with the source code, create a script that starts the configuration:
')
We get something like this:

In the file menu at
/linux-4.14.57/arch/arm/configs/
select the
/linux-4.14.57/arch/arm/configs/
file, there are the basic settings of the sunxi processor. And then you need to add some settings. Those. look for the flags below and configure them.
If possible, we build everything into the kernel.
CONFIG_BLK_DEV_INITRD - we will not use ramfs instead, then we will get Aufs (advanced multi-layered unification filesystem). In short, remove the checkbox.
CONFIG_MEMCG - we include as all that is inside
CONFIG_BLK_CGROUP - enable
CONFIG_CGROUP_DEVICE - enable
CONFIG_CGROUP_CPUACCT - enable
CONFIG_CGROUP_PERF - we include as well as everything inside
CONFIG_EXPERT - just select and leave everything in by default.
CONFIG_BLK_WBT - we choose, like all that is inside
CONFIG_PARTITION_ADVANCED - select and inside
CONFIG_SUN_PARTITION - choose
ARCH_SUNXI - we leave only MACH_SUN5I inside
In bus support, select CONFIG_PCI, since USB wifi requires PCI bus support. Obviously, when enabled, the wifi kernel does not require a pci bus, but without this wpa, the supplicant does not find usb wifi. Why this happens, you can look into the depths of history, but judging from the historical background, in general, you need to know and remember.
CONFIG_CPU_FREQ_STAT - we find and select
Inside CONFIG_NET we select WIRELESS and then CONFIG_CFG80211 and there we mark CONFIG_NL80211_TESTMODE and CONFIG_CFG80211_WEXT, the latter includes our wifi driver for the supplient.
CONFIG_MAC80211 - turn on the network stack.
CONFIG_MAC80211_MESH - enable
CONFIG_MAC80211_LED - so choose it
CONFIG_NFC - we include as well as what is inside except CONFIG_NFC_NCI.
CONFIG_PARPORT - enable
CONFIG_LED_TRIGGER_PHY - choose
CONFIG_REALTEK_PHY - choose
CONFIG_WLAN - choose
CONFIG_RTL8XXXU - select and inside CONFIG_RTL8XXXU_UNTESTED we mark.
CONFIG_SERIO_SUN4I_PS2 - enable
CONFIG_SERIAL_DEV_BUS - turn on and inside select SERIAL_DEV_CTRL_TTYPORT.
CONFIG_USB_WUSB_CBAF - enable
CONFIG_USB_WUSB_CBAF_DEBUG - enable
CONFIG_USB_WDM - enable
CONFIG_USB_SERIAL - choose
CONFIG_UWB - select and inside select CONFIG_UWB_HWA and CONFIG_UWB_I1480U and then CONFIG_USB_WUSB will appear and also select.
We select CONFIG_STAGING and inside we select the CONFIG_RTL8192U and CONFIG_RTLLIB driver, and inside the latter we also select everything. They are marked with modules so the poet will have to screw them separately.
CONFIG_R8188EU - choose
In general, this is a necessary minimum of kernel settings, if you suddenly want to include something else then carefully read the dependencies of this parameter, otherwise there will be an error when compiling. Next you need to start compiling:
make O=../olimex-kernel-4.14.57/ -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage
At the same time collect and devicetree files:
make O=../olimex-kernel-4.14.57 -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- dtbs
This is necessary just in case, because the source files can be with an error even though they are the same in the kernel and in the uboot. Therefore, not one will work the other way.
The next step is to collect the collected files on the first sd card section:
-
/olimex-kernel-4.14.57/arch/arm/boot/
from here we get the assembled kernel, it is called uImage and weighs only 4.7 meters.
-
/olimex-uboot/arch/arm/dts/
from here we get the compiled tree, the file sun5i-a13-olinuxino.dtb
-
/u-boot-2018.05/
from here we get the compiled boot script boot.scr.
Build ubuntu
Since all the necessary parts for downloading rootfs are prepared, it remains to build ubuntu and for this we will get the latest version 18.04.
First, create a folder in the root directory:
sudo mkdir /destrupt
It is here because in order to use chroot then you need either full rights as in the root directory, or register the chroot configuration for any other folder. In short, it is easier to create a folder in the root directory and do not fool around with configuration.
To build, we need the following packages, they need to be delivered if not:
- Qemu-user-static
- debootstarp
- schroot
Next, run the ubuntu build:
sudo qemu-debootstrap
# we use exactly qemu since along with the build ubuntu will be installed and qemu that will allow you to immediately run a chroot on the assembled version of ubuntu
--arch armhf
# processor architecture type
--variant=minbase
# build in minimum version
bionic
# build version 18.04
/destrup/
# address where to collect
http://ports.ubuntu.com/ubuntu-ports
# from where to collect source
Well, ubuntu 18.04 is now compiled; let's now proceed to the step-by-step configuration:
1. Before launching we climb into / destrup / etc / apt / and rule sources.list, add the following:
deb http://ports.ubuntu.com/ubuntu-ports bionic main restricted deb http://ports.ubuntu.com/ubuntu-ports bionic universe deb http://ports.ubuntu.com/ubuntu-ports bionic multiverse
These are just sources for distros under our processor.
2. Run change root on the ubuntu distrib that you just created:
sudo chroot /destrup
First of all, set the password for the root user:
passwd root
This password is required to log into the system at boot.
3. Install the following packages.
apt update
- update packages
We put a list of packages for network operation:
iputils-ping, dhcpcd5, iproute2, iw, networkd-dispatcher, wireless-tools, net-tools.
System packages for work with the network:
linux-firmware, wpasupplicant, systemd, hostapd, kmod, udev.
Well, the rest so that it would all be convenient to edit and configure: nano, mc, usbutils, sudo.
And I will not describe everything because it will stretch out for a couple of articles, just go through some of the packages required in the setup.
Configure wpa supplicant.
To begin with, let's briefly analyze what is usb wifi.
The chip itself which provides wifi (in this case rtl8188) is a wired ADC, with its own special data presentation and usb output. those. If you run the lsmod command without the r8188eu.ko module loaded, then we will see only that someone else occupied the usb port. When the module is loaded, the device name will be already visible, in other words, this module is only a software interface for managing this chip.
The next most important library is lib80211.ko, the IEEE 802.11 standard itself, in simple words it is the interpretation of digitized broadcast signals into the presentation of specific ehternet protocols. But in order to manage all these it is necessary to install linux-firmware in its composition there will be a driver -wext- which will do all this. We will connect it in further.
Let's start the configuration of the supplikant.
We climb in the freshly collected ubunte to this address:
/ etc / wpa_supplicant / wpa_supplicant.conf
And we create a configuration file if there isn’t, and if so, we reign to this:
ctrl_interface_group=0
If everything is configured correctly and the modules described above are loaded, then a device file will be created at the address specified in the configuration (ctrl_interface parameter).
Systemd setup
We configured the supplicant, but there is no one to launch it yet. You can of course install a network-manager and enjoy auto-tuning, but where is the hardcore where the trash is. In general, solid boredom.
Therefore we climb to the address:
/ etc / systemd / system/
And here we create a file with the name
network-wireless.service
if not, and if there is, we begin to edit:
[Unit]
Let us dwell on the launch of the supplikant:
ExecStart=/sbin/wpa_supplicant
# access path to the supplicant
-B
# run in the background
-i wlx007005012449
# interface to run, the same device file
-D wext
# driver name for the whistle from linux-firmware
-c /etc/wpa_supplicant/wpa_supplicant.conf
# address of the supplicant configuration file
Well, in general, everything you need is configured, go to the installation of modules.
Installing modules.
To install the modules, go back a little bit, namely to the folder with the kernel source and run the command to copy modules from the kernel to the folder with ubuntu from there:
make O=../olimex-kernel-4.14.57 -j2 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules_install
After that, all our assembled modules are copied to ubuntu at:
/ lib / modules / 4.14.57 / kernel
Now the most important thing is to register the launch of the copied modules and all their dependencies, so we crawl to the address:
/ etc / modules
And run open the modules file for editing and append the following modules:
michael_mic r8188eu # r8192e_pci rtllib rtllib_crypt_ccmp rtllib_crypt_tkip rtllib_crypt_wep r8192u_usb # lib80211 # IEEE 802.11
Now it remains to copy the entire collected ubuntu to the sd card section marked in the previous article as a section for ubuntu.
After that, you can insert a USB flash drive into the board, apply power and sit on its uart to access its controls or ssh. You can add a command to systemd to set an ip address or another configuration in general, then everything else is in your hands ...
The first part of the articleThe second part of the article