mirror of
https://github.com/AsahiLinux/u-boot
synced 2025-02-26 12:27:12 +00:00
cmd_fat: add FAT write command
Once CONFIG_FAT_WRITE is defined, users can invoke 'fatwrite' command that saves data in RAM as a FAT file. This patch was originally part of http://article.gmane.org/gmane.comp.boot-loaders.u-boot/121847 Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Maximilian Schwerin <mvs@tigris.de> Signed-off-by: Anatolij Gustschin <agust@denx.de>
This commit is contained in:
parent
bf6b6af746
commit
656f4c6537
2 changed files with 63 additions and 2 deletions
8
README
8
README
|
@ -1233,8 +1233,12 @@ The following options need to be configured:
|
||||||
|
|
||||||
- FAT(File Allocation Table) filesystem write function support:
|
- FAT(File Allocation Table) filesystem write function support:
|
||||||
CONFIG_FAT_WRITE
|
CONFIG_FAT_WRITE
|
||||||
Support for saving memory data as a file
|
|
||||||
in FAT formatted partition
|
Define this to enable support for saving memory data as a
|
||||||
|
file in FAT formatted partition.
|
||||||
|
|
||||||
|
This will also enable the command "fatwrite" enabling the
|
||||||
|
user to write files to FAT.
|
||||||
|
|
||||||
- Keyboard Support:
|
- Keyboard Support:
|
||||||
CONFIG_ISA_KEYBOARD
|
CONFIG_ISA_KEYBOARD
|
||||||
|
|
|
@ -184,3 +184,60 @@ U_BOOT_CMD(
|
||||||
"<interface> <dev[:part]>\n"
|
"<interface> <dev[:part]>\n"
|
||||||
" - print information about filesystem from 'dev' on 'interface'"
|
" - print information about filesystem from 'dev' on 'interface'"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
#ifdef CONFIG_FAT_WRITE
|
||||||
|
static int do_fat_fswrite(cmd_tbl_t *cmdtp, int flag,
|
||||||
|
int argc, char * const argv[])
|
||||||
|
{
|
||||||
|
long size;
|
||||||
|
unsigned long addr;
|
||||||
|
unsigned long count;
|
||||||
|
block_dev_desc_t *dev_desc = NULL;
|
||||||
|
int dev = 0;
|
||||||
|
int part = 1;
|
||||||
|
char *ep;
|
||||||
|
|
||||||
|
if (argc < 5)
|
||||||
|
return cmd_usage(cmdtp);
|
||||||
|
|
||||||
|
dev = (int)simple_strtoul(argv[2], &ep, 16);
|
||||||
|
dev_desc = get_dev(argv[1], dev);
|
||||||
|
if (dev_desc == NULL) {
|
||||||
|
puts("\n** Invalid boot device **\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (*ep) {
|
||||||
|
if (*ep != ':') {
|
||||||
|
puts("\n** Invalid boot device, use `dev[:part]' **\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
part = (int)simple_strtoul(++ep, NULL, 16);
|
||||||
|
}
|
||||||
|
if (fat_register_device(dev_desc, part) != 0) {
|
||||||
|
printf("\n** Unable to use %s %d:%d for fatwrite **\n",
|
||||||
|
argv[1], dev, part);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
addr = simple_strtoul(argv[3], NULL, 16);
|
||||||
|
count = simple_strtoul(argv[5], NULL, 16);
|
||||||
|
|
||||||
|
size = file_fat_write(argv[4], (void *)addr, count);
|
||||||
|
if (size == -1) {
|
||||||
|
printf("\n** Unable to write \"%s\" from %s %d:%d **\n",
|
||||||
|
argv[4], argv[1], dev, part);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%ld bytes written\n", size);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
U_BOOT_CMD(
|
||||||
|
fatwrite, 6, 0, do_fat_fswrite,
|
||||||
|
"write file into a dos filesystem",
|
||||||
|
"<interface> <dev[:part]> <addr> <filename> <bytes>\n"
|
||||||
|
" - write file 'filename' from the address 'addr' in RAM\n"
|
||||||
|
" to 'dev' on 'interface'"
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue