嵌入式开发之linux内核移植

 前言

       很早就买了OK6410开发板,由于linux内核学习难度大,加上时间工作和时间的原因,断断续续移植linux内核、文件系统和u-boot,linux学习已作为一种求知态度。

移植linux内核的软硬件环境如下:

主机环境:Ubuntu 18.04.4 LTS

编译环境:arm-linux-gcc-4.3.2

目标机:飞凌-OK6410-A

目标机内核:linux 3.0.1

内核移植的总体思路脉络如下:


 

一、下载内核源码

1.1 下载linux-3.0.1

(1)Linux官网下载地址:The Linux Kernel Archives,选择HTTP或GIT方式下载;

(2)浏览器输入https://mirrors.edge.kernel.org/pub/linux/kernel/v3.0/linux-3.0.1.tar.bz2下载;

1.2 解压源码文件

进入下载包所在的目录并解压到目录“~/tmp”,操作如下:

# Create a temporary directory
sudo mkdir ~/tmp
 
# Extract the installation source file
sudo tar -jxvf linux-3.0.1.tar.bz2 -C ~/tmp

二、 内核添加yaffs2文件系统支持

2.1 下载yaffs2

方法1:使用git命令下载最新的yaffs2到目录“~/tmp”。

cd ~/tmp

git init
git clone git://www.aleph1.co.uk/yaffs2

方法2:下载特定版本yaffs2(yaffs2-e68d2bd.tar.gz 2011-08-15提交,可用于当前OK6410开发板的文件系统),解压到~/tmp目录并重命名。

sudo  tar -zxvf yaffs2-e68d2bd.tar.gz -C ~/tmp

sudo mv ~/tmp/yaffs2-e68d2bd ~/tmp/yaffs2

由于开发板硬件发布时间过长,推荐使用方法2来集成yaffs2文件系统。

2.2 内核添加yaffs2文件补丁

进入“yaffs2”目录,执行“patch-ker.sh”脚本,安装补丁。

cd ~/tmp/yaffs2

sudo chmod +x patch-ker.sh
sudo ./patch-ker.sh c m ~/tmp/linux-3.0.1/

 补丁安装成功后,在~/tmp/linux-3.0.1目录下执行“sudo make menuconfig”,内核中添加对yaffs2文件系统的支持。


File systems  --->
    [*] Miscellaneous filesystems  --->
        <*>   yaffs2 file system support

三、配置开发板

3.1 修改机器ID

由于机器ID要和uboot里面(uboot/include/configs/smdk6410.h)的MACH_TYPE保持一致,所以需要修改内核的“mach-types”文件。

sudo vim ~/tmp/linux-3.0.1/arch/arm/tools/mach-types

删除“smdk6410”配置信息行,并添加自定义的“my6410”新行配置信息,如下:

my6410        MACH_MY6410       MY6410        1626

3.2 添加开发板初始化文件

内核源码自带的文件“mach-smdk6410.c”保留有开发板相关的配置,可以直接复制加以利用。

sudo cp ~/tmp/linux-3.0.1/arch/arm/mach-s3c64xx/mach-smdk6410.c ~/tmp/linux-3.0.1/arch/arm/mach-s3c64xx/mach-my6410.c

使用sed命令将“mach-my6410.c”文件中的所有小写的“smdk6410”改成“my6410”。

sudo sed -i 's/smdk6410/my6410/g' ~/tmp/linux-3.0.1/arch/arm/mach-s3c64xx/mach-my6410.c

使用sed命令将“mach-my6410.c”文件中的所有全字匹配的“SMDK6410”改成“MY6410”。

sudo sed -i 's/\<SMDK6410\>/MY6410/g' ~/tmp/linux-3.0.1/arch/arm/mach-s3c64xx/mach-my6410.c

3.3 配置NandFalsh

3.3.1 添加NandFlash设备

(1) 配置NandFalsh分区表

sudo vim ~/tmp/linux-3.0.1/arch/arm/mach-s3c64xx/mach-my6410.c

在“~/tmp/linux-3.0.1/arch/arm/mach-s3c64xx/mach-my6410.c”中增加三个头文件,如下:

// add necessary includes here
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <plat/nand.h>

NandFlash上设置四个分区:“Bootloader”、“Kernel”、“User”和“File System”。

/*
 * Configuring Nandflash on MY6410
*/
struct mtd_partition my6410_nand_part[] = {
	{
		.name		= "Bootloader",
		.offset		= 0,
		.size		= (2 * SZ_1M),
		.mask_flags	= MTD_CAP_NANDFLASH,
	},
	{
		.name		= "Kernel",
		.offset		= (2 * SZ_1M),
		.size		= (5*SZ_1M) ,
		.mask_flags	= MTD_CAP_NANDFLASH,
	},
	{
		.name		= "User",
		.offset		= (7 * SZ_1M),
		.size		= (200*SZ_1M) ,
	},
	{
		.name		= "File System",
		.offset		= MTDPART_OFS_APPEND,
		.size		= MTDPART_SIZ_FULL,
	}
};

