Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OS
U-Boot.Mirror
提交
1a7f8cce
U
U-Boot.Mirror
项目概览
OS
/
U-Boot.Mirror
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
U-Boot.Mirror
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
1a7f8cce
编写于
8月 27, 2008
作者:
K
Kyungmin Park
提交者:
Wolfgang Denk
9月 06, 2008
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add JFFS2 command support on OneNAND
Signed-off-by:
N
Kyungmin Park
<
kyungmin.park@samsung.com
>
上级
f5c3ba79
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
187 addition
and
9 deletion
+187
-9
common/cmd_jffs2.c
common/cmd_jffs2.c
+63
-6
fs/jffs2/jffs2_1pass.c
fs/jffs2/jffs2_1pass.c
+118
-0
include/jffs2/load_kernel.h
include/jffs2/load_kernel.h
+6
-3
未找到文件。
common/cmd_jffs2.c
浏览文件 @
1a7f8cce
...
...
@@ -51,7 +51,7 @@
* mtdids=<idmap>[,<idmap>,...]
*
* <idmap> := <dev-id>=<mtd-id>
* <dev-id> := 'nand'|'nor'<dev-num>
* <dev-id> := 'nand'|'nor'
|'onenand'
<dev-num>
* <dev-num> := mtd device number, 0...
* <mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
*
...
...
@@ -103,6 +103,13 @@
#include <nand.h>
#endif
/* !CONFIG_NAND_LEGACY */
#endif
#if defined(CONFIG_CMD_ONENAND)
#include <linux/mtd/mtd.h>
#include <linux/mtd/onenand.h>
#include <onenand_uboot.h>
#endif
/* enable/disable debugging messages */
#define DEBUG_JFFS
#undef DEBUG_JFFS
...
...
@@ -400,6 +407,43 @@ static int part_validate_nand(struct mtdids *id, struct part_info *part)
#endif
}
/**
* Performs sanity check for supplied OneNAND flash partition.
* Table of existing OneNAND flash devices is searched and partition device
* is located. Alignment with the granularity of nand erasesize is verified.
*
* @param id of the parent device
* @param part partition to validate
* @return 0 if partition is valid, 1 otherwise
*/
static
int
part_validate_onenand
(
struct
mtdids
*
id
,
struct
part_info
*
part
)
{
#if defined(CONFIG_CMD_ONENAND)
/* info for OneNAND chips */
struct
mtd_info
*
mtd
;
mtd
=
&
onenand_mtd
;
if
((
unsigned
long
)(
part
->
offset
)
%
mtd
->
erasesize
)
{
printf
(
"%s%d: partition (%s) start offset"
"alignment incorrect
\n
"
,
MTD_DEV_TYPE
(
id
->
type
),
id
->
num
,
part
->
name
);
return
1
;
}
if
(
part
->
size
%
mtd
->
erasesize
)
{
printf
(
"%s%d: partition (%s) size alignment incorrect
\n
"
,
MTD_DEV_TYPE
(
id
->
type
),
id
->
num
,
part
->
name
);
return
1
;
}
return
0
;
#else
return
1
;
#endif
}
/**
* Performs sanity check for supplied partition. Offset and size are verified
* to be within valid range. Partition type is checked and either
...
...
@@ -436,6 +480,8 @@ static int part_validate(struct mtdids *id, struct part_info *part)
return
part_validate_nand
(
id
,
part
);
else
if
(
id
->
type
==
MTD_DEV_TYPE_NOR
)
return
part_validate_nor
(
id
,
part
);
else
if
(
id
->
type
==
MTD_DEV_TYPE_ONENAND
)
return
part_validate_onenand
(
id
,
part
);
else
DEBUGF
(
"part_validate: invalid dev type
\n
"
);
...
...
@@ -755,7 +801,15 @@ static int device_validate(u8 type, u8 num, u32 *size)
#else
printf
(
"support for NAND devices not present
\n
"
);
#endif
}
}
else
if
(
type
==
MTD_DEV_TYPE_ONENAND
)
{
#if defined(CONFIG_CMD_ONENAND)
*
size
=
onenand_mtd
.
size
;
return
0
;
#else
printf
(
"support for OneNAND devices not present
\n
"
);
#endif
}
else
printf
(
"Unknown defice type %d
\n
"
,
type
);
return
1
;
}
...
...
@@ -1065,8 +1119,8 @@ static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_
#endif
/* #ifdef CONFIG_JFFS2_CMDLINE */
/**
* Parse device id string <dev-id> := 'nand'|'nor'
<dev-num>, return device
* type and number.
* Parse device id string <dev-id> := 'nand'|'nor'
|'onenand'<dev-num>,
*
return device
type and number.
*
* @param id string describing device id
* @param ret_id output pointer to next char after parse completes (output)
...
...
@@ -1085,6 +1139,9 @@ int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num)
}
else
if
(
strncmp
(
p
,
"nor"
,
3
)
==
0
)
{
*
dev_type
=
MTD_DEV_TYPE_NOR
;
p
+=
3
;
}
else
if
(
strncmp
(
p
,
"onenand"
,
7
)
==
0
)
{
*
dev_type
=
MTD_DEV_TYPE_ONENAND
;
p
+=
7
;
}
else
{
printf
(
"incorrect device type in %s
\n
"
,
id
);
return
1
;
...
...
@@ -1489,7 +1546,7 @@ static int parse_mtdids(const char *const ids)
while
(
p
&&
(
*
p
!=
'\0'
))
{
ret
=
1
;
/* parse 'nor'|'nand'<dev-num> */
/* parse 'nor'|'nand'
|'onenand'
<dev-num> */
if
(
id_parse
(
p
,
&
p
,
&
type
,
&
num
)
!=
0
)
break
;
...
...
@@ -2181,7 +2238,7 @@ U_BOOT_CMD(
"'mtdids' - linux kernel mtd device id <-> u-boot device id mapping
\n\n
"
"mtdids=<idmap>[,<idmap>,...]
\n\n
"
"<idmap> := <dev-id>=<mtd-id>
\n
"
"<dev-id> := 'nand'|'nor'<dev-num>
\n
"
"<dev-id> := 'nand'|'nor'
|'onenand'
<dev-num>
\n
"
"<dev-num> := mtd device number, 0...
\n
"
"<mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
\n\n
"
"'mtdparts' - partition list
\n\n
"
...
...
fs/jffs2/jffs2_1pass.c
浏览文件 @
1a7f8cce
...
...
@@ -268,6 +268,107 @@ static void put_fl_mem_nand(void *buf)
}
#endif
#if defined(CONFIG_CMD_ONENAND)
#include <linux/mtd/mtd.h>
#include <linux/mtd/onenand.h>
#include <onenand_uboot.h>
#define ONENAND_PAGE_SIZE 2048
#define ONENAND_PAGE_SHIFT 11
#define ONENAND_PAGE_MASK (~(ONENAND_PAGE_SIZE-1))
#ifndef ONENAND_CACHE_PAGES
#define ONENAND_CACHE_PAGES 4
#endif
#define ONENAND_CACHE_SIZE (ONENAND_CACHE_PAGES*ONENAND_PAGE_SIZE)
static
u8
*
onenand_cache
;
static
u32
onenand_cache_off
=
(
u32
)
-
1
;
static
int
read_onenand_cached
(
u32
off
,
u32
size
,
u_char
*
buf
)
{
u32
bytes_read
=
0
;
size_t
retlen
;
int
cpy_bytes
;
while
(
bytes_read
<
size
)
{
if
((
off
+
bytes_read
<
onenand_cache_off
)
||
(
off
+
bytes_read
>=
onenand_cache_off
+
ONENAND_CACHE_SIZE
))
{
onenand_cache_off
=
(
off
+
bytes_read
)
&
ONENAND_PAGE_MASK
;
if
(
!
onenand_cache
)
{
/* This memory never gets freed but 'cause
it's a bootloader, nobody cares */
onenand_cache
=
malloc
(
ONENAND_CACHE_SIZE
);
if
(
!
onenand_cache
)
{
printf
(
"read_onenand_cached: can't alloc cache size %d bytes
\n
"
,
ONENAND_CACHE_SIZE
);
return
-
1
;
}
}
retlen
=
ONENAND_CACHE_SIZE
;
if
(
onenand_read
(
&
onenand_mtd
,
onenand_cache_off
,
retlen
,
&
retlen
,
onenand_cache
)
!=
0
||
retlen
!=
ONENAND_CACHE_SIZE
)
{
printf
(
"read_onenand_cached: error reading nand off %#x size %d bytes
\n
"
,
onenand_cache_off
,
ONENAND_CACHE_SIZE
);
return
-
1
;
}
}
cpy_bytes
=
onenand_cache_off
+
ONENAND_CACHE_SIZE
-
(
off
+
bytes_read
);
if
(
cpy_bytes
>
size
-
bytes_read
)
cpy_bytes
=
size
-
bytes_read
;
memcpy
(
buf
+
bytes_read
,
onenand_cache
+
off
+
bytes_read
-
onenand_cache_off
,
cpy_bytes
);
bytes_read
+=
cpy_bytes
;
}
return
bytes_read
;
}
static
void
*
get_fl_mem_onenand
(
u32
off
,
u32
size
,
void
*
ext_buf
)
{
u_char
*
buf
=
ext_buf
?
(
u_char
*
)
ext_buf
:
(
u_char
*
)
malloc
(
size
);
if
(
NULL
==
buf
)
{
printf
(
"get_fl_mem_onenand: can't alloc %d bytes
\n
"
,
size
);
return
NULL
;
}
if
(
read_onenand_cached
(
off
,
size
,
buf
)
<
0
)
{
if
(
!
ext_buf
)
free
(
buf
);
return
NULL
;
}
return
buf
;
}
static
void
*
get_node_mem_onenand
(
u32
off
)
{
struct
jffs2_unknown_node
node
;
void
*
ret
=
NULL
;
if
(
NULL
==
get_fl_mem_onenand
(
off
,
sizeof
(
node
),
&
node
))
return
NULL
;
ret
=
get_fl_mem_onenand
(
off
,
node
.
magic
==
JFFS2_MAGIC_BITMASK
?
node
.
totlen
:
sizeof
(
node
),
NULL
);
if
(
!
ret
)
{
printf
(
"off = %#x magic %#x type %#x node.totlen = %d
\n
"
,
off
,
node
.
magic
,
node
.
nodetype
,
node
.
totlen
);
}
return
ret
;
}
static
void
put_fl_mem_onenand
(
void
*
buf
)
{
free
(
buf
);
}
#endif
#if defined(CONFIG_CMD_FLASH)
/*
...
...
@@ -313,6 +414,11 @@ static inline void *get_fl_mem(u32 off, u32 size, void *ext_buf)
return
get_fl_mem_nand
(
off
,
size
,
ext_buf
);
#endif
#if defined(CONFIG_CMD_ONENAND)
if
(
id
->
type
==
MTD_DEV_TYPE_ONENAND
)
return
get_fl_mem_onenand
(
off
,
size
,
ext_buf
);
#endif
printf
(
"get_fl_mem: unknown device type, using raw offset!
\n
"
);
return
(
void
*
)
off
;
}
...
...
@@ -332,6 +438,11 @@ static inline void *get_node_mem(u32 off)
return
get_node_mem_nand
(
off
);
#endif
#if defined(CONFIG_CMD_ONENAND)
if
(
id
->
type
==
MTD_DEV_TYPE_ONENAND
)
return
get_node_mem_onenand
(
off
);
#endif
printf
(
"get_node_mem: unknown device type, using raw offset!
\n
"
);
return
(
void
*
)
off
;
}
...
...
@@ -345,6 +456,13 @@ static inline void put_fl_mem(void *buf)
if
(
id
->
type
==
MTD_DEV_TYPE_NAND
)
return
put_fl_mem_nand
(
buf
);
#endif
#if defined(CONFIG_CMD_ONENAND)
struct
mtdids
*
id
=
current_part
->
dev
->
id
;
if
(
id
->
type
==
MTD_DEV_TYPE_ONENAND
)
return
put_fl_mem_onenand
(
buf
);
#endif
}
/* Compression names */
...
...
include/jffs2/load_kernel.h
浏览文件 @
1a7f8cce
...
...
@@ -28,9 +28,12 @@
#include <linux/list.h>
/* mtd device types */
#define MTD_DEV_TYPE_NOR 0x0001
#define MTD_DEV_TYPE_NAND 0x0002
#define MTD_DEV_TYPE(type) ((type == MTD_DEV_TYPE_NAND) ? "nand" : "nor")
#define MTD_DEV_TYPE_NOR 0x0001
#define MTD_DEV_TYPE_NAND 0x0002
#define MTD_DEV_TYPE_ONENAND 0x0004
#define MTD_DEV_TYPE(type) ((type == MTD_DEV_TYPE_NAND) ? "nand" : \
(type == MTD_DEV_TYPE_ONENAND) ? "onenand" : "nor")
struct
mtd_device
{
struct
list_head
link
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录