歡迎您光臨本站 註冊首頁

在FS2410開發板上移植linux2.6.24初步成功

←手機掃碼閱讀     火星人 @ 2014-03-26 , reply:0

說是移植,也不太準確,因為linux2.6.24內核已經將s3c2410納入。在移植的時候只是需要做幾個小的改動以及幾個注意的地方。

一. 前言
使用的內核:linux2.6.24,http://www.kernel.org/pub/linux/kernel/v2.6/
使用的arm交叉編譯工具(4.2.0):http://www.codesourcery.com/gnu_toolchains/arm/download.html
環境:VMware中的Ubuntu 7.10

二. 移植
1. 修改MakeFile文件,確定arm平台以及使用的交叉編譯工具:
修改的文件:
linux-2.6.24/Makefile

修改的內容:

#ARCH ?= $(SUBARCH)
ARCH ?= arm
#CROSS_COMPILE ?=
CROSS_COMPILE ?= /usr/local/arm/arm-2007q3/bin/arm-none-linux-gnueabi-

2. 根據開發板修改NAND Flash初始化代碼:
修改的文件:
linux-2.6.24/arch/arm/plat-s3c24xx/common-smdk.c
說明:這一部分的修改與具體的開發板電路有關係

修改的內容:
/* NAND parititon from 2.4.18-swl5 */

static struct mtd_partition smdk_default_nand_part[] = {
[0] = {
.name = "boot", //= "Boot Agent",
.size = SZ_256K, //= SZ_16K,
.offset = 0,
},
[1] = {
.name = "kernel", //= "S3C2410 flash partition 1",
.offset = SZ_256K, //= 0,
.size = SZ_2M-SZ_256K, //= SZ_2M,
},
[2] = {
.name = "rootfs", //= "S3C2410 flash partition 2",
.offset = SZ_2M, //= SZ_4M,
.size = 30 * SZ_1M, //= SZ_4M,
},
[3] = {
.name = "ext-fs1", //= "S3C2410 flash partition 3",
.offset = SZ_32M, //= SZ_8M,
.size = SZ_16M, //= SZ_2M,
},
[4] = {
.name = "ext-fs2", //= "S3C2410 flash partition 4",
.offset = SZ_32M+SZ_16M, //= SZ_1M * 10,
.size = SZ_16M, //= SZ_4M,
},
/* [5] = {
.name = "S3C2410 flash partition 5",
.offset = SZ_1M * 14,
.size = SZ_1M * 10,
},
[6] = {
.name = "S3C2410 flash partition 6",
.offset = SZ_1M * 24,
.size = SZ_1M * 24,
},
[7] = {
.name = "S3C2410 flash partition 7",
.offset = SZ_1M * 48,
.size = SZ_16M,
}*/
};
參考資料:
yl2.6.8.1提供的內核源代碼
linux-2.6.8.1-zzm/drivers/mtd/nand/s3c2410_nand.c

static struct mtd_partition partition_info[] = {
{ name: "boot",
offset: 0,
size: SZ_256K },
{ name: "kernel",
offset: SZ_256K,
size: SZ_2M - SZ_256K },
{ name: "rootfs",
offset: SZ_2M,
size: 30 * SZ_1M },
{ name: "ext-fs1",
offset: SZ_32M,
size: SZ_16M },
{ name: "ext-fs2",
offset: SZ_32M + SZ_16M,
size: SZ_16M },
};

3. 增加devfs文件系統支持
linux2.6.24已經去掉devfs,為了內核支持devfs以及在啟動時並在/sbin/init運行之前能自動掛載/dev為devfs文件系統,修改fs的Kconfig文件。
linux-2.6.24/fs/Kconfig

修改的內容:
找到menu "Pseudo filesystems"
添加如下語句:
config DEVFS_FS
bool "/dev file system support (OBSOLETE)"
depends on EXPERIMENTAL
help
This is support for devfs, a virtual file system (like /proc) which
provides the file system interface to device drivers, normally found
in /dev. Devfs does not depend on major and minor number
allocations. Device drivers register entries in /dev which then
appear automatically, which means that the system administrator does
not have to create character and block special device files in the
/dev directory using the mknod command (or MAKEDEV script) anymore.

