Linux第55步_根文件系统第2步_测试使用busybox生成的根文件系统

测试使用busybox生成的根文件系统。测试内容较多,很杂。

1、修改"nfs-kernel-server"

1)、打开终端

输入"sudo vi /etc/default/nfs-kernel-server回车",打开"nfs-kernel-server"文件。

输入密码"123456回车"

见下图:

2)、在最后面添加内容如下:

RPCNFSDOPTS="--nfs-version 2,3,4 --debug --syslog"

修改后,见下图:

3)、按"ESC键",输入":wq回车"

输入"sudo /etc/init.d/nfs-kernel-server restart回车",重启"nfs-kernel-server"

4)、在串口设置"bootargs"环境变量

连接串口通讯线,开启虚拟机,打开MobaXterm,给开饭上电,等待出现"Hit any key to stop autoboot",按下"回车键"

先要保证开发板能从网络启动,然后才能测试"根文件系统"。

通过设置环境变量bootcmd的值,从网络启动linux系统

出现"STM32MP>"时输入setenv bootcmd 'tftp c2000000 uImage;tftp c4000000 stm32mp157d-atk.dtb;bootm c2000000 - c4000000',设置从网络启动linux系统

出现"STM32MP>"时输入: saveenv,保存bootcmd的值

出现"STM32MP>"时输入: boot,启动 Linux 系统

输入"setenv bootargs 'console=ttySTM0,115200 root=/dev/nfs nfsroot=192.168.2.180:/home/zgq/linux/nfs/rootfs,proto=tcp rw ip=192.168.2.178:192.168.2.180:192.168.2.1:255.255.255.0::eth0:off'

回车"

输入"saveenv回车"

输入"boot回车"

解释:

"bootargs"环境变量

"console=ttySTM0,115200"表示串口波特率为115200

"192.168.2.180"为虚拟机IP地址

"/home/zgq/linux/nfs/rootfs"为根文件系统存放路径

"proto=tcp"表示使用TCP协议

"rw"表示nfs挂载的根文件系统可读可写

"192.168.2.178"为开发板IP地址

"192.168.2.1"为网关地址

"255.255.255.0"为子网掩码

"eth0"为设备名/网卡名

"off"不使用自动配置

举例:

setenv bootargs 'console=ttySTM0,115200 root=/dev/nfs nfsroot=192.168.2.180:/home/zgq/linux/nfs/rootfs,proto=tcp rw ip=192.168.2.178:192.168.2.180:192.168.2.1:255.255.255.0::eth0:off'

5)、串口输出结果:

Hit any key to stop autoboot: 0

STM32MP> setenv bootargs 'console=ttySTM0,115200 root=/dev/nfs nfsroot=192.168.2.180:/home/zgq/linux/nfs/rootfs,proto=tcp rw ip=192.168.2.178:192.168.2.180:192.168.2.1:255.255.255.0::eth0:off'

STM32MP> saveenv

Saving Environment to MMC... Writing to redundant MMC(1)... OK

STM32MP> boot

ethernet@5800a000 Waiting for PHY auto negotiation to complete.... done

Using ethernet@5800a000 device

TFTP from server 192.168.2.180; our IP address is 192.168.2.178

Filename 'uImage'.

Load address: 0xc2000000

Loading: #################################################################

#################################################################

#################################################################

#################################################################

#################################################################

#################################################################

#################################################################

#######################T #####################

682.6 KiB/s

done

Bytes transferred = 7312152 (6f9318 hex)

Using ethernet@5800a000 device

TFTP from server 192.168.2.180; our IP address is 192.168.2.178

Filename 'stm32mp157d-atk.dtb'.

Load address: 0xc4000000

Loading: #####

989.3 KiB/s

done

Bytes transferred = 63833 (f959 hex)

Booting kernel from Legacy Image at c2000000 ...

Image Name: Linux-5.4.31

Created: 2024-02-12 6:18:02 UTC

Image Type: ARM Linux Kernel Image (uncompressed)

Data Size: 7312088 Bytes = 7 MiB

Load Address: c2000040

Entry Point: c2000040

Verifying Checksum ... OK

Flattened Device Tree blob at c4000000

Booting using the fdt blob at 0xc4000000

XIP Kernel Image

Loading Device Tree to cffed000, end cffff958 ... OK