static struct s3c2410_nand_set my6410_nand_sets[] = {
	[0] = {
		.name       = "nand",
		.nr_chips   = 1,
		.nr_partitions  = ARRAY_SIZE(my6410_nand_part),
		.partitions = my6410_nand_part,
	},
};

static struct s3c2410_platform_nand my6410_nand_info = {
	.tacls      = 25,
	.twrph0     = 55,
	.twrph1     = 40,
	.nr_sets    = ARRAY_SIZE(my6410_nand_sets),
	.sets       = my6410_nand_sets,
};

 在函数“my6410_machine_init”中调用“s3c_nand_set_platdata”,添加当前的分区配置信息。

static void __init my6410_machine_init(void)
{

    // modified by daniel
	s3c_nand_set_platdata(&my6410_nand_info);

    ...
}

(2)添加NandFlash设备到开发板

在结构体“my6410_devices”中添加“s3c_device_nand”设备信息。

static struct platform_device *my6410_devices[] __initdata = {

    // modified by daniel
    &s3c_device_nand, 

    ...
};

“s3c_device_nand”代表本开发版上的Nand flash,它定义在“~/tmp/linux-3.0.1/arch/arm/plat-samsung/dev-nand.c”。修改s3c_nand_resource”和“s3c_device_nand结构体

sudo vim ~/tmp/linux-3.0.1/arch/arm/plat-samsung/dev-nand.c

修改s3c_nand_resource结构体,将“.end   = S3C_PA_NAND + SZ_1M”改成“.end   = S3C_PA_NAND + SZ_1M - 1”。

 static struct resource s3c_nand_resource[] = {
    [0] = {
        .start = S3C_PA_NAND,

        // modified by daniel
        // .end   = S3C_PA_NAND + SZ_1M,
        .end   = S3C_PA_NAND + SZ_1M - 1,

        .flags = IORESOURCE_MEM,
    }
};

修改s3c_device_nand结构体,将“.name = "s3c2410-nand",”改成“.name = "s3c6410-nand",”。

struct platform_device s3c_device_nand = {
    // modified by daniel
    //.name    = "s3c2410-nand",
    .name    = "s3c6410-nand",

	.id        = -1,
	.num_resources	  = ARRAY_SIZE(s3c_nand_resource),
	.resource	  = s3c_nand_resource,
};

3.3.2 添加NandFlash驱动

(1)复制s3c_nand.c

从官方给的内核源码包中复制s3c_nand.c到目录“~/tmp/linux-3.0.1/drivers/mtd/nand”。

(2)修改regs-nand.h

sudo vim ~/tmp/linux-3.0.1/arch/arm/plat-samsung/include/plat/regs-nand.h

在文件“~/tmp/linux-3.0.1/arch/arm/plat-samsung/include/plat/regs-nand.h”中,添加以下定义:

/*
 * for s3c-nand.c
 * modified by daniel
*/
#define S3C_NFCONF      S3C2410_NFREG(0x00)
#define S3C_NFCONT      S3C2410_NFREG(0x04)
#define S3C_NFCMMD      S3C2410_NFREG(0x08)
#define S3C_NFADDR      S3C2410_NFREG(0x0c)
#define S3C_NFDATA8     S3C2410_NFREG(0x10)
#define S3C_NFDATA      S3C2410_NFREG(0x10)
#define S3C_NFMECCDATA0     S3C2410_NFREG(0x14)
#define S3C_NFMECCDATA1      S3C2410_NFREG(0x18)
#define S3C_NFSECCDATA  S3C2410_NFREG(0x1c)
#define S3C_NFSBLK   S3C2410_NFREG(0x20)
#define S3C_NFEBLK   S3C2410_NFREG(0x24)
#define S3C_NFSTAT    S3C2410_NFREG(0x28)
#define S3C_NFMECCERR0 S3C2410_NFREG(0x2c)
#define S3C_NFMECCERR1 S3C2410_NFREG(0x30)
#define S3C_NFMECC0       S3C2410_NFREG(0x34)
#define S3C_NFMECC1       S3C2410_NFREG(0x38)
#define S3C_NFSECC   S3C2410_NFREG(0x3c)
#define S3C_NFMLCBITPT  S3C2410_NFREG(0x40)
 
#define S3C_NF8ECCERR0  S3C2410_NFREG(0x44)
#define S3C_NF8ECCERR1  S3C2410_NFREG(0x48)
#define S3C_NF8ECCERR2  S3C2410_NFREG(0x4c)

#define S3C_NFM8ECC0      S3C2410_NFREG(0x50)
#define S3C_NFM8ECC1      S3C2410_NFREG(0x54)
#define S3C_NFM8ECC2      S3C2410_NFREG(0x58)
#define S3C_NFM8ECC3      S3C2410_NFREG(0x5c)
 
#define S3C_NFMLC8BITPT0     S3C2410_NFREG(0x60)
#define S3C_NFMLC8BITPT1     S3C2410_NFREG(0x64)
 
