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