2 * (C) Copyright 2011 - 2012 Samsung Electronics
3 * EXT4 filesystem implementation in Uboot by
4 * Uma Shankar <uma.shankar@samsung.com>
5 * Manjunatha C Achar <a.manjunatha@samsung.com>
8 * made from existing cmd_ext2.c file of Uboot
11 * esd gmbh <www.esd-electronics.com>
12 * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
14 * made from cmd_reiserfs by
16 * (C) Copyright 2003 - 2004
17 * Sysgo Real-Time Solutions, AG <www.elinos.com>
18 * Pavel Bartusek <pba@sysgo.com>
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License as
22 * published by the Free Software Foundation; either version 2 of
23 * the License, or (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
39 * 0.1 - Newly created file for ext4fs support. Taken from cmd_ext2.c
40 * file in uboot. Added ext4fs ls load and write support.
48 #include <linux/ctype.h>
49 #include <asm/byteorder.h>
50 #include <ext_common.h>
52 #include <linux/stat.h>
55 #if defined(CONFIG_CMD_USB) && defined(CONFIG_USB_STORAGE)
59 int do_ext4_load(cmd_tbl_t *cmdtp, int flag, int argc,
62 if (do_ext_load(cmdtp, flag, argc, argv))
68 int do_ext4_ls(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
70 if (do_ext_ls(cmdtp, flag, argc, argv))
76 #if defined(CONFIG_CMD_EXT4_WRITE)
77 int do_ext4_write(cmd_tbl_t *cmdtp, int flag, int argc,
80 const char *filename = "/";
82 unsigned long ram_address;
83 unsigned long file_size;
84 disk_partition_t info;
85 block_dev_desc_t *dev_desc;
88 return cmd_usage(cmdtp);
90 part = get_device_and_partition(argv[1], argv[2], &dev_desc, &info, 1);
96 /* get the filename */
99 /* get the address in hexadecimal format (string to int) */
100 ram_address = simple_strtoul(argv[4], NULL, 16);
102 /* get the filesize in base 10 format */
103 file_size = simple_strtoul(argv[5], NULL, 10);
105 /* set the device as block device */
106 ext4fs_set_blk_dev(dev_desc, &info);
108 /* mount the filesystem */
109 if (!ext4fs_mount(info.size)) {
110 printf("Bad ext4 partition %s %d:%lu\n", argv[1], dev, part);
115 if (ext4fs_write(filename, (unsigned char *)ram_address, file_size)) {
116 printf("** Error ext4fs_write() **\n");
129 U_BOOT_CMD(ext4write, 6, 1, do_ext4_write,
130 "create a file in the root directory",
131 "<interface> <dev[:part]> [Absolute filename path] [Address] [sizebytes]\n"
132 " - create a file in / directory");
136 U_BOOT_CMD(ext4ls, 4, 1, do_ext4_ls,
137 "list files in a directory (default /)",
138 "<interface> <dev[:part]> [directory]\n"
139 " - list files from 'dev' on 'interface' in a 'directory'");
141 U_BOOT_CMD(ext4load, 6, 0, do_ext4_load,
142 "load binary file from a Ext4 filesystem",
143 "<interface> <dev[:part]> [addr] [filename] [bytes]\n"
144 " - load binary file 'filename' from 'dev' on 'interface'\n"
145 " to address 'addr' from ext4 filesystem");