Starting kernel ...

Booting Linux on physical CPU 0x0

Linux version 5.4.31 (zgq@zgq-virtual-machine) (gcc version 9.2.1 20191025 (GNU Toolchain for the A-profile Architecture 9.2-2019.12 (arm-9.10))) #4 SMP PREEMPT Mon Feb 12 14:17:47 CST 2024

CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d

CPU: div instructions available: patching division code

CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

OF: fdt: Machine model: STMicroelectronics STM32MP157D eval daughter

Memory policy: Data cache writealloc

Reserved memory: created DMA memory pool at 0x10000000, size 0 MiB

OF: reserved mem: initialized node mcuram2@10000000, compatible id shared-dma-pool

Reserved memory: created DMA memory pool at 0x10040000, size 0 MiB

OF: reserved mem: initialized node vdev0vring0@10040000, compatible id shared-dma-pool

Reserved memory: created DMA memory pool at 0x10041000, size 0 MiB

OF: reserved mem: initialized node vdev0vring1@10041000, compatible id shared-dma-pool

Reserved memory: created DMA memory pool at 0x10042000, size 0 MiB

OF: reserved mem: initialized node vdev0buffer@10042000, compatible id shared-dma-pool

Reserved memory: created DMA memory pool at 0x30000000, size 0 MiB

OF: reserved mem: initialized node mcuram@30000000, compatible id shared-dma-pool

Reserved memory: created DMA memory pool at 0x38000000, size 0 MiB

OF: reserved mem: initialized node retram@38000000, compatible id shared-dma-pool

cma: Reserved 128 MiB at 0xe8000000

psci: probing for conduit method from DT.

psci: PSCIv1.1 detected in firmware.

psci: Using standard PSCI v0.2 function IDs

psci: MIGRATE_INFO_TYPE not supported.

psci: SMC Calling Convention v1.0

percpu: Embedded 20 pages/cpu s50124 r8192 d23604 u81920

Built 1 zonelists, mobility grouping on. Total pages: 227647

Kernel command line: console=ttySTM0,115200 root=/dev/nfs nfsroot=192.168.2.180:/home/zgq/linux/nfs/rootfs,proto=tcp rw ip=192.168.2.178:192.168.2.180:192.168.2.1:255.255.255.0::eth0:off

Dentry cache hash table entries: 131072 (order: 7, 524288 bytes, linear)

Inode-cache hash table entries: 65536 (order: 6, 262144 bytes, linear)

mem auto-init: stack:off, heap alloc:off, heap free:off

Memory: 759396K/917500K available (11264K kernel code, 869K rwdata, 3408K rodata, 1024K init, 213K bss, 27032K reserved, 131072K cma-reserved, 131068K highmem)

SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1

rcu: Preemptible hierarchical RCU implementation.

rcu: RCU event tracing is enabled.

Tasks RCU enabled.

rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.

NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16

random: get_random_bytes called from start_kernel+0x31c/0x4f4 with crng_init=0

arch_timer: cp15 timer(s) running at 24.00MHz (virt).

clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns

sched_clock: 56 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns

Switching to timer-based delay loop, resolution 41ns

Console: colour dummy device 80x30

Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)

pid_max: default: 32768 minimum: 301

Mount-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)

Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes, linear)

CPU: Testing write buffer coherency: ok

/cpus/cpu@0 missing clock-frequency property

/cpus/cpu@1 missing clock-frequency property

CPU0: thread -1, cpu 0, socket 0, mpidr 80000000

Setting up static identity map for 0xc0100000 - 0xc0100060

rcu: Hierarchical SRCU implementation.

smp: Bringing up secondary CPUs ...

CPU1: thread -1, cpu 1, socket 0, mpidr 80000001

smp: Brought up 1 node, 2 CPUs

SMP: Total of 2 processors activated (96.00 BogoMIPS).

CPU: All CPU(s) started in SVC mode.

devtmpfs: initialized

VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5

clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns

futex hash table entries: 512 (order: 3, 32768 bytes, linear)

pinctrl core: initialized pinctrl subsystem

NET: Registered protocol family 16

DMA: preallocated 256 KiB pool for atomic coherent allocations

hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.

hw-breakpoint: maximum watchpoint size is 8 bytes.

Serial: AMBA PL011 UART driver

stm32-pm-domain pm_domain: domain core-ret-power-domain registered

stm32-pm-domain pm_domain: subdomain core-power-domain registered

stm32-pm-domain pm_domain: domains probed

reg-fixed-voltage buck1: Fixed regulator specified with variable voltages

reg-fixed-voltage: probe of buck1 failed with error -22

SCSI subsystem initialized

usbcore: registered new interface driver usbfs

usbcore: registered new interface driver hub

usbcore: registered new device driver usb

pps_core: LinuxPPS API ver. 1 registered

pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>

PTP clock support registered

EDAC MC: Ver: 3.0.0

Advanced Linux Sound Architecture Driver Initialized.

clocksource: Switched to clocksource arch_sys_counter

thermal_sys: Registered thermal governor 'step_wise'

NET: Registered protocol family 2

tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes, linear)

TCP established hash table entries: 8192 (order: 3, 32768 bytes, linear)

TCP bind hash table entries: 8192 (order: 4, 65536 bytes, linear)

TCP: Hash tables configured (established 8192 bind 8192)

UDP hash table entries: 512 (order: 2, 16384 bytes, linear)

UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)

NET: Registered protocol family 1

RPC: Registered named UNIX socket transport module.

RPC: Registered udp transport module.

RPC: Registered tcp transport module.

RPC: Registered tcp NFSv4.1 backchannel transport module.

hw perfevents: enabled with armv7_cortex_a7 PMU driver, 5 counters available

Initialise system trusted keyrings

workingset: timestamp_bits=14 max_order=18 bucket_order=4

squashfs: version 4.0 (2009/01/31) Phillip Lougher

NFS: Registering the id_resolver key type

Key type id_resolver registered

Key type id_legacy registered

ntfs: driver 2.1.32 [Flags: R/O].

jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.

fuse: init (API version 7.31)

NET: Registered protocol family 38

Key type asymmetric registered

Asymmetric key parser 'x509' registered

bounce: pool size: 64 pages

Block layer SCSI generic (bsg) driver version 0.4 loaded (major 246)

io scheduler mq-deadline registered

io scheduler kyber registered

STM32 USART driver initialized

brd: module loaded

loop: module loaded

libphy: Fixed MDIO Bus: probed

CAN device driver interface

pegasus: v0.9.3 (2013/04/25), Pegasus/Pegasus II USB Ethernet driver

usbcore: registered new interface driver pegasus

usbcore: registered new interface driver asix

usbcore: registered new interface driver ax88179_178a

usbcore: registered new interface driver cdc_ether

usbcore: registered new interface driver smsc75xx

usbcore: registered new interface driver smsc95xx

usbcore: registered new interface driver net1080

usbcore: registered new interface driver cdc_subset

usbcore: registered new interface driver zaurus

usbcore: registered new interface driver cdc_ncm

ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver

ehci-platform: EHCI generic platform driver

ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver

ohci-platform: OHCI generic platform driver

usbcore: registered new interface driver cdc_acm

cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters

usbcore: registered new interface driver usb-storage

i2c /dev entries driver

stm32-cpufreq stm32-cpufreq: Failed to get chip info: -517

sdhci: Secure Digital Host Controller Interface driver

sdhci: Copyright(c) Pierre Ossman

Synopsys Designware Multimedia Card Interface Driver

sdhci-pltfm: SDHCI platform and OF driver helper

ledtrig-cpu: registered to indicate activity on CPUs

usbcore: registered new interface driver usbhid

usbhid: USB HID core driver

arm-smc-mbox mailbox-0: ARM SMC mailbox enabled.

arm-smc-mbox mailbox-1: ARM SMC mailbox enabled.

Unable to get STM32 DDR PMU clock

drop_monitor: Initializing network drop monitor service

NET: Registered protocol family 17

can: controller area network core (rev 20170425 abi 9)

NET: Registered protocol family 29

can: raw protocol (rev 20170425)

can: broadcast manager protocol (rev 20170425 t)

can: netlink gateway (rev 20190810) max_hops=1

Key type dns_resolver registered

ThumbEE CPU extension supported.

Registering SWP/SWPB emulation handler

registered taskstats version 1

Loading compiled-in X.509 certificates

