新闻中心

EEPW首页>嵌入式系统>设计应用> real6410移植记录一

real6410移植记录一

作者: 时间:2016-11-10 来源:网络 收藏
配置开发板的NFS驱动和移植NandFlash驱动

开发板为华天正的real6410,选定的内核版本为linux-2.6.37,交叉工具链为开发板自带的。

本文引用地址://m.amcfsurvey.com/article/201611/317277.htm

1、修改Makefile

首先修改Makefile,对交叉工具和目标架构进行设置。具体如下:

-ARCH ?= $(SUBARCH)

-CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)

+ARCH ?=arm

+CROSS_COMPILE ?= arm-none-linux-gnueabi-

2、修改机器码

可以修改u-boot,也可以修改kernel,只要两者匹配即可。建议修改kernel的,因为内核的修改比较容易一些。

在u-boot/include/configs/smdk6410.h文件中:

#define MACH_TYPE 1626

在linux-2.6.37/arch/arm/tools/mach-types中修改如下:

-real6410 MACH_REAL6410 REAL6410 2990

+real6410 MACH_REAL6410 REAL6410 1626

3、进行NFS相关配置,并从NFS启动系统

设置启动方式:

setenv bootargs noinitrd root=/dev/nfs console=ttySAC0 nfsroot=192.168.1.10:/home/fantity/work/real6410/target/real6410_fs ip=192.168.1.20:192.168.1.10:192.168.1.1:255.255.255.0::eth0:on fbcon=rotate:1 init=/linuxrc

移植过程中需要配置NFS和相关的网络驱动,否则出现如下错误:

VFS: Cannot open root device "nfs" or unknown-block(0,255)

Please append acorrect "root=" boot option; here are the available partitions:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,255)

[ ] (unwind_backtrace+0x0/0xec) from [ ] (panic+0x54/0x174)

[ ] (panic+0x54/0x174) from [ ] (mount_block_root+0x25c/0x2ac)

[ ] (mount_block_root+0x25c/0x2ac) from [ ] (prepare_namespace+0x164/0x1bc)

[ ] (prepare_namespace+0x164/0x1bc) from [ ] (kernel_init+0x10c/0x14c)

[ ] (kernel_init+0x10c/0x14c) from [ ] (kernel_thread_exit+0x0/0x8)

相关的配置如下图所示,注意,NFS的配置选项必须在TCP/IP选择之后才可以看到。

[*] Networking support --->

Networking options --->

[*] TCP/IP networking

[*] IP: kernel level autoconfiguration

[*] IP: BOOTP support

Device Drivers --->

[*] Network device support --->

<*> PHY Device support and infrastructure --->

[*] Ethernet (10 or 100Mbit) --->

<*> DM9000 support

File systems --->

[*] Network File Systems --->

<*> NFS client support

[*] NFS client support for NFS version 3

[ ] NFS client support for the NFSv3 ACL protocol extension

[*] NFS client support for NFS version 4

[ ] NFS client support for NFSv4.1

[*] Root file system on NFS

4、Nand Flash配置

对arch/arm/mach-s3c64xx/mach-real6410.c作出如下修改:

static struct mtd_partition real6410_nand_part[] = {

[0] = {

- .name = "uboot",

- .size = SZ_1M,

- .offset = 0,

+ .name = "uboot",

+ .offset = 0,

+ .size = (256*SZ_1K),

+ .mask_flags = MTD_CAP_NANDFLASH,

},

[1] = {

- .name = "kernel",

- .size = SZ_2M,

- .offset = SZ_1M,

+ .name = "Kernel",

+ .offset = (256*SZ_1K),

+ .size = (4*SZ_1M) - (256*SZ_1K),

+ .mask_flags = MTD_CAP_NANDFLASH,

},

[2] = {

- .name = "rootfs",

- .size = MTDPART_SIZ_FULL,

- .offset = SZ_1M + SZ_2M,

+ .name = "cramfs",

+ .offset = (4*SZ_1M),

+ .size = (4*SZ_1M),

+ },

+ [3] = {

+ .name = "ubifs",

+ .offset = MTDPART_OFS_APPEND,

+ .size = MTDPART_SIZ_FULL,

},

};

将驱动s3c_nand.c、regs-nand.h文件拷贝到相应的目录drivers/mtd/nand/s3c_nand.c和arch/arm/plat-samsung/include/plat/regs-nand.h下。

同时修改文件drivers/mtd/nand/Kconfig

+config MTD_NAND_S3C

+ state "NAND Flash support for Samsung S3C SoCs"

+ depends on ARCH_S3C2410 || ARCH_S3C64XX

+ help

+ This enables the NAND flash controller on the S3C SoCs

+

+ No board specific support is done by this driver, each board

+ must advertise a platform_device for the driver to attach.

+

+config MTD_NAND_S3C_DEBUG

+ bool "Samsung S3C NAND driver debug"

+ depends on MTD_NAND_S3C

+ help

+ Enable debugging of the S3C NAND driver

+

+config MTD_NAND_S3C_HWECC

+ bool "Samsung S3C NAND Hardware ECC"

+ depends on MTD_NAND_S3C

+ help

+ Enable the use of the controllers internal ECC generator when

+ using NAND. Early versions of the chips have had problems with

+ incorrect ECC generation, and if using these, the default of

+ software ECC is preferable.

修改文件drivers/mtd/nand/Makefile

obj-$(CONFIG_MTD_NAND_S3C2410) += s3c2410.o

+obj-$(CONFIG_MTD_NAND_S3C) += s3c_nand.o

需要选择如下驱动配置:

Device Drivers --->

<*> Memory Technology Device (MTD) support --->

<*> NAND Device Support --->

<> NAND Flash support for Samsung S3C SoCs //不选

<*> NAND Flash support for S3C SoC

[*] S3C NAND Hardware ECC

[ ] S3C NAND driver debug

编译内核,出现如下错误:

drivers/built-in.o: In function `s3c_nand_probe:

/home/weimen/Work/realarm/lsp/kernel/real6410_linux-2.6.37/drivers/mtd/nand/s3c_nand.c:1192: undefined reference to `add_mtd_partitions

修改内核配置,make menuconfig,添加分区支持配置。

Device Drivers --->

<*> Memory Technology Device (MTD) support --->

[*] MTD partitioning support

系统启动,出现如下信息时,说明nand driver移植正常。

S3C NAND Driver, (c) 2008 Samsung Electronics

S3C NAND Driver is using hardware ECC.

NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung )

Creating 4 MTD partitions on "NAND 1GiB 3,3V 8-bit":

0x000000000000-0x000000040000 : "uboot"

0x000000040000-0x000000400000 : "Kernel"

0x000000400000-0x000000800000 : "cramfs"

0x000000800000-0x000040000000 : "ubifs"

根文件系统启动到最后,出现如下错误。

VFS: Unable to mount root fs via NFS, trying floppy.

VFS: Cannot open root device "mtdblock2" or unknown-block(2,0)

Please append a correct "root=" boot option; here are the available partitions:

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

[ ] (unwind_backtrace+0x0/0xec) from [ ] (panic+0x54/0x174)

[ ] (panic+0x54/0x174) from [ ] (mount_block_root+0x1d0/0x210)

[ ] (mount_block_root+0x1d0/0x210) from [ ] (mount_root+0xa0/0xc0)

[ ] (mount_root+0xa0/0xc0) from [ ] (prepare_namespace+0x164/0x1bc)

[ ] (prepare_namespace+0x164/0x1bc) from [ ] (kernel_init+0x10c/0x14c)

[ ] (kernel_init+0x10c/0x14c) from [ ] (kernel_thread_exit+0x0/0x8)

上面的问题在于没有配置好mtd的驱动,对驱动进行如下配置,下面分别表示可以将MTD设备当作字符设备和块设备进行操作。选择之后通过NFS挂载,在/dev/目录下出现mtdblock1、mtdblock2、mtdblock3、mtdblock4设备节点。

<*> Memory Technology Device (MTD) support --->

<*> Direct char device access to MTD devices

<*> Caching block device access to MTD devices

上面的配置完成后,出现如下错误:

end_request: I/O error, dev mtdblock2, sector 0

Buffer I/O error on device mtdblock2, logical block 0

s3c6400_setup_sdhci_cfg_card: CTRL 2=c0004100, 3=80808080

end_request: I/O error, dev mtdblock2, sector 0

Buffer I/O error on device mtdblock2, logical block 0

end_request: I/O error, dev mtdblock2, sector 8

Buffer I/O error on device mtdblock2, logical block 1

mmc0: mmc_rescan: trying to init card at 200000 Hz

end_request: I/O error, dev mtdblock2, sector 8

Buffer I/O error on device mtdblock2, logical block 1

end_request: I/O error, dev mtdblock2, sector 24

Buffer I/O error on device mtdblock2, logical block 3

s3c6400_setup_sdhci_cfg_card: CTRL 2=c0004100, 3=80808080

end_request: I/O error, dev mtdblock2, sector 24

Buffer I/O error on device mtdblock2, logical block 3

List of all partitions:

1f00 256 mtdblock0 (driver?)

1f01 3840 mtdblock1 (driver?)

1f02 4096 mtdblock2 (driver?)

1f03 1040384 mtdblock3 (driver?)

No filesystem could mount root, tried: cramfs

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)

[ ] (unwind_backtrace+0x0/0xec) from [ ] (panic+0x54/0x174)

[ ] (panic+0x54/0x174) from [ ] (mount_block_root+0x1d0/0x210)

[ ] (mount_block_root+0x1d0/0x210) from [ ] (mount_root+0xa0/0xc0)

[ ] (mount_root+0xa0/0xc0) from [ ] (prepare_namespace+0x164/0x1bc)

[ ] (prepare_namespace+0x164/0x1bc) from [ ] (kernel_init+0x10c/0x14c)

[ ] (kernel_init+0x10c/0x14c) from [ ] (kernel_thread_exit+0x0/0x8)

