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
21 #define PRINTF(fmt, args...) printf(fmt, ##args)
23 #define PRINTF(fmt, args...) do { } while (0)
26 extern void cmd_yaffs_dev_ls(void);
27 extern void cmd_yaffs_tracemask(unsigned set, unsigned mask);
28 extern void cmd_yaffs_devconfig(char *mp, int flash_dev,
29 int start_block, int end_block);
30 extern void cmd_yaffs_mount(char *mp);
31 extern void cmd_yaffs_umount(char *mp);
32 extern void cmd_yaffs_read_file(char *fn);
33 extern void cmd_yaffs_write_file(char *fn, char bval, int sizeOfFile);
34 extern void cmd_yaffs_ls(const char *mountpt, int longlist);
35 extern void cmd_yaffs_mwrite_file(char *fn, char *addr, int size);
36 extern void cmd_yaffs_mread_file(char *fn, char *addr);
37 extern void cmd_yaffs_mkdir(const char *dir);
38 extern void cmd_yaffs_rmdir(const char *dir);
39 extern void cmd_yaffs_rm(const char *path);
40 extern void cmd_yaffs_mv(const char *oldPath, const char *newPath);
42 extern int yaffs_dump_dev(const char *path);
44 /* ytrace - show/set yaffs trace mask */
45 int do_ytrace(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
48 cmd_yaffs_tracemask(1, simple_strtol(argv[1], NULL, 16));
50 cmd_yaffs_tracemask(0, 0);
55 /* ydevls - lists yaffs mount points. */
56 int do_ydevls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
63 /* ydevconfig mount_pt mtd_dev_num start_block end_block */
64 int do_ydevconfig(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
73 ("Bad arguments: ydevconfig mount_pt mtd_dev start_block end_block\n");
78 mtd_dev = simple_strtol(argv[2], NULL, 16);
79 start_block = simple_strtol(argv[3], NULL, 16);
80 end_block = simple_strtol(argv[4], NULL, 16);
82 cmd_yaffs_devconfig(mtpoint, mtd_dev, start_block, end_block);
87 int do_ymount(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
92 printf("Bad arguments: ymount mount_pt\n");
97 printf("Mounting yaffs2 mount point %s\n", mtpoint);
99 cmd_yaffs_mount(mtpoint);
104 int do_yumount(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
109 printf("Bad arguments: yumount mount_pt\n");
114 printf("Unmounting yaffs2 mount point %s\n", mtpoint);
115 cmd_yaffs_umount(mtpoint);
120 int do_yls(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
124 if (argc < 2 || argc > 3 || (argc == 3 && strcmp(argv[1], "-l"))) {
125 printf("Bad arguments: yls [-l] dir\n");
129 dirname = argv[argc - 1];
131 cmd_yaffs_ls(dirname, (argc > 2) ? 1 : 0);
136 int do_yrd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
141 printf("Bad arguments: yrd file_name\n");
147 printf("Reading file %s ", filename);
149 cmd_yaffs_read_file(filename);
155 int do_ywr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
162 printf("Bad arguments: ywr file_name value n_values\n");
167 value = hextoul(argv[2], NULL);
168 numValues = hextoul(argv[3], NULL);
170 printf("Writing value (%lx) %lx times to %s... ", value, numValues,
173 cmd_yaffs_write_file(filename, value, numValues);
179 int do_yrdm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
185 printf("Bad arguments: yrdm file_name addr\n");
190 addr = hextoul(argv[2], NULL);
192 cmd_yaffs_mread_file(filename, (char *)addr);
197 int do_ywrm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
204 printf("Bad arguments: ywrm file_name addr size\n");
209 addr = hextoul(argv[2], NULL);
210 size = hextoul(argv[3], NULL);
212 cmd_yaffs_mwrite_file(filename, (char *)addr, size);
217 int do_ymkdir(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
222 printf("Bad arguments: ymkdir dir_name\n");
227 cmd_yaffs_mkdir(dirname);
232 int do_yrmdir(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
237 printf("Bad arguments: yrmdir dir_name\n");
242 cmd_yaffs_rmdir(dirname);
247 int do_yrm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
252 printf("Bad arguments: yrm name\n");
263 int do_ymv(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
269 printf("Bad arguments: ymv old_path new_path\n");
276 cmd_yaffs_mv(newPath, oldPath);
281 U_BOOT_CMD(ytrace, 2, 0, do_ytrace,
282 "show/set yaffs trace mask",
283 "[new_mask] show/set yaffs trace mask");
285 U_BOOT_CMD(ydevls, 1, 0, do_ydevls,
286 "list yaffs mount points", "list yaffs mount points");
288 U_BOOT_CMD(ydevconfig, 5, 0, do_ydevconfig,
289 "configure yaffs mount point",
290 "mtpoint mtd_id start_block end_block configures a yaffs2 mount point");
292 U_BOOT_CMD(ymount, 2, 0, do_ymount,
293 "mount yaffs", "mtpoint mounts a yaffs2 mount point");
295 U_BOOT_CMD(yumount, 2, 0, do_yumount,
296 "unmount yaffs", "mtpoint unmounts a yaffs2 mount point");
298 U_BOOT_CMD(yls, 3, 0, do_yls, "yaffs ls", "[-l] dirname");
300 U_BOOT_CMD(yrd, 2, 0, do_yrd,
301 "read file from yaffs", "path read file from yaffs");
303 U_BOOT_CMD(ywr, 4, 0, do_ywr,
304 "write file to yaffs",
305 "filename value num_vlues write values to yaffs file");
307 U_BOOT_CMD(yrdm, 3, 0, do_yrdm,
308 "read file to memory from yaffs",
309 "filename offset reads yaffs file into memory");
311 U_BOOT_CMD(ywrm, 4, 0, do_ywrm,
312 "write file from memory to yaffs",
313 "filename offset size writes memory to yaffs file");
315 U_BOOT_CMD(ymkdir, 2, 0, do_ymkdir,
316 "YAFFS mkdir", "dir create a yaffs directory");
318 U_BOOT_CMD(yrmdir, 2, 0, do_yrmdir,
319 "YAFFS rmdir", "dirname removes a yaffs directory");
321 U_BOOT_CMD(yrm, 2, 0, do_yrm, "YAFFS rm", "path removes a yaffs file");
323 U_BOOT_CMD(ymv, 4, 0, do_ymv,
325 "old_path new_path moves/rename files within a yaffs mount point");