#define S3C_NFCONF_NANDBOOT   (1<<31)
#define S3C_NFCONF_ECCCLKCON (1<<30)
#define S3C_NFCONF_ECC_MLC      (1<<24)
#define S3C_NFCONF_ECC_1BIT      (0<<23)
#define S3C_NFCONF_ECC_4BIT      (2<<23)
#define S3C_NFCONF_ECC_8BIT      (1<<23)
#define S3C_NFCONF_TACLS(x)       ((x)<<12)
#define S3C_NFCONF_TWRPH0(x)    ((x)<<8)
#define S3C_NFCONF_TWRPH1(x)    ((x)<<4)
#define S3C_NFCONF_ADVFLASH    (1<<3)
#define S3C_NFCONF_PAGESIZE      (1<<2)
#define S3C_NFCONF_ADDRCYCLE (1<<1)
#define S3C_NFCONF_BUSWIDTH    (1<<0)
 
#define S3C_NFCONT_ECC_ENC      (1<<18)
#define S3C_NFCONT_LOCKTGHT   (1<<17)
#define S3C_NFCONT_LOCKSOFT    (1<<16)
#define S3C_NFCONT_MECCLOCK   (1<<7)
#define S3C_NFCONT_SECCLOCK    (1<<6)
#define S3C_NFCONT_INITMECC     (1<<5)
#define S3C_NFCONT_INITSECC      (1<<4)
#define S3C_NFCONT_nFCE1     (1<<2)
#define S3C_NFCONT_nFCE0     (1<<1)
#define S3C_NFCONT_INITECC (S3C_NFCONT_INITSECC | S3C_NFCONT_INITMECC)

#define S3C_NFSTAT_ECCENCDONE       (1<<7)
#define S3C_NFSTAT_ECCDECDONE       (1<<6)
#define S3C_NFSTAT_BUSY       (1<<0)

#define S3C_NFECCERR0_ECCBUSY (1<<31)

(3)修改partitions.h

sudo vim ~/tmp/linux-3.0.1/include/linux/mtd/partitions.h

在文件“~/tmp/linux-3.0.1/include/linux/mtd/partitions.h”中,添加以下声明:

/*
 * modified by daniel
*/
int add_mtd_partitions(struct mtd_info *,const struct mtd_partition *, int);
int del_mtd_partitions(struct mtd_info *);

 (4)修改Kconfig(Nand驱动)

sudo vim ~/tmp/linux-3.0.1/drivers/mtd/nand/Kconfig

在目录“~/tmp/linux-3.0.1/drivers/mtd/nand/Kconfig”下,仿照“MTD_NAND_S3C2410”,添加“MTD_NAND_S3C”配置节点,如下:

config MTD_NAND_S3C
	tristate "NAND support for Samsung S3C Socs (MY6410)"
	depends on (ARCH_S3C64XX || ARCH_S5P64XX || ARCH_S5PC1XX) && MTD_NAND
	help
	  This enables the NAND flash controller on the S3C

	  No board specific support is done by this driver, each board
	  must advertise a platform_device for the driver to attach. (modified by daniel)

config MTD_NAND_S3C_DEBUG
	bool "S3C NAND driver debug"
	depends on MTD_NAND_S3C
	help
	  Enable debugging of the S3C NAND driver (modified by daniel)

config MTD_NAND_S3C_HWECC
	bool "S3C NAND Hardware ECC"
	depends on MTD_NAND_S3C
	help
	  Enable the use of the S3C's internal ECC generator when
	  using NAND. Early versions of the chip have had problems with
	  incorrect ECC generation, and if using these, the default of
	  software ECC is preferable.

	  If you lay down a device with the hardware ECC, then you will
	  currently not be able to switch to software, as there is no
	  implementation for ECC method used by the S3C (modified by daniel)

 (4)修改Makefile(Nand驱动)

sudo vim ~/tmp/linux-3.0.1/drivers/mtd/nand/Makefile

“~/tmp/linux-3.0.1/drivers/mtd/nand/Makefile”下仿照“s3c2410.o”,添加“s3c_nand.o”编译项。

obj-$(CONFIG_MTD_NAND_S3C)		+= s3c_nand.o

 可以使用sed命令来完成,如下:

sudo sed -i '$a\obj-$(CONFIG_MTD_NAND_S3C)\t+= s3c_nand.o' ~/tmp/linux-3.0.1/drivers/mtd/nand/Makefile

3.3 修改Kconfig(支持MY6410)

sudo vim ~/tmp/linux-3.0.1/arch/arm/mach-s3c64xx/Kconfig

编辑“arch/arm/mach-s3c64xx/Kconfig”,增加“MACH_MY6410”配置选项,内容如下:

