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