从这个网址上下载了latest stable kernel:linux-2.6.33.1
tar xvfj linux-2.6.33.1.tar.bz2 -C ./
cd linux-2.6.33.1
cp arch/arm/configs/at91sam9260ek_defconfig ./config
|
我们的文件系统是ramdisk+jffs2,
ramdisk文件系统的大小大概是1.4M左右,默认内核是支持ramdisk的,但是大小需要修改一下
make menuconfig
Device Drivers --> Block devices -- > Default RAM disk size
这个选项原来是8192,改成16384
|
还有一点知道我们的开发板和at91sam9260ek开发板的区别就是我们的flash是norflash,所以我们要把flash驱动添加进去,driver/mtd/maps/下都是各个具体flash的驱动,我们仿照cfi_flagadm.c来写自己的驱动
cp drivers/mtd/maps/cfi_flagadm.c drivers/mtd/maps/my_sst3201.c
|
主要就是该flash的起始地址,大小以及分区情况,最后我选择用jedec,我个人觉得cfi对sst的支持不好(或者说sst的cfi不够标准)。下面给出my_sst3201.c的代码
#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>
#define FLASH_PHYS_ADDR 0x10000000
#define FLASH_SIZE 0x400000
#define FLASH_PARTITION0_ADDR 0x00000000
#define FLASH_PARTITION0_SIZE 0x00030000
//#define FLASH_PARTITION1_ADDR 0x00030000
#define FLASH_PARTITION1_SIZE 0x001d0000
//#define FLASH_PARTITION2_ADDR 0x001a0000
#define FLASH_PARTITION2_SIZE 0x00180000
//#define FLASH_PARTITION3_ADDR 0x00380000
#define FLASH_PARTITION3_SIZE 0x00060000
//#define FLASH_PARTITION4_ADDR 0x003E0000
#define FLASH_PARTITION4_SIZE 0x00020000
struct map_info my_sst3201_map = {
.name = "sst3201 flash device",
.size = FLASH_SIZE,
.bankwidth = 2,
.phys = FLASH_PHYS_ADDR,
};
struct mtd_partition my_sst3201_parts[] = {
{
.name = "Bootloader",
.offset = FLASH_PARTITION0_ADDR,
.size = FLASH_PARTITION0_SIZE
},
{
.name = "Kernel image",
.offset = MTDPART_OFS_APPEND,
.size = FLASH_PARTITION1_SIZE
},
{
.name = "Initial ramdisk image",
.offset = MTDPART_OFS_APPEND,
.size = FLASH_PARTITION2_SIZE
},
{
.name = "jffs2 image",
.offset = MTDPART_OFS_APPEND,
.size = FLASH_PARTITION3_SIZE
},
{
.name = "perminant key",
.offset = MTDPART_OFS_APPEND,
.size = FLASH_PARTITION4_SIZE
}
};
#define PARTITION_COUNT ARRAY_SIZE(my_sst3201_parts)
static struct mtd_info *mymtd;
int __init init_my_sst3201(void)
{
printk(KERN_NOTICE "SST3201 flash device: %x at %x\n",
FLASH_SIZE, FLASH_PHYS_ADDR);
my_sst3201_map.phys = FLASH_PHYS_ADDR;
my_sst3201_map.virt = ioremap(FLASH_PHYS_ADDR,
FLASH_SIZE);
if (!my_sst3201_map.virt) {
printk("Failed to ioremap\n");
return -EIO;
}
simple_map_init(&my_sst3201_map);
// mymtd = do_map_probe("cfi_probe", &my_sst3201_map);
mymtd = do_map_probe("jedec_probe", &my_sst3201_map);
if (mymtd) {
mymtd->owner = THIS_MODULE;
add_mtd_partitions(mymtd, my_sst3201_parts, PARTITION_COUNT);
printk(KERN_NOTICE "SST3201 flash device initialized\n");
return 0;
}
else
{
printk(KERN_NOTICE "mymtd is null.\n");
}
iounmap((void *)my_sst3201_map.virt);
return -ENXIO;
}
static void __exit cleanup_my_sst3201(void)
{
if (mymtd) {
del_mtd_partitions(mymtd);
map_destroy(mymtd);
}
if (my_sst3201_map.virt) {
iounmap((void *)my_sst3201_map.virt);
my_sst3201_map.virt = 0;
}
}
module_init(init_my_sst3201);
module_exit(cleanup_my_sst3201);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Kári Davíðsson ");
MODULE_DESCRIPTION("MTD map driver for Flaga digital module")
|
然后再drivers/mtd/maps/Makefie中添加
obj-$(CONFIG_MTD_SST3201) += my_sst3201.o
|
在drivers/mtd/maps/Kconfig中添加
config MTD_SST3201
tristate "modify by eelb"
|
还有一点蛮奇怪drivers/mtd/chips/jedec.c中
把sst40lf080a那个信息去掉,因为这个芯片id是005b,3201是235b,所以不去掉会检测到前者。懒得查原因了。
都修改好了
make menuconfig里面
Device Drivers
先把mtd选上
然后进入mtd
把mtd partitioning support选上
然后再把mapping drivers for chip access里面选上modify by eelb
同时把ram/ROM/FLASH chip drivers 里面选上 jedec的选项,再把出现的amd的那个选上就可以了(sst的命令格式属于amd那类的)
|
最后要让内核支持jffs2,
file systems --> miscellaneous filesystems --> 找到jffs2选上
|
如果想要挂载nfs,同理需要配置内核支持
file systems --> network file systems里面
|
最后配置好了
make ARCH=arm CROSS_COMPILE=arm-linux- uImage
|
阅读(1787) | 评论(0) | 转发(0) |