This is work in progress. If you want to use this, you *must* read
the material in , especially
the file README there.

Note that devfs no longer manages /dev/pts! If you are using UNIX98
ptys, you will also need to mount the /dev/pts filesystem (devpts).

Note that devfs has been obsoleted by udev,
<http://www.kernel.org/pub/linux/utils/kernel/hotplug/>.
It has been stripped down to a bare minimum and is only provided for
legacy installations that use its naming scheme which is
unfortunately different from the names normal Linux installations
use.

If unsure, say N.

config DEVFS_MOUNT
bool "Automatically mount at boot"
depends on DEVFS_FS
help
This option appears if you have CONFIG_DEVFS_FS enabled. Setting
this to 'Y' will make the kernel automatically mount devfs onto /dev
when the system is booted, before the init thread is started.
You can override this with the "devfs=nomount" boot option.

If unsure, say N.

config DEVFS_DEBUG
bool "Debug devfs"
depends on DEVFS_FS
help
If you say Y here, then the /dev file system code will generate
debugging messages. See the file
for more
details.

If unsure, say N.

4. 編譯內核
make menuconfig(這一部分比較麻煩,要根據自己的需要以及開發板的實際情況設定)
make zImage

5. 修改根文件系統
如不修改根文件系統,啟動時會提示「Warning: unable to open an initial console.」的錯誤信息。修改方法(根據FS2410使用手冊整理):
(1) 將yl2410_demo.cramfs 拷貝到任意目錄下
(2) 在該目錄下建立兩個文件:
mkdir chang
mkdir guo
(3) 將yl2410_demo.cramfs 掛接到chang 目錄(必須以root 身份登陸系統)
mount chang yl2410_demo.cramfs ?o loop
(4) 將chang 目錄下的內容壓縮
cd chang
tar ?cvf /chang 的上一級目錄/1.tar ./
這樣將在chang 的上一級目錄產生一個1.tar 的包
(5) 將包解壓到guo 目錄下。
umount chang ;卸載掛接
cd .. ;進入上一級目錄
mv 1.tar guo ;
cd guo ;
tar ?xvf 1.tar ;將打包的根文件系統的里的內容解壓
rm 1.tar

(6)轉到dev目錄
執行mknod console c 5 1
執行mknod null c 1 3

(7)轉到usr目錄
用剛編譯linux2.6.24內核的相應文件替換掉以下文件
|-- ov511.ko #位於linux-2.6.24/drivers/media/video/目錄
|-- ov511.o #位於linux-2.6.24/drivers/media/video/目錄
|-- sd_mod.ko #位於linux-2.6.24/drivers/scsi/目錄
|-- usb-storage.ko #位於linux-2.6.24/drivers/usb/storage/目錄
|-- usbvideo.ko #位於linux-2.6.24/drivers/media/video/usbvideo/目錄
|-- usbvideo.o #位於linux-2.6.24/drivers/media/video/usbvideo/目錄
`-- videodev.o #位於linux-2.6.24/drivers/media/video/目錄

說明:以上的文件能否生成根據在開始配置的情況決定。

(8)製作cramfs 根文件系統
先將mkcramfs 文件拷貝到guo 所在的目錄
在這個目錄下運行命令:
mkcramfs guo fs2410.cramfs
運行成功后,會在該目錄下生成fs2410.cramfs 根文件系統

6. 下載,燒錄,修改啟動參數,啟動
根據FS2410使用手冊下載、燒錄;先修改啟動參數為:root=1f02 init=/linuxrc console=ttySAC0,115200 devfs=mount display=sam320,主要是將原來的ttyS0改為ttySAC0(這是由於linux內核對串列口的改動);然後啟動即可。

三. 後記
為什麼說初步成功?因為在製作根文件系統時使用的是開發板自帶的,然後進行了簡單的修改。我嘗試自己使用BusyBox製作,可是總不能成功,總是提示」Failed to execute /linuxrc. Attempting defaults...「的錯誤,現在還沒有解決。

[火星人 ] 在FS2410開發板上移植linux2.6.24初步成功已經有465次圍觀

http://coctec.com/docs/linux/show-post-187004.html