【教程】迅为iTOP-4412精英版exynos4412开发板搭建原生Linux最小系统(二)

上一篇,我们用选择的交叉编译器成功编译了uboot,并在开发板上运行成功。接下来,我们还要编译内核、设备树和文件系统。

编译Linux内核

[本文参考资料1:移植linux4.14内核到4412开发板(衡山法师)]
[本文参考资料2:iTop-4412 SCP 精英版 linux-4.14.12 内核移植(2)_hyyoxhk的博客-CSDN博客]

Linux内核官网下载Linux4.14.2版本的内核压缩包,压缩包的文件名为linux-4.14.2.tar.gz。
解压后,打开Makefile文件,将ARCH修改为arm,CROSS_COMPILE修改为叫交叉编译器的全路径。

编译内核同样也会出现yylloc的问题,所以也要加上-fcommon:

保存好Makefile文件后,执行make exynos_defconfig命令,选择exynos默认配置:

[oct1158@fedora linux-4.14.2]$ make exynos_defconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  SHIPPED scripts/kconfig/zconf.tab.c
  SHIPPED scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
#
# configuration written to .config
#

然后执行make menuconfig命令,进入菜单配置。但是这个时候系统报错,提示没有安装ncurses库。
(我们后面在开发板上移植sl软件包,也会用到这个库,而且到时候我们要交叉编译到开发板上运行)

[oct1158@fedora linux-4.14.2]$ make menuconfig
 *** Unable to find the ncurses libraries or the
 *** required header files.
 *** 'make menuconfig' requires the ncurses libraries.
 *** 
 *** Install ncurses (ncurses-devel) and try again.
 *** 
make[1]: *** [scripts/kconfig/Makefile:202: scripts/kconfig/dochecklxdialog] Error 1
make: *** [Makefile:552: menuconfig] Error 2

在Linux虚拟机里面,只需执行sudo dnf install ncurses-devel,就能安装这个库。(后面在开发板上就没这么简单了,我们得下载源码包下来编译)

[oct1158@fedora linux-4.14.2]$ sudo dnf install ncurses-devel
[sudo] password for oct1158: 
Fedora Modular 34 - x86_64 - Updates            1.2 kB/s | 6.3 kB     00:05    
Fedora 34 - x86_64 - Updates                    4.5 kB/s | 5.3 kB     00:01    
Fedora 34 - x86_64 - Updates                    122 kB/s | 2.7 MB     00:22    
Fedora 34 - x86_64                              103 kB/s |  54 MB     08:52    
Dependencies resolved.
================================================================================
 Package               Arch        Version                    Repository   Size
================================================================================
Installing:
 ncurses-devel         x86_64      6.2-4.20200222.fc34        fedora      510 k
Installing dependencies:
 ncurses-c++-libs      x86_64      6.2-4.20200222.fc34        fedora       37 k

Transaction Summary
================================================================================
Install  2 Packages

Total download size: 547 k
Installed size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): ncurses-c++-libs-6.2-4.20200222.fc34.x86  59 kB/s |  37 kB     00:00    
(2/2): ncurses-devel-6.2-4.20200222.fc34.x86_64 179 kB/s | 510 kB     00:02    
--------------------------------------------------------------------------------
Total                                           159 kB/s | 547 kB     00:03     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : ncurses-c++-libs-6.2-4.20200222.fc34.x86_64            1/2 
  Installing       : ncurses-devel-6.2-4.20200222.fc34.x86_64               2/2 
  Running scriptlet: ncurses-devel-6.2-4.20200222.fc34.x86_64               2/2 
  Verifying        : ncurses-c++-libs-6.2-4.20200222.fc34.x86_64            1/2 
  Verifying        : ncurses-devel-6.2-4.20200222.fc34.x86_64               2/2 

Installed:
  ncurses-c++-libs-6.2-4.20200222.fc34.x86_64                                   
  ncurses-devel-6.2-4.20200222.fc34.x86_64                                      

Complete!

这时就能进入菜单配置界面了。

我们进入System Type ---> Samsung EXYNOS,选择芯片类型为exynos4412,其余的全部取消勾选:

然后配置调试串口。返回菜单的一级目录,进入Kernel hacking菜单项,选择Kernel low-level debugging functions (read help!)

在Kernel low-level debugging port选项上选择调试串口为UART2:

返回到一级目录,进入Device Drivers ---> Character devices ---> Serial drivers,选中Samsung SoC serial debug (NEW)和Support for console on Samsung SoC serial port:

然后再返回Device Drivers菜单项,去掉DMA Engine support选项:

设置完成后,保存并退出。执行make uImage LOADADDR=0x40007000命令编译内核。
编译到最后,生成了zImage,但没有生成uImage,报错:
"mkimage" command not found - U-Boot images will not be built

用sudo dnf whatprovides mkimage查询一下安装什么软件包可以拥有mkimage命令:

[oct1158@fedora linux-4.14.2]$ sudo dnf whatprovides mkimage
[sudo] password for oct1158: 
Last metadata expiration check: 0:02:44 ago on Fri 27 Aug 2021 22:03:34.
uboot-tools-2021.04-2.fc34.x86_64 : U-Boot utilities
Repo        : fedora
Matched from:
Filename    : /usr/bin/mkimage

uboot-tools-2021.04-3.fc34.x86_64 : U-Boot utilities
Repo        : updates
Matched from:
Filename    : /usr/bin/mkimage

查询结果为uboot-tools。于是安装uboot-tools软件包:
sudo dnf install uboot-tools

[oct1158@fedora linux-4.14.2]$ sudo dnf install uboot-tools
Last metadata expiration check: 0:04:11 ago on Fri 27 Aug 2021 22:03:34.
Dependencies resolved.
================================================================================
 Package            Architecture  Version                  Repository      Size
================================================================================
Installing:
 uboot-tools        x86_64        2021.04-3.fc34           updates        402 k
Installing dependencies:
 dtc                x86_64        1.6.1-1.fc34             updates        102 k

Transaction Summary
================================================================================
Install  2 Packages

Total download size: 504 k
Installed size: 1.9 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): dtc-1.6.1-1.fc34.x86_64.rpm              145 kB/s | 102 kB     00:00    
(2/2): uboot-tools-2021.04-3.fc34.x86_64.rpm    169 kB/s | 402 kB     00:02    
--------------------------------------------------------------------------------
Total                                           146 kB/s | 504 kB     00:03     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : dtc-1.6.1-1.fc34.x86_64                                1/2 
  Installing       : uboot-tools-2021.04-3.fc34.x86_64                      2/2 
  Running scriptlet: uboot-tools-2021.04-3.fc34.x86_64                      2/2 
  Verifying        : dtc-1.6.1-1.fc34.x86_64                                1/2 
  Verifying        : uboot-tools-2021.04-3.fc34.x86_64                      2/2 

Installed:
  dtc-1.6.1-1.fc34.x86_64           uboot-tools-2021.04-3.fc34.x86_64          

Complete!

再次执行编译内核的命令,就能成功得到uImage了。

[oct1158@fedora linux-4.14.2]$ make uImage LOADADDR=0x40007000
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  CHK     include/generated/compile.h
  Kernel: arch/arm/boot/Image is ready
  Kernel: arch/arm/boot/zImage is ready
  UIMAGE  arch/arm/boot/uImage
Image Name:   Linux-4.14.2
Created:      Fri Aug 27 22:09:02 2021
Image Type:   ARM Linux Kernel Image (uncompressed)
Data Size:    5516168 Bytes = 5386.88 KiB = 5.26 MiB
Load Address: 40007000
Entry Point:  40007000
  Kernel: arch/arm/boot/uImage is ready

接下来,我们需要编译设备树。进入linux-4.14.2/arch/arm/boot/dts文件夹,复制exynos4412-itop-elite.dts和exynos4412-itop-scp-core.dtsi这两个文件,分别命名为myexynos4412-itop-elite.dts和myexynos4412-itop-scp-core.dtsi。

[oct1158@fedora dts]$ cp exynos4412-itop-elite.dts myexynos4412-itop-elite.dts
[oct1158@fedora dts]$ cp exynos4412-itop-scp-core.dtsi myexynos4412-itop-scp-core.dtsi

打开myexynos4412-itop-elite.dts文件,修改include的dtsi的文件名称,然后把LED2灯的GPIO口修改为GPL20:

打开myexynos4412-itop-scp-core.dtsi文件,修改以下内容:

我们板子上的DDR3内存容量为1GB,起始地址为0x40000000。1GB=1073741824字节,换算成十六进制也是0x40000000。所以上图中memory的reg值是两个0x40000000。

继续修改后面的内容,bus_dmc的devfreq-events属性要改为devfreq-event:

配置核心板电源芯片:

打开这个文件夹下的Makefile文件,在161行处把我们新增的myexynos4412-itop-elite添加进去:

在内核根目录下执行make dtbs,编译设备树,得到myexynos4412-itop-elite.dtb文件:

[oct1158@fedora linux-4.14.2]$ make dtbs
  CHK     include/config/kernel.release
  CHK     include/generated/uapi/linux/version.h
  CHK     include/generated/utsrelease.h
  CHK     include/generated/bounds.h
  CHK     include/generated/timeconst.h
  CHK     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHK     scripts/mod/devicetable-offsets.h
  DTC     arch/arm/boot/dts/exynos4210-origen.dtb
  DTC     arch/arm/boot/dts/exynos4210-smdkv310.dtb
  DTC     arch/arm/boot/dts/exynos4210-trats.dtb
  DTC     arch/arm/boot/dts/exynos4210-universal_c210.dtb
  DTC     arch/arm/boot/dts/exynos4412-itop-elite.dtb
  DTC     arch/arm/boot/dts/myexynos4412-itop-elite.dtb
  DTC     arch/arm/boot/dts/exynos4412-odroidu3.dtb
  DTC     arch/arm/boot/dts/exynos4412-odroidx.dtb
  DTC     arch/arm/boot/dts/exynos4412-odroidx2.dtb
  DTC     arch/arm/boot/dts/exynos4412-origen.dtb
  DTC     arch/arm/boot/dts/exynos4412-smdk4412.dtb
  DTC     arch/arm/boot/dts/exynos4412-tiny4412.dtb
  DTC     arch/arm/boot/dts/exynos4412-trats2.dtb

