本文以 linux-3.0 內核移植到 S3C2440(mini2440)板子為例,把需要動到的檔案逐一列出。核心版本可從官方網站下載,.tar.bz2 格式用 tar -jxvf xx.tar.bz2 解開。
ARCH ?= arm CROSS_COMPILE ?=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-
console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7
檔案位置:u-boot-2010.09/board/lingyun/fl2440/fl2440.c
gpio->GPHUP = 0x000007FF; #if defined(CONFIG_FL2440) gd->bd->bi_arch_number = MACH_TYPE_MINI2440; #else gd->bd->bi_arch_number = MACH_TYPE_SMDK2410; #endif gd->bd->bi_boot_params = 0x30000100;
all: vmlinux cp arch/arm/boot/zImage . -f mkimage -A arm -O linux -T kernel -C none -a 30008000 -e 30008040 \ -n "Linux Kernel" -d zImage linuxrom-s3c2440.bin rm -f zImage
其中 mkimage 位於編譯好的 u-boot 的 tools 目錄下。
distclean: mrproper @find $(srctree) $(RCS_FIND_IGNORE) \ \( -name '*.orig' -o -name '*.rej' -o -name '*~' ... \) \ -type f -print | xargs rm -f @rm -f linuxrom-s3c2440.bin
arch/arm/mach-s3c2440/mach-smdk2440.c 中的 smdk2440_map_io():
s3c24xx_init_clocks(12000000);
drivers/tty/serial/samsung.c:
#define S3C24XX_SERIAL_NAME "ttyS"
cp arch/arm/configs/mini2440_defconfig .config make menuconfig
在 System Type → S3C2440 and S3C2442 Machines 中,勾選 SMDK2440 與 SMDK2440 with S3C2440 CPU module,其餘保持不選。
arch/arm/tools/mach-types 中確認 mini2440 對應 MACH_MINI2440、編號 362。
arch/arm/plat-s3c24xx/common-smdk.c 中的 smdk_default_nand_part[],依序規劃 bootloader(1M)、linux(15M)、rootfs(64M)、apps(80M)、data(48M)、info。
cp ~/fl2440/roofs/roof_tree.tar.bz2 ~/ciel/fl2440/roors make menuconfig # General setup → Initial RAM filesystem and RAM disk support # Initramfs source file(s) 填入 /opt/roofs
在 mach-smdk2440.c 中引入 <linux/dm9000.h>,並補上資源結構、平台資料與 platform_device:
#define DM9000_BASE (S3C2410_CS4 + 0x300)
static struct resource s3c_dm9000_resource[] = { ... };
static struct dm9000_plat_data s3c_dm9000_pdata = {
.flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};
static struct platform_device s3c_device_dm9000 = { .name = "dm9000", ... };再把 &s3c_device_dm9000 加進 smdk2440_devices[] 陣列。
重新 make 之後,開機即可用 ifconfig 確認網卡、ping 通閘道,之後就能用 tftp 把檔案灌進開發板,內核移植到此完成。