在网上查了下,说是要关闭Hard ECC,关闭之后又出现如下错误,可能是cramfs的问题,需要重新制作,这个问题后面再解决了。

List of all partitions:

1f00 256 mtdblock0 (driver?)

1f01 3840 mtdblock1 (driver?)

1f02 4096 mtdblock2 (driver?)

1f03 1040384 mtdblock3 (driver?)

No filesystem could mount root, tried: cramfs

Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,2)

[ ] (unwind_backtrace+0x0/0xec) from [ ] (panic+0x6c/0x188)

[ ] (panic+0x6c/0x188) from [ ] (mount_block_root+0x1d0/0x210)

[ ] (mount_block_root+0x1d0/0x210) from [ ] (mount_root+0xa0/0xc0)

[ ] (mount_root+0xa0/0xc0) from [ ] (prepare_namespace+0x158/0x1b0)

[ ] (prepare_namespace+0x158/0x1b0) from [ ] (kernel_init+0x10c/0x14c)

[ ] (kernel_init+0x10c/0x14c) from [ ] (kernel_thread_exit+0x0/0x8)

5、制作ubifs文件系统

先使用NFS挂载文件系统,使用如下配置:

setenv bootargs noinitrd root=/dev/nfs console=ttySAC0 nfsroot=192.168.1.115:/home/xx/Work/realarm/target/rootfs_cramfs ip=192.168.1.20:192.168.1.10:192.168.1.1:255.255.255.0::eth0:on fbcon=rotate:1 init=/linuxrc

使用ubifs文件系统,其中mtd3分区即为ubifs分区。使用如下命令将文件系统烧录进nand中。(注意需要关闭硬件ECC校验,否则/sbin/ubiattach /dev/ubi_ctrl -m 3会出错)。

且读取启动开发板时会出现如下错误:

UBI error: ubi_io_read: error -74 (ECC error) while reading 2048 bytes from PEB 547:2048, read 2048 bytes

UBI error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 548:0, read 64 bytes

使用命令/sbin/ubiattach /dev/ubi_ctrl -m 3,当出现如下错误时,说明ubifs文件系统未配置好。

ubiattach: error!: UBI is not present in the system

再次执行make menuconfig配置好ubifs文件系统

File systems --->

[*] Miscellaneous filesystems --->

<*> UBIFS file system support

新建一个文件夹rootfs_qtopia,将开发板所提供的源码包qtopia.tar.gz解压进去。同时解压源码包qtopia-2.2.0-Real6410.tar.bz2,并对其进行编译,执行./build命令。安装结果就在qtopia-2.2.0-Real6410/qtopia/image/opt目录。使用编译出来的qtopia-2.2.0-Real6410/qtopia/image/opt替换rootfs_qtopia/opt。打包成Qt文件系统

cd rootfs_qtopia/

$ /sbin/flash_eraseall /dev/mtd3

$ /sbin/ubiattach /dev/ubi_ctrl -m 3

$ /sbin/ubimkvol /dev/ubi0 -N rootfs -m

$ mount -t ubifs ubi0_0 /mnt/nfs

$ tar xvf /qtopia-2.2.0-Real6410.tar.bz2 -C /mnt/nfs/

$ sync

修改启动命令为:

setenv bootargs noinitrd mem=224M console=ttySAC0 init=/linuxrc ubi.mtd=3 root=ubi0:rootfs rootfstype=ubifs

如下是启动信息:

UBIFS: recovery completed

UBIFS: mounted UBI device 0, volume 0, name "rootfs"

UBIFS: file system size: 1034514432 bytes (1010268 KiB, 986 MiB, 4009 LEBs)

UBIFS: journal size: 33546240 bytes (32760 KiB, 31 MiB, 130 LEBs)

UBIFS: media format: w4/r0 (latest is w4/r0)

UBIFS: default compressor: lzo

UBIFS: reserved for root: 4952683 bytes (4836 KiB)

VFS: Mounted root (ubifs filesystem) on device 0:10.

Freeing init memory: 128K

hwclock: cant open /dev/misc/rtc: No such file or directory

amixer: Control default open error: No such file or directory

amixer: Control default open error: No such file or directory

/usr/sbin/alsactl: load_state:1236: No soundcards found...

Try to bring eth0 interface up....../etc/init.d/ifconfig-eth0: line 6: //ifconfig: not found

eth0: link up, 100Mbps, full-duplex, lpa 0x4DE1

Done

Now,starting the qtopia-2.2.0....

unifi_sdio: version magic 2.6.28.6 preempt mod_unload ARMv6 should be 2.6.37-gfb40001 preempt mod_unload ARMv6

insmod: cannot insert /lib/modules/2.6.28.6/unifi_sdio.ko: invalid module format

Please press Enter to activate this console. Cannot open touchscreen /dev/input/event1 (No such file or directory)

Mouse type intelliMouse:/dev/input/mice unsupported

Warning: could not register server

[root@Real6410 /]# pwd

/



关键词:real6410移植记

评论


技术专区

关闭