I.MX6Q-SDB development board porting ubuntu
0. Preface
In the past two days, I cleaned up the pile of groceries and found an I.MX6QSDB development board that my tutor applied for when I was in school. The Android system was flashed in the SD card when it was shipped from the factory. Later, I flashed NXP's official Yocto linux into emmc. It is used to learn some driver development, and then it has been eating ashes. Now that I have the ability to tinker with devices, I want to adapt to the ubuntu system and replace the previously low-performance Wankeyun.
1. Preparation
First download the relevant resource files of this development board from the NXP official website , including the official Linux6.1 toolkit and User Guide. Among them, the official Linux toolkit includes the device tree, u-boot, and linux kernel files of this development board. Since you need to adapt ubuntu yourself, the rootfs file is not needed. User Guide is used to guide some hardware-related operations, including DIP switch settings, image burning address, etc.
2. Ubuntu porting
The transplantation of ubuntu is essentially the transplantation of the root file system, and has nothing to do with kernel, u-boot, etc. This part can refer to this article .
1. Download the root file system released by ubuntu
Download the required files from the ubuntu official ubuntu-base file system website. Here the author downloads the root file system of the ubuntu22.04 version, which needs to be selected according to its own hardware platform and version requirements.
2. Simple modification of the root file system
The official root file system is still a little crude, and needs to be modified first to facilitate subsequent porting to the board. Unzip the downloaded file into a folder in ubuntu. The relevant files are as follows:
It can be seen that there is not much difference from the common Linux root file directory. Follow the steps in the transplant case, first use the following command to install and run the emulator:
sudo apt install qemu-user-static
Then copy the simulator whose CPU architecture is ARM to the root file system:
sudo cp /usr/bin/qemu-arm-static ./usr/bin/
Then copy the DNS configuration file under the host. Without this file, you cannot use apt-get to download the software:
sudo cp /etc/resolv.conf ./etc/resolv.conf
Then replace the source address:
注:这里更换源地址时建议先备份原本的源地址文件,方便后续出错时恢复。
cp ./etc/apt/sources.list ./etc/apt/sources.list.bak
vim ./etc/apt/sources.list
When modifying the source address, just replace the ubuntu official source prefix in this file with the domestic source, and the latter suffix does not need to be modified. For example, the official source is originally, you only need to replace deb http://ports.ubuntu.com/ubuntu-ports/ jammy multiverse
the previous one http://ports.ubuntu.com
with the domestic Aliyun, Tsinghua source, Huawei source source address. Optional prefix:
http://mirrors.aliyun.com
https://mirrors.ustc.edu.cn
https://mirrors.tuna.tsinghua.edu.cn
Save and exit after the modification is complete, and then follow the process in the case to mount the relevant directories in the ubuntu host to this directory:
sudo mount -t proc /proc ./proc
sudo mount -t sysfs /sysfs ./sys
sudo mount -o bind /dev ./dev
sudo mount -o bind /dev/pts ./dev/pts
Then switch the file system to this directory:
sudo chroot ./
Update and install related apps:
apt-get update
apt-get upgrade
apt-get install -y sudo vim kmod net-tools ethtool ifupdown language-pack-en-base rsyslog htop iputils-ping dosfstools systemd
注:
If the error Couldn't create temporary file /tmp/apt.conf.AdvpMV for passing *** is reported during the update, as shown in the figure below, execute it in the current window chmod 777 /tmp
to solve it.
3. Board adaptation settings
Continue to follow the process in the case, set the login password of the board, the host name, and adapt the serial port, etc.
set password:
passwd root
Set the hostname:
echo "usr-name" > /etc/hostname
echo "127.0.0.1 localhost" >> /etc/hosts
echo "127.0.0.1 usr-name" >> /etc/hosts
Set the serial port terminal: Take serial port 1 as an example, its device file name is ttymxc0, so use the ln command to create a soft link file pointing to /lib/systemd/system/[email protected]:
ln -s /lib/systemd/system/[email protected] /etc/systemd/system/getty.target.wants/[email protected]
注:这里需要根据自己的板卡串口进行修改,可以先启动到官方的u-boot中使用print env命令查看相关参数。
Configure network autostart:
echo auto eth0 > /etc/network/interfaces.d/eth0
echo iface eth0 inet dhcp >> /etc/network/interfaces.d/eth0
Finally, exit the current file system and unmount the four directories and files proc, sys, dev, dev/pts:
exit
sudo umount ./proc
sudo umount ./sys
sudo umount ./dev/pts
sudo umount ./dev
4. Pack the root file system
Pack the root file system into a file in xxx.tar.bz2 format.
Enter the directory where the root file system is located, and execute the following command:
tar -cvjf my_rootfs.tar.bz2 *
3. Burn image
There are three options for NXP series board programming: dd command, uuu tool, mfgtool tool.
1.dd command
Under Linux, partition the storage medium according to the requirements, and then burn the zImage, dtb file, u-boot file, and rootfs to the corresponding partitions. The advantage of this method is that it is convenient and fast, you can directly use the corresponding command, and you can program files one by one. The disadvantage is that it can only be programmed into the sd card device. For the specific operation method, you can go to the NXP official website and download the corresponding User Guide for reference.
2. uuu tools
The uuu tool can be understood as an upgraded version of mfgtool. The official mfgtool tool can only burn a complete Yocto image. If you want to burn your own image, you need to package it into a corresponding file as required, or modify the logic in the burning script. The uuu tool can burn u-boot and other files independently, and the burning speed has been greatly improved.
However, the author encountered some problems when programming according to the official introduction: the u-boot file can be programmed separately with the uuu tool, but other kernels, rootfs, etc. cannot be programmed separately. After consulting, the official said that if you want to use uuu to burn your own image, you must package the kernel, dtb, and rootfs into a Yocto-style .wic file. I also checked the relevant manuals and introductions. If you want to package into this format, you need to install a lot of tool chains and compilation environments, so in the end the author gave up this method.
3. mfgtool tool
In the end, the author chose this most commonly used method. Although the burning speed is a little slower, it is more convenient to operate. The author downloaded the mfgtool in the punctual atom resource package, but the official downloaded device can't be found during the programming process, and I don't know why. Copy the kernel, dtb and u-boot in the official resource package, and the packaged ubuntu rootfs file after transplantation to the resource folder of mfgtool, and run the corresponding programming script.
4. Dial setting of i.mx6q-sdb:
DIP1 - DIP6 | flash media |
---|---|
11010110 | emmc |
10000010 | SD card slot 2 |
01000010 | SD card slot 3, programming mode |
00000100 | sata |
4. The big speechless incident
When the author programmed the emmc to start, and after the test was correct, he wrote the official original Yocto image into an SD card for backup. When the author started the image, he unexpectedly found that the official image was transplanted based on the Debain system. , Spending two nights in vain to tinker with ubuntu, but it can be regarded as accumulating the experience of porting ubutnu to the development board (just comfort yourself like this).