arm-scmi firmware:scmi-0: SCMI Protocol v2.0 'ST:' Firmware version 0x0

Unable to get STM32 DDR PMU clock

debugfs: Directory 'cpu0' with parent 'opp' already present!

Unable to get STM32 DDR PMU clock

stm32-mdma 58000000.dma: STM32 MDMA driver registered

stm32-dma 48000000.dma: STM32 DMA driver registered

stm32-dma 48001000.dma: STM32 DMA driver registered

reg11: supplied by regulator-dummy

reg18: supplied by regulator-dummy

usb33: supplied by regulator-dummy

stm_thermal 50028000.thermal: stm_thermal_probe: Driver initialized successfully

debugfs: Directory 'cpu0' with parent 'opp' already present!

stm32-crc32 58009000.crc: Initialized

stm32-hash 54002000.hash: will run requests pump with realtime priority

random: fast init done

stm32-hash 54002000.hash: Init HASH done HW ver 23 DMA mode 1

stm32-ddr-pmu: probed (ID=0x00140061 VER=0x00000010), DDR@533MHz

random: crng init done

/soc/interrupt-controller@5000d000: bank0

/soc/interrupt-controller@5000d000: bank1

/soc/interrupt-controller@5000d000: bank2

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOA bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOB bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOC bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOD bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOE bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOF bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOG bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOH bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOI bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOJ bank added

stm32mp157-pinctrl soc:pin-controller@50002000: GPIOK bank added

stm32mp157-pinctrl soc:pin-controller@50002000: Pinctrl STM32 initialized

stm32mp157-pinctrl soc:pin-controller-z@54004000: GPIOZ bank added

stm32mp157-pinctrl soc:pin-controller-z@54004000: Pinctrl STM32 initialized

stm32-usart 40010000.serial: interrupt mode for rx (no dma)

stm32-usart 40010000.serial: interrupt mode for tx (no dma)

40010000.serial: ttySTM0 at MMIO 0x40010000 (irq = 47, base_baud = 4000000) is a stm32-usart

printk: console [ttySTM0] enabled

stm32-dwmac 5800a000.ethernet: PTP uses main clock

stm32-dwmac 5800a000.ethernet: no reset control found

stm32-dwmac 5800a000.ethernet: No phy clock provided...

stm32-dwmac 5800a000.ethernet: User ID: 0x40, Synopsys ID: 0x42

stm32-dwmac 5800a000.ethernet: DWMAC4/5

stm32-dwmac 5800a000.ethernet: DMA HW capability register supported

stm32-dwmac 5800a000.ethernet: RX Checksum Offload Engine supported

stm32-dwmac 5800a000.ethernet: TX Checksum insertion supported

stm32-dwmac 5800a000.ethernet: Wake-Up On Lan supported

stm32-dwmac 5800a000.ethernet: TSO supported

stm32-dwmac 5800a000.ethernet: Enable RX Mitigation via HW Watchdog Timer

stm32-dwmac 5800a000.ethernet: device MAC address 00:04:9f:04:d2:36

stm32-dwmac 5800a000.ethernet: TSO feature enabled

libphy: stmmac: probed

stm32_rtc 5c004000.rtc: registered as rtc0

stm32_rtc 5c004000.rtc: Date/Time must be initialized

stm32_rtc 5c004000.rtc: registered rev:1.2

mmci-pl18x 58005000.sdmmc: mmc0: PL180 manf 53 rev2 at 0x58005000 irq 43,0 (pio)

mmci-pl18x 58007000.sdmmc: mmc1: PL180 manf 53 rev2 at 0x58007000 irq 44,0 (pio)

mmc0: host does not support reading read-only switch, assuming write-enable

stm32-ipcc 4c001000.mailbox: ipcc rev:1.0 enabled, 6 chans, proc 0

mmc0: new high speed SDHC card at address 1234

stm32_rtc 5c004000.rtc: setting system clock to 2000-01-01T00:32:54 UTC (946686774)

stm32-dwmac 5800a000.ethernet eth0: PHY [stmmac-0:00] driver [YT8511 Gigabit Ethernet]

mmcblk0: mmc0:1234 SA16G 14.4 GiB

mmcblk0: p1

dwmac4: Master AXI performs any burst length

stm32-dwmac 5800a000.ethernet eth0: No Safety Features support found

