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
22 #define PRINTF(fmt, args...) printf(fmt, ##args)
24 #define PRINTF(fmt, args...) do { } while (0)
27 extern void cmd_yaffs_dev_ls(void);
28 extern void cmd_yaffs_tracemask(unsigned set, unsigned mask);
29 extern void cmd_yaffs_devconfig(char *mp, int flash_dev,
30 int start_block, int end_block);
31 extern void cmd_yaffs_mount(char *mp);
32 extern void cmd_yaffs_umount(char *mp);
33 extern void cmd_yaffs_read_file(char *fn);
34 extern void cmd_yaffs_write_file(char *fn, char bval, int sizeOfFile);
35 extern void cmd_yaffs_ls(const char *mountpt, int longlist);
36 extern void cmd_yaffs_mwrite_file(char *fn, char *addr, int size);
37 extern void cmd_yaffs_mread_file(char *fn, char *addr);
38 extern void cmd_yaffs_mkdir(const char *dir);
39 extern void cmd_yaffs_rmdir(const char *dir);
40 extern void cmd_yaffs_rm(const char *path);
41 extern void cmd_yaffs_mv(const char *oldPath, const char *newPath);
43 extern int yaffs_dump_dev(const char *path);
45 /* ytrace - show/set yaffs trace mask */
46 int do_ytrace(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
49 cmd_yaffs_tracemask(1, simple_strtol(argv[1], NULL, 16));
51 cmd_yaffs_tracemask(0, 0);
56 /* ydevls - lists yaffs mount points. */
57 int do_ydevls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
64 /* ydevconfig mount_pt mtd_dev_num start_block end_block */
65 int do_ydevconfig(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
74 ("Bad arguments: ydevconfig mount_pt mtd_dev start_block end_block\n");
79 mtd_dev = simple_strtol(argv[2], NULL, 16);
80 start_block = simple_strtol(argv[3], NULL, 16);
81 end_block = simple_strtol(argv[4], NULL, 16);
83 cmd_yaffs_devconfig(mtpoint, mtd_dev, start_block, end_block);
88 int do_ymount(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
93 printf("Bad arguments: ymount mount_pt\n");
98 printf("Mounting yaffs2 mount point %s\n", mtpoint);
100 cmd_yaffs_mount(mtpoint);
105 int do_yumount(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
110 printf("Bad arguments: yumount mount_pt\n");
115 printf("Unmounting yaffs2 mount point %s\n", mtpoint);
116 cmd_yaffs_umount(mtpoint);
121 int do_yls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
125 if (argc < 2 || argc > 3 || (argc == 3 && strcmp(argv[1], "-l"))) {
126 printf("Bad arguments: yls [-l] dir\n");
130 dirname = argv[argc - 1];
132 cmd_yaffs_ls(dirname, (argc > 2) ? 1 : 0);
137 int do_yrd(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
142 printf("Bad arguments: yrd file_name\n");
148 printf("Reading file %s ", filename);
150 cmd_yaffs_read_file(filename);
156 int do_ywr(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
163 printf("Bad arguments: ywr file_name value n_values\n");
168 value = simple_strtoul(argv[2], NULL, 16);
169 numValues = simple_strtoul(argv[3], NULL, 16);
171 printf("Writing value (%lx) %lx times to %s... ", value, numValues,
174 cmd_yaffs_write_file(filename, value, numValues);
180 int do_yrdm(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
186 printf("Bad arguments: yrdm file_name addr\n");
191 addr = simple_strtoul(argv[2], NULL, 16);
193 cmd_yaffs_mread_file(filename, (char *)addr);
198 int do_ywrm(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
205 printf("Bad arguments: ywrm file_name addr size\n");
210 addr = simple_strtoul(argv[2], NULL, 16);
211 size = simple_strtoul(argv[3], NULL, 16);
213 cmd_yaffs_mwrite_file(filename, (char *)addr, size);
218 int do_ymkdir(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
223 printf("Bad arguments: ymkdir dir_name\n");
228 cmd_yaffs_mkdir(dirname);
233 int do_yrmdir(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
238 printf("Bad arguments: yrmdir dir_name\n");
243 cmd_yaffs_rmdir(dirname);
248 int do_yrm(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
253 printf("Bad arguments: yrm name\n");
264 int do_ymv(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
270 printf("Bad arguments: ymv old_path new_path\n");
277 cmd_yaffs_mv(newPath, oldPath);
282 U_BOOT_CMD(ytrace, 2, 0, do_ytrace,
283 "show/set yaffs trace mask",
284 "[new_mask] show/set yaffs trace mask");
286 U_BOOT_CMD(ydevls, 1, 0, do_ydevls,
287 "list yaffs mount points", "list yaffs mount points");
289 U_BOOT_CMD(ydevconfig, 5, 0, do_ydevconfig,
290 "configure yaffs mount point",
291 "mtpoint mtd_id start_block end_block configures a yaffs2 mount point");
293 U_BOOT_CMD(ymount, 2, 0, do_ymount,
294 "mount yaffs", "mtpoint mounts a yaffs2 mount point");
296 U_BOOT_CMD(yumount, 2, 0, do_yumount,
297 "unmount yaffs", "mtpoint unmounts a yaffs2 mount point");
299 U_BOOT_CMD(yls, 3, 0, do_yls, "yaffs ls", "[-l] dirname");
301 U_BOOT_CMD(yrd, 2, 0, do_yrd,
302 "read file from yaffs", "path read file from yaffs");
304 U_BOOT_CMD(ywr, 4, 0, do_ywr,
305 "write file to yaffs",
306 "filename value num_vlues write values to yaffs file");
308 U_BOOT_CMD(yrdm, 3, 0, do_yrdm,
309 "read file to memory from yaffs",
310 "filename offset reads yaffs file into memory");
312 U_BOOT_CMD(ywrm, 4, 0, do_ywrm,
313 "write file from memory to yaffs",
314 "filename offset size writes memory to yaffs file");
316 U_BOOT_CMD(ymkdir, 2, 0, do_ymkdir,
317 "YAFFS mkdir", "dir create a yaffs directory");
319 U_BOOT_CMD(yrmdir, 2, 0, do_yrmdir,
320 "YAFFS rmdir", "dirname removes a yaffs directory");
322 U_BOOT_CMD(yrm, 2, 0, do_yrm, "YAFFS rm", "path removes a yaffs file");
324 U_BOOT_CMD(ymv, 4, 0, do_ymv,
326 "old_path new_path moves/rename files within a yaffs mount point");