config MACH_MY6410
     bool "MY6410"
     select CPU_S3C6410
     select SAMSUNG_DEV_ADC
     select S3C_DEV_HSMMC
     select S3C_DEV_HSMMC1
     select S3C_DEV_I2C1
     select SAMSUNG_DEV_IDE
     select S3C_DEV_FB
     select S3C_DEV_RTC
     select SAMSUNG_DEV_TS
     select S3C_DEV_USB_HOST
     select S3C_DEV_USB_HSOTG
     select S3C_DEV_WDT
     select SAMSUNG_DEV_KEYPAD
     select SAMSUNG_DEV_PWM
     select HAVE_S3C2410_WATCHDOG if WATCHDOG
     select S3C64XX_SETUP_SDHCI
     select S3C64XX_SETUP_I2C1
     select S3C64XX_SETUP_IDE
     select S3C64XX_SETUP_FB_24BPP
     select S3C64XX_SETUP_KEYPAD
     help
       Machine support for the Samsung SMDK6410 (modifed by daniel)

3.4 修改Makefile(支持MY6410)

 在开发板配置“linux-3.0.1/arch/arm/mach-s3c64xx/”目录下的Makefile文件中最后一行,实现支持my6410.c文件编译。

obj-$(CONFIG_MACH_MY6410) += mach-my6410.o

可以使用sed命令来完成,如下:

sudo sed -i '$a\obj-$(CONFIG_MACH_MY6410) += mach-my6410.o' ~/tmp/linux-3.0.1/arch/arm/mach-s3c64xx/Makefile

四、配置和编译内核

4.1 设置运行平台和编译器

Makefile文件保存了编译器和连接器的参数选项,以及整个工程的编译规则。

sudo vim ~/tmp/linux-3.0.1/Makefile

修改平台和交叉编译配置选项:

a. 修改195行, “ARCH        ?= $(SUBARCH)”改为:ARCH ?= arm

b. 修改196行,“ CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)”改为:CROSS_COMPILE ?= arm-linux-为:CROSS_COMPILE ?= arm-linux-

也可以使用sed命令来完成,如下:

# Configure ARCH and CROSS_COMPILE
sudo sed -i 's/ARCH\t\t?= \$(SUBARCH)/ARCH ?= arm/g' ~/tmp/linux-3.0.1/Makefile
sudo sed -i 's/CROSS_COMPILE\t?= $(CONFIG_CROSS_COMPILE:"%"=%)/CROSS_COMPILE ?= arm-linux-/g'  ~/tmp/linux-3.0.1/Makefile

4.2 图形化界面配置内核

进入“~/tmp/linux-3.0.1”源码目录,运行“make menuconfig”,启动图形化界面配置。

sudo make menuconfig ARCH=arm CROSS_COMPILE=arm-linux-

在默认配置的基础上进行相关修改,如下:

System Type  --->
     ARM system type (Samsung S3C64XX)  --->
          (X) Samsung S3C64XX
     [*] MY6410

Kernel Features  ---> 
    [*] Use the ARM EABI to compile the kernel

Kernel hacking  --->
    [*] Kernel low-level debugging functions

Device Drivers  --->
    <*> Memory Technology Device (MTD) support  ---> 
          <*>   Caching block device access to MTD devices
          <*>   NAND Device Support  --->
              < >   NAND Flash support for Samsung S3C SoCs 
              <*>   NAND support for Samsung S3C (MY6410) 
              [*]     Samsung S3C NAND driver debug
              [*]     Samsung S3C NAND Hardware ECC

    [*] Block devices  --->
        <*>     RAM block device support

    Character devices  --->
        Serial drivers  --->
            < > 8250/16550 and compatible serial support 
            <*> Samsung SoC serial support
            [*] Support for console on Samsung SoC serial port
            <*> Samsung S3C6400/S3C6410/S5P6440/S5P6450/S5PC100 Serial port support

    [*] Real Time Clock  --->
         <*>   Samsung S3C series SoC RTC

    Security options  --->
        [ ] Enable different security models

    Input device support  ---> 
       [ ] Touchscreens  ---> 

    [ ] Multifunction device drivers  --->

    [ ] Staging drivers  ---> 

File systems  --->
    [*] Miscellaneous filesystems  --->
        <*>   yaffs2 file system support

4.3 编译内核

su root

source /etc/profile

make zImage ARCH=arm CROSS_COMPILE=arm-linux-

 编译完成后,在~/tmp/linux-3.01.1/arch/arm/boot生成下生成内核文件。

五、移植内核

5.1 烧写内核文件

dnw ~/tmp/linux-3.0.1/arm/arch/boot/zImage

5.2 内核启动日志

使用minicom打印出内核启动日志

U-Boot 1.1.6 (Mar 31 2013 - 06:38:14) for SMDK6410

****************************************
**    u-boot 1.1.6                    **
**    Updated for OK6410  TE6410 Board  **
**    Version (2012-09-23)          **
**    OEM: Forlinx Embedded           **
**    Web: http://www.witech.com.cn   **
****************************************

CPU:     S3C6410 @532MHz
         Fclk = 532MHz, Hclk = 133MHz, Pclk = 66MHz, Serial = CLKUART (SYNC Mode) 