stm32-dwmac 5800a000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported

stm32-dwmac 5800a000.ethernet eth0: registered PTP clock

stm32-dwmac 5800a000.ethernet eth0: configuring for phy/rgmii-id link mode

mmc1: new high speed MMC card at address 0001

mmcblk1: mmc1:0001 8GTF4R 7.28 GiB

mmcblk1boot0: mmc1:0001 8GTF4R partition 1 4.00 MiB

mmcblk1boot1: mmc1:0001 8GTF4R partition 2 4.00 MiB

mmcblk1rpmb: mmc1:0001 8GTF4R partition 3 512 KiB, chardev (242:0)

mmcblk1: p1 p2

stm32-dwmac 5800a000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

IP-Config: Complete:

device=eth0, hwaddr=00:04:9f:04:d2:36, ipaddr=192.168.2.178, mask=255.255.255.0, gw=192.168.2.1

host=192.168.2.178, domain=, nis-domain=(none)

bootserver=192.168.2.180, rootserver=192.168.2.180, rootpath=

ALSA device list:

No soundcards found.

VFS: Mounted root (nfs filesystem) on device 0:16.

devtmpfs: mounted

Freeing unused kernel memory: 1024K

Run /sbin/init as init process

can't run '/etc/init.d/rcS': No such file or directory

Please press Enter to activate this console.

/ #

6)、在串口终端,输入"ls回车"

串口可以执行"ls"命令

2、解决"can't run '/etc/init.d/rcS': No such file or directory"

rcS是个shell脚本,Linux内核启动以后需要启动一些服务,而rcS就是规定启动哪些文件的脚本文件。因此,需要在rootfs中创建"/etc/init.dhcS"文件。

1)、在串口终端,输入"ls回车"

输入"cd etc/回车",切换得到"etc"目录

输入"ls回车", 查询"etc"目录下的文件和文件夹

输入"mkdir init.d回车",创建"init.d"目录

输入"ls回车", 查询"etc"目录下的文件和文件夹

输入"cd init.d/回车",切换得到"init.d"目录

2)、输入"vi rcS回车",创建"rcS"文件

#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin:$PATH

LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/lib:/usr/lib

export PATH LD_LIBRARY_PATH

mount -a

mkdir /dev/pts

mount -t devpts devpts /dev/pts

echo /sbin/mdev > /proc/sys/kernel/hotplug

3)、按"ESC键",输入":wq回车",保存退出

4)、输入"chmod 777 rcS回车",给rcS赋可执行权限

输入"ls回车", 查询"init.d"目录下的文件和文件夹

输入"reboot回车",重启

运行结果:

stm32-dwmac 5800a000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

IP-Config: Complete:

device=eth0, hwaddr=00:04:9f:04:d2:36, ipaddr=192.168.2.178, mask=255.255.255.0, gw=192.168.2.1

host=192.168.2.178, domain=, nis-domain=(none)

bootserver=192.168.2.180, rootserver=192.168.2.180, rootpath=

ALSA device list:

No soundcards found.

VFS: Mounted root (nfs filesystem) on device 0:16.

devtmpfs: mounted

Freeing unused kernel memory: 1024K

Run /sbin/init as init process

mount: can't read '/etc/fstab': No such file or directory

/etc/init.d/rcS: line 11: can't create /proc/sys/kernel/hotplug: nonexistent directory

Please press Enter to activate this console.

3、解决"mount: can't read '/etc/fstab': No such file or directory"

1)、在串口终端,输入"ls回车"

输入"cd etc/回车",切换得到"etc"目录

输入"ls回车", 查询"etc"目录下的文件和文件夹

输入"vi fstab回车",创建"fstab"文件

2)、添加内容如下:

#<file system> <mount point> <type> <options> <dump> <pass>

proc /proc proc defaults 0 0

tmpfs /tmp tmpfs defaults 0 0

sysfs /sys sysfs defaults 0 0

3)、按"ESC键",输入":wq回车",保存退出

输入"ls回车", 查询"etc"目录下的文件和文件夹

输入"reboot回车",重启

运行结果:

VFS: Mounted root (nfs filesystem) on device 0:16.

devtmpfs: mounted

Freeing unused kernel memory: 1024K

Run /sbin/init as init process

