Based on AM335X development board (ARM Cortex-A8)——Linux system user manual (medium)
[Copy link]
This article mainly explains how to correctly test and use the Linux system in embedded boards, including U-Boot compilation, U-Boot commands and environment variables, Linux kernel compilation, xtra driver compilation, system information query, program startup self-starting instructions, NFS usage instructions, TFTP usage instructions, TFTP + NFS system startup test instructions, inux device driver instructions, etc. The case source code is partially open.
In addition, the test board of this article adopts the TL335x-EVM-S development board of Chuanglong Technology, which is a development board designed based on the TI Sitara series AM3352/AM3354/AM3359 ARM Cortex-A8 high-performance and low-power processor. It has rich interface resources and leads to dual-channel Gigabit network ports, LCD, HDMI, GPMC, CAN and other interfaces, which facilitates users to quickly evaluate product solutions and conduct technical pre-research, and is applied in typical fields such as communication management, data acquisition, human-computer interaction, motion control, and smart power.
Preface
This document is applicable to the following development environments:
Windows development environment: Windows 7 64bit, Windows 10 64bit
Linux development environment: Ubuntu 14.04.3 64bit
Virtual machine: VMware 15.1.0
U-Boot: U-Boot-2017.01
Kernel: Linux-4.9.65, Linux-RT-4.9.65
Linux Processor SDK: ti-processor-sdk-linux-rt-am335x-evm-04.03.00.05
The Linux system software related files are in the product information "4-Software Information\Linux\" directory, including four folders: U-Boot, Kernel, Filesystem and Makesdboot (see the table below for details). The system supports Linux kernel and Linux-RT real-time kernel, and the default is Linux kernel. If the system real-time performance is required to be high, you can switch to Linux-RT kernel.
Extra driver compilation
The extra driver needs to be recompiled locally for the first time to make it consistent with the new kernel image version. If the kernel image is generated again locally, there is no need to compile the extra driver at the same time, that is, the extra driver only needs to be recompiled once.
The extra driver source code is included in the Linux Processer SDK. The following is a description of some of the extra drivers used.
Extra drive
|
illustrate
|
cryptodev
|
crypto encryption algorithm call
|
ti-sgx-ddk-km
|
GPU Initialization
|
uio-module-drv
|
mmap, interrupt and other upper-layer application interface calls
|
Go to the Linux Processer SDK package installation directory, execute the following command to open the Rules.make file, and modify the DESTDIR and LINUXKERNEL_INSTALL_DIR parameter values as follows.
Host# cd /home/tronlong/ti-processor-sdk-linux-rt-am335x-evm-04.03.00.05/
Host# ls board-support/extra-drivers/
Host# sudo vi Rules.make
DESTDIR=/media/tronlong/rootfs //Specify the extra driver installation path as the directory where the file system is located
LINUXKERNEL_INSTALL_DIR=/home/tronlong/AM335x/Kernel/Linux-4.9.65 //Specify the kernel source code installation directory that the extra driver depends on for compilation
When compiling an extra driver, the Linux kernel that the extra driver depends on will be compiled again by default. To shorten the compilation time, modify the Makefile file as follows so that the Linux kernel does not need to be compiled again when compiling the extra driver.
Run the following command to open the Makefile file, delete the linux strings in the locations where the cryptodev, ti-sgx-ddk-km, and uio-module-drv drivers are located, and save the changes after they are complete.
Host# sudo vi Makefile
In the Linux Processor SDK installation directory, execute the following commands in sequence to compile the extra driver.
Host# sudo make cryptodev
Host# sudo make uio-module-drv
Host# sudo make ti-sgx-ddk-km
Insert the Linux system boot card into the PC through the card reader and successfully mount it to the Ubuntu system. The mount path of the Linux system boot card in this operation demonstration is "/media/tronlong/rootfs/". In the Linux Processor SDK installation directory, execute the following commands in sequence to install the extra driver to the Linux system boot card file system rootfs partition "/lib/modules/<kernel_release>/extra/" directory. If the version management tool is not used locally, <kernel_release> is generally 4.9.65-rt23.
Host# sudo make cryptodev_install
Host# sudo make uio-module-drv_install
Host# sudo make ti-sgx-ddk-km_install
Run the following command to check whether the kernel is successfully installed in the /lib/modules/<kernel_release>/extra/ directory of the Linux system boot card rootfs partition.
Host# ls /media/tronlong/rootfs/lib/modules/4.9.65-rt23/extra/
System Information Query
After the evaluation board system is started, the root user will be automatically logged in. You can refer to the following method to query system related information.
Target# cat /etc/issue
The operating system login welcome information is recorded in the "/etc/issue" file. You can modify the content of this file to change the system login information. When a network user or through the serial port logs in to the system, the "/etc/issue" file content is displayed before the login prompt, and the "/etc/motd" file content is displayed after the user successfully logs in to the system.
Target# hostname
The host name is recorded in "/etc/hostname". You can modify the content of this file to change the host name.
Target# cat /proc/version
content
|
illustrate
|
4.9.65-rt23
|
Kernel version
|
gfc51450
|
Version management serial number
|
Linaro GCC 6.2-2016.11
|
Cross-compilation tool version
|
#1
|
Number of compilations after cleaning the kernel
|
SMP PREEMPT/SMP PREEMPT RT
|
SMP PREEMPT: Linux Kernel
SMP PREEMPT RT: Linux-RT kernel
|
xxxxx CST 2021
|
Kernel image compilation time
|
Target# lsb_release -r
Target# top
Target# cat /proc/meminfo
Target#env
Target# ls /usr/lib/
Target# ls /boot/
Target# ls /lib/modules/4.9.65-rt23-gfc51450/kernel/
Target# ls /lib/modules/4.9.65-rt23-gfc51450/extra/
Target#lsmod
Program startup instructions
In Linux, there are two ways to realize the program startup: init process and systemd service. The systemd method is more flexible and efficient, and it provides a complete solution for system startup and management. This chapter mainly demonstrates how to set up a script program to start automatically at startup through the systemd service method.
After the evaluation board is powered on, enter the file system and execute the following command to create a helloworld.sh script and grant the script executable permissions.
Target# vi helloworld.sh
Target# chmod 777 helloworld.sh
Add the following content to the script. The script content can be replaced and modified according to actual needs.
#!/bin/bash
echo ""
echo "Hello World!"
echo ""
echo "www.tronlong.com"
Enter the /lib/systemd/system/ directory of the file system and create a self-starting systemd service configuration file helloworld.service.
Target# cd /lib/systemd/system/
Target# vi helloworld.service
Add the following content to the helloworld.service file. In actual applications, please modify it according to actual needs. Description is a brief description of the systemd service, ExecStartPre is the print information of the systemd service, and ExecStart is the command to start the current service.
[Unit]
Description=helloworld
After=basic.service X.service thermal-zone-init.service
[Service]
Environment=DISPLAY=0:0
ExecStartPre=/bin/echo "****Start to run helloworld.service****"
ExecStart=/home/root/helloworld.sh
StandardOutput=tty
KillMode=process
KillSignal=SIGKILL
SendSIGKILL=yes
[Install]
WantedBy=multi-user.target
Please enter the following command to enable the systemd service. The "-f" option means force, which can be selected as needed, and then execute the system restart command.
Target# systemctl -f enable /lib/systemd/system/helloworld.service
Target# reboot
After restarting the Linux system, the systemd service will automatically execute the contents of the helloworld.sh script after it is started. The system prints information as shown in the figure below.
To cancel the automatic startup of the systemd service, run the following command.
Target# systemctl disable helloworld.service
TFTP Usage Instructions
TFTP (Trivial File Transfer Protocol) is a simple network protocol used to download remote files. It is an application based on the UDP protocol. Embedded Linux TFTP includes a server and a client. It is often used to complete the file transfer function between the evaluation board (client) and the PC (server), which can avoid the frequent USB disk copy process.
The evaluation board supports TFTP server and client programs (as shown in the figure below). This chapter mainly demonstrates the use of the evaluation board as a client, and builds a TFTP server in the PC Linux system, ultimately realizing the TFTP file transfer method between the PC and the evaluation board.
|