Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Unsorted Block Image commands |
| 3 | * |
| 4 | * Copyright (C) 2008 Samsung Electronics |
| 5 | * Kyungmin Park <kyungmin.park@samsung.com> |
| 6 | * |
Stefan Roese | 62eafb7 | 2009-04-24 20:24:19 +0200 | [diff] [blame] | 7 | * Copyright 2008-2009 Stefan Roese <sr@denx.de>, DENX Software Engineering |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <common.h> |
| 15 | #include <command.h> |
| 16 | #include <exports.h> |
Simon Glass | a87fc0a | 2015-09-02 17:24:57 -0600 | [diff] [blame] | 17 | #include <memalign.h> |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 18 | #include <nand.h> |
| 19 | #include <onenand_uboot.h> |
| 20 | #include <linux/mtd/mtd.h> |
| 21 | #include <linux/mtd/partitions.h> |
Heiko Schocher | f5895d1 | 2014-06-24 10:10:04 +0200 | [diff] [blame] | 22 | #include <linux/err.h> |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 23 | #include <ubi_uboot.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 24 | #include <linux/errno.h> |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 25 | #include <jffs2/load_kernel.h> |
| 26 | |
Joe Hershberger | 47550fc | 2013-04-08 10:32:49 +0000 | [diff] [blame] | 27 | #undef ubi_msg |
| 28 | #define ubi_msg(fmt, ...) printf("UBI: " fmt "\n", ##__VA_ARGS__) |
| 29 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 30 | #define DEV_TYPE_NONE 0 |
| 31 | #define DEV_TYPE_NAND 1 |
| 32 | #define DEV_TYPE_ONENAND 2 |
Piotr Ziecik | 88bddfd | 2008-11-17 15:58:00 +0100 | [diff] [blame] | 33 | #define DEV_TYPE_NOR 3 |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 34 | |
| 35 | /* Private own data */ |
| 36 | static struct ubi_device *ubi; |
Stefan Roese | 1b71405 | 2008-11-24 08:31:16 +0100 | [diff] [blame] | 37 | static char buffer[80]; |
Stefan Roese | 1b20eb8 | 2008-11-27 14:07:09 +0100 | [diff] [blame] | 38 | static int ubi_initialized; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 39 | |
| 40 | struct selected_dev { |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 41 | char part_name[80]; |
Stefan Roese | 62eafb7 | 2009-04-24 20:24:19 +0200 | [diff] [blame] | 42 | int selected; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 43 | int nr; |
| 44 | struct mtd_info *mtd_info; |
| 45 | }; |
| 46 | |
| 47 | static struct selected_dev ubi_dev; |
| 48 | |
Stefan Roese | 408c6c4 | 2010-11-01 17:28:22 +0100 | [diff] [blame] | 49 | #ifdef CONFIG_CMD_UBIFS |
Tien Fong Chee | dbc9d85 | 2018-07-06 16:25:12 +0800 | [diff] [blame] | 50 | #include <ubifs_uboot.h> |
Stefan Roese | 408c6c4 | 2010-11-01 17:28:22 +0100 | [diff] [blame] | 51 | #endif |
| 52 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 53 | static void display_volume_info(struct ubi_device *ubi) |
| 54 | { |
| 55 | int i; |
| 56 | |
| 57 | for (i = 0; i < (ubi->vtbl_slots + 1); i++) { |
| 58 | if (!ubi->volumes[i]) |
| 59 | continue; /* Empty record */ |
| 60 | ubi_dump_vol_info(ubi->volumes[i]); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | static void display_ubi_info(struct ubi_device *ubi) |
| 65 | { |
| 66 | ubi_msg("MTD device name: \"%s\"", ubi->mtd->name); |
| 67 | ubi_msg("MTD device size: %llu MiB", ubi->flash_size >> 20); |
| 68 | ubi_msg("physical eraseblock size: %d bytes (%d KiB)", |
| 69 | ubi->peb_size, ubi->peb_size >> 10); |
| 70 | ubi_msg("logical eraseblock size: %d bytes", ubi->leb_size); |
| 71 | ubi_msg("number of good PEBs: %d", ubi->good_peb_count); |
| 72 | ubi_msg("number of bad PEBs: %d", ubi->bad_peb_count); |
| 73 | ubi_msg("smallest flash I/O unit: %d", ubi->min_io_size); |
| 74 | ubi_msg("VID header offset: %d (aligned %d)", |
| 75 | ubi->vid_hdr_offset, ubi->vid_hdr_aloffset); |
| 76 | ubi_msg("data offset: %d", ubi->leb_start); |
| 77 | ubi_msg("max. allowed volumes: %d", ubi->vtbl_slots); |
| 78 | ubi_msg("wear-leveling threshold: %d", CONFIG_MTD_UBI_WL_THRESHOLD); |
| 79 | ubi_msg("number of internal volumes: %d", UBI_INT_VOL_COUNT); |
| 80 | ubi_msg("number of user volumes: %d", |
| 81 | ubi->vol_count - UBI_INT_VOL_COUNT); |
| 82 | ubi_msg("available PEBs: %d", ubi->avail_pebs); |
| 83 | ubi_msg("total number of reserved PEBs: %d", ubi->rsvd_pebs); |
| 84 | ubi_msg("number of PEBs reserved for bad PEB handling: %d", |
| 85 | ubi->beb_rsvd_pebs); |
| 86 | ubi_msg("max/mean erase counter: %d/%d", ubi->max_ec, ubi->mean_ec); |
| 87 | } |
| 88 | |
| 89 | static int ubi_info(int layout) |
| 90 | { |
| 91 | if (layout) |
| 92 | display_volume_info(ubi); |
| 93 | else |
| 94 | display_ubi_info(ubi); |
| 95 | |
| 96 | return 0; |
| 97 | } |
| 98 | |
Heiko Schocher | 1762ab1 | 2014-01-25 07:27:11 +0100 | [diff] [blame] | 99 | static int ubi_check_volumename(const struct ubi_volume *vol, char *name) |
| 100 | { |
| 101 | return strcmp(vol->name, name); |
| 102 | } |
| 103 | |
| 104 | static int ubi_check(char *name) |
| 105 | { |
| 106 | int i; |
| 107 | |
| 108 | for (i = 0; i < (ubi->vtbl_slots + 1); i++) { |
| 109 | if (!ubi->volumes[i]) |
| 110 | continue; /* Empty record */ |
| 111 | |
| 112 | if (!ubi_check_volumename(ubi->volumes[i], name)) |
| 113 | return 0; |
| 114 | } |
| 115 | |
Stefan Agner | 6a889f2 | 2015-04-10 11:25:43 +0200 | [diff] [blame] | 116 | return 1; |
Heiko Schocher | 1762ab1 | 2014-01-25 07:27:11 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 120 | static int verify_mkvol_req(const struct ubi_device *ubi, |
| 121 | const struct ubi_mkvol_req *req) |
| 122 | { |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 123 | int n, err = EINVAL; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 124 | |
| 125 | if (req->bytes < 0 || req->alignment < 0 || req->vol_type < 0 || |
| 126 | req->name_len < 0) |
| 127 | goto bad; |
| 128 | |
| 129 | if ((req->vol_id < 0 || req->vol_id >= ubi->vtbl_slots) && |
| 130 | req->vol_id != UBI_VOL_NUM_AUTO) |
| 131 | goto bad; |
| 132 | |
| 133 | if (req->alignment == 0) |
| 134 | goto bad; |
| 135 | |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 136 | if (req->bytes == 0) { |
| 137 | printf("No space left in UBI device!\n"); |
| 138 | err = ENOMEM; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 139 | goto bad; |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 140 | } |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 141 | |
| 142 | if (req->vol_type != UBI_DYNAMIC_VOLUME && |
| 143 | req->vol_type != UBI_STATIC_VOLUME) |
| 144 | goto bad; |
| 145 | |
| 146 | if (req->alignment > ubi->leb_size) |
| 147 | goto bad; |
| 148 | |
| 149 | n = req->alignment % ubi->min_io_size; |
| 150 | if (req->alignment != 1 && n) |
| 151 | goto bad; |
| 152 | |
| 153 | if (req->name_len > UBI_VOL_NAME_MAX) { |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 154 | printf("Name too long!\n"); |
| 155 | err = ENAMETOOLONG; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 156 | goto bad; |
| 157 | } |
| 158 | |
| 159 | return 0; |
| 160 | bad: |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 161 | return err; |
| 162 | } |
| 163 | |
Ladislav Michl | 39370f1 | 2016-09-13 07:14:01 +0200 | [diff] [blame] | 164 | static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id) |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 165 | { |
| 166 | struct ubi_mkvol_req req; |
| 167 | int err; |
| 168 | |
| 169 | if (dynamic) |
| 170 | req.vol_type = UBI_DYNAMIC_VOLUME; |
| 171 | else |
| 172 | req.vol_type = UBI_STATIC_VOLUME; |
| 173 | |
Ladislav Michl | 39370f1 | 2016-09-13 07:14:01 +0200 | [diff] [blame] | 174 | req.vol_id = vol_id; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 175 | req.alignment = 1; |
| 176 | req.bytes = size; |
| 177 | |
| 178 | strcpy(req.name, volume); |
| 179 | req.name_len = strlen(volume); |
| 180 | req.name[req.name_len] = '\0'; |
| 181 | req.padding1 = 0; |
| 182 | /* It's duplicated at drivers/mtd/ubi/cdev.c */ |
| 183 | err = verify_mkvol_req(ubi, &req); |
| 184 | if (err) { |
| 185 | printf("verify_mkvol_req failed %d\n", err); |
| 186 | return err; |
| 187 | } |
Paul Burton | df68616 | 2013-09-04 15:16:58 +0100 | [diff] [blame] | 188 | printf("Creating %s volume %s of size %lld\n", |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 189 | dynamic ? "dynamic" : "static", volume, size); |
| 190 | /* Call real ubi create volume */ |
| 191 | return ubi_create_volume(ubi, &req); |
| 192 | } |
| 193 | |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 194 | static struct ubi_volume *ubi_find_volume(char *volume) |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 195 | { |
Peter Tyser | f2dbedc | 2010-04-04 22:40:50 -0500 | [diff] [blame] | 196 | struct ubi_volume *vol = NULL; |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 197 | int i; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 198 | |
| 199 | for (i = 0; i < ubi->vtbl_slots; i++) { |
| 200 | vol = ubi->volumes[i]; |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 201 | if (vol && !strcmp(vol->name, volume)) |
| 202 | return vol; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 203 | } |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 204 | |
| 205 | printf("Volume %s not found!\n", volume); |
| 206 | return NULL; |
| 207 | } |
| 208 | |
| 209 | static int ubi_remove_vol(char *volume) |
| 210 | { |
| 211 | int err, reserved_pebs, i; |
| 212 | struct ubi_volume *vol; |
| 213 | |
| 214 | vol = ubi_find_volume(volume); |
| 215 | if (vol == NULL) |
| 216 | return ENODEV; |
| 217 | |
| 218 | printf("Remove UBI volume %s (id %d)\n", vol->name, vol->vol_id); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 219 | |
| 220 | if (ubi->ro_mode) { |
| 221 | printf("It's read-only mode\n"); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 222 | err = EROFS; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 223 | goto out_err; |
| 224 | } |
| 225 | |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 226 | err = ubi_change_vtbl_record(ubi, vol->vol_id, NULL); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 227 | if (err) { |
| 228 | printf("Error changing Vol tabel record err=%x\n", err); |
| 229 | goto out_err; |
| 230 | } |
| 231 | reserved_pebs = vol->reserved_pebs; |
| 232 | for (i = 0; i < vol->reserved_pebs; i++) { |
| 233 | err = ubi_eba_unmap_leb(ubi, vol, i); |
| 234 | if (err) |
| 235 | goto out_err; |
| 236 | } |
| 237 | |
| 238 | kfree(vol->eba_tbl); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 239 | ubi->volumes[vol->vol_id]->eba_tbl = NULL; |
| 240 | ubi->volumes[vol->vol_id] = NULL; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 241 | |
| 242 | ubi->rsvd_pebs -= reserved_pebs; |
| 243 | ubi->avail_pebs += reserved_pebs; |
| 244 | i = ubi->beb_rsvd_level - ubi->beb_rsvd_pebs; |
| 245 | if (i > 0) { |
| 246 | i = ubi->avail_pebs >= i ? i : ubi->avail_pebs; |
| 247 | ubi->avail_pebs -= i; |
| 248 | ubi->rsvd_pebs += i; |
| 249 | ubi->beb_rsvd_pebs += i; |
| 250 | if (i > 0) |
| 251 | ubi_msg("reserve more %d PEBs", i); |
| 252 | } |
| 253 | ubi->vol_count -= 1; |
| 254 | |
| 255 | return 0; |
| 256 | out_err: |
Heiko Schocher | 94b66de | 2015-10-22 06:19:21 +0200 | [diff] [blame] | 257 | ubi_err(ubi, "cannot remove volume %s, error %d", volume, err); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 258 | if (err < 0) |
| 259 | err = -err; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 260 | return err; |
| 261 | } |
| 262 | |
Jeroen Hofstee | f384fbf | 2014-06-23 00:22:08 +0200 | [diff] [blame] | 263 | static int ubi_volume_continue_write(char *volume, void *buf, size_t size) |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 264 | { |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 265 | int err = 1; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 266 | struct ubi_volume *vol; |
| 267 | |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 268 | vol = ubi_find_volume(volume); |
| 269 | if (vol == NULL) |
| 270 | return ENODEV; |
| 271 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 272 | err = ubi_more_update_data(ubi, vol, buf, size); |
| 273 | if (err < 0) { |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 274 | printf("Couldnt or partially wrote data\n"); |
| 275 | return -err; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 276 | } |
| 277 | |
| 278 | if (err) { |
| 279 | size = err; |
| 280 | |
| 281 | err = ubi_check_volume(ubi, vol->vol_id); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 282 | if (err < 0) |
| 283 | return -err; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 284 | |
| 285 | if (err) { |
Heiko Schocher | 94b66de | 2015-10-22 06:19:21 +0200 | [diff] [blame] | 286 | ubi_warn(ubi, "volume %d on UBI device %d is corrupt", |
| 287 | vol->vol_id, ubi->ubi_num); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 288 | vol->corrupted = 1; |
| 289 | } |
| 290 | |
| 291 | vol->checked = 1; |
| 292 | ubi_gluebi_updated(vol); |
| 293 | } |
| 294 | |
| 295 | return 0; |
| 296 | } |
| 297 | |
Paul Burton | 6627aa3 | 2013-09-04 15:16:59 +0100 | [diff] [blame] | 298 | int ubi_volume_begin_write(char *volume, void *buf, size_t size, |
| 299 | size_t full_size) |
| 300 | { |
| 301 | int err = 1; |
| 302 | int rsvd_bytes = 0; |
| 303 | struct ubi_volume *vol; |
| 304 | |
| 305 | vol = ubi_find_volume(volume); |
| 306 | if (vol == NULL) |
| 307 | return ENODEV; |
| 308 | |
| 309 | rsvd_bytes = vol->reserved_pebs * (ubi->leb_size - vol->data_pad); |
xypron.glpk@gmx.de | 632a945 | 2017-04-15 16:25:25 +0200 | [diff] [blame] | 310 | if (size > rsvd_bytes) { |
Paul Burton | 6627aa3 | 2013-09-04 15:16:59 +0100 | [diff] [blame] | 311 | printf("size > volume size! Aborting!\n"); |
| 312 | return EINVAL; |
| 313 | } |
| 314 | |
| 315 | err = ubi_start_update(ubi, vol, full_size); |
| 316 | if (err < 0) { |
| 317 | printf("Cannot start volume update\n"); |
| 318 | return -err; |
| 319 | } |
| 320 | |
| 321 | return ubi_volume_continue_write(volume, buf, size); |
| 322 | } |
| 323 | |
| 324 | int ubi_volume_write(char *volume, void *buf, size_t size) |
| 325 | { |
| 326 | return ubi_volume_begin_write(volume, buf, size, size); |
| 327 | } |
| 328 | |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 329 | int ubi_volume_read(char *volume, char *buf, size_t size) |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 330 | { |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 331 | int err, lnum, off, len, tbuf_size; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 332 | void *tbuf; |
| 333 | unsigned long long tmp; |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 334 | struct ubi_volume *vol; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 335 | loff_t offp = 0; |
Holger Dengler | a14912b | 2017-08-30 18:38:52 +0200 | [diff] [blame] | 336 | size_t len_read; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 337 | |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 338 | vol = ubi_find_volume(volume); |
| 339 | if (vol == NULL) |
| 340 | return ENODEV; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 341 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 342 | if (vol->updating) { |
| 343 | printf("updating"); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 344 | return EBUSY; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 345 | } |
| 346 | if (vol->upd_marker) { |
| 347 | printf("damaged volume, update marker is set"); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 348 | return EBADF; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 349 | } |
| 350 | if (offp == vol->used_bytes) |
| 351 | return 0; |
| 352 | |
| 353 | if (size == 0) { |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 354 | printf("No size specified -> Using max size (%lld)\n", vol->used_bytes); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 355 | size = vol->used_bytes; |
| 356 | } |
| 357 | |
Tom Rini | 3aa6e39 | 2018-07-26 11:17:24 -0400 | [diff] [blame] | 358 | printf("Read %zu bytes from volume %s to %p\n", size, volume, buf); |
Stefan Agner | 08d4e0c | 2018-06-25 11:19:12 +0200 | [diff] [blame] | 359 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 360 | if (vol->corrupted) |
| 361 | printf("read from corrupted volume %d", vol->vol_id); |
| 362 | if (offp + size > vol->used_bytes) |
Marek Vasut | 40c0c8b | 2011-09-30 12:13:25 +0200 | [diff] [blame] | 363 | size = vol->used_bytes - offp; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 364 | |
| 365 | tbuf_size = vol->usable_leb_size; |
| 366 | if (size < tbuf_size) |
| 367 | tbuf_size = ALIGN(size, ubi->min_io_size); |
Marcel Ziswiler | abc574b | 2015-08-18 13:06:37 +0200 | [diff] [blame] | 368 | tbuf = malloc_cache_aligned(tbuf_size); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 369 | if (!tbuf) { |
| 370 | printf("NO MEM\n"); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 371 | return ENOMEM; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 372 | } |
| 373 | len = size > tbuf_size ? tbuf_size : size; |
| 374 | |
| 375 | tmp = offp; |
| 376 | off = do_div(tmp, vol->usable_leb_size); |
| 377 | lnum = tmp; |
Holger Dengler | a14912b | 2017-08-30 18:38:52 +0200 | [diff] [blame] | 378 | len_read = size; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 379 | do { |
| 380 | if (off + len >= vol->usable_leb_size) |
| 381 | len = vol->usable_leb_size - off; |
| 382 | |
| 383 | err = ubi_eba_read_leb(ubi, vol, lnum, tbuf, off, len, 0); |
| 384 | if (err) { |
| 385 | printf("read err %x\n", err); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 386 | err = -err; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 387 | break; |
| 388 | } |
| 389 | off += len; |
| 390 | if (off == vol->usable_leb_size) { |
| 391 | lnum += 1; |
| 392 | off -= vol->usable_leb_size; |
| 393 | } |
| 394 | |
| 395 | size -= len; |
| 396 | offp += len; |
| 397 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 398 | memcpy(buf, tbuf, len); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 399 | |
| 400 | buf += len; |
| 401 | len = size > tbuf_size ? tbuf_size : size; |
| 402 | } while (size); |
| 403 | |
Holger Dengler | a14912b | 2017-08-30 18:38:52 +0200 | [diff] [blame] | 404 | if (!size) |
| 405 | env_set_hex("filesize", len_read); |
| 406 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 407 | free(tbuf); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 408 | return err; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 409 | } |
| 410 | |
Simon Kagstrom | 4a8fbfb | 2009-07-07 16:59:46 +0200 | [diff] [blame] | 411 | static int ubi_dev_scan(struct mtd_info *info, char *ubidev, |
| 412 | const char *vid_header_offset) |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 413 | { |
| 414 | struct mtd_device *dev; |
| 415 | struct part_info *part; |
| 416 | struct mtd_partition mtd_part; |
Simon Kagstrom | 4a8fbfb | 2009-07-07 16:59:46 +0200 | [diff] [blame] | 417 | char ubi_mtd_param_buffer[80]; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 418 | u8 pnum; |
| 419 | int err; |
| 420 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 421 | if (find_dev_and_part(ubidev, &dev, &pnum, &part) != 0) |
| 422 | return 1; |
| 423 | |
| 424 | sprintf(buffer, "mtd=%d", pnum); |
| 425 | memset(&mtd_part, 0, sizeof(mtd_part)); |
| 426 | mtd_part.name = buffer; |
| 427 | mtd_part.size = part->size; |
| 428 | mtd_part.offset = part->offset; |
| 429 | add_mtd_partitions(info, &mtd_part, 1); |
| 430 | |
Simon Kagstrom | 4a8fbfb | 2009-07-07 16:59:46 +0200 | [diff] [blame] | 431 | strcpy(ubi_mtd_param_buffer, buffer); |
| 432 | if (vid_header_offset) |
| 433 | sprintf(ubi_mtd_param_buffer, "mtd=%d,%s", pnum, |
| 434 | vid_header_offset); |
| 435 | err = ubi_mtd_param_parse(ubi_mtd_param_buffer, NULL); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 436 | if (err) { |
| 437 | del_mtd_partitions(info); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 438 | return -err; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 439 | } |
| 440 | |
| 441 | err = ubi_init(); |
| 442 | if (err) { |
| 443 | del_mtd_partitions(info); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 444 | return -err; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 445 | } |
| 446 | |
Stefan Roese | 1b20eb8 | 2008-11-27 14:07:09 +0100 | [diff] [blame] | 447 | ubi_initialized = 1; |
| 448 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 449 | return 0; |
| 450 | } |
| 451 | |
Heiko Schocher | 8b4b05f | 2016-06-07 08:55:40 +0200 | [diff] [blame] | 452 | int ubi_detach(void) |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 453 | { |
Andreas Huber | 7bf15f8 | 2009-04-02 17:15:34 +0200 | [diff] [blame] | 454 | if (mtdparts_init() != 0) { |
| 455 | printf("Error initializing mtdparts!\n"); |
| 456 | return 1; |
| 457 | } |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 458 | |
| 459 | #ifdef CONFIG_CMD_UBIFS |
| 460 | /* |
| 461 | * Automatically unmount UBIFS partition when user |
| 462 | * changes the UBI device. Otherwise the following |
| 463 | * UBIFS commands will crash. |
| 464 | */ |
| 465 | if (ubifs_is_mounted()) |
| 466 | cmd_ubifs_umount(); |
| 467 | #endif |
| 468 | |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 469 | /* |
| 470 | * Call ubi_exit() before re-initializing the UBI subsystem |
| 471 | */ |
| 472 | if (ubi_initialized) { |
| 473 | ubi_exit(); |
| 474 | del_mtd_partitions(ubi_dev.mtd_info); |
Heiko Schocher | 8b4b05f | 2016-06-07 08:55:40 +0200 | [diff] [blame] | 475 | ubi_initialized = 0; |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 476 | } |
| 477 | |
Heiko Schocher | 8b4b05f | 2016-06-07 08:55:40 +0200 | [diff] [blame] | 478 | ubi_dev.selected = 0; |
| 479 | return 0; |
| 480 | } |
| 481 | |
| 482 | int ubi_part(char *part_name, const char *vid_header_offset) |
| 483 | { |
| 484 | int err = 0; |
| 485 | char mtd_dev[16]; |
| 486 | struct mtd_device *dev; |
| 487 | struct part_info *part; |
| 488 | u8 pnum; |
| 489 | |
| 490 | ubi_detach(); |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 491 | /* |
| 492 | * Search the mtd device number where this partition |
| 493 | * is located |
| 494 | */ |
| 495 | if (find_dev_and_part(part_name, &dev, &pnum, &part)) { |
| 496 | printf("Partition %s not found!\n", part_name); |
| 497 | return 1; |
| 498 | } |
| 499 | sprintf(mtd_dev, "%s%d", MTD_DEV_TYPE(dev->id->type), dev->id->num); |
| 500 | ubi_dev.mtd_info = get_mtd_device_nm(mtd_dev); |
| 501 | if (IS_ERR(ubi_dev.mtd_info)) { |
| 502 | printf("Partition %s not found on device %s!\n", part_name, |
| 503 | mtd_dev); |
| 504 | return 1; |
| 505 | } |
| 506 | |
| 507 | ubi_dev.selected = 1; |
| 508 | |
| 509 | strcpy(ubi_dev.part_name, part_name); |
| 510 | err = ubi_dev_scan(ubi_dev.mtd_info, ubi_dev.part_name, |
| 511 | vid_header_offset); |
| 512 | if (err) { |
| 513 | printf("UBI init error %d\n", err); |
Stefan Roese | 8a717d5 | 2018-06-26 08:12:32 +0200 | [diff] [blame] | 514 | printf("Please check, if the correct MTD partition is used (size big enough?)\n"); |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 515 | ubi_dev.selected = 0; |
| 516 | return err; |
| 517 | } |
| 518 | |
| 519 | ubi = ubi_devices[0]; |
| 520 | |
| 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
| 525 | { |
Paul Burton | df68616 | 2013-09-04 15:16:58 +0100 | [diff] [blame] | 526 | int64_t size = 0; |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 527 | ulong addr = 0; |
| 528 | |
| 529 | if (argc < 2) |
| 530 | return CMD_RET_USAGE; |
Andreas Huber | 7bf15f8 | 2009-04-02 17:15:34 +0200 | [diff] [blame] | 531 | |
Heiko Schocher | 8b4b05f | 2016-06-07 08:55:40 +0200 | [diff] [blame] | 532 | |
| 533 | if (strcmp(argv[1], "detach") == 0) { |
| 534 | if (argc < 2) |
| 535 | return CMD_RET_USAGE; |
| 536 | |
| 537 | return ubi_detach(); |
| 538 | } |
| 539 | |
| 540 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 541 | if (strcmp(argv[1], "part") == 0) { |
Simon Kagstrom | 4a8fbfb | 2009-07-07 16:59:46 +0200 | [diff] [blame] | 542 | const char *vid_header_offset = NULL; |
Stefan Roese | 62eafb7 | 2009-04-24 20:24:19 +0200 | [diff] [blame] | 543 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 544 | /* Print current partition */ |
| 545 | if (argc == 2) { |
Stefan Roese | 62eafb7 | 2009-04-24 20:24:19 +0200 | [diff] [blame] | 546 | if (!ubi_dev.selected) { |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 547 | printf("Error, no UBI device/partition selected!\n"); |
| 548 | return 1; |
| 549 | } |
| 550 | |
Stefan Roese | 62eafb7 | 2009-04-24 20:24:19 +0200 | [diff] [blame] | 551 | printf("Device %d: %s, partition %s\n", |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 552 | ubi_dev.nr, ubi_dev.mtd_info->name, ubi_dev.part_name); |
| 553 | return 0; |
| 554 | } |
| 555 | |
Wolfgang Denk | 3b68311 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 556 | if (argc < 3) |
Simon Glass | a06dfc7 | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 557 | return CMD_RET_USAGE; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 558 | |
Simon Kagstrom | 4a8fbfb | 2009-07-07 16:59:46 +0200 | [diff] [blame] | 559 | if (argc > 3) |
| 560 | vid_header_offset = argv[3]; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 561 | |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 562 | return ubi_part(argv[2], vid_header_offset); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 563 | } |
| 564 | |
Stefan Roese | 62eafb7 | 2009-04-24 20:24:19 +0200 | [diff] [blame] | 565 | if ((strcmp(argv[1], "part") != 0) && (!ubi_dev.selected)) { |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 566 | printf("Error, no UBI device/partition selected!\n"); |
| 567 | return 1; |
| 568 | } |
| 569 | |
| 570 | if (strcmp(argv[1], "info") == 0) { |
| 571 | int layout = 0; |
| 572 | if (argc > 2 && !strncmp(argv[2], "l", 1)) |
| 573 | layout = 1; |
| 574 | return ubi_info(layout); |
| 575 | } |
| 576 | |
Heiko Schocher | 1762ab1 | 2014-01-25 07:27:11 +0100 | [diff] [blame] | 577 | if (strcmp(argv[1], "check") == 0) { |
| 578 | if (argc > 2) |
| 579 | return ubi_check(argv[2]); |
| 580 | |
| 581 | printf("Error, no volume name passed\n"); |
| 582 | return 1; |
| 583 | } |
| 584 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 585 | if (strncmp(argv[1], "create", 6) == 0) { |
| 586 | int dynamic = 1; /* default: dynamic volume */ |
Ladislav Michl | 39370f1 | 2016-09-13 07:14:01 +0200 | [diff] [blame] | 587 | int id = UBI_VOL_NUM_AUTO; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 588 | |
| 589 | /* Use maximum available size */ |
| 590 | size = 0; |
| 591 | |
Ladislav Michl | 39370f1 | 2016-09-13 07:14:01 +0200 | [diff] [blame] | 592 | /* E.g., create volume size type vol_id */ |
| 593 | if (argc == 6) { |
| 594 | id = simple_strtoull(argv[5], NULL, 16); |
| 595 | argc--; |
| 596 | } |
| 597 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 598 | /* E.g., create volume size type */ |
| 599 | if (argc == 5) { |
| 600 | if (strncmp(argv[4], "s", 1) == 0) |
| 601 | dynamic = 0; |
| 602 | else if (strncmp(argv[4], "d", 1) != 0) { |
| 603 | printf("Incorrect type\n"); |
| 604 | return 1; |
| 605 | } |
| 606 | argc--; |
| 607 | } |
| 608 | /* E.g., create volume size */ |
| 609 | if (argc == 4) { |
Ladislav Michl | 4fb937b | 2017-01-19 11:45:35 +0100 | [diff] [blame] | 610 | if (argv[3][0] != '-') |
| 611 | size = simple_strtoull(argv[3], NULL, 16); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 612 | argc--; |
| 613 | } |
| 614 | /* Use maximum available size */ |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 615 | if (!size) { |
Paul Burton | df68616 | 2013-09-04 15:16:58 +0100 | [diff] [blame] | 616 | size = (int64_t)ubi->avail_pebs * ubi->leb_size; |
| 617 | printf("No size specified -> Using max size (%lld)\n", size); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 618 | } |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 619 | /* E.g., create volume */ |
| 620 | if (argc == 3) |
Ladislav Michl | 39370f1 | 2016-09-13 07:14:01 +0200 | [diff] [blame] | 621 | return ubi_create_vol(argv[2], size, dynamic, id); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | if (strncmp(argv[1], "remove", 6) == 0) { |
| 625 | /* E.g., remove volume */ |
| 626 | if (argc == 3) |
| 627 | return ubi_remove_vol(argv[2]); |
| 628 | } |
| 629 | |
| 630 | if (strncmp(argv[1], "write", 5) == 0) { |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 631 | int ret; |
| 632 | |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 633 | if (argc < 5) { |
| 634 | printf("Please see usage\n"); |
| 635 | return 1; |
| 636 | } |
| 637 | |
| 638 | addr = simple_strtoul(argv[2], NULL, 16); |
Stefan Roese | 1b71405 | 2008-11-24 08:31:16 +0100 | [diff] [blame] | 639 | size = simple_strtoul(argv[4], NULL, 16); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 640 | |
Paul Burton | 6627aa3 | 2013-09-04 15:16:59 +0100 | [diff] [blame] | 641 | if (strlen(argv[1]) == 10 && |
| 642 | strncmp(argv[1] + 5, ".part", 5) == 0) { |
| 643 | if (argc < 6) { |
| 644 | ret = ubi_volume_continue_write(argv[3], |
| 645 | (void *)addr, size); |
| 646 | } else { |
| 647 | size_t full_size; |
| 648 | full_size = simple_strtoul(argv[5], NULL, 16); |
| 649 | ret = ubi_volume_begin_write(argv[3], |
| 650 | (void *)addr, size, full_size); |
| 651 | } |
| 652 | } else { |
| 653 | ret = ubi_volume_write(argv[3], (void *)addr, size); |
| 654 | } |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 655 | if (!ret) { |
Paul Burton | df68616 | 2013-09-04 15:16:58 +0100 | [diff] [blame] | 656 | printf("%lld bytes written to volume %s\n", size, |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 657 | argv[3]); |
| 658 | } |
| 659 | |
| 660 | return ret; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 661 | } |
| 662 | |
| 663 | if (strncmp(argv[1], "read", 4) == 0) { |
| 664 | size = 0; |
| 665 | |
| 666 | /* E.g., read volume size */ |
| 667 | if (argc == 5) { |
Stefan Roese | 1b71405 | 2008-11-24 08:31:16 +0100 | [diff] [blame] | 668 | size = simple_strtoul(argv[4], NULL, 16); |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 669 | argc--; |
| 670 | } |
| 671 | |
| 672 | /* E.g., read volume */ |
| 673 | if (argc == 4) { |
| 674 | addr = simple_strtoul(argv[2], NULL, 16); |
| 675 | argc--; |
| 676 | } |
| 677 | |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 678 | if (argc == 3) { |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 679 | return ubi_volume_read(argv[3], (char *)addr, size); |
Joe Hershberger | 9219845 | 2013-04-08 10:32:47 +0000 | [diff] [blame] | 680 | } |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | printf("Please see usage\n"); |
Stefan Roese | 8cfc696 | 2011-03-14 14:34:21 +0100 | [diff] [blame] | 684 | return 1; |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 685 | } |
| 686 | |
Frans Meulenbroeks | 7675a09 | 2010-07-31 15:01:53 +0200 | [diff] [blame] | 687 | U_BOOT_CMD( |
| 688 | ubi, 6, 1, do_ubi, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 689 | "ubi commands", |
Heiko Schocher | 8b4b05f | 2016-06-07 08:55:40 +0200 | [diff] [blame] | 690 | "detach" |
| 691 | " - detach ubi from a mtd partition\n" |
| 692 | "ubi part [part] [offset]\n" |
Simon Kagstrom | 4a8fbfb | 2009-07-07 16:59:46 +0200 | [diff] [blame] | 693 | " - Show or set current partition (with optional VID" |
| 694 | " header offset)\n" |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 695 | "ubi info [l[ayout]]" |
| 696 | " - Display volume and ubi layout information\n" |
Heiko Schocher | 1762ab1 | 2014-01-25 07:27:11 +0100 | [diff] [blame] | 697 | "ubi check volumename" |
| 698 | " - check if volumename exists\n" |
Ladislav Michl | 4fb937b | 2017-01-19 11:45:35 +0100 | [diff] [blame] | 699 | "ubi create[vol] volume [size] [type] [id]\n" |
| 700 | " - create volume name with size ('-' for maximum" |
| 701 | " available size)\n" |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 702 | "ubi write[vol] address volume size" |
| 703 | " - Write volume from address with size\n" |
Paul Burton | 6627aa3 | 2013-09-04 15:16:59 +0100 | [diff] [blame] | 704 | "ubi write.part address volume size [fullsize]\n" |
| 705 | " - Write part of a volume from address\n" |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 706 | "ubi read[vol] address volume [size]" |
| 707 | " - Read volume to address with size\n" |
| 708 | "ubi remove[vol] volume" |
| 709 | " - Remove volume\n" |
| 710 | "[Legends]\n" |
Andrzej Wolski | 7dcc170 | 2009-07-17 22:26:54 +0200 | [diff] [blame] | 711 | " volume: character name\n" |
| 712 | " size: specified in bytes\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 713 | " type: s[tatic] or d[ynamic] (default=dynamic)" |
Kyungmin Park | 3d2c5ff | 2008-11-19 11:47:05 +0100 | [diff] [blame] | 714 | ); |