/etc/init.d/rcS: line 11: can't create /proc/sys/kernel/hotplug: nonexistent directory

Please press Enter to activate this console.

4、创建"/etc/inittab"

1)、在串口终端,输入"ls回车"

输入"cd etc/回车",切换得到"etc"目录

输入"ls回车", 查询"etc"目录下的文件和文件夹

输入"vi inittab回车",创建"inittab"文件

2)、添加内容如下:

#etc/inittab

::sysinit:/etc/init.d/rcS

#系统启动以后运行/etc/init.drcs 这个脚本文件

console::askfirst:-/bin/sh

#将console作为控制台终端,也就是 ttySTM0

::restart:/sbin/init

#重启的话运行/sbin/imit

::ctrlaltdel:/sbin/reboot

#按下ctrl+alt+del组合键就运行/sbinreboot,看来ctrl+alt+del组合键用于重启系统

::shutdown:/bin/umount -a -r

#关机的时候执行/bin/umount,也就是卸载各个文件系统

::shutdown:/sbin/swapoff -a

#关机的时候执行/sbin/swapof,也就是关闭交换分区

3)、按"ESC键",输入":wq回车",保存退出

输入"ls回车", 查询"etc"目录下的文件和文件夹

至此,根文件系统要创建的文件就已经全部完成了。

5、使能内核uevet helper

1)、打开虚拟机终端

输入"ls回车"

输入"cd linux/回车",切换到"linux"目录

输入"ls回车",列出"linux"目录下的文件和文件夹

输入"cd atk-mp1/回车",切换到"atk-mp1"目录

输入"ls回车",列出"atk-mp1"目录下的文件和文件夹

输入"cd linux/回车",切换到"linux"目录

输入"ls回车",列出"linux"目录下的文件和文件夹

输入"cd my_linux/回车",切换到"my_linux"目录

输入"ls回车",列出"my_linux"目录下的文件和文件夹

输入"cd linux-5.4.31/回车",切换到"linux-5.4.31"目录

输入"ls回车",列出"linux-5.4.31"目录下的文件和文件夹

输入"make menuconfig回车",打开linux的图形配置化界面

2)、移动向下光标键,找到"Device Drivers"

3)、按回车键,移动向下光标键,找到"Generic Driver Options"

4)、按回车键,移动向下光标键,找到"Support for uevent helper",按"Y"

5)、按"ESC键",直到出现下面的对话框

6)、按"Y"保存

输入"make menuconfig回车",打开linux的图形配置化界面

移动向右光标键至"Save"

7)、按"回车键"

8)、删除".config",改为"./arch/arm/configs/stm32mp1_atk_defconfig"

9)、移动向下光标键至"Ok",按"O"保存

10)、按"ESC键"关闭对话框

由于设备树dtbs没有被修改,我们只需编译uImage

输入"make uImage LOADADDR=0XC2000040 -j8回车"

#编译镜像文件,linux内核在DDR中的加载地址为0XC2000040,-j8表示采用8线程编译

11)、输入"cp arch/arm/boot/uImage /home/zgq/linux/tftpboot/ -f回车",执行文件拷贝;

12)、在串口输入"reboot回车",重启

运行结果:

mmcblk1: p1 p2

stm32-dwmac 5800a000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx

IP-Config: Complete:

device=eth0, hwaddr=00:04:9f:04:d2:36, ipaddr=192.168.2.178, mask=255.255.255.0, gw=192.168.2.1

host=192.168.2.178, domain=, nis-domain=(none)

bootserver=192.168.2.180, rootserver=192.168.2.180, rootpath=

ALSA device list:

No soundcards found.

VFS: Mounted root (nfs filesystem) on device 0:16.

devtmpfs: mounted

Freeing unused kernel memory: 1024K

Run /sbin/init as init process

Please press Enter to activate this console.

运行正确。

6、在根文件系统下创建"drivers"目录,将来编写的驱动就可以放到"drivers"目录中

在串口终端,输入"ls回车"

输入"mkdir drivers回车",创建"drivers"目录

输入"ls回车",查询根目录下的文件和文件夹

7、软件运行测试

1)、输入"ls回车"

输入"cd linux/回车",切换到"linux"目录

输入"ls回车",列出"linux"目录下的文件和文件夹

输入"cd nfs/回车",切换到"nfs"目录