将SD卡读卡器插到虚拟机里面,用dd命令烧写Linux内核和Linux设备树到SD卡中:

[oct1158@fedora linux-4.14.2]$ sudo dd iflag=dsync oflag=dsync if=arch/arm/boot/uImage of=/dev/sdb seek=4096
[sudo] password for oct1158: 
10773+1 records in
10773+1 records out
5516232 bytes (5.5 MB, 5.3 MiB) copied, 47.4342 s, 116 kB/s
[oct1158@fedora linux-4.14.2]$ sudo dd iflag=dsync oflag=dsync if=arch/arm/boot/dts/myexynos4412-itop-elite.dtb of=/dev/sdb seek=2048
109+1 records in
109+1 records out
55843 bytes (56 kB, 55 KiB) copied, 0.419605 s, 133 kB/s

编译Busybox根文件系统

[本文参考资料1:Busybox构建根文件系统和制作Ramdisk]
[本文参考资料2(推荐阅读):【正点原子Linux连载】第三十八章 根文件系统构建 -摘自【正点原子】I.MX6U嵌入式Linux驱动开发指南V1.0]

去busybox官网下载1.26.2版本的压缩包,文件名为busybox-1.26.2.tar.bz2。解压后,先执行make defconfig,然后再执行make menuconfig ARCH=arm,进入菜单配置:

进入Busybox Settings菜单项,找到--- Build Options栏目,选中Build BusyBox as a static binary (no shared libs)选项,将busybox配置为静态链接,这样我们就不需要复制编译器里面的lib库了。然后在Cross Compiler prefix里面设置交叉编译器的路径:/home/oct1158/Downloads/gcc-arm-10.3-2021.07-x86_64-arm-none-linux-gnueabihf/bin/arm-none-linux-gnueabihf-

只需要设置好这两个选项,就可以保存退出了。就这么简单。

然后执行make编译,但是这个时候报了一个stime函数的错误:

date.c:(.text.date_main+0x166): undefined reference to `stime'
collect2: error: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"
make: *** [Makefile:717: busybox_unstripped] Error 1

用“grep "stime" -Inwr .”命令搜索一下stime函数是在哪个文件里面定义的:

[oct1158@fedora busybox-1.26.2]$ grep "stime" -Inwr .
./libbb/missing_syscalls.c:19:int stime(const time_t *t)
./libbb/procps.c:397:				"%lu %lu "             /* utime, stime */
./libbb/procps.c:413:				&sp->utime, &sp->stime,
./libbb/procps.c:449:			sp->stime = fast_strtoul_10(&cp);
./libbb/procps.c:640:		cputime_to_clock_t(stime),
./util-linux/rdate.c:83:			if (stime(&remote_time) < 0)
./coreutils/date.c:296:		if ((opt & OPT_SET) && stime(&ts.tv_sec) < 0) {
./procps/ps.c:415:	mm = (ps->utime + ps->stime) / get_kernel_HZ();
./procps/ps.c:797:				unsigned sut = (p->stime + p->utime) / 100;
./procps/top.c:1192:				top[n].ticks = p->stime + p->utime;
./include/libbb.h:1641:	unsigned long stime, utime;
./busybox_unstripped.out:17:rdate.c:(.text.rdate_main+0x92): undefined reference to `stime'
./busybox_unstripped.out:19:date.c:(.text.date_main+0x166): undefined reference to `stime'

可以看到libbb/missing_syscalls.c文件里面有stime函数的定义,但是却是放在#if defined(ANDROID) || defined(__ANDROID__)里面的。我们把stime函数的定义拿出#if语句块,然后重新编译。

编译到最后,提示没有pod2html命令:

  LINK    busybox_unstripped
Static linking against glibc, can't use --gc-sections
Trying libraries: crypt m
 Library crypt is not needed, excluding it
 Library m is needed, can't exclude it (yet)
Final link with: m
  DOC     busybox.pod
  DOC     BusyBox.txt
  DOC     busybox.1
/bin/sh: line 1: pod2html: command not found
make: [/home/oct1158/Downloads/busybox-1.26.2/Makefile.custom:168: docs/busybox.net/BusyBox.html] Error 127 (ignored)
  DOC     BusyBox.html
[1]+  Done                    gedit libbb/missing_syscalls.c

用sudo dnf whatprovides pod2html命令查询一下,发现这个命令是由perl-Pod-Html软件包提供的,于是执行sudo dnf install perl-Pod-Html安装:

[oct1158@fedora busybox-1.26.2]$ sudo dnf whatprovides pod2html
[sudo] password for oct1158: 
Last metadata expiration check: 1:16:52 ago on Fri 27 Aug 2021 22:03:34.
perl-Pod-Html-1.25-474.fc34.noarch : Convert POD files to HTML
Repo        : fedora
Matched from:
Filename    : /usr/bin/pod2html

perl-Pod-Html-1.25-477.fc34.noarch : Convert POD files to HTML
Repo        : updates
Matched from:
Filename    : /usr/bin/pod2html

[oct1158@fedora busybox-1.26.2]$ sudo dnf install perl-Pod-Html
Last metadata expiration check: 1:19:27 ago on Fri 27 Aug 2021 22:03:34.
Dependencies resolved.
================================================================================
 Package              Architecture  Version                Repository      Size
================================================================================
Installing:
 perl-Pod-Html        noarch        1.25-477.fc34          updates         37 k
Installing dependencies:
 perl-locale          noarch        1.09-477.fc34          updates         24 k

Transaction Summary
================================================================================
Install  2 Packages

Total download size: 61 k
Installed size: 45 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): perl-locale-1.09-477.fc34.noarch.rpm      53 kB/s |  24 kB     00:00    
(2/2): perl-Pod-Html-1.25-477.fc34.noarch.rpm    74 kB/s |  37 kB     00:00    
--------------------------------------------------------------------------------
Total                                            21 kB/s |  61 kB     00:02     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : perl-locale-1.09-477.fc34.noarch                       1/2 
  Installing       : perl-Pod-Html-1.25-477.fc34.noarch                     2/2 
  Running scriptlet: perl-Pod-Html-1.25-477.fc34.noarch                     2/2 
  Verifying        : perl-Pod-Html-1.25-477.fc34.noarch                     1/2 
  Verifying        : perl-locale-1.09-477.fc34.noarch                       2/2 

Installed:
  perl-Pod-Html-1.25-477.fc34.noarch      perl-locale-1.09-477.fc34.noarch     

Complete!

安装完成后,再次make,就编译成功了。

接着再执行make install,生成文件系统。生成的文件系统是在_install文件夹里面。

进入到_install文件夹里面,建立常用目录:

[oct1158@fedora busybox-1.26.2]$ cd _install
[oct1158@fedora _install]$ ls
bin  linuxrc  sbin  usr
[oct1158@fedora _install]$ mkdir root etc dev lib tmp mnt sys proc var
[oct1158@fedora _install]$ mkdir usr/lib
[oct1158@fedora _install]$ 

其中,dev目录是必须要建立的,不然启动后会一直报没有/dev/tty1~4的警告。
dev目录保持为空就行了,不需要建立console和null这两个设备文件。linux内核启动后,dev文件夹下会自动出现很多设备。

然后,将examples/bootfloppy/etc里面的所有文件复制到我们的etc目录下:

[oct1158@fedora _install]$ cp -r ../examples/bootfloppy/etc/* etc
[oct1158@fedora _install]$ ls -l etc
total 12
-rw-r--r--. 1 oct1158 oct1158  33 Aug 27 23:49 fstab
drwxr-xr-x. 1 oct1158 oct1158   6 Aug 27 23:49 init.d
-rw-r--r--. 1 oct1158 oct1158 100 Aug 27 23:49 inittab
-rw-r--r--. 1 oct1158 oct1158 133 Aug 27 23:49 profile
[oct1158@fedora _install]$ ls -l etc/init.d
total 4
-rwxr-xr-x. 1 oct1158 oct1158 26 Aug 27 23:49 rcS
[oct1158@fedora _install]$ 

其中inittab文件内容不完整,需要把examples/inittab里面的部分内容补充进去。我们用grep命令结合正则表达式看一下examples/inittab里面的非注释行有哪些:

[oct1158@fedora busybox-1.26.2]$ grep "^[^#]" examples/inittab
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh
tty4::askfirst:-/bin/sh
tty4::respawn:/sbin/getty 38400 tty5
tty5::respawn:/sbin/getty 38400 tty6
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a

正则表达式“^[^#]”匹配的是非#号开头的所有行。以下是examples/bootfloppy/etc/inittab文件的原有内容:

[oct1158@fedora busybox-1.26.2]$ cat _install/etc/inittab 
::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
tty2::askfirst:-/bin/sh
::ctrlaltdel:/bin/umount -a -r

里面缺少了下面这两行:
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
这两行的意思是:关机前,先卸载所有的磁盘分区,然后卸载swap交换分区。尤其是第一句话很重要,关机前不卸载分区的话,下次开机,系统就会提示文件系统有问题需要修复。

我们可以直接将grep命令的输出结果覆盖到根文件系统的/etc/inittab文件中:

[oct1158@fedora busybox-1.26.2]$ grep "^[^#]" examples/inittab > _install/etc/inittab
[oct1158@fedora busybox-1.26.2]$ cat _install/etc/inittab
::sysinit:/etc/init.d/rcS
::askfirst:-/bin/sh
tty2::askfirst:-/bin/sh
tty3::askfirst:-/bin/sh
tty4::askfirst:-/bin/sh
tty4::respawn:/sbin/getty 38400 tty5
tty5::respawn:/sbin/getty 38400 tty6
::restart:/sbin/init
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a

内容覆盖后,::respawn:-/bin/sh被删掉了,ctrlaltdel的行为由卸载磁盘改成了重启开发板。增加了两个shutdown指令(关机时执行的指令)。
开机时由/etc/init.d/rcS负责mount fstab里面的磁盘分区,关机时用umount命令卸载所有磁盘分区。
由于/etc/init.d/rcS脚本是要开机执行的,所以必须检查一下rcS文件是否有执行权限。下面可以看到rcS文件的权限是755,所有用户都有执行权限:

[oct1158@fedora _install]$ ls -l etc/init.d/rcS
-rwxr-xr-x. 1 oct1158 oct1158 26 Aug 27 23:49 etc/init.d/rcS
[oct1158@fedora _install]$ cat etc/init.d/rcS
#! /bin/sh

/bin/mount -a

打开etc/fstab文件,里面只有一个/proc。我们后面要用到/sys这个文件系统,所以把sysfs加进去,顺便把tmpfs也加进去:

proc		/proc	proc	defaults    0	0
tmpfs		/tmp	tmpfs	defaults    0	0
sysfs		/sys	sysfs	defaults    0	0

 现在文件系统就已经制作好了,我们把_install文件夹里面的所有文件复制到SD卡的ext4分区里面去。命令前面要加上sudo,保证文件和文件夹的所有者是root。

sudo cp -r * /run/media/oct1158/df9ab0e3-4168-4efe-8175-fb6eb4af4e03

安全弹出SD卡,拔出读卡器,将SD卡插到开发板上,启动开发板:

U-Boot 2017.11 (Aug 26 2021 - 23:02:28 +0800) for itop-4412

CPU:   Exynos4412 @ 1 GHz
Model: itop-4412 based on Exynos4412
Board: itop-4412 based on Exynos4412
DRAM:  1 GiB
WARNING: Caches not enabled
MMC:   SAMSUNG SDHCI: 0
*** Warning - bad CRC, using default environment

Hit any key to stop autoboot:  0
SD/MMC found on device 0
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **
Failed to mount ext2 filesystem...
** Unrecognized filesystem type **

MMC read: dev # 0, block # 4096, count 16384 ... 16384 blocks read: OK

MMC read: dev # 0, block # 2048, count 160 ... 160 blocks read: OK
## Booting kernel from Legacy Image at 40007000 ...
   Image Name:   Linux-4.14.2
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    5516168 Bytes = 5.3 MiB
   Load Address: 40007000
   Entry Point:  40007000
   Verifying Checksum ... OK
## Flattened Device Tree blob at 41000000
   Booting using the fdt blob at 0x41000000
   Loading Kernel Image ... OK
   Loading Device Tree to 4ffef000, end 4ffffa22 ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
s3c24xx_serial_console_setup: co=c0d28850 (2), 115200n8
s3c24xx_serial_probe(ef23c400) 1
s3c24xx_serial_probe: initialising port c0d289e0...
s3c24xx_serial_init_port: port=c0d28a10, platdev=ef23c400
resource [mem 0x13810000-0x138100ff])
port: map=0x13810000, mem=f08e1000, irq=49 (49,50), clock=1
s3c24xx_serial_probe: adding port
s3c24xx_serial_console_setup: co=c0d28850 (2), 115200n8
s3c24xx_serial_probe(ef23c800) 2
s3c24xx_serial_probe: initialising port c0d28b38...
s3c24xx_serial_init_port: port=c0d28b68, platdev=ef23c800
resource [mem 0x13820000-0x138200ff])
port: map=0x13820000, mem=f7020000, irq=50 (50,51), clock=1
                                                           s3c24xx_serial_probe: adding port
s3c24xx_serial_console_setup: co=c0d28850 (2), 115200n8
s3c24xx_serial_console_setup: port=c0d28b68 (2)
s3c24xx_serial_console_setup: baud 115200
fracval = 0004
config: 8bits/char
setting ulcon to 00000003, brddiv to 53, udivslot 00000004
uart: ulcon = 0x00000003, ucon = 0x000003c5, ufcon = 0x00000111
[    0.000000] Booting Linux on physical CPU 0xa00
[    0.000000] Linux version 4.14.2 (oct1158@fedora) (gcc version 10.3.1 20210621 (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))) #1 SMP PREEMPT Fri Aug 27 21:58:22 CST 2021
[    0.000000] CPU: ARMv7 Processor [413fc090] revision 0 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
[    0.000000] OF: fdt: Machine model: TOPEET iTop 4412 Elite board based on Exynos4412
[    0.000000] Memory policy: Data cache writealloc
[    0.000000] Reserved memory: created DMA memory pool at 0x7f800000, size 8 MiB
[    0.000000] OF: reserved mem: initialized node region_mfc_right, compatible id shared-dma-pool
[    0.000000] Reserved memory: created DMA memory pool at 0x7d400000, size 36 MiB
[    0.000000] OF: reserved mem: initialized node region_mfc_left, compatible id shared-dma-pool
[    0.000000] cma: Reserved 96 MiB at 0x77400000
[    0.000000] Samsung CPU ID: 0xe4412011
[    0.000000] percpu: Embedded 16 pages/cpu @ef7d8000 s36136 r8192 d21208 u65536
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 249344
[    0.000000] Kernel command line: console=ttySAC2,115200n8 earlyprintk
[    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
[    0.000000] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Memory: 875672K/1003520K available (8192K kernel code, 430K rwdata, 2648K rodata, 1024K init, 7587K bss, 29544K reserved, 98304K cma-reserved, 118784K highmem)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
[    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
[    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
[    0.000000]       .text : 0xc0008000 - 0xc0900000   (9184 kB)
[    0.000000]       .init : 0xc0c00000 - 0xc0d00000   (1024 kB)
[    0.000000]       .data : 0xc0d00000 - 0xc0d6b8a8   ( 431 kB)
[    0.000000]        .bss : 0xc0d737c8 - 0xc14dc3e4   (7588 kB)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
[    0.000000] Running RCU self tests
[    0.000000] Preemptible hierarchical RCU implementation.
[    0.000000]  RCU lockdep checking is enabled.
[    0.000000]  RCU restricting CPUs from NR_CPUS=8 to nr_cpu_ids=4.
[    0.000000]  Tasks RCU enabled.
[    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=4
[    0.000000] NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
[    0.000000] L2C: platform modifies aux control register: 0x02070000 -> 0x3e470001
[    0.000000] L2C: platform provided aux values permit register corruption.
[    0.000000] L2C: DT/platform modifies aux control register: 0x02070000 -> 0x3e470001
[    0.000000] L2C-310 enabling early BRESP for Cortex-A9
[    0.000000] L2C-310: enabling full line of zeros but not enabled in Cortex-A9
[    0.000000] L2C-310 dynamic clock gating enabled, standby mode enabled
[    0.000000] L2C-310 cache controller enabled, 16 ways, 1024 kB
[    0.000000] L2C-310: CACHE_ID 0x4100c4c8, AUX_CTRL 0x4e470001
[    0.000000] Exynos4x12 clocks: sclk_apll = 500000000, sclk_mpll = 800000000
[    0.000000]  sclk_epll = 192000000, sclk_vpll = 54375000, arm_clk = 1000000000
[    0.000000] Switching to timer-based delay loop, resolution 41ns
[    0.000000] clocksource: mct-frc: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
[    0.000005] sched_clock: 32 bits at 24MHz, resolution 41ns, wraps every 89478484971ns
[    0.000339] Console: colour dummy device 80x30
[    0.005145] Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar
[    0.005156] ... MAX_LOCKDEP_SUBCLASSES:  8
[    0.005166] ... MAX_LOCK_DEPTH:          48
[    0.005175] ... MAX_LOCKDEP_KEYS:        8191
[    0.005184] ... CLASSHASH_SIZE:          4096
[    0.005194] ... MAX_LOCKDEP_ENTRIES:     32768
[    0.005203] ... MAX_LOCKDEP_CHAINS:      65536
[    0.005212] ... CHAINHASH_SIZE:          32768
[    0.005221]  memory used by lock dependency info: 4655 kB
[    0.005231]  per task-struct memory footprint: 1536 bytes
[    0.005277] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=240000)
[    0.005297] pid_max: default: 32768 minimum: 301
[    0.005529] Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.005548] Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.007475] CPU: Testing write buffer coherency: ok
[    0.008487] CPU0: thread -1, cpu 0, socket 10, mpidr 80000a00
[    0.040057] Setting up static identity map for 0x40100000 - 0x40100060
[    0.060011] Hierarchical SRCU implementation.
[    0.120001] smp: Bringing up secondary CPUs ...
[    0.200204] CPU1: thread -1, cpu 1, socket 10, mpidr 80000a01
[    0.280092] CPU2: thread -1, cpu 2, socket 10, mpidr 80000a02
[    0.360090] CPU3: thread -1, cpu 3, socket 10, mpidr 80000a03
[    0.360289] smp: Brought up 1 node, 4 CPUs
[    0.360317] SMP: Total of 4 processors activated (192.00 BogoMIPS).
[    0.360329] CPU: All CPU(s) started in SVC mode.
[    0.362041] devtmpfs: initialized
[    0.393169] random: get_random_u32 called from bucket_table_alloc+0xf4/0x244 with crng_init=0
[    0.393663] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
[    0.395195] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.395235] futex hash table entries: 1024 (order: 4, 65536 bytes)
[    0.399105] pinctrl core: initialized pinctrl subsystem
[    0.400718] /lcd0-power-domain@10023C80 has as child subdomain: /tv-power-domain@10023C20.
[    0.403191] NET: Registered protocol family 16
[    0.406005] DMA: preallocated 256 KiB pool for atomic coherent allocations
[    0.408723] cpuidle: using governor menu
[    0.443008] genirq: irq_chip COMBINER did not update eff. affinity mask of irq 94
[    0.473745] SCSI subsystem initialized
[    0.474282] usbcore: registered new interface driver usbfs
[    0.474412] usbcore: registered new interface driver hub
[    0.474573] usbcore: registered new device driver usb
[    0.475490] s3c-i2c 13870000.i2c: slave address 0x00
[    0.475512] s3c-i2c 13870000.i2c: bus frequency set to 390 KHz
[    0.476836] sec_pmic 1-0066: No interrupt specified, no interrupts
[    0.481262] VDDQ_M12: Bringing 1200000uV into 1500000-1500000uV
[    0.485371] VDD10_MPLL: Bringing 1100000uV into 1000000-1000000uV
[    0.487167] VDD10_XPLL: Bringing 1100000uV into 1000000-1000000uV
[    0.487304] random: fast init done
[    0.499587] VDDA28_2M: Bringing 3300000uV into 2800000-2800000uV
[    0.502381] VDD18_CAM: Bringing 1200000uV into 1800000-1800000uV
[    0.505233] DVDD12: Bringing 1800000uV into 1200000-1200000uV
[    0.516499] s3c-i2c 13870000.i2c: i2c-1: S3C I2C adapter
[    0.516841] s3c-i2c 138a0000.i2c: slave address 0x10
[    0.516861] s3c-i2c 138a0000.i2c: bus frequency set to 97 KHz
[    0.517508] s3c-i2c 138a0000.i2c: i2c-4: S3C I2C adapter
[    0.518964] Advanced Linux Sound Architecture Driver Initialized.
[    0.521202] nfc: nfc_init: NFC Core ver 0.1
[    0.521325] NET: Registered protocol family 39
[    0.521911] clocksource: Switched to clocksource mct-frc
[    0.540244] NET: Registered protocol family 2
[    0.541513] TCP established hash table entries: 8192 (order: 3, 32768 bytes)
[    0.541626] TCP bind hash table entries: 8192 (order: 6, 294912 bytes)
[    0.543532] TCP: Hash tables configured (established 8192 bind 8192)
[    0.543884] UDP hash table entries: 512 (order: 3, 40960 bytes)
[    0.544165] UDP-Lite hash table entries: 512 (order: 3, 40960 bytes)
[    0.544895] NET: Registered protocol family 1
[    0.545965] RPC: Registered named UNIX socket transport module.
[    0.545994] RPC: Registered udp transport module.
[    0.546006] RPC: Registered tcp transport module.
[    0.546018] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.548867] workingset: timestamp_bits=30 max_order=18 bucket_order=0
[    0.562545] NFS: Registering the id_resolver key type
[    0.562789] Key type id_resolver registered
[    0.562818] Key type id_legacy registered
[    0.562917] romfs: ROMFS MTD (C) 2007 Red Hat, Inc.
[    0.568588] bounce: pool size: 64 pages
[    0.568688] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 248)
[    0.568761] io scheduler noop registered
[    0.568776] io scheduler deadline registered
[    0.569039] io scheduler cfq registered (default)
[    0.569054] io scheduler mq-deadline registered
[    0.569067] io scheduler kyber registered
[    0.571620] samsung-usb2-phy 125b0000.exynos-usbphy: 125b0000.exynos-usbphy supply vbus not found, using dummy regulator
[    0.691912] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.719523] 13810000.serial: ttySAC1 at MMIO 0x13810000 (irq = 49, base_baud = 0) is a S3C6400/10
[    0.749168] 13820000.serial: ttySAC2 at MMIO 0x13820000 (irq = 50, base_baud = 0) is a S3C6400/10
[    1.593496] console [ttySAC2] enabled
[    1.620358] brd: module loaded
[    1.639836] loop: module loaded
[    1.643853] libphy: Fixed MDIO Bus: probed
[    1.646817] usbcore: registered new interface driver r8152
[    1.652079] usbcore: registered new interface driver asix
[    1.657393] usbcore: registered new interface driver ax88179_178a
[    1.663511] usbcore: registered new interface driver cdc_ether
[    1.669296] usbcore: registered new interface driver smsc75xx
[    1.675065] usbcore: registered new interface driver smsc95xx
[    1.680737] usbcore: registered new interface driver net1080
[    1.686411] usbcore: registered new interface driver cdc_subset
[    1.692307] usbcore: registered new interface driver zaurus
[    1.697859] usbcore: registered new interface driver cdc_ncm
[    1.706014] dwc2 12480000.hsotg: dwc2_check_params: Invalid parameter g_np_tx_fifo_size=1024
[    1.713098] dwc2 12480000.hsotg: EPs: 16, dedicated fifos, 7808 entries in SPRAM
[    1.723115] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    1.728186] ehci-exynos: EHCI EXYNOS driver
[    1.733093] exynos-ehci 12580000.ehci: EHCI Host Controller
[    1.738184] exynos-ehci 12580000.ehci: new USB bus registered, assigned bus number 1
[    1.746089] exynos-ehci 12580000.ehci: irq 47, io mem 0x12580000
[    1.771949] exynos-ehci 12580000.ehci: USB 2.0 started, EHCI 1.00
[    1.777323] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.783381] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.790541] usb usb1: Product: EHCI Host Controller
[    1.795434] usb usb1: Manufacturer: Linux 4.14.2 ehci_hcd
[    1.800782] usb usb1: SerialNumber: 12580000.ehci
[    1.807553] hub 1-0:1.0: USB hub found
[    1.809936] hub 1-0:1.0: 3 ports detected
[    1.816105] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.820829] ohci-exynos: OHCI EXYNOS driver
[    1.825911] usbcore: registered new interface driver usb-storage
[    1.841658] usb3503 usb-hub: switched to HUB mode
[    1.844924] usb3503 usb-hub: usb3503_probe: probed in hub mode
[    1.851479] using random self ethernet address
[    1.855174] using random host ethernet address
[    1.860390] usb0: HOST MAC 26:8a:83:db:61:cb
[    1.864278] usb0: MAC 52:47:d3:6c:3c:e2
[    1.867653] using random self ethernet address
[    1.872092] using random host ethernet address
[    1.876718] g_ether gadget: Ethernet Gadget, version: Memorial Day 2008
[    1.883125] g_ether gadget: g_ether ready
[    1.887190] dwc2 12480000.hsotg: bound driver g_ether
[    1.897350] s3c-rtc 10070000.rtc: rtc disabled, re-enabling
[    1.901641] s3c-rtc 10070000.rtc: warning: invalid RTC value so initializing it
[    1.908933] rtc rtc0: invalid alarm value: 1900-1-1 0:0:0
[    1.914602] s3c-rtc 10070000.rtc: rtc core: registered s3c as rtc0
[    1.925776] s5m-rtc s5m-rtc: rtc core: registered s5m-rtc as rtc1
[    1.930395] s5m-rtc s5m-rtc: Alarm IRQ not available
[    1.935453] i2c /dev entries driver
[    1.940711] IR NEC protocol handler initialized
[    1.943810] IR RC5(x/sz) protocol handler initialized
[    1.948800] IR RC6 protocol handler initialized
[    1.953342] IR JVC protocol handler initialized
[    1.957828] IR Sony protocol handler initialized
[    1.962459] IR SANYO protocol handler initialized
[    1.967115] IR Sharp protocol handler initialized
[    1.971802] IR MCE Keyboard/mouse protocol handler initialized
[    1.977650] IR XMP protocol handler initialized
[    1.987484] s3c2410-wdt 10060000.watchdog: watchdog inactive, reset disabled, irq disabled
[    1.995455] device-mapper: ioctl: 4.37.0-ioctl (2017-09-20) initialised: dm-devel@redhat.com
[    2.013527] sdhci: Secure Digital Host Controller Interface driver
[    2.018229] sdhci: Copyright(c) Pierre Ossman
[    2.023062] s3c-sdhci 12530000.sdhci: clock source 2: mmc_busclk.2 (100000000 Hz)
[    2.030151] s3c-sdhci 12530000.sdhci: Got CD GPIO
[    2.095551] mmc0: SDHCI controller on samsung-hsmmc [12530000.sdhci] using ADMA
[    2.102843] Synopsys Designware Multimedia Card Interface Driver
[    2.111492] dwmmc_exynos 12550000.mmc: IDMAC supports 32-bit address mode.
[    2.117442] dwmmc_exynos 12550000.mmc: Using internal DMA controller.
[    2.123473] dwmmc_exynos 12550000.mmc: Version ID is 240a
[    2.128972] dwmmc_exynos 12550000.mmc: DW MMC controller at irq 102,32 bit host data width,128 deep fifo
[    2.140944] mmc_host mmc1: card is polling.
[    2.173592] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 400000Hz, actual 396825HZ div = 63)
[    2.222471] usb 1-3: new high-speed USB device number 2 using exynos-ehci
[    2.235908] s5p-secss 10830000.sss: s5p-sss driver registered
[    2.242322] usbcore: registered new interface driver usbhid
[    2.246417] usbhid: USB HID core driver
[    2.251861] exynos-bus bus_dmc: failed to get the count of devfreq-event in /bus_dmc node
[    2.258653] exynos-bus bus_dmc: failed to get the count of devfreq-event dev
[    2.268303] exynos-bus: probe of bus_dmc failed with error -22
[    2.282432] exynos-ppmu: new PPMU device registered 106a0000.ppmu_dmc0 (ppmu-event3-dmc0)
[    2.286766] mmc_host mmc1: Bus speed (slot 0) = 50000000Hz (slot req 52000000Hz, actual 50000000HZ div = 0)
[    2.287062] mmc1: new DDR MMC card at address 0001
[    2.288051] mmcblk1: mmc1:0001 8GTF4R 7.28 GiB
[    2.288291] mmcblk1boot0: mmc1:0001 8GTF4R partition 1 4.00 MiB
[    2.288510] mmcblk1boot1: mmc1:0001 8GTF4R partition 2 4.00 MiB
[    2.288711] mmcblk1rpmb: mmc1:0001 8GTF4R partition 3 512 KiB
[    2.290454]  mmcblk1: p1 p2 p3 p4
[    2.329931] exynos-ppmu: new PPMU device registered 106b0000.ppmu_dmc1 (ppmu-event3-dmc1)
[    2.338006] exynos-ppmu: new PPMU device registered 112a0000.ppmu_rightbus (ppmu-event3-rightbus)
[    2.346875] exynos-ppmu: new PPMU device registered 116a0000.ppmu_leftbus0 (ppmu-event3-leftbus)
[    2.362220] NET: Registered protocol family 10
[    2.367005] Segment Routing with IPv6
[    2.369249] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[    2.370799] mmc0: new high speed SDHC card at address 1234
[    2.371285] mmcblk0: mmc0:1234 SA32G 28.9 GiB
[    2.373000]  mmcblk0: p1 p2 p3
[    2.388962] NET: Registered protocol family 17
[    2.392504] NET: Registered protocol family 15
[    2.397057] Key type dns_resolver registered
[    2.401299] Registering SWP/SWPB emulation handler
[    2.422514] usb 1-3: New USB device found, idVendor=0424, idProduct=3503
[    2.427748] usb 1-3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    2.436174] hub 1-3:1.0: USB hub found
[    2.438759] hub 1-3:1.0: 3 ports detected
[    2.452359] exynos-bus: new bus device registered: bus_leftbus (100000 KHz ~ 200000 KHz)
[    2.459644] exynos-bus: new bus device registered: bus_rightbus (100000 KHz ~ 200000 KHz)
[    2.468008] exynos-bus: new bus device registered: bus_fsys (100000 KHz ~ 134000 KHz)
[    2.475751] exynos-bus: new bus device registered: bus_peri ( 50000 KHz ~ 100000 KHz)
[    2.483353] exynos-bus: new bus device registered: bus_mfc (100000 KHz ~ 200000 KHz)
[    2.497020] input: gpio-keys as /devices/platform/gpio-keys/input/input0
[    2.503070] s3c-rtc 10070000.rtc: setting system clock to 2000-01-01 00:00:01 UTC (946684801)
[    2.516762] VDD_LDO5: disabling
[    2.519309] VDD10_MIPI: disabling
[    2.524087] VDD18_MIPI: disabling
[    2.528982] ALSA device list:
[    2.530471]   No soundcards found.
s3c64xx_serial_startup: port=c0d28b68 (13820000,f7020000)
[    2.540773] samsung-uart 13820000.serial: DMA request failed, DMA will not be used
s3c64xx_serial_startup ok
fracval = 0004
config: 8bits/char
setting ulcon to 00000003, brddiv to 53, udivslot 00000004
uart: ulcon = 0x00000003, ucon = 0x0000f3c5, ufcon = 0x00000131
[    2.565499] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    2.571502] Please append a correct "root=" boot option; here are the available partitions:
[    2.580092] 0100            8192 ram0
[    2.580098]  (driver?)
[    2.585919] 0101            8192 ram1
[    2.585925]  (driver?)
[    2.592022] 0102            8192 ram2
[    2.592028]  (driver?)
[    2.598069] 0103            8192 ram3
[    2.598074]  (driver?)
[    2.604209] 0104            8192 ram4
[    2.604215]  (driver?)
[    2.610221] 0105            8192 ram5
[    2.610226]  (driver?)
[    2.616298] 0106            8192 ram6
[    2.616304]  (driver?)
[    2.622435] 0107            8192 ram7
[    2.622441]  (driver?)
[    2.628449] 0108            8192 ram8
[    2.628454]  (driver?)
[    2.634526] 0109            8192 ram9
[    2.634531]  (driver?)
[    2.640601] 010a            8192 ram10
[    2.640606]  (driver?)
[    2.646765] 010b            8192 ram11
[    2.646770]  (driver?)
[    2.652955] 010c            8192 ram12
[    2.652961]  (driver?)
[    2.659089] 010d            8192 ram13
[    2.659094]  (driver?)
[    2.665253] 010e            8192 ram14
[    2.665259]  (driver?)
[    2.671415] 010f            8192 ram15
[    2.671420]  (driver?)
[    2.677587] b300         7634944 mmcblk1
[    2.677593]  driver: mmcblk
[    2.684407]   b301         5172205 mmcblk1p1 00000000-01
[    2.684413]
[    2.691117]   b302         1052353 mmcblk1p2 00000000-02
[    2.691122]
[    2.697888]   b303         1052353 mmcblk1p3 00000000-03
[    2.697893]
[    2.704658]   b304          313467 mmcblk1p4 00000000-04
[    2.704663]
[    2.711433] b330             512 mmcblk1rpmb
[    2.711439]  (driver?)
[    2.718129] b320            4096 mmcblk1boot1
[    2.718134]  (driver?)
[    2.724885] b310            4096 mmcblk1boot0
[    2.724890]  (driver?)
[    2.731654] b340        30253056 mmcblk0
[    2.731660]  driver: mmcblk
[    2.738424]   b341         1465344 mmcblk0p1 848a5eb3-01
[    2.738429]
[    2.745194]   b342        13672448 mmcblk0p2 848a5eb3-02
[    2.745199]
[    2.752019]   b343        15114240 mmcblk0p3 848a5eb3-03
[    2.752024]
[    2.758735] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[    2.766977] CPU: 3 PID: 1 Comm: swapper/0 Not tainted 4.14.2 #1
[    2.771932] usb 1-3.2: new high-speed USB device number 3 using exynos-ehci
[    2.779821] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[    2.785912] [<c0110260>] (unwind_backtrace) from [<c010c7b0>] (show_stack+0x10/0x14)
[    2.793628] [<c010c7b0>] (show_stack) from [<c086fca8>] (dump_stack+0x94/0xc0)
[    2.800832] [<c086fca8>] (dump_stack) from [<c011d3cc>] (panic+0xdc/0x25c)
[    2.807693] [<c011d3cc>] (panic) from [<c0c0124c>] (mount_block_root+0x1b8/0x24c)
[    2.815153] [<c0c0124c>] (mount_block_root) from [<c0c01654>] (prepare_namespace+0x180/0x1c4)
[    2.823659] [<c0c01654>] (prepare_namespace) from [<c0c00e38>] (kernel_init_freeable+0x1bc/0x1cc)
[    2.832514] [<c0c00e38>] (kernel_init_freeable) from [<c0882a2c>] (kernel_init+0x8/0x108)
[    2.840676] [<c0882a2c>] (kernel_init) from [<c0108928>] (ret_from_fork+0x14/0x2c)
[    2.848291] CPU0: stopping
[    2.850913] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.14.2 #1
[    2.856812] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[    2.862895] [<c0110260>] (unwind_backtrace) from [<c010c7b0>] (show_stack+0x10/0x14)
[    2.870617] [<c010c7b0>] (show_stack) from [<c086fca8>] (dump_stack+0x94/0xc0)
[    2.877822] [<c086fca8>] (dump_stack) from [<c010f27c>] (handle_IPI+0x188/0x1b4)
[    2.885200] [<c010f27c>] (handle_IPI) from [<c0101584>] (gic_handle_irq+0x98/0x9c)
[    2.892751] [<c0101584>] (gic_handle_irq) from [<c010d6f0>] (__irq_svc+0x70/0xb0)
[    2.900213] Exception stack(0xc0d01f30 to 0xc0d01f78)
[    2.905249] 1f20:                                     00000001 00000001 00000000 c0d0a6c0
[    2.913409] 1f40: c0d00000 c0d0747c c0d07420 c0c57570 c0ae81b4 c0d01f88 00000000 00000000
[    2.921567] 1f60: 00000000 c0d01f80 c016e150 c01093e0 20000113 ffffffff
[    2.928167] [<c010d6f0>] (__irq_svc) from [<c01093e0>] (arch_cpu_idle+0x24/0x3c)
[    2.935550] [<c01093e0>] (arch_cpu_idle) from [<c01625fc>] (do_idle+0x200/0x26c)
[    2.942923] [<c01625fc>] (do_idle) from [<c01629cc>] (cpu_startup_entry+0x18/0x1c)
[    2.950474] [<c01629cc>] (cpu_startup_entry) from [<c0c00c70>] (start_kernel+0x394/0x3a0)
[    2.958632] [<c0c00c70>] (start_kernel) from [<4000807c>] (0x4000807c)
[    2.965140] CPU1: stopping
[    2.967832] CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.14.2 #1
[    2.973732] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[    2.979814] [<c0110260>] (unwind_backtrace) from [<c010c7b0>] (show_stack+0x10/0x14)
[    2.987537] [<c010c7b0>] (show_stack) from [<c086fca8>] (dump_stack+0x94/0xc0)
[    2.994741] [<c086fca8>] (dump_stack) from [<c010f27c>] (handle_IPI+0x188/0x1b4)
[    3.002119] [<c010f27c>] (handle_IPI) from [<c0101584>] (gic_handle_irq+0x98/0x9c)
[    3.009670] [<c0101584>] (gic_handle_irq) from [<c010d6f0>] (__irq_svc+0x70/0xb0)
[    3.017133] Exception stack(0xef0adf68 to 0xef0adfb0)
[    3.022170] df60:                   00000001 00000001 00000000 ef0a1800 ef0ac000 c0d0747c
[    3.030329] df80: c0d07420 c0c57570 c0ae81b4 ef0adfc0 00000000 00000000 00000000 ef0adfb8
[    3.038486] dfa0: c016e150 c01093e0 20000013 ffffffff
[    3.043524] [<c010d6f0>] (__irq_svc) from [<c01093e0>] (arch_cpu_idle+0x24/0x3c)
[    3.050903] [<c01093e0>] (arch_cpu_idle) from [<c01625fc>] (do_idle+0x200/0x26c)
[    3.058280] [<c01625fc>] (do_idle) from [<c01629cc>] (cpu_startup_entry+0x18/0x1c)
[    3.065830] [<c01629cc>] (cpu_startup_entry) from [<4010190c>] (0x4010190c)
[    3.072772] CPU2: stopping
[    3.075464] CPU: 2 PID: 0 Comm: swapper/2 Not tainted 4.14.2 #1
[    3.081364] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree)
[    3.087446] [<c0110260>] (unwind_backtrace) from [<c010c7b0>] (show_stack+0x10/0x14)
[    3.095169] [<c010c7b0>] (show_stack) from [<c086fca8>] (dump_stack+0x94/0xc0)
[    3.102373] [<c086fca8>] (dump_stack) from [<c010f27c>] (handle_IPI+0x188/0x1b4)
[    3.109751] [<c010f27c>] (handle_IPI) from [<c0101584>] (gic_handle_irq+0x98/0x9c)
[    3.117302] [<c0101584>] (gic_handle_irq) from [<c010d6f0>] (__irq_svc+0x70/0xb0)
[    3.124764] Exception stack(0xef0aff68 to 0xef0affb0)
[    3.129801] ff60:                   00000001 00000001 00000000 ef0a2400 ef0ae000 c0d0747c
[    3.137961] ff80: c0d07420 c0c57570 c0ae81b4 ef0affc0 00000000 00000000 00000000 ef0affb8
[    3.146118] ffa0: c016e150 c01093e0 20000113 ffffffff
[    3.151156] [<c010d6f0>] (__irq_svc) from [<c01093e0>] (arch_cpu_idle+0x24/0x3c)
[    3.158534] [<c01093e0>] (arch_cpu_idle) from [<c01625fc>] (do_idle+0x200/0x26c)
[    3.165912] [<c01625fc>] (do_idle) from [<c01629cc>] (cpu_startup_entry+0x18/0x1c)
[    3.173462] [<c01629cc>] (cpu_startup_entry) from [<4010190c>] (0x4010190c)
[    3.180418] ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)

因为我们还没有在uboot里面配置根文件系统的位置,所以现在内核无法启动成功,提示end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)。
我们可以看到里面有这样一句话:Please append a correct "root=" boot option; here are the available partitions。这句话的下面帮我们列举出了可用于挂载根文件系统的分区。我们的SD卡共有3个分区,其中第二个分区是根文件系统的分区,文件系统类型为ext4,容量为14GB。
显然,mmcblk0这个设备拥有3个分区,就是我们的SD卡。第二个分区显示的容量差不多就是14GB,分区名称为mmcblk0p2。

[    2.565499] VFS: Cannot open root device "(null)" or unknown-block(0,0): error -6
[    2.571502] Please append a correct "root=" boot option; here are the available partitions:
[    2.580092] 0100            8192 ram0
[    2.580098]  (driver?)
[    2.585919] 0101            8192 ram1
[    2.585925]  (driver?)
[    2.592022] 0102            8192 ram2
[    2.592028]  (driver?)
[    2.598069] 0103            8192 ram3
[    2.598074]  (driver?)
[    2.604209] 0104            8192 ram4
[    2.604215]  (driver?)
[    2.610221] 0105            8192 ram5
[    2.610226]  (driver?)
[    2.616298] 0106            8192 ram6
[    2.616304]  (driver?)
[    2.622435] 0107            8192 ram7
[    2.622441]  (driver?)
[    2.628449] 0108            8192 ram8
[    2.628454]  (driver?)
[    2.634526] 0109            8192 ram9
[    2.634531]  (driver?)
[    2.640601] 010a            8192 ram10
[    2.640606]  (driver?)
[    2.646765] 010b            8192 ram11
[    2.646770]  (driver?)
[    2.652955] 010c            8192 ram12
[    2.652961]  (driver?)
[    2.659089] 010d            8192 ram13
[    2.659094]  (driver?)
[    2.665253] 010e            8192 ram14
[    2.665259]  (driver?)
[    2.671415] 010f            8192 ram15
[    2.671420]  (driver?)
[    2.677587] b300         7634944 mmcblk1
[    2.677593]  driver: mmcblk
[    2.684407]   b301         5172205 mmcblk1p1 00000000-01
[    2.684413]
[    2.691117]   b302         1052353 mmcblk1p2 00000000-02
[    2.691122]
[    2.697888]   b303         1052353 mmcblk1p3 00000000-03
[    2.697893]
[    2.704658]   b304          313467 mmcblk1p4 00000000-04
[    2.704663]
[    2.711433] b330             512 mmcblk1rpmb
[    2.711439]  (driver?)
[    2.718129] b320            4096 mmcblk1boot1
[    2.718134]  (driver?)
[    2.724885] b310            4096 mmcblk1boot0
[    2.724890]  (driver?)
[    2.731654] b340        30253056 mmcblk0
[    2.731660]  driver: mmcblk
[    2.738424]   b341         1465344 mmcblk0p1 848a5eb3-01
[    2.738429]
[    2.745194]   b342        13672448 mmcblk0p2 848a5eb3-02
[    2.745199]
[    2.752019]   b343        15114240 mmcblk0p3 848a5eb3-03
[    2.752024]

所以,我们在uboot里面设置bootargs启动参数,将根文件系统设为/dev/mmcblk0p2,可读写(rw),文件系统类型为ext4:

u-boot # printenv bootargs
bootargs=console=ttySAC2,115200n8 earlyprintk
u-boot # setenv bootargs console=ttySAC2,115200n8 earlyprintk root=/dev/mmcblk0p2 rw rootfstype=ext4 init=/linuxrc
u-boot # printenv bootargs
bootargs=console=ttySAC2,115200n8 earlyprintk root=/dev/mmcblk0p2 rw rootfstype=ext4 init=/linuxrc
u-boot # boot

这下,我们就能成功启动内核,进入shell命令行了。

刚才在uboot里面,我们只执行了setenv命令设置环境变量,没有执行saveenv命令保存,所以板子断电后会丢失,再开机还是会启动不了内核。
只有在setenv后执行了saveenv命令,这个环境变量的值才会保存到SD卡里面,重启板子后不会丢失,并且*** Warning - bad CRC, using default environment警告也会消失。这个警告的意思就是SD卡里面没有保存有环境变量的值,使用的是uboot的include/configs/itop4412.h里面的默认环境变量值。

saveenv其实也不是完全保险。只要我们重新编译了uboot,用dd命令烧写进sd卡,那么以前保存的环境变量又会丢失。
我们最好修改include/configs/itop4412.h文件里面的默认环境变量值,这样即使我们重新烧写了uboot,环境变量的值也不会丢。
我们把里面没用的环境变量全部删除,只保留四个环境变量:dtbaddr、loadaddr、bootargs和bootcmd(由CONFIG_BOOTCOMMAND宏配置)。

#define CONFIG_EXTRA_ENV_SETTINGS \
	"dtbaddr=0x41000000\0" /* DDR3内存中存放设备树的位置 */ \
	"loadaddr=0x40007000\0" /* DDR3内存中存放内核的位置 */ \
	"bootargs=console=ttySAC2,115200n8 earlyprintk root=/dev/mmcblk0p2 rw rootfstype=ext4 init=/linuxrc\0" /* 内核启动参数 */
#define CONFIG_BOOTCOMMAND \
	"mmc read ${dtbaddr} 0x800 0xa0;" /* [读设备树] 将SD卡的第2048~2207扇区(共计80KB)读到DDR3内存的dtbaddr地址处 */ \
	                                  /* 请注意mmc read的最后两个参数必须是十六进制格式 */ \
	"mmc read ${loadaddr} 0x1000 0x4000;" /* [读Linux内核] 将SD卡的第4096~20479扇区(共计8MB)读到DDR3内存的loadaddr地址处 */ \
	"bootm ${loadaddr} - ${dtbaddr}" /* [启动内核] 使用带3个参数的bootm命令, 第一个参数是内核地址loadaddr, 第二个参数是initrd地址(填"-"代表没有initrd), 第三个参数是设备树地址dtbaddr */

修改完成后,用“./build.sh”命令编译,用“sudo ./mkuboot.sh”命令合成bin文件并烧写到SD卡。(板子一定要先执行poweroff命令关机,然后断电,再取下SD卡,插到电脑上)

注意:目前移植的这个系统暂不支持reboot命令重启,只能自己按板子上的开关重启。笔者目前还没有研究出这个问题的解决方案。

挂载SD卡的FAT32分区

现在我们已经将SD卡的第二个分区(ext4分区)挂载到了根目录“/”下了,但SD卡还有第三个分区(FAT32分区)还没有挂载上去,无法访问。
我们先用fdisk -l命令列举一下所有的磁盘分区:

/dev/mmcblk1一看容量7456MB约等于8GB,就知道是板子上的eMMC Flash。
/dev/mmcblk0才是我们的32GB的SD卡,/dev/mmcblk0p3就是第三个分区,文件系统类型为FAT32。
我们在/mnt文件夹下面建立一个myfat目录,然后再用mount /dev/mmcblk0p3 /mnt/myfat命令把第三个分区挂载上去,就可以访问了。

但是板子重启后,又需要重新挂载。为了让板子自动挂载FAT32分区到/mnt/myfat目录下,我们可以在板子上用vi编辑器修改/etc/fstab文件,把fat32分区的信息加进去:
/dev/mmcblk0p3  /mnt/myfat vfat defaults    0   0

:wq保存,重启板子,就能自动挂载了。

挂载U盘

开发板上有两个USB口。每个USB口都可以插U盘。在开机状态下把U盘插到板子上,串口里面会提示U盘已插入,并且还会显示U盘的型号和容量:

/ # [  537.372565] usb 1-3.3: new high-speed USB device number 9 using exynos-ehci
[  537.528840] usb 1-3.3: New USB device found, idVendor=03f0, idProduct=9740
[  537.534729] usb 1-3.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  537.541625] usb 1-3.3: Product: x730w
[  537.545316] usb 1-3.3: Manufacturer: HP
[  537.549027] usb 1-3.3: SerialNumber: AA0000003641
[  537.557331] usb-storage 1-3.3:1.0: USB Mass Storage device detected
[  537.562866] scsi host0: usb-storage 1-3.3:1.0
[  538.808580] scsi 0:0:0:0: Direct-Access     hp       x730w            1100 PQ: 0 ANSI: 6
[  538.823347] sd 0:0:0:0: [sda] 60620800 512-byte logical blocks: (31.0 GB/28.9 GiB)
[  538.831596] sd 0:0:0:0: [sda] Write Protect is off
[  538.831871] sd 0:0:0:0: Attached scsi generic sg0 type 0
[  538.841418] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[  538.857935]  sda: sda1
[  538.864092] sd 0:0:0:0: [sda] Attached SCSI removable disk

在上面的消息中我们可以看到U盘设备名为/dev/sda1,容量为31GB,型号为HP x730w。
我们用fdisk -l命令,也能看到U盘的详细信息:

Disk /dev/sda: 29 GB, 31037849600 bytes, 60620800 sectors
3773 cylinders, 255 heads, 63 sectors/track
Units: cylinders of 16065 * 512 = 8225280 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sda1    0,3,36      1023,254,63        224   60620798   60620575 28.9G  c Win95 FAT32 (LBA)

我们可以用mount命令将U盘挂载到文件系统里面:

/ # mkdir /mnt/myusbdisk
/ # mount /dev/sda1 /mnt/myusbdisk
/ # cd /mnt/myusbdisk/
/mnt/myusbdisk # ls
05_a_tr.xml                  AC6102_WEB_SERVER_GMII.rar
05_p_tr.xml                  AIS????
20210223_2.zip               AISMOB-5.6.rar
20210423                     HX2AF01_20210310.zip
20210423????.rar             HX2AF01_20210315.zip
20210423_2.zip               KA??
20210719                     Ka??
20210818                     Quartus
????                         SFP.rar
????.rar                     System Volume Information
?????? v2.32                 V5.0??APP&????&????2???.rar
???????(rn_log)              ddr2_20210422_failed.zip
????????20210507             ddr2_nios_test_20210422.zip
??????Schematic Prints?.zip  simulate_memory.rar
??????_20210425.rar          stm32f107rc_02A5.zip
A703-35T.part1.rar           xxx
A703-35T.part2.rar           yyyy
A703-35T.part3.rar
/mnt/myusbdisk #

U盘不用了想要弹出的话,可以使用umount命令:

/mnt/myusbdisk #
/mnt/myusbdisk # cd /
/ # umount /dev/sda1
/ # ls /mnt/myusbdisk/
/ #

从USB口拔出U盘后,串口里面会提示U盘已拔出:

/ # [  812.277737] usb 1-3.3: USB disconnect, device number 9
[  812.301001] sd 0:0:0:0: [sda] Synchronizing SCSI cache
[  812.304869] sd 0:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=0x01 driverbyte=0x00

关于/dev、/proc、/tmp和/sys

/dev目录

虽然我们在制作busybox根文件系统的时候,/dev目录下没有放任何文件,但系统启动后,我们可以看到里面自动出现了各种各样的设备文件:

里面有console、null、zero、full、random和urandom等设备文件。
尽管我们没有在/etc/fstab里面声明/dev,但是在/dev里面建立文件夹和文件后,重启板子,我们会发现这些文件夹和文件都丢失了。

/dev/zero文件可以读到无限个0x00,经常用来生成指定大小的空文件。
在板子上的最小linux系统中同样可以使用dd命令。下面是用dd命令从/dev/zero里面读512x4=2048字节的0x00出来,写入到haha.bin文件中。其中bs是block size的意思,count是block count。最终生成的haha.bin文件大小为2048字节。

/mnt/myfat # dd if=/dev/zero of=haha.bin bs=512 count=4
4+0 records in
4+0 records out
2048 bytes (2.0KB) copied, 0.088655 seconds, 22.6KB/s
/mnt/myfat # ls -l
total 40
drwxr-xr-x    2 0        0             8192 Aug 19  2021 System Volume Information
-rwxr-xr-x    1 0        0             2048 Jan  1 00:06 haha.bin
drwxr-xr-x    2 0        0             8192 Aug 26  2021 haho
drwxr-xr-x    2 0        0             8192 Aug 21  2021 hello
drwxr-xr-x    2 0        0             8192 Aug 22  2021 sdupdate

用od -tx1 haha.bin命令可以查看haha.bin的二进制内容,但是显示时会用*号省略重复的内容。

/mnt/myfat # od -tx1 haha.bin
0000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
*
0004000

最左边那一栏显示的是地址(偏移量),右边才是文件内容。想要不显示地址的话,可以加上-An选项:od -tx1 -An haha.bin。
要想显示完所有的0x00,不用*号省略,可以加上-v选项:od -tx1 -v haha.bin。
-j可以指定从哪个地址开始显示,-N可以指定显示多少字节,如:

/mnt/myfat # od -tx1 -v -j16 -N40 haha.bin
0000020 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000040 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000060 00 00 00 00 00 00 00 00
0000070

random和urandom文件都是随机数生成器,可以从中读到无数个随机数。例如:

/mnt/myfat # od -tx1 -An -vN32 /dev/urandom | tr -d " "
af95c5362a21a5b35040ad2409035555
d92954740e3585de8748ddbfd3a76b3b
/mnt/myfat # od -tx1 -An -vN32 -w32 /dev/urandom | tr -d " "
6dbbc4b3599ee564c486fdbfec52b77776def7c2276b73b03c601f5f714bb9be

第一个命令生成了两行32字符的十六进制随机字符串,第二个命令生成了一行64字符的十六进制随机字符串,这是因为-w参数决定了换行的位置。管道符号“|”右边的tr -d " "命令用于删除空格。

/proc目录

/proc目录下有很多系统信息。比如在/proc/version中可以看到Linux内核的版本,以及编译内核用的编译器的版本。/proc/cpuinfo里面可以看到CPU信息。/proc/meminfo里面可以看到内存信息。
这些都是linux内核自动生成的文件。

/ # ls /proc
1               33              92              kpageflags
10              34              93              loadavg
100             35              94              lockdep
11              36              95              lockdep_chains
118             37              96              lockdep_stats
12              38              99              locks
13              39              asound          meminfo
14              4               buddyinfo       misc
142             40              bus             modules
147             41              cgroups         mounts
15              42              cmdline         net
151             43              consoles        pagetypeinfo
157             44              cpu             partitions
16              45              cpuinfo         sched_debug
161             46              crypto          scsi
164             6               device-tree     self
17              67              devices         slabinfo
174             69              diskstats       softirqs
19              7               driver          stat
2               70              execdomains     swaps
20              71              fb              sys
21              74              filesystems     sysrq-trigger
22              78              fs              sysvipc
23              8               interrupts      thread-self
25              80              iomem           timer_list
26              86              ioports         tty
27              87              irq             uptime
28              88              kallsyms        version
29              89              key-users       vmallocinfo
30              9               keys            vmstat
31              90              kmsg            zoneinfo
32              91              kpagecount
/ # cat /proc/version
Linux version 4.14.2 (oct1158@fedora) (gcc version 10.3.1 20210621 (GNU Toolchain for the A-profile Architecture 10.3-2021.07 (arm-10.29))) #1 SMP PREEMPT Fri Aug 27 21:58:22 CST 2021
/ # cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 52.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

processor       : 1
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 52.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

processor       : 2
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 52.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

processor       : 3
model name      : ARMv7 Processor rev 0 (v7l)
BogoMIPS        : 52.80
Features        : half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x3
CPU part        : 0xc09
CPU revision    : 0

Hardware        : SAMSUNG EXYNOS (Flattened Device Tree)
Revision        : 0000
Serial          : 0000000000000000
/ # cat /proc/meminfo
MemTotal:         975000 kB
MemFree:          955560 kB
MemAvailable:     949468 kB
Buffers:             840 kB
Cached:             1216 kB
SwapCached:            0 kB
Active:             2120 kB
Inactive:             56 kB
Active(anon):        116 kB
Inactive(anon):        0 kB
Active(file):       2004 kB
Inactive(file):       56 kB
Unevictable:           0 kB
Mlocked:               0 kB
HighTotal:        217088 kB
HighFree:         214856 kB
LowTotal:         757912 kB
LowFree:          740704 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 4 kB
Writeback:             0 kB
AnonPages:           116 kB
Mapped:             1024 kB
Shmem:                 0 kB
Slab:              12544 kB
SReclaimable:       4400 kB
SUnreclaim:         8144 kB
KernelStack:         584 kB
PageTables:           40 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:      487500 kB
Committed_AS:        864 kB
VmallocTotal:     245760 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB
CmaTotal:          98304 kB
CmaFree:           98012 kB

/tmp目录

/tmp目录挂载的是tmpfs,和/dev目录类似,这也是一个临时文件目录,板子关机后这里面的所有文件都会丢失。

/sys目录

/sys目录里面的文件也是linux内核自动生成的。
/sys/devices/system/cpu目录下可以看到当前板子的CPU信息。exynos4412是一个四核的处理器,所以这里面可以看到cpu0~3这四个cpu。其中0-3都是online的,没有cpu是offline的。
笔者之前在一个使用国产飞腾(FT)处理器的路由器项目里面就有一个产品功耗优化的需求。那个FT CPU里面一共有16个核,但每个CPU核是无法单独打开或关闭的。最终为了降低功耗,笔者用了sched_setaffinity函数设置进程绑定的CPU号,把所有与路由相关的进程都绑定到同一个CPU上,就能不关CPU核降低CPU功耗。

/ # ls /sys/devices/system/cpu
cpu0        cpu3        hotplug     modalias    possible    uevent
cpu1        cpufreq     isolated    offline     power
cpu2        cpuidle     kernel_max  online      present
/ # cat /sys/devices/system/cpu/online
0-3
/ # cat /sys/devices/system/cpu/offline

/ #

/sys/class/leds文件夹还可以控制在设备树里面定义了的LED灯:

/sys/class/leds # ls
mmc0::      red:system  red:user

可以看到red:system和red:user就是我们之前在设备树里面的leds语句块里定义的两个LED灯,分别对应板子上的LED2和LED3。
点亮LED3:echo 1 > red:user/brightness
熄灭LED3:echo 0 > red:user/brightness
不过,由于在设备树里面,LED2定义了linux,default-trigger = "heartbeat",是一个系统指示灯,所以我们无法直接控制这个灯的亮灭。只能LED2一秒自动闪烁两次。
把这个属性去掉,make dtbs重新编译设备树,烧写进SD卡,我们就能用echo命令控制red:system(LED2)的亮灭了。

现在,我们用vi编辑器写一个shell脚本,命名为/root/led.sh,控制这两个LED灯:

#!/bin/sh
for i in `seq 1 5`
do
        echo "i=$i"
        echo 1 > /sys/class/leds/red:user/brightness
        echo 1 > /sys/class/leds/red:system/brightness
        sleep 1
        echo 0 > /sys/class/leds/red:user/brightness
        echo 0 > /sys/class/leds/red:system/brightness
        sleep 1
done
/ # cd root
/root # vi leds.sh
/root # chmod +x leds.sh
/root # ./leds.sh
i=1
i=2
i=3
i=4
i=5

运行脚本后可以看到,板子上的两个灯都闪起来了。两秒钟闪烁一次。

/sys/bus/iio/devices/iio:device0目录里面的in_voltageN_raw文件可以读取ADC转换器的转换结果。这是Linux内核里面自带的exynos4412 adc的驱动,版本为samsung,exynos-adc-v1,驱动文件的路径为linux-4.14.2/drivers/iio/adc/exynos_adc.c。
开发板的耳机插孔旁边有一个蓝色的滑动变阻器,这个滑动变阻器接的ADC通道是ADC0,顺时针旋转,ADC0的值会减小。顺时针旋转1/4圈,数值大约减小40。

/ # cd /sys/bus/iio/devices/iio:device0
/sys/devices/platform/126c0000.adc/iio:device0 # ls
dev              in_voltage3_raw  in_voltage7_raw  subsystem
in_voltage0_raw  in_voltage4_raw  name             uevent
in_voltage1_raw  in_voltage5_raw  of_node
in_voltage2_raw  in_voltage6_raw  power
/sys/devices/platform/126c0000.adc/iio:device0 # cat in_voltage0_raw
2213
/sys/devices/platform/126c0000.adc/iio:device0 # cat in_voltage0_raw
2213
/sys/devices/platform/126c0000.adc/iio:device0 # cat in_voltage0_raw
2213
/sys/devices/platform/126c0000.adc/iio:device0 # cat in_voltage0_raw
2145
/sys/devices/platform/126c0000.adc/iio:device0 # cat in_voltage0_raw
2019
/sys/devices/platform/126c0000.adc/iio:device0 # cat in_voltage0_raw
1942
/sys/devices/platform/126c0000.adc/iio:device0 # cat in_voltage0_raw
1862
/sys/devices/platform/126c0000.adc/iio:device0 # cat in_voltage0_raw
1792

可以在root目录下写一个adc.sh脚本,每隔一秒读取一次8个通道的ADC值:

#!/bin/sh
for i in `seq 1 100`
do
        for j in `seq 0 7`
        do
                value=`cat /sys/bus/iio/devices/iio:device0/in_voltage${j}_raw`
                echo -n "$value "
        done
        echo
        sleep 1
done

 脚本运行结果:

/root # ./adc.sh
1640 1954 1977 3077 0 0 0 0
1642 1750 1818 1834 0 0 0 0
1641 1756 1761 1837 0 0 0 0
1640 1745 1762 1916 0 0 0 0
1639 1639 1748 1953 0 0 0 0
1643 1668 1693 1812 0 0 0 0
1609 1692 1707 1908 0 0 0 0
1582 1661 1760 1913 0 0 0 0
1573 1649 1671 1934 0 0 0 0
1572 1615 1720 1898 0 0 0 0
1565 1635 1723 1837 0 0 0 0
1530 1674 1663 1791 0 0 0 0
1513 1747 1801 1921 0 0 0 0
1508 1652 1689 1935 0 0 0 0
1525 1632 1757 1958 0 0 0 0
1529 1723 1735 1948 0 0 0 0
1493 1685 1675 1932 0 0 0 0
1489 1746 1792 1860 0 0 0 0
1485 1675 1789 1901 0 0 0 0
1437 1745 1739 1804 0 0 0 0
1422 1663 1738 1893 0 0 0 0
1422 1736 1683 1881 0 0 0 0
1360 1645 1679 1854 0 0 0 0
1338 1664 1697 1914 0 0 0 0
1336 1639 1734 1938 0 0 0 0
1337 1707 1694 1903 0 0 0 0
1336 1715 1731 1874 0 0 0 0

最左边那一栏就是滑动变阻器的ADC测量值。 exynos4412只有四个ADC通道,所以只有前四列有数据。

Linux内核里面还有很多其他的驱动,比如platform_i2c_driver、platform_spi_driver等等。linux-4.14.2/drivers/iio/adc/ad799x.c就利用了module_i2c_driver,实现了I2C接口的ADC芯片的读取。

关于zImage内核镜像

刚才,我们编译内核的时候,使用的是make uImage LOADADDR=0x40007000命令,生成的文件是zImage和uImage。我们最终烧写的是uImage镜像,然后在uboot里面用bootm命令启动内核。
其实,我们烧写zImage镜像也是可以的,只不过要把uboot命令换成bootz。
编译命令:make zImage
烧写命令:sudo dd iflag=dsync oflag=dsync if=arch/arm/boot/zImage of=/dev/sdb seek=20480
烧写命令的seek可以随便定义,我们定义成烧写zImage内核到20480扇区处。
插好SD卡,板子通电后,在uboot里面修改bootcmd环境变量:
setenv bootcmd mmc read ${dtbaddr} 0x800 0xa0\;mmc read ${loadaddr} 0x5000 0x4000\;bootz ${loadaddr} - ${dtbaddr}
其中第二条命令的那个0x5000就是刚才烧写内核时的seek值,转换成十进制就是20480。

U-Boot 2017.11 (Aug 28 2021 - 11:13:25 +0800) for itop-4412

CPU:   Exynos4412 @ 1 GHz
Model: itop-4412 based on Exynos4412
Board: itop-4412 based on Exynos4412
DRAM:  1 GiB
WARNING: Caches not enabled
MMC:   SAMSUNG SDHCI: 0
*** Warning - bad CRC, using default environment

Hit any key to stop autoboot:  0
u-boot # setenv bootcmd mmc read ${dtbaddr} 0x800 0xa0\;mmc read ${loadaddr} 0x5000 0x4000\;bootz ${loadaddr} - ${dtbaddr}
u-boot # printenv bootcmd
bootcmd=mmc read 0x41000000 0x800 0xa0;mmc read 0x40007000 0x5000 0x4000;bootz 0x40007000 - 0x41000000

然后输入boot启动内核:

u-boot # boot

MMC read: dev # 0, block # 2048, count 160 ... 160 blocks read: OK

MMC read: dev # 0, block # 20480, count 16384 ... 16384 blocks read: OK
Kernel image @ 0x40007000 [ 0x000000 - 0x542b88 ]
## Flattened Device Tree blob at 41000000
   Booting using the fdt blob at 0x41000000
   Loading Device Tree to 4ffef000, end 4ffffa22 ... OK

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
s3c24xx_serial_console_setup: co=c0d28850 (2), 115200n8
s3c24xx_serial_probe(ef23c400) 1
s3c24xx_serial_probe: initialising port c0d289e0...
s3c24xx_serial_init_port: port=c0d28a10, platdev=ef23c400
resource [mem 0x13810000-0x138100ff])

zImage内核也能启动成功。

[下一篇]

  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

巨大八爪鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值