由于要准备linux内核升级,首先要先将原来2.6.16版本的内核移植到2.6.16.13版本上,由于以前并没有进行过类似的操作,故此次首先按照前辈们的做法先来练练。
1、首先参考阿虚师兄的2.16.16版本的移植方法:
下载里面的压缩包,并按照里面的步骤来进行操作至第三步。
在第四步:
修改 /arch/arm/Kconfig文件
第95行 添加:
config ARCH_SEP4020
bool "sep4020"
help
Support for Southeast University sep4020 boards.
第 258 行 添加:
source "arch/arm/mach-sep4020/Kconfig"
第五步:
修改 /arch/arm/Makefile文件
第 94 行 添加:
machine-$(CONFIG_ARCH_SEP4020) := sep4020
第六步:
修改 /arch/arm/mm/Kconfig
第 45 行 替换所有arm720t内容:
# ARM720T
config CPU_ARM720T
bool "Support ARM720T processor" if !ARCH_CLPS711X && !ARCH_SEP4020 && !ARCH_L7200 && !ARCH_CDB89712 && ARCH_INTEGRATOR
default y if ARCH_CLPS711X || ARCH_L7200 || ARCH_CDB89712 || ARCH_H720X ||ARCH_SEP4020
select CPU_32v4
select CPU_ABRT_LV4T
select CPU_CACHE_V4
select CPU_CACHE_VIVT
select CPU_COPY_V4WT
select CPU_TLB_V4WT
help
A 32-bit RISC processor with 8kByte Cache, Write Buffer and
MMU built around an ARM7TDMI core.
Say Y if you want support for the ARM720T processor.
Otherwise, say N.
第七步:
修改/arch/arm/tools/mach-types
最后一行添加
sep4020 ARCH_4020 GFD4020 194
修改第 211 行i519 ARCH_I519 I519 1940
第八步:
复制sep4020_defconfig到arch/arm/configs中
第九步: 执行make sep4020_defconfig 套用默认内核配置
第十步: 执行make编译内核
在编译时会发生错误:
CC arch/arm/mach-sep4020/irq.o
arch/arm/mach-sep4020/irq.c:35: error: variable ‘sep4020_chip’ has initializer but incomplete type
arch/arm/mach-sep4020/irq.c:37: error: unknown field ‘ack’ specified in initializer
arch/arm/mach-sep4020/irq.c:37: warning: excess elements in struct initializer
arch/arm/mach-sep4020/irq.c:37: warning: (near initialization for ‘sep4020_chip’)
arch/arm/mach-sep4020/irq.c:38: error: unknown field ‘mask’ specified in initializer
arch/arm/mach-sep4020/irq.c:38: warning: excess elements in struct initializer
arch/arm/mach-sep4020/irq.c:38: warning: (near initialization for ‘sep4020_chip’)
arch/arm/mach-sep4020/irq.c:39: error: unknown field ‘unmask’ specified in initializer
arch/arm/mach-sep4020/irq.c:39: warning: excess elements in struct initializer
arch/arm/mach-sep4020/irq.c:39: warning: (near initialization for ‘sep4020_chip’)
arch/arm/mach-sep4020/irq.c: In function ‘sep4020_init_irq’:
arch/arm/mach-sep4020/irq.c:54: error: ‘handle_level_irq’ undeclared (first use in this function)
arch/arm/mach-sep4020/irq.c:54: error: (Each undeclared identifier is reported only once
arch/arm/mach-sep4020/irq.c:54: error: for each function it appears in.)
arch/arm/mach-sep4020/irq.c:55: warning: passing argument 2 of ‘set_irq_chip’ from incompatible pointer type
make[1]: *** [arch/arm/mach-sep4020/irq.o] Error 1
make: *** [arch/arm/mach-sep4020] Error 2
第十一步:
修改arch/arm/mach-sep4020/irq.c
第 35 行:修改为
static struct irqchip sep4020_chip= //irqchip kyon
第 54 行:修改为
set_irq_handler(i, do_level_IRQ);
此时编译会出现:
In file included from arch/arm/mach-sep4020/time.c:7:
include/linux/irq.h:94:55: error: asm/hw_irq.h: No such file or directory
arch/arm/mach-sep4020/time.c: In function ‘sep4020_timer_interrupt’:
arch/arm/mach-sep4020/time.c:30: error: too few arguments to function ‘timer_tick’
arch/arm/mach-sep4020/time.c: At top level:
arch/arm/mach-sep4020/time.c:39: error: ‘IRQF_DISABLED’ undeclared here (not in a function)
arch/arm/mach-sep4020/time.c:39: error: ‘IRQF_TIMER’ undeclared here (not in a function)
arch/arm/mach-sep4020/time.c:39: error: ‘IRQF_IRQPOLL’ undeclared here (not in a function)
make[1]: *** [arch/arm/mach-sep4020/time.o] Error 1
make: *** [arch/arm/mach-sep4020] Error 2
第十一步:
修改arch/arm/mach-sep4020/time.c
第 30 行:修改为
timer_tick(regs);
第 39 行:修改为:
.flags = SA_INTERRUPT | SA_TIMER,
删除掉 第 7 行:
此时编译会出现:
LD arch/arm/boot/compressed/vmlinux
arch/arm/boot/compressed/misc.o: In function `error':
misc.c:(.text+0x3f0): undefined reference to `putstr'
misc.c:(.text+0x3f8): undefined reference to `putstr'
misc.c:(.text+0x404): undefined reference to `putstr'
arch/arm/boot/compressed/misc.o: In function `flush_window':
misc.c:(.text+0xd44): undefined reference to `putstr'
arch/arm/boot/compressed/misc.o: In function `decompress_kernel':
misc.c:(.text+0x2b1c): undefined reference to `putstr'
arch/arm/boot/compressed/misc.o:misc.c:(.text+0x2b2c): more undefined references to `putstr' follow
make[2]: *** [arch/arm/boot/compressed/vmlinux] Error 1
make[1]: *** [arch/arm/boot/compressed/vmlinux] Error 2
make: *** [zImage] Error 2
第十二步:
修改 include/asm/arch/uncompress.h
第 20 行以下全部替换为:
#include
#include
#include
/*
* This does not append a newline
*/
static void putstr(const char *s)
{
char c;
while ((c = *s++) != '\0')
{
while(!((*(volatile unsigned char *)(0x10005014))& 0x40)); /*deleted by shixq*/
*(volatile unsigned long*)UART0_TXFIFO = (int)c;
if (c == '\n')
{
while(!((*(volatile unsigned char *)(0x10005014))& 0x40)); /*deleted by shixq*/
*(volatile unsigned long*)UART0_TXFIFO = (int)('\r');
}
}
}
/*
* nothing to do
*/
#define arch_decomp_setup()
#define arch_decomp_wdog()
此时编译,通过生成zImage文件。
下面挂载 ramfs 镜像:
第十三步:
在我的目录下执行以下操作:
# mkdir initrd
#dd if=/dev/zero of=initrd.img bs=1k count=3072
# mke2fs -F -v -m0 initrd.img
# mount -o loop initrd.img initrd
# cp -av nfs/* initrd
# umount initrd
# gzip -9 initrd.img
这样我就在当前目录下得到了一个名为initrd.img.gz的ramdisk的文件系统镜像(看来它是一个压缩的镜像),这个镜像在下面我们会用到的。
第十四步:
制作内核和文件系统同一的镜像bootpImage:
a、在device driver中进入block device中选中中间四个
b、进入file system中,选中ext2文件系统的支持。
c、如果你是一般挂载ramdisk文件系统你还得在Boot options--->中填上自己的启动参数
root=/dev/ram0 console=ttyS0,115200 initrd=0x31000000,0x300000 其中:
root=/dev/ram0:使用RAMFS
console=ttyS0,115200:默认控制台为串口0,使用115200的波特率
initrd=0x31000000,0x300000:RAMFS文件系统位于0x31000000处,大小为3M
保存配置并退出。
步骤二:编译内核,并将文件系统映像编译进去make bootpImage INITRD_PHYS=0x31000000 INITRD=/home/yourenpa/initrd.img.gz PARAMS_PHYS=0x30000100
其中:
make:编译指令
bootpImage:编译选项,固定
INITRD_PHYS=0x31000000:RAMFS文件系统的位置,与bootargs对应(FP的文章里有不对应的小错误)
INITRD=/home/yourenpa/initrd.img.gz:RAMFS映像在PC上的位置,就是楼主生成的Image
PARAMS_PHYS=0x30000100:Bootargs的位置,这句感觉有点没必要,bootm引导内核的时候会传参数
此时就会生成我们所需要的bootpImage文件,路径为:arch/arm/boot/bootpImage。步骤三:运行内核
修改板子的bootatgs参数:
SEP4020=>set bootargs root=/dev/ram0 rw console=ttyS0,115200 initrd=0x31000000,0x300000 mem=32mb
这因为使用bootm时会将bootargs传参到内核,所以尽管在内核中指定的默认的参数,但有可能会被忽略掉,最好还是修改一下bootargs。
SEP4020=>set bootcmd tftp 30008000 bootpImage\; bootm 30008000
SEP4020=>save
重启开发板,效果如下图:
ramfs 挂载成功。