Embedded linux environment construction

Summarized from "Embedded Linux Application Development Complete Manual_Wei Dongshan Complete Series of Video Documents V2.4"

1. The computer BIOS starts virtualization

Insert picture description here
Insert picture description here

2. Linux network card view and IP settings

View all network cards

ifconfig -a

Set network IP

$ sudo ifconfig ens160 192.168.1.16

If the following command is unsuccessful, it means that the routing is not set up:

$ ping 8.8.8.8
connect: Network is unreachable

If "ping 8.8.8.8" is successful, but "ping www.baidu.com" is unsuccessful, the DNS is not set properly:

$ ping www.baidu.com
ping: unknown host www.baidu.com

DNS settings are relatively simple. 8.8.8.8 is an easy-to-remember DNS server. Modify the /etc/resolv.conf file in Ubuntu to read as follows:

nameserver 8.8.8.8

3. Windows NAT virtual network configuration

Insert picture description here
Insert picture description here

4. Modify the mountd port of Ubuntu

In the NAT network, if you want the development board to mount Ubuntu via NFS, you need to modify the mountd port to 9999.
If you don't know how to use the vi command, you can start the terminal on the Ubuntu desktop, execute the following command, and modify it with the GUI tool:

sudo gedit /etc/services

Command explanation: modify /etc/services:
add 2 lines:

mountd 9999/tcp
mountd 9999/udp

5. MobaXterm settings

Install and run MobaXterm, and set up Session as follows:
Insert picture description here
Note: For Ubuntu using NAT, the IP entered in step 2 in the above figure is 127.0.0.1; if you are not using NAT, you need to enter the Ubuntu IP.

6. FileZilla settings

Insert picture description here
Note: For Ubuntu using NAT, the IP entered in step 2 in the above figure is 127.0.0.1; if you are not using NAT, you need to enter the Ubuntu IP.

6, ubuntu cross compilation chain setting and inspection

Permanently effective
1. Execute: gedit ~/.bashrcor vi ~/.bashrc
2. Add or modify at the end of the line, and add the following lines (the third line is very long, and a small font is used here for everyone to copy):

export ARCH=arm
export CROSS_COMPILE=arm-buildroot-linux-gnueabihf-
export PATH=$PATH:/home/book/100ask_stm32mp157_pro-sdk/ToolChain/arm-buildroot-linux-gnueabihf_sdk-buildroot/bin

3. To execute source ~/.bashrcthe command to take effect, this command is to load the environment variables for these settings.

7, ubuntu compile the kernel

The compilation process of the kernel of the STM32MP157 development board is as follows (you need to configure some environment variables such as the tool chain before compiling the kernel):

book@100ask:~/100ask_stm32mp157_pro-sdk$ cd Linux-5.4
book@100ask:~/100ask_stm32mp157_pro-sdk/Linux-5.4$ make 100ask_stm32mp157_pro_defconfig
book@100ask:~/100ask_stm32mp157_pro-sdk/Linux-5.4$ make uImage LOADADDR=0xC2000040 -j4
book@100ask:~/100ask_stm32mp157_pro-sdk/Linux-5.4$ make dtbs
book@100ask:~/100ask_stm32mp157_pro-sdk/Linux-5.4$ cp arch/arm/boot/uImage ~/nfs_rootfs
book@100ask:~/100ask_stm32mp157_pro-sdk/Linux-5.4$ cp arch/arm/boot/dts/100ask-stm32m1p157c-pro.dtb ~/nfs_rootfs

8, ubuntu compiles the kernel module

After the STM32MP157 development board enters the kernel source directory, you can compile the kernel module:

book@100ask:~$ cd 100ask_stm32mp157_pro-sdk/Linux-5.4
book@100ask:~/100ask_stm32mp157_pro-sdk/Linux-5.4$ make modules -j4
book@100ask:~/100ask_stm32mp157_pro-sdk/Linux-5.4$ sudo make INSTALL_MOD_PATH=/home/book/nfs_rootfs modules_install

The last command is to install the module to the /home/book/nfs_rootfs directory for backup, and you will get the
/home/book/nfs_rootfs/lib/modules directory.

9. Install the kernel and modules on the development board

Assumptions: executing the command, in the Ubuntu / home book under / / nfs_rootfs directory already zImage or uImage , DTB file,
and there lib / modules subdirectory (which contains various modules).
Next, copy these files to the development board.
1. If you are using VMware NAT, assuming that the Windows IP is 192.168.1.100, after the development board boots into Linux, enter
root to log in, and then execute the following commands (Note: You must specify the port as 2049 and mountport as 9999):

mount -t nfs -o nolock,vers=3,port=2049,mountport=9999 192.168.1.100:/home/book/nfs_rootfs /mnt
cp /mnt/zImage /boot 或 cp /mnt/uImage /boot 
cp /mnt/*.dtb /boot
cp /mnt/lib/modules /lib -rfd
sync
reboot

2. If you are using the VMware bridging method, assuming that the Ubuntu IP is 192.168.1.100, execute the following command on the development board:

mount -t nfs -o nolock,vers=3 192.168.1.100:/home/book/nfs_rootfs /mnt
cp /mnt/zImage /boot 或 cp /mnt/uImage /boot 
cp /mnt/*.dtb /boot
cp /mnt/lib/modules /lib -rfd
sync
reboot

Finally restart the development board, it will use the new zImage or uImage, dtb, module.

10. ubuntu modifies the Makefile to specify the kernel directory

After uploading the first driver 01_hello_drv to Ubuntu, modify its Makefile and set the KERN_DIR variable in it to the kernel source directory. Take IMX6ULL as an example, as follows:

KERN_DIR = /home/book/100ask_imx6ull-sdk/Linux-4.9.88

11. Compile the first driver

1. After setting up the tool chain, configuring, and compiling the kernel, execute the make command in the 01_hello_drv directory to compile the driver and test program, as follows:

Insert picture description here

2. After copying to the development board, install the driver and verify whether it is successful:

[root@board:~]# insmod hello_drv.ko

Execute "lsmod" to see the hello_drv driver, as follows:
Insert picture description here

3. Execute "cat /proc/devices": view the device name and device number

Insert picture description here
Execute "ls -l /dev/hello", you can find this device node, and its major device number is the same as the figure above:
Insert picture description here

12. Program update

Insert picture description here

Guess you like

Origin blog.csdn.net/LIU944602965/article/details/115379243