Board:   SMDK6410
DRAM:    256 MB
Flash:   0 kB
NAND:    2048 MB 
In:      serial
Out:     serial
Err:     serial
Hit any key to stop autoboot:  1  0 

NAND read: device 0 offset 0x200000, size 0x500000
 5242880 bytes read: OK
Boot with zImage

Starting kernel ...

Uncompressing Linux... done, booting the kernel.
[    0.000000] Initializing cgroup subsys cpuset
[    0.000000] Initializing cgroup subsys cpu
[    0.000000] Linux version 3.0.1 (root@ubuntu) (gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72) ) #8 Sun Jan 15 05:43:18 PST 2023
[    0.000000] CPU: ARMv6-compatible processor [410fb766] revision 6 (ARMv7), cr=00c5387f
[    0.000000] CPU: VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] Machine: MY6410
[    0.000000] Memory policy: ECC disabled, Data cache writeback
[    0.000000] CPU S3C6410 (id 0x36410101)
[    0.000000] S3C24XX Clocks, Copyright 2004 Simtec Electronics
[    0.000000] camera: no parent clock specified
[    0.000000] S3C64XX: PLL settings, A=532000000, M=532000000, E=24000000
[    0.000000] S3C64XX: HCLK2=266000000, HCLK=133000000, PCLK=66500000
[    0.000000] mout_apll: source is fout_apll (1), rate is 532000000
[    0.000000] mout_epll: source is epll (1), rate is 24000000
[    0.000000] mout_mpll: source is mpll (1), rate is 532000000
[    0.000000] mmc_bus: source is mout_epll (0), rate is 24000000
[    0.000000] mmc_bus: source is mout_epll (0), rate is 24000000
[    0.000000] mmc_bus: source is mout_epll (0), rate is 24000000
[    0.000000] usb-bus-host: source is clk_48m (0), rate is 48000000
[    0.000000] uclk1: source is dout_mpll (1), rate is 66500000
[    0.000000] spi-bus: source is mout_epll (0), rate is 24000000
[    0.000000] spi-bus: source is mout_epll (0), rate is 24000000
[    0.000000] audio-bus: source is mout_epll (0), rate is 24000000
[    0.000000] audio-bus: source is mout_epll (0), rate is 24000000
[    0.000000] audio-bus: source is mout_epll (0), rate is 24000000
[    0.000000] irda-bus: source is mout_epll (0), rate is 24000000
[    0.000000] camera: no parent clock specified
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 65024
[    0.000000] Kernel command line: root=/dev/mtdblock2 rootfstype=yaffs2 init=/linuxrc console=ttySAC0,115200
[    0.000000] PID hash table entries: 1024 (order: 0, 4096 bytes)
[    0.000000] Dentry cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Inode-cache hash table entries: 16384 (order: 4, 65536 bytes)
[    0.000000] Memory: 256MB = 256MB total
[    0.000000] Memory: 253480k/253480k available, 8664k reserved, 0K highmem
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xfff00000 - 0xfffe0000   ( 896 kB)
[    0.000000]     DMA     : 0xff600000 - 0xffe00000   (   8 MB)
[    0.000000]     vmalloc : 0xd0800000 - 0xf6000000   ( 600 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xd0000000   ( 256 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .init : 0xc0008000 - 0xc0041000   ( 228 kB)
[    0.000000]       .text : 0xc0041000 - 0xc0589000   (5408 kB)
[    0.000000]       .data : 0xc058a000 - 0xc05bc7e0   ( 202 kB)
[    0.000000]        .bss : 0xc05bc804 - 0xc0635cfc   ( 486 kB)
[    0.000000] SLUB: Genslabs=13, HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:246 nr_irqs:246 246
[    0.000000] VIC @f6000000: id 0x00041192, vendor 0x41
[    0.000000] VIC @f6010000: id 0x00041192, vendor 0x41
[    0.000000] Console: colour dummy device 80x30
[    0.000000] console [ttySAC0] enabled
[    0.030000] Calibrating delay loop... 528.79 BogoMIPS (lpj=2643968)
[    0.080000] pid_max: default: 32768 minimum: 301
[    0.090000] Mount-cache hash table entries: 512
[    0.090000] Initializing cgroup subsys cpuacct
[    0.100000] Initializing cgroup subsys devices
[    0.100000] Initializing cgroup subsys freezer
[    0.100000] Initializing cgroup subsys blkio
[    0.110000] Initializing cgroup subsys perf_event
[    0.110000] CPU: Testing write buffer coherency: ok
[    0.120000] ftrace: allocating 14644 entries in 44 pages
[    0.140000] hw perfevents: enabled with v6 PMU driver, 3 counters available
[    0.150000] devtmpfs: initialized
[    0.150000] print_constraints: dummy: 
[    0.150000] NET: Registered protocol family 16
[    0.160000] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[    0.160000] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.170000] s3c64xx_dma_init: Registering DMA channels
[    0.170000] PL080: IRQ 73, at d0804000, channels 0..8
[    0.180000] PL080: IRQ 74, at d0806000, channels 8..16
[    0.180000] S3C6410: Initialising architecture
[    0.200000] bio: create slab <bio-0> at 0
[    0.200000] SCSI subsystem initialized
[    0.200000] usbcore: registered new interface driver usbfs
[    0.210000] usbcore: registered new interface driver hub
[    0.210000] usbcore: registered new device driver usb
[    0.220000] s3c-i2c s3c2440-i2c.0: slave address 0x10
[    0.220000] s3c-i2c s3c2440-i2c.0: bus frequency set to 64 KHz
[    0.230000] s3c-i2c s3c2440-i2c.0: i2c-0: S3C I2C adapter
[    0.230000] s3c-i2c s3c2440-i2c.1: slave address 0x10
[    0.240000] s3c-i2c s3c2440-i2c.1: bus frequency set to 64 KHz
[    0.240000] s3c-i2c s3c2440-i2c.1: i2c-1: S3C I2C adapter
[    0.290000] NET: Registered protocol family 2
[    0.290000] IP route cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.300000] TCP established hash table entries: 8192 (order: 4, 65536 bytes)
[    0.310000] TCP bind hash table entries: 8192 (order: 3, 32768 bytes)
[    0.310000] TCP: Hash tables configured (established 8192 bind 8192)
[    0.320000] TCP reno registered
[    0.320000] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.330000] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.340000] NET: Registered protocol family 1
[    0.340000] audit: initializing netlink socket (disabled)
[    0.340000] type=2000 audit(0.340:1): initialized
[    0.540000] VFS: Disk quotas dquot_6.5.2
[    0.540000] Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.550000] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.550000] fuse init (API version 7.16)
[    0.550000] msgmni has been set to 495
[    0.560000] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 253)
[    0.560000] io scheduler noop registered
[    0.570000] io scheduler deadline registered
[    0.570000] io scheduler cfq registered (default)
[    0.580000] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
[    0.580000] s3c6400-uart.0: ttySAC0 at MMIO 0x7f005000 (irq = 16) is a S3C6400/10
[    0.590000] s3c6400-uart.1: ttySAC1 at MMIO 0x7f005400 (irq = 20) is a S3C6400/10
[    0.600000] s3c6400-uart.2: ttySAC2 at MMIO 0x7f005800 (irq = 24) is a S3C6400/10
[    0.600000] s3c6400-uart.3: ttySAC3 at MMIO 0x7f005c00 (irq = 28) is a S3C6400/10
[    0.630000] brd: module loaded
[    0.630000] loop: module loaded
[    0.640000] S3C NAND Driver, (c) 2008 Samsung Electronics
[    0.640000] NandFlash is busying.........
[    0.640000] forlinx nandflash dev_id=d7
[    0.640000] forlinx****Nandflash:ChipType= MLC  ChipName=samsung-K9LBG08U0D************ 
[    0.650000] S3C NAND Driver is using hardware ECC.
[    0.660000] NAND device: Manufacturer ID: 0xec, Chip ID: 0xd7 (Samsung NAND 4GiB 3,3V 8-bit)
[    0.670000] Creating 4 MTD partitions on "NAND 4GiB 3,3V 8-bit":
[    0.670000] 0x000000000000-0x000000200000 : "Bootloader"
[    0.680000] 0x000000200000-0x000000700000 : "Kernel"
[    0.680000] 0x000000700000-0x00000cf00000 : "User"
[    0.710000] 0x00000cf00000-0x000100000000 : "File System"
[    1.020000] Fixed MDIO Bus: probed
[    1.020000] PPP generic driver version 2.4.2
[    1.030000] tun: Universal TUN/TAP device driver, 1.6
[    1.030000] tun: (C) 1999-2004 Max Krasnyansky <maxk@qualcomm.com>
[    1.040000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    1.050000] s3c2410-ohci s3c2410-ohci: S3C24XX OHCI
[    1.050000] s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1
[    1.060000] s3c2410-ohci s3c2410-ohci: irq 79, io mem 0x74300000
[    1.120000] s3c2410-ohci s3c2410-ohci: init err (00000000 0000)
[    1.120000] ohci_hcd: can't start s3c24xx
[    1.120000] s3c2410-ohci s3c2410-ohci: startup error -75
[    1.120000] s3c2410-ohci s3c2410-ohci: USB bus 1 deregistered
[    1.130000] s3c2410-ohci: probe of s3c2410-ohci failed with error -75
[    1.140000] mousedev: PS/2 mouse device common for all mice
[    1.140000] S3C24XX RTC, (c) 2004,2006 Simtec Electronics
[    1.150000] s3c-rtc s3c64xx-rtc: rtc disabled, re-enabling
[    1.150000] s3c-rtc s3c64xx-rtc: rtc core: registered s3c as rtc0
[    1.160000] i2c /dev entries driver
[    1.170000] device-mapper: ioctl: 4.20.0-ioctl (2011-02-02) initialised: dm-devel@redhat.com
[    1.170000] cpuidle: using governor ladder
[    1.180000] TCP cubic registered
[    1.180000] NET: Registered protocol family 10
[    1.190000] NET: Registered protocol family 17
[    1.190000] Registering the dns_resolver key type
[    1.200000] registered taskstats version 1
[    1.200000] s3c-rtc s3c64xx-rtc: setting system clock to 2023-01-15 21:54:19 UTC (1673819659)
[    1.210000] md: Waiting for all devices to be available before autodetect
[    1.210000] md: If you don't use raid, use raid=noautodetect
[    1.220000] md: Autodetecting RAID arrays.
[    1.220000] md: Scanned 0 and added 0 devices.
[    1.230000] md: autorun ...
[    1.230000] md: ... autorun DONE.
[    1.230000] yaffs: dev is 32505858 name is "mtdblock2" rw
[    1.240000] yaffs: passed flags ""
[    1.940000] s3c-nand: MLC8 1 bit(s) error detected, corrected successfully
[    4.010000] s3c-nand: MLC8 1 bit(s) error detected, corrected successfully
[    8.020000] s3c-nand: MLC8 1 bit(s) error detected, corrected successfully
[    9.080000] s3c-nand: MLC8 1 bit(s) error detected, corrected successfully
[    9.400000] s3c-nand: MLC8 1 bit(s) error detected, corrected successfully
[   12.460000] VFS: Mounted root (yaffs2 filesystem) on device 31:2.
[   12.460000] devtmpfs: mounted
[   12.460000] Freeing init memory: 228K
[   12.560000] s3c-nand: MLC8 1 bit(s) error detected, corrected successfully

