博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
S3C2410上Jffs2的移植
阅读量:3515 次
发布时间:2019-05-20

本文共 12714 字,大约阅读时间需要 42 分钟。

2007-12-25 10:06:19
字体变小
字体变大

参照llg写的关于hharm(e28f128flash)上的jffs2的移植

具体如下:

1.移植环境:

CPU:ARMS3C2410
Linux version:2.4.18
Flash:Intel E28F128

2.修改设备号

由于ROM设备和MTDBlock设备的主设备号(major)都是31,所以如果你不想把JFFS2作为根文件系统的话,必须修改他们之一的major。如果你要修改JFFS2的设备major,在uClinux-dist/linux-2.4.x/include/linux/mtd/mtd.h中把
#define MTD_BLOCK_MAJOR 31
改成
#define MTD_BLOCK_MAJOR 30

3.编写Maps文件

添加在flash上的map文件。在HHARM2410-R3/kernel/drivers/mtd/maps下添加flash(e28f128j3a-150)的map,我把握的文件内容贴上,仅供参考:
S3c2410_wpq.c
/*
* Normal mappings of chips on Samsung s3c2410 in physical memory
*/
#include >linux/module.h<
#include >linux/types.h<
#include >linux/kernel.h<
#include >asm/io.h<
#include >linux/mtd/mtd.h<
#include >linux/mtd/map.h<
#include >linux/mtd/partitions.h<
#include >linux/config.h<
#define WINDOW_ADDR 0x01000000 //基地址
#define WINDOW_SIZE 0x01600000 //flash大小 16M
#define BUSWIDTH 2
static struct mtd_info *mymtd;
__u8 s3c2410_read8(struct map_info *map, unsigned long ofs)
{
return readb(map- }
__u16 s3c2410_read16(struct map_info *map, unsigned long ofs)
{
return readw(map- }
__u32 s3c2410_read32(struct map_info *map, unsigned long ofs)
{
return readl(map- }
void s3c2410_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
{
memcpy(to, (void *)(map- }
void s3c2410_write8(struct map_info *map, __u8 d, unsigned long adr)
{
writeb(d, map- }
void s3c2410_write16(struct map_info *map, __u16 d, unsigned long adr)
{
writew(d, map- }
void s3c2410_write32(struct map_info *map, __u32 d, unsigned long adr)
{
writel(d, map- }
void s3c2410_copy_to(struct map_info *map, unsigned long to, const void *from, ssize_t len)
{
memcpy((void *)(map- }
struct map_info s3c2410_map = {
name: "s3c2410 flash device",
size: WINDOW_SIZE,
buswidth: BUSWIDTH,
read8: s3c2410_read8,
read16: s3c2410_read16,
read32: s3c2410_read32,
copy_from: s3c2410_copy_from,
write8: s3c2410_write8,
write16: s3c2410_write16,
write32: s3c2410_write32,
copy_to: s3c2410_copy_to,
map_priv_1: WINDOW_ADDR,
map_priv_2: -1,
};
//以下是分区的内容,当然要根据你自己的需要确定了
static struct mtd_partition s3c2410_partitions[] = {
{
name: "reserved for bootloader",
size: 0x040000,
offset: 0x0,
mask_flags: MTD_WRITEABLE,
},
{
name: "reserved for kernel",
size: 0x0100000,
offset: 0x040000,
mask_flags: MTD_WRITEABLE,
},
{
name: "reserved for ramdisk",
size: 0x400000 offset: 0x140000,
mask_flags: MTD_WRITEABLE,
},
{
name: "jffs2(8M)",
size: 0x800000,
offset: 0x800000,
}
};
int __init init_s3c2410(void)
{
printk(KERN_NOTICE "s3c2410 flash device: %x at %x/n", WINDOW_SIZE, WINDOW_ADDR);
s3c2410_map.map_priv_1 = (unsigned long)ioremap(WINDOW_ADDR, WINDOW_SIZE);
//printk("0/n");
if (!s3c2410_map.map_priv_1) {
printk("Failed to ioremap/n");
return -EIO;
}
//printk("1/n");
mymtd = do_map_probe("jedec_probe", &s3c2410_map);
if (!mymtd)
mymtd = do_map_probe("cfi_probe", &s3c2410_map);
//printk("2/n");
if (mymtd) {
mymtd- mymtd- return add_mtd_partitions(mymtd, s3c2410_partitions, sizeof(s3c2410_partitions) / sizeof(struct mtd_partition));
}
//printk("3/n");
iounmap((void *)s3c2410_map.map_priv_1);
return -ENXIO;
}
static void __exit cleanup_s3c2410(void)
{
if (mymtd) {
del_mtd_partitions(mymtd);
map_destroy(mymtd);
}
if (s3c2410_map.map_priv_1) {
iounmap((void *)s3c2410_map.map_priv_1);
s3c2410_map.map_priv_1 = 0;
}
}
module_init(init_s3c2410);
module_exit(cleanup_s3c2410);
至于其文件内容及语句的含义网上相关的文章也有不少,参考一下吧。

4.将配置加入HHARM2410-R3/kernel/drivers/mtd/maps/Config.in

if [ "$CONFIG_ARM" = "y" ]; then
dep_tristate ' CFI Flash device mapped on ARM Integrator/P720T' CONFIG_MTD_ARM_INTEGRATOR $CONFIG_MTD_CFI $CONFIG_ARCH_INTEGRATOR
dep_tristate ' Cirrus CDB89712 evaluation board mappings' CONFIG_MTD_CDB89712 $CONFIG_MTD_CFI $CONFIG_ARCH_CDB89712
dep_tristate ' CFI Flash device mapped on StrongARM SA11x0' CONFIG_MTD_SA1100 $CONFIG_MTD_CFI $CONFIG_ARCH_SA1100 $CONFIG_MTD_PARTITIONS
dep_tristate ' CFI Flash device mapped on DC21285 Footbridge' CONFIG_MTD_DC21285 $CONFIG_MTD_CFI $CONFIG_ARCH_FOOTBRIDGE $CONFIG_MTD_PARTITIONS
dep_tristate ' CFI Flash device mapped on Lubbock board' CONFIG_MTD_LUBBOCK $CONFIG_MTD_CFI $CONFIG_ARCH_LUBBOCK $CONFIG_MTD_PARTITIONS
dep_tristate ' CFI Flash device mapped on the FortuNet board' CONFIG_MTD_FORTUNET $CONFIG_MTD_CFI $CONFIG_ARCH_FORTUNET $CONFIG_MTD_PARTITIONS
dep_tristate ' CFI Flash device mapped on Epxa10db' CONFIG_MTD_EPXA10DB $CONFIG_MTD_CFI $CONFIG_MTD_PARTITIONS $CONFIG_ARCH_CAMELOT
dep_tristate ' CFI Flash device mapped on PXA CerfBoard' CONFIG_MTD_PXA_CERF $CONFIG_MTD_CFI $CONFIG_ARCH_PXA_CERF $CONFIG_MTD_PARTITIONS
dep_tristate ' NV-RAM mapping AUTCPU12 board' CONFIG_MTD_AUTCPU12 $CONFIG_ARCH_AUTCPU12
#wpq add S3C2410 的CFI配置
dep_tristate ' CFI Flash device mapped on S3C2410' CONFIG_MTD_S3C2410 $CONFIG_MTD_CFI
fi

5. 修改Makefile文件

在HHARM2410-R3/kernel/drivers/mtd/maps/ Makefile文件中加入如下语句(当然要根据你的实际情况写啊?!):
#wpq add
obj-$(CONFIG_MTD_S3C2410) += s3c2410_wpq.o

6.配置内核使其支持jffs2

说明:
这里要特别注意Memory Technology Devices (MTD)的选项支持及其子项
RAM/ROM/Flash chip drivers ---<
Mapping drivers for chip access ---<
的选项支持;
还有File systems下选项支持。
##################################
***********************
#############################################
Linux Kernel v2.4.18-rmk7-pxa1 Configuration
Linux Kernel v2.4.18-rmk7-pxa1 Configuration
------------------------------------------------------------------------------
+-------------------- Memory Technology Devices (MTD) --------------------+
| Arrow keys navigate the menu. >Enter< selects submenus ---<. |
| Highlighted letters are hotkeys. Pressing >Y< includes, >N< excludes, |
| >M< modularizes features. Press >Esc<>Esc< to exit, >?< for Help. |
| Legend: [*] built-in [ ] excluded >M< module > < module capable |
| +---------------------------------------------------------------------+ |
| | >*< Memory Technology Device (MTD) support | |
| | [*] Debugging | |
| | (3) Debugging verbosity (0 = quiet, 3 = noisy) | |
| | >*< MTD partitioning support | |
| | >*< MTD concatenating support | |
| | > < RedBoot partition table parsing | |
| | > < Command line partition table parsing | |
| | > < ARM Firmware Suite partition parsing | |
| | --- User Modules And Translation Layers | |
| | >*< Direct char device access to MTD devices | |
| | >*< Caching block device access to MTD devices | |
| > < FTL (Flash Translation Layer) support | |
| | > < NFTL (NAND Flash Translation Layer) support | |
| | RAM/ROM/Flash chip drivers ---< | |
| | Mapping drivers for chip access ---< | |
| | Self-contained MTD device drivers ---< | |
| | NAND Flash Device Drivers ---< | |
| +---------------------------------------------------------------------+ |
+------------------------
| +---------v(+)--------------------------------------------------------+ |
+-------------------------------------------------------------------------+
| >Select< > Exit < > Help < |
+---------------------------------------------------
Linux Kernel v2.4.18-rmk7-pxa1 Configuration
------------------------------------------------------------------------------
+---------------------- RAM/ROM/Flash chip drivers -----------------------+
| Arrow keys navigate the menu. >Enter< selects submenus ---<. |
| Highlighted letters are hotkeys. Pressing >Y< includes, >N< excludes, |
| >M< modularizes features. Press >Esc<>Esc< to exit, >?< for Help. |
| Legend: [*] built-in [ ] excluded >M< module > < module capable |
| +---------------------------------------------------------------------+ |
| |>*< Detect flash chips by Common Flash Interface (CFI) probe | |
| |>*< Detect JEDEC JESD21c compatible flash chips | |
| |[ ] Flash chip driver advanced configuration options | |
| |>*< Support for Intel/Sharp flash chips | |
| |> < Support for AMD/Fujitsu flash chips | |
| |> < Support for RAM chips in bus mapping | |
| |> < Support for ROM chips in bus mapping | |
| |> < Support for absent chips in bus mapping | |
| |[ ] Older (theoretically obsoleted now) drivers for non-CFI chips | |
| | | |
| | | |
| +---------------------------------------------------------------------+ |
+-------------------------------------------------------------------------+
| >Select< > Exit < > Help < |
+-------------------------------------------------------------------------+
Linux Kernel v2.4.18-rmk7-pxa1 Configuration
------------------------------------------------------------------------------
+-------------------- Mapping drivers for chip access --------------------+
| Arrow keys navigate the menu. >Enter< selects submenus ---<. |
| Highlighted letters are hotkeys. Pressing >Y< includes, >N< excludes, |
| >M< modularizes features. Press >Esc<>Esc< to exit, >?< for Help. |
| Legend: [*] built-in [ ] excluded >M< module > < module capable |
| +---------------------------------------------------------------------+ |
| | >*< CFI Flash device in physical memory map | |
| | (800000) Physical start address of flash mapping | |
| | (800000) Physical length of flash mapping | |
| | (2) Bus width in octets | |
| | >*< CFI Flash device mapped on S3C2410 | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| +---------------------------------------------------------------------+ |
+-------------------------------------------------------------------------+
| >Select< > Exit < > Help < |
+-------------------------------------------------------------------------+
Linux Kernel v2.4.18-rmk7-pxa1 Configuration
------------------------------------------------------------------------------
+----------------------------- File systems ------------------------------+
| Arrow keys navigate the menu. >Enter< selects submenus ---<. |
| Highlighted letters are hotkeys. Pressing >Y< includes, >N< excludes, |
| >M< modularizes features. Press >Esc<>Esc< to exit, >?< for Help. |
| Legend: [*] built-in [ ] excluded >M< module > < module capable |
| +---------------------------------------------------------------------+ |
| | [ ] Quota support | |
| | > < Kernel automounter support | |
| | > < Kernel automounter version 4 support (also supports v3) | |
| | > < Reiserfs support | |
| | > < ADFS file system support | |
| | > < Amiga FFS file system support (EXPERIMENTAL) | |
| | > < Apple Macintosh file system support (EXPERIMENTAL) | |
| | > < BFS file system support (EXPERIMENTAL) | |
| | >*< Ext3 journalling file system support (EXPERIMENTAL) | |
| | [ ] JBD (ext3) debugging support | |
| | >*< DOS FAT fs support | |
| > < MSDOS fs support | |
| | >*< VFAT (Windows-95) fs support | |
| | > < EFS file system support (read only) (EXPERIMENTAL) | |
| | > < Journalling Flash File System (JFFS) support | |
| | >*< Journalling Flash File System v2 (JFFS2) support | |
| | (2) JFFS2 debugging verbosity (0 = quiet, 2 = noisy) | |
| | >*< Compressed ROM file system support | |
| | [*] Virtual memory file system support (former shm fs) | |
| | >*< Simple RAM-based file system support | |
| | > < ISO 9660 CDROM file system support | |
| | > < Minix fs support
| > < FreeVxFS file system support (VERITAS VxFS(TM) compatible) | |
| | > < NTFS file system support (read only) | |
| | > < OS/2 HPFS file system support | |
| | [*] /proc file system support | |
| | [*] /dev file system support (EXPERIMENTAL) | |
| | [*] Automatically mount at boot | |
| | [ ] Debug devfs | |
| | [*] /dev/pts file system for Unix98 PTYs | |
| | > < QNX4 file system support (read only) (EXPERIMENTAL) | |
| | > < ROM file system support | |
| | >*< Second extended fs support
| [ ] Debug devfs | |
| | [*] /dev/pts file system for Unix98 PTYs | |
| | > < QNX4 file system support (read only) (EXPERIMENTAL) | |
| | > < ROM file system support | |
| | >*< Second extended fs support | |
| | > < System V/Xenix/V7/Coherent file system support | |
| | > < UDF file system support (read only) | |
| | > < UFS file system support (read only) | |
| | Network File Systems ---< | |
| | Partition Types ---< | |
| | Native Language Support ---<
| +--v(+)---------------------------------------------------------------+ |
+-------------------------------------------------------------------------+
| >Select< > Exit < > Help < |
+-------------------------------------------------------------------------+

7.制作jffs2映象

首先取得jffs2的制作工具:mkfs.jffs2(可从网上取得)
执行如下命令即可生成所要的映象:
chmod 777 mkfs.jffs2 //取得mkfs.jffs2的执行权限,即mkfs.jffs2成为可执行文件
./mkfs.jffs2 -d jffs2/ -o jffs2.img //生成jffs2文件映象,其中目录jffs2可以是任意的目录,这里的jffs2是我新建的一个目录

8.Jffs2的应用

对于ppcboot、zImage、ramdisk.image.gz向romfs一样正常烧写;
以上三项烧写完之后,接着烧写jffs2.img,具体烧写如下:
tftp 30800000 jffs2.img
fl 1800000 30800000 20000 (其中20000可根据jffs2的大小适当调整,理论上只要比jffs2.img略大即可,但要为20000的整数倍)
特别注意:要想使我们做的jffs2文件系统更加的人性化,我们还可以在ramdisk.image.gz的mnt/etc/init.d/rc$文件中加入如下指令以便启动时自动挂载jffs2文件系统。
Mount -t jffs2 /dev/mtdblock/4 /mnt //其中的/dev/mtdblock/4是flash上的jffs2分区。

9.以上配置烧写完成之后就可启动我们的系统,对jffs2分区尽情的添加和删除了,添加的东东再不会因断电而丢失了,呵呵就到这了。

转载地址:http://ufiqj.baihongyu.com/

你可能感兴趣的文章
N1-Kali虚拟机中SQLmap
查看>>
N11-sql注入(http头注入)
查看>>
N2-sqlmap初使用
查看>>
N12-sql盲注原理以及boolean盲注案例实现
查看>>
N13-sqli盲注 基于时间型
查看>>
N1 技术心得 2019-6-26
查看>>
N1-环境配置
查看>>
N2-审计方法与步骤
查看>>
N3-常见的INI配置
查看>>
代码审计 N4 常见危险函数和特殊函数(一)
查看>>
MySQL笔记
查看>>
计算机运算方法之(原码 补码 反码 移码)
查看>>
计算机组成原理之(二进制与十进制互相转换,数的定点表示与浮点数表示)例题:设浮点数字长16位,其中阶码5位(含有1位阶符),尾数11位(含有1位数符)
查看>>
冒泡排序及其优化
查看>>
选择排序(java代码实现)
查看>>
插入排序
查看>>
哈夫曼树java代码实现
查看>>
快速排序
查看>>
vue路由高亮的两种方式
查看>>
vue router 报错: Uncaught (in promise) NavigationDuplicated {_name:""NavigationDuplicated"... 的解决方法
查看>>