2 * Modified by Charles Manning by adding ydevconfig command.
4 * Use ydevconfig to configure a mountpoint before use.
6 * # Configure mountpt xxx using nand device 0 using blocks 100-500
7 * ydevconfig xxx 0 100 500
12 * yrdm xxx/boot-image 82000000
20 #define PRINTF(fmt, args...) printf(fmt, ##args)
22 #define PRINTF(fmt, args...) do { } while (0)
25 extern void cmd_yaffs_dev_ls(void);
26 extern void cmd_yaffs_tracemask(unsigned set
, unsigned mask
);
27 extern void cmd_yaffs_devconfig(char *mp
, int flash_dev
,
28 int start_block
, int end_block
);
29 extern void cmd_yaffs_mount(char *mp
);
30 extern void cmd_yaffs_umount(char *mp
);
31 extern void cmd_yaffs_read_file(char *fn
);
32 extern void cmd_yaffs_write_file(char *fn
, char bval
, int sizeOfFile
);
33 extern void cmd_yaffs_ls(const char *mountpt
, int longlist
);
34 extern void cmd_yaffs_mwrite_file(char *fn
, char *addr
, int size
);
35 extern void cmd_yaffs_mread_file(char *fn
, char *addr
);
36 extern void cmd_yaffs_mkdir(const char *dir
);
37 extern void cmd_yaffs_rmdir(const char *dir
);
38 extern void cmd_yaffs_rm(const char *path
);
39 extern void cmd_yaffs_mv(const char *oldPath
, const char *newPath
);
41 extern int yaffs_dump_dev(const char *path
);
43 /* ytrace - show/set yaffs trace mask */
44 int do_ytrace(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
47 cmd_yaffs_tracemask(1, simple_strtol(argv
[1], NULL
, 16));
49 cmd_yaffs_tracemask(0, 0);
54 /* ydevls - lists yaffs mount points. */
55 int do_ydevls(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
62 /* ydevconfig mount_pt mtd_dev_num start_block end_block */
63 int do_ydevconfig(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
72 ("Bad arguments: ydevconfig mount_pt mtd_dev start_block end_block\n");
77 mtd_dev
= simple_strtol(argv
[2], NULL
, 16);
78 start_block
= simple_strtol(argv
[3], NULL
, 16);
79 end_block
= simple_strtol(argv
[4], NULL
, 16);
81 cmd_yaffs_devconfig(mtpoint
, mtd_dev
, start_block
, end_block
);
86 int do_ymount(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
91 printf("Bad arguments: ymount mount_pt\n");
96 printf("Mounting yaffs2 mount point %s\n", mtpoint
);
98 cmd_yaffs_mount(mtpoint
);
103 int do_yumount(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
108 printf("Bad arguments: yumount mount_pt\n");
113 printf("Unmounting yaffs2 mount point %s\n", mtpoint
);
114 cmd_yaffs_umount(mtpoint
);
119 int do_yls(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
123 if (argc
< 2 || argc
> 3 || (argc
== 3 && strcmp(argv
[1], "-l"))) {
124 printf("Bad arguments: yls [-l] dir\n");
128 dirname
= argv
[argc
- 1];
130 cmd_yaffs_ls(dirname
, (argc
> 2) ? 1 : 0);
135 int do_yrd(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
140 printf("Bad arguments: yrd file_name\n");
146 printf("Reading file %s ", filename
);
148 cmd_yaffs_read_file(filename
);
154 int do_ywr(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
161 printf("Bad arguments: ywr file_name value n_values\n");
166 value
= hextoul(argv
[2], NULL
);
167 numValues
= hextoul(argv
[3], NULL
);
169 printf("Writing value (%lx) %lx times to %s... ", value
, numValues
,
172 cmd_yaffs_write_file(filename
, value
, numValues
);
178 int do_yrdm(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
184 printf("Bad arguments: yrdm file_name addr\n");
189 addr
= hextoul(argv
[2], NULL
);
191 cmd_yaffs_mread_file(filename
, (char *)addr
);
196 int do_ywrm(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
203 printf("Bad arguments: ywrm file_name addr size\n");
208 addr
= hextoul(argv
[2], NULL
);
209 size
= hextoul(argv
[3], NULL
);
211 cmd_yaffs_mwrite_file(filename
, (char *)addr
, size
);
216 int do_ymkdir(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
221 printf("Bad arguments: ymkdir dir_name\n");
226 cmd_yaffs_mkdir(dirname
);
231 int do_yrmdir(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
236 printf("Bad arguments: yrmdir dir_name\n");
241 cmd_yaffs_rmdir(dirname
);
246 int do_yrm(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
251 printf("Bad arguments: yrm name\n");
262 int do_ymv(struct cmd_tbl
*cmdtp
, int flag
, int argc
, char *const argv
[])
268 printf("Bad arguments: ymv old_path new_path\n");
275 cmd_yaffs_mv(newPath
, oldPath
);
280 U_BOOT_CMD(ytrace
, 2, 0, do_ytrace
,
281 "show/set yaffs trace mask",
282 "[new_mask] show/set yaffs trace mask");
284 U_BOOT_CMD(ydevls
, 1, 0, do_ydevls
,
285 "list yaffs mount points", "list yaffs mount points");
287 U_BOOT_CMD(ydevconfig
, 5, 0, do_ydevconfig
,
288 "configure yaffs mount point",
289 "mtpoint mtd_id start_block end_block configures a yaffs2 mount point");
291 U_BOOT_CMD(ymount
, 2, 0, do_ymount
,
292 "mount yaffs", "mtpoint mounts a yaffs2 mount point");
294 U_BOOT_CMD(yumount
, 2, 0, do_yumount
,
295 "unmount yaffs", "mtpoint unmounts a yaffs2 mount point");
297 U_BOOT_CMD(yls
, 3, 0, do_yls
, "yaffs ls", "[-l] dirname");
299 U_BOOT_CMD(yrd
, 2, 0, do_yrd
,
300 "read file from yaffs", "path read file from yaffs");
302 U_BOOT_CMD(ywr
, 4, 0, do_ywr
,
303 "write file to yaffs",
304 "filename value num_vlues write values to yaffs file");
306 U_BOOT_CMD(yrdm
, 3, 0, do_yrdm
,
307 "read file to memory from yaffs",
308 "filename offset reads yaffs file into memory");
310 U_BOOT_CMD(ywrm
, 4, 0, do_ywrm
,
311 "write file from memory to yaffs",
312 "filename offset size writes memory to yaffs file");
314 U_BOOT_CMD(ymkdir
, 2, 0, do_ymkdir
,
315 "YAFFS mkdir", "dir create a yaffs directory");
317 U_BOOT_CMD(yrmdir
, 2, 0, do_yrmdir
,
318 "YAFFS rmdir", "dirname removes a yaffs directory");
320 U_BOOT_CMD(yrm
, 2, 0, do_yrm
, "YAFFS rm", "path removes a yaffs file");
322 U_BOOT_CMD(ymv
, 4, 0, do_ymv
,
324 "old_path new_path moves/rename files within a yaffs mount point");