第一部分
1.解压缩内核清理内核(先安装交叉编译器)
tarzxvf linux-2.6.39.tar.gz -C .
cdlinux-2.6.39
makemrproper ;
viMakefile ,注释SUBARCH,修改ARCH和Complie
2. cparch/arm/configs/s3c2410_defconfig .config
3. makemenuconfig
1.关闭内核Power management options 选项
它可能引起内核 bootingthe kernel 卡死
2.Bootoptions
default kernel command string
initrd=0x30800000,0x400000mem=64M root=/dev/ram rw init=/linuxrc console=ttySAC0,115200(一定不要写错,否则如现象1)
勾选Always use the default kernelcommand string
3.DeviceDrivers-->LED Support 取消所有选项,因为编译时程序有错误。
4.内核添加dm9000 支持
5.KernelFeatures -->开启Use theARM EABI to compile the kernel
兼容root 根文件系统EABI 编译的
6.DeviceDrivers -->Block devices 修改DefaultRAM disk size为8192
4.arch/arm/boot/Makefile添加zImage 拷贝
$(obj)/zImage: $(obj)/compressed/vmlinuxFORCE
$(callif_changed,objcopy)
@echo' Kernel: $@ is ready'
cparch/arm/boot/zImage /tftpboot -f
5.打开arch/arm/mach-s3c2410/smdk2410.c
发现内核配置中没有关于DM9000的配置,于是找了下其他文件,发现mach-mini2440.c里有dm9000的配置代码,于是华丽得Ctrl+C,Ctrl+V。添加修改,参照开发板CS1,INT0
//addby kerson
#include<linux/dm9000.h>
#defineMACH_SMDK2410_DM9K_BASE (S3C2410_CS1+ 0x300)
/*DM9000AEP 10/100 ethernet controller */
staticstruct resource s3c_dm9k_resource[] = {
[0] = {
.start =MACH_SMDK2410_DM9K_BASE,
.end =MACH_SMDK2410_DM9K_BASE + 3,
.flags = IORESOURCE_MEM
},
[1] = {
.start =MACH_SMDK2410_DM9K_BASE + 4,
.end =MACH_SMDK2410_DM9K_BASE + 7,
.flags = IORESOURCE_MEM
},
[2] = {
.start =IRQ_EINT0,
.end = IRQ_EINT0,
.flags = IORESOURCE_IRQ |IORESOURCE_IRQ_HIGHEDGE,
}
};
/*
*The DM9000 has no eeprom, and it's MAC address is set by
*the bootloader before starting the kernel.
*/
staticstruct dm9000_plat_data s3c_dm9k_pdata = {
.flags =(DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
};
staticstruct platform_device s3c_device_eth = {
.name = "dm9000",
.id = -1,
.num_resources =ARRAY_SIZE(s3c_dm9k_resource),
.resource = s3c_dm9k_resource,
.dev = {
.platform_data =&s3c_dm9k_pdata,
},
};
staticstruct platform_device *s3c_devices[] __initdata = {
&s3c_device_ohci,
// &s3c_device_lcd,
&s3c_device_wdt,
&s3c_device_i2c0,
// &s3c_device_iis,
&s3c_device_eth,
};
-
6.viarch/arm/plat-s3c24xx/irq.c
在void __inits3c24xx_init_irq(void) 函数末尾添加
//add by kerson__raw_writel(__raw_readl(S3C2410_INTMOD)&(~1),S3C2410_INTMOD);
解决dm9000 网卡ifconfigeth0 up 死机问题,是由于ppcboot将int0初始化为fiq模式,导致request_irq中断申请卡死
7.make 内核制作完成
第二部分 制作root文件系统
1.制作ramdisk.image根文件系统—busy-1.18.5
1.tar-jxvf busybox-1.18.5.tar.bz2 -C .
Makefile修改ARCH和CROSS_COMPILE
3.makemenuconfig
1.BusyboxSettings – >
Build Options – >
[*]Buid BusyBox as a static binary (no shared libs)
4make install
在busybox 根文件下有个_install文件夹下有生成的根文件系统
1.sudocp -r /dev _install/ 复制dev文件,裁剪dev文件
mkdir proc
2.制作ext2ramdisk,
ddif=/dev/zero of=ramdisk.image bs=1024 count=8192
mke2fsramdisk.image
sudomount -o loop ramdisk.image /mnt
sudocp -r _install/* /mnt/
sudoumount /mnt
gzipramdisk.image
sudocp ramdisk.image.gz /tftpboot
sudochmod 777 -R /tftpboot
第三部分 ppcboot
1.sudo apt-get install binutils-dev 安装开发库包,否则缺少头文件
使用 opt/host/armv4l/include/bfd.h和ansidecl.h到/usr/include 否则会出现process_section 结构体不存在成员
2.make distclean
make smdk2410_config
make
3.修改 lib_arm/armlinux.c ,bootm 复制内核地址增大
#if10
/*copy kernel and ramdisk from FLASH to SDRAM add by HHTECH*/
ret = memcpy((void *)0x30008000, (void *)0x40000, 0x400000);
If(ret != (void *)0x30008000)
printf("copy kernel failed\n");
else
printf("copy kernel done\n");
#endif
#ifdefRAMDISK
ret = memcpy((void *)0x30800000, (void *)0x440000, 0x800000);
if(ret != (void *)0x30800000)
printf("haha failed\n");
else
printf("copy ramdisk done\n");
#endif
40000| |
| 40 0000 | kernel
440000| |
| 80 0000 | ramdisk
第四部分
1.initrd
2.ramfs使用
使用initramfs的内核配置(使用initramfs做根文件系统):
------------------------------------------------------
Generalsetup --->
[*] Initial RAM filesystem and RAM disk(initramfs/initrd) support
(/rootfs_dir) Initramfs source file(s)//输入根文件系统的所在目录
/home/kerson/ramdisk/
使用initramfs的内核启动参数
不需要"initrd="和"root="参数,但是必须在initramfs中创建/init文件或者修改内核启动最后代码(init文件是软连接,指向什么?init -> bin/busybox,否则内核启动将会失败)
commandline:init=/linuxrc console=ttySAC0,115200
注意 再次编译内核会出现多个目标匹配错误,需要重新替换usr目录编译,还未解决
3.tmpfs一般不做根文件系统
4.nfs
1.Bootoptions-->Default kernel command string
root=/dev/nfsrw nfsroot=192.168.1.56:/armnfs,rsize=1500,wsize=1500ip=192.168.1.199 mem=64M console=ttySAC0(增加rsize和wsize,否则会出现notresponding)
init=/linuxrc
2.Filesystems-- >Network File Systems
NFS Client support(全选)
Root file system on NFS
3.Networkingsupport-- >
Networkingoptions -->IP:kernellevel autoconfiguration
5.norflash jffs2
1.制作jffs2文件系统
sudoapt-get install mtd-utils 安装mtd套件
mkfs.jffs2 -d /armnfs -o jffs2.img
将jffs2.img 通过ppcboot烧写到正确扇区
文件系统中记得添加
#mkdir mtdblock
# cd mtdblock
# mknod -m 666 0 b 31 0
#mknod -m 666 1 b 31 1
# mknod -m 666 2 b 31 2
# mknod -m666 3 b 31 3
2.添加内核选项
随便在maps中找一个都可以拿来改改用的,不过方便一点还是提供一份源码好了
这个驱动是for Intel E28F128J3A-150 on s2c2410的,不同的芯片就需修改一些参数了
当然需要在drivers/mtd/maps/Kconfig中添加选项
#addby kerson
configMTD_S3C2410
tristate"CFI Flash device mapped on ARM S3C2410 "
dependson MTD_CFI && ARCH_SMDK2410 && MTD_PARTITIONS
help
This provides a driver for the NOR flash attached to a S3C2410 chip.
再makefile中添加
#addby kerson
obj-$(CONFIG_MTD_S3C2410) +=s3c2410.o
在maps中添加文件s3c2410.c
/*maps driver for Intel E28F128J3A-150 on s2c2410 */
#include<linux/module.h>
#include<linux/types.h>
#include<linux/kernel.h>
#include<linux/init.h>
#include<asm/io.h>
#include<linux/mtd/mtd.h>
#include<linux/mtd/map.h>
#include<linux/mtd/partitions.h>
#defineFLASH_PHYS_ADDR 0x00000000
#defineFLASH_SIZE 0x01000000
#defineFLASH_PARTITION0_ADDR 0x00000000
#defineFLASH_PARTITION0_SIZE 0x00040000
#defineFLASH_PARTITION1_ADDR 0x00040000
#defineFLASH_PARTITION1_SIZE 0x00400000
#defineFLASH_PARTITION2_ADDR 0x00440000
#defineFLASH_PARTITION2_SIZE 0x00800000
#defineFLASH_PARTITION3_ADDR 0x00c40000
#defineFLASH_PARTITION3_SIZE 0x003c0000
structmap_info s3c2410_map = {
.name= "s3c2410 NOR flash Intel E28F128J3A",
.size= FLASH_SIZE,
.bankwidth= 2,
.phys= FLASH_PHYS_ADDR,
};
structmtd_partition s3c2410_parts[] = {
{
.name= "Bootloader",
.offset= FLASH_PARTITION0_ADDR,
.size= FLASH_PARTITION0_SIZE,
.mask_flags= MTD_WRITEABLE //禁止写
},
{
.name= "Kernel",
.offset= FLASH_PARTITION1_ADDR,
.size= FLASH_PARTITION1_SIZE,
.mask_flags= MTD_WRITEABLE
},
{
.name= "Jffs2",
.offset= FLASH_PARTITION2_ADDR,
.size= FLASH_PARTITION2_SIZE,
},
/*{
.name= "Jffs2",
.offset= FLASH_PARTITION3_ADDR,
.size= FLASH_PARTITION3_SIZE
}*/
};
#definePARTITION_COUNT (sizeof(s3c2410_parts)/sizeof(struct mtd_partition))
staticstruct mtd_info *mymtd;
int__init init_s3c2410(void)
{
printk(KERN_NOTICE"s3c2410 flash device: %x at %x\n",FLASH_SIZE,FLASH_PHYS_ADDR);
s3c2410_map.phys= FLASH_PHYS_ADDR;
s3c2410_map.virt= ioremap(FLASH_PHYS_ADDR,FLASH_SIZE);
if(!s3c2410_map.virt) {
printk("Failedto ioremap\n");
return-EIO;
}
simple_map_init(&s3c2410_map);
mymtd= do_map_probe("cfi_probe", &s3c2410_map);
if(mymtd) {
mymtd->owner= THIS_MODULE;
mymtd->erasesize=0x20000;
add_mtd_partitions(mymtd,s3c2410_parts, PARTITION_COUNT);
printk(KERN_NOTICE"s3c2410 flash device initialized\n");
return0;
}
iounmap((void*)s3c2410_map.virt);
return-ENXIO;
}
staticvoid __exit cleanup_s3c2410(void)
{
if(mymtd) {
del_mtd_partitions(mymtd);
map_destroy(mymtd);
}
if(s3c2410_map.virt) {
iounmap((void*)s3c2410_map.virt);
s3c2410_map.virt= 0;
}
}
module_init(init_s3c2410);
module_exit(cleanup_s3c2410);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Dansen");
MODULE_DESCRIPTION("MTDmap driver for S3C2410");
完成文件的添加
3.makemenuconfig
DeviceDrivers-- >
MemoryTechnology Devices(MTD)-->
<*>Memory Technology Device (MTD) support
[*]MTD partitioning support
<*>Caching block device access to MTD devices
RAM/ROM/Flash chip drivers-->
<*>Detect flash chips by Common Flash Interface (CFI)probe
<*>Support for Inter/Sharp flash chips
Mapping drivers for chip access-->
<*>CFI flash device mapped on S3C2410
Miscellaneous filesystems-->
<*>Journalling Flash File System v2 (JFFS2) support
当然内核配置需要添加
Filesystems --->
<*> Kernelautomounter support
记得配置内核ARMEABI compile the kernel
添加内核 commandline:
root=/dev/mtdblock2rw rootfstype=jffs2init=/linuxrc mem=64M console=ttySAC0,115200