输入"ls回车",列出"nfs"目录下的文件和文件夹

输入"vi hello.c回车",创建"hello.c"

2)、输入内容如下:

#include <stdio.h>

int main(void)

{

while(1) {

printf("hello world!\r\n"); //串口输出"hello world!"

sleep(2); //延时2妙

}

return 0;

}

3)、按"ESC键",输入":wq"保存退出

输入"arm-none-linux-gnueabihf-gcc hello.c -o hello回车",使用交叉编译"hello.c"

输入"file hello回车",查看hello的文件类型以及编码格式

输入"sudo cp hello /home/zgq/linux/nfs/rootfs/drivers/回车",将"hello"拷贝到"/home/zgq/linux/nfs/rootfs/drivers/"目录中

输入"ls回车",列出"linux"目录下的文件和文件夹

输入"cd rootfs/回车",切换到"rootfs"目录

输入"ls回车",列出"rootfs"目录下的文件和文件夹

输入"cd drivers/回车",切换到"drivers"目录

输入"ls回车",列出"drivers"目录下的文件和文件夹

4)、在串口终端输入"cd drivers/回车"

输入"ls/回车"

输入"./hello回车"

得到下面的界面

5)、按"CTRL+C"暂停

输入"./hello &回车"将"hello"放到后台执行

6)、关闭后台运行,输入"ps回车"查看"hello"的ID

7)、输入"kill -9 154回车",就可以删除"hello运行"

8)、再次输入"ps回车"查看"hello"是不是没有了

8、中文字符测试

1)、输入"cd ..回车",返回到"/linux/nfs/rootfs"目录下

输入"mkdir 中文测试",创建"中文测试目录"

输入"ls回车"

输入"cd 中文测试"

输入"vi 中文测试.txt",这个中文文档只能建在中文目录下

输入内容如下:

这是中文测试文档

测试时间:2024年2月14

按"ESC键",输入":wq回车",保存

2)、在串口终端

输入"ls"

输入"cd 中文测试"

输入"ls"

输入"cat 中文测试.txt"

9、开机自动启动hello程序

1)、输入"cd 中文测试.."

输入"ls"

输入"cd etc/"

输入"ls"

输入"cd init.d/"

输入"ls"

输入"vi rsS"

添加内容如下:

cd /drivers

./hello &

cd /

2)、输入"reboot"重启

3)、测试正确后,先停止hello程序,然后打开"etc/init.d/rcS"修改如下图:

4)、按"ESC键",输入":wq回车",保存

10、使用ping命令测试外网连接

1)、在rootfs中新建文件/etc/resolv.conf,然后在里面输入如下内容:

输入"ls"

输入"cd etc/"

输入"ls"

输入"vi resolv.conf"

2)、输入内容如下:

meserver 114.114.114.114

nameserver 192.168.2.1

3)、按"ESC键",输入":wq回车",保存

输入"reboot",重启

输入"ping www.baidu.com"

执行结果如下:

至此,"根文件系统"制作完成了。

相关推荐
zzzhpzhpzzz1 分钟前
Ubuntu如何查看硬件型号
linux·运维·ubuntu
蜜獾云4 分钟前
linux firewalld 命令详解
linux·运维·服务器·网络·windows·网络安全·firewalld
兔C36 分钟前
微信小程序的轮播图学习报告
学习·微信小程序·小程序
o(╥﹏╥)37 分钟前
linux(ubuntu )卡死怎么强制重启
linux·数据库·ubuntu·系统安全
娶不到胡一菲的汪大东42 分钟前
Ubuntu概述
linux·运维·ubuntu
海海不掉头发43 分钟前
苍穹外卖-day05redis 缓存的学习
学习·缓存
Yuan_o_1 小时前
Linux 基本使用和程序部署
java·linux·运维·服务器·数据库·后端
云云3211 小时前
怎么通过亚矩阵云手机实现营销?
大数据·服务器·安全·智能手机·矩阵
那就举个栗子!1 小时前
Ubuntu 20.04下Kinect2驱动环境配置与测试【稳定无坑版】
linux·ubuntu
灯火不休➴1 小时前
[Xshell] Xshell的下载安装使用、连接linux、 上传文件到linux系统-详解(附下载链接)
linux·运维·服务器