Please press Enter to activate this console. 
[root@(none)]# date
Sun Jan 15 21:54:34 UTC 2023
[root@(none)]# ls
bin         etc         linuxrc     proc        sys         var
boot        home        lost+found  root        tmp
dev         lib         mnt         sbin        usr

六、几个严重错误

6.1  安全模型配置不正确

错误日志:

[    0.570000] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled
[    0.590000] s3c6400-uart.0: ttySAC0 at MMIO 0x7f005000 (irq = 16) is a S3C6400/10
[    0.590000] s3c6400-uart.1: ttySAC1 at MMIO 0x7f005400 (irq = 20) is a S3C6400/10
[    0.600000] s3c6400-uart.2: ttySAC2 at MMIO 0x7f005800 (irq = 24) is a S3C6400/10
[    0.610000] s3c6400-uart.3: ttySAC3 at MMIO 0x7f005c00 (irq = 28) is a S3C6400/10
[    0.620000] Unhandled fault: imprecise external abort (0xc06) at 0x00000000
[    0.620000] Internal error: : c06 [#1]
[    0.620000] Modules linked in:
[    0.620000] CPU: 0    Not tainted  (3.0.1 #1)
[    0.620000] PC is at request_locality+0x34/0x1c4
[    0.620000] LR is at init_tis+0xe0/0x5b0
[    0.620000] pc : [<c02e0be0>]    lr : [<c00264d0>]    psr: 20000013
[    0.620000] sp : cf85ff00  ip : cf85ff48  fp : cf85ff44
[    0.620000] r10: 00000000  r9 : c00263f0  r8 : c060e09c
[    0.620000] r7 : 00000000  r6 : c069d4a0  r5 : cf88fe00  r4 : 00000000
[    0.620000] r3 : 00000000  r2 : cccccccd  r1 : 00000000  r0 : cf88fe00
[    0.620000] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment kernel
[    0.620000] Control: 00c5387d  Table: 50004008  DAC: 00000017
[    0.620000] Process swapper (pid: 1, stack limit = 0xcf85e268)
[    0.620000] Stack: (0xcf85ff00 to 0xcf860000)
[    0.620000] ff00: c00263f0 00000000 cf85ff34 cf85ff18 c005102c c0050df4 c0026484 00000000
[    0.620000] ff20: cf88fe00 c069d4a0 cf88fd08 c060e09c c00263f0 00000000 cf85ff7c cf85ff48
[    0.620000] ff40: c00264d0 c02e0bb8 00000000 00000000 00000000 c0087880 c06234c0 00000000
[    0.620000] ff60: c002f3e8 00000013 cf85e000 00000000 cf85ffd4 cf85ff80 c00473a8 c00263fc
[    0.620000] ff80: c00afaac c00afb28 00000064 00000000 cf85ffb4 30310690 00000030 000000f6
[    0.620000] ffa0: cf85ffbc cf85ffb0 c00abcf8 c002f2dc c002eefc c002f3e8 00000013 00000000
[    0.620000] ffc0: 00000000 00000000 cf85fff4 cf85ffd8 c0008474 c0047370 00000000 c00083d4
[    0.620000] ffe0: c0069004 00000013 00000000 cf85fff8 c0069004 c00083e0 ffffffff ffffffff
[    0.620000] Backtrace: 
[    0.620000] [<c02e0bac>] (request_locality+0x0/0x1c4) from [<c00264d0>] (init_tis+0xe0/0x5b0)
[    0.620000] [<c00263f0>] (init_tis+0x0/0x5b0) from [<c00473a8>] (do_one_initcall+0x44/0x190)
[    0.620000] [<c0047364>] (do_one_initcall+0x0/0x190) from [<c0008474>] (kernel_init+0xa0/0x14c)
[    0.620000] [<c00083d4>] (kernel_init+0x0/0x14c) from [<c0069004>] (do_exit+0x0/0x774)
[    0.620000]  r7:00000013 r6:c0069004 r5:c00083d4 r4:00000000
[    0.620000] Code: e7d32601 e1a07601 e3a03000 ee073f9a (e20220a0) 

 解决办法:

在图形配置界面,去掉“Enable different security models”选项,使用默认的安全模型。

Security options  --->
        [ ] Enable different security models

6.2 未添加文件系统yaffs2

错误日志:

240 [    1.460000] VFS: Cannot open root device "mtdblock2" or unknown-block(31,2)
241 [    1.460000] Please append a correct "root=" boot option; here are the available partitions:
242 [    1.470000] 1f00            2048 mtdblock0  (driver?)
243 [    1.480000] 1f01            5120 mtdblock1  (driver?)
244 [    1.480000] 1f02          204800 mtdblock2  (driver?)
245 [    1.490000] 1f03         3982336 mtdblock3  (driver?)
246 [    1.490000] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)
247 [    1.500000] Backtrace:
248 [    1.500000] [<c004450c>] (dump_backtrace+0x0/0x114) from [<c0423298>] (dump_stack+0x20/0x24)
249 [    1.510000]  r7:00000013 r6:cf822000 r5:00008000 r4:cf85ff48
250 [    1.520000] [<c0423278>] (dump_stack+0x0/0x24) from [<c0423304>] (panic+0x68/0x1b4)
251 [    1.520000] [<c042329c>] (panic+0x0/0x1b4) from [<c0008f7c>] (mount_block_root+0x188/0x2c8)
252 [    1.530000]  r3:00000000 r2:cf80de74 r1:cf85ff48 r0:c04f98d0
253 [    1.540000] [<c0008df4>] (mount_block_root+0x0/0x2c8) from [<c0009110>] (mount_root+0x54/0x6c)
254 [    1.550000] [<c00090bc>] (mount_root+0x0/0x6c) from [<c0009248>] (prepare_namespace+0x120/0x1e4)
255 [    1.550000]  r5:c002a38c r4:c059e660
256 [    1.560000] [<c0009128>] (prepare_namespace+0x0/0x1e4) from [<c00084dc>] (kernel_init+0x108/0x14c)
257 [    1.570000]  r6:c0029968 r5:c00294c0 r4:c0029968
258 [    1.570000] [<c00083d4>] (kernel_init+0x0/0x14c) from [<c0061f44>] (do_exit+0x0/0x774)
259 [    1.580000]  r7:00000013 r6:c0061f44 r5:c00083d4 r4:00000000

解决办法:

在图形配置界面,勾选中“yaffs2 file system support”选项,内核支持yaffs2文件系统。

File systems  --->
    [*] Miscellaneous filesystems  --->
        <*>   yaffs2 file system support

6.3 yaffs2文件系统挂载失败

错误日志:

200 [    1.510000] yaffs: dev is 32505858 name is "mtdblock2" rw
201 [    1.510000] yaffs: passed flags ""
202 [    1.710000] VFS: Mounted root (yaffs2 filesystem) on device 31:2.
203 [    1.710000] devtmpfs: error mounting -2
204 [    1.720000] Freeing init memory: 296K
205 [    1.720000] Failed to execute /linuxrc.  Attempting defaults...
206 [    1.730000] Kernel panic - not syncing: No init found.  Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
207 [    1.740000] [<c0059998>] (unwind_backtrace+0x0/0x104) from [<c060098c>] (dump_stack+0x20/0x24)
208 [    1.750000] [<c060098c>] (dump_stack+0x20/0x24) from [<c06009f8>] (panic+0x68/0x1bc)
209 [    1.760000] [<c06009f8>] (panic+0x68/0x1bc) from [<c00525c4>] (init_post+0xd0/0x148)
210 [    1.760000] [<c00525c4>] (init_post+0xd0/0x148) from [<c0008480>] (kernel_init+0x10c/0x14c)
211 [    1.770000] [<c0008480>] (kernel_init+0x10c/0x14c) from [<c0053b44>] (kernel_thread_exit+0x0/0x8)

 解决办法:

制作yaffs2文件系统并烧录到开发板,可参考我的文章:嵌入式开发之linux根文件系统移植


总结

       从linux内核官网直接下载源码并移植,这个过程会经常遇到内核崩溃问题,需要我们学会定位问题点、分析问题及查找资料来解决问题,linux博大精深,内核移植只是迈出了第一步,加油!

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值