summaryrefslogtreecommitdiffstats
path: root/commands/ubiformat.c
Commit message (Collapse)AuthorAgeFilesLines
* commands/*: Replace license and copyright boilerplate by SPDX identfiersUwe Kleine-König2020-04-271-14/+3
| | | | | | | | | | | | | While at it also drop references to the non-existing CREDITS file and do some small rearrangements for some uniform formatting. (SPDX-License-Identifier first, then copyright texts and then an empty line.) The advantage is that these specifiers are machine-parseable which helps license conformance. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: improve generation of UBI image sequenceSascha Hauer2019-07-151-1/+0
| | | | | | | | | | | | | | | | | | | | The UBI ec_hdr has an image_seq field. During attaching UBI expects that its value is the same for all eraseblocks. The value should be changed with every ubiformat and is used to detect half written images. In barebox we use a pseudo random number generated with rand() for this value. The ubiformat command calls srand(get_time_ns()) to initialize the pseudo random numbber generator. This is done in the option parser, so when ubiformat() is called directly (from fastboot for example) the pseudo random number generator is not initialized and we get the same values after every barebox restart. This patch moves the pseudo random number generator initialization to the place where the numbers are generated. Also use random32() rather than rand() to generate 32bit values rather than 15bit values (0 - RAND_MAX). Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: use default values for ubi_ver and image_seqSascha Hauer2016-04-261-2/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: ubiformat: move code to common/Sascha Hauer2016-04-261-638/+2
| | | | | | | This is the final step to separate the ubiformat code from the command. With this the ubiformat code gains a C API. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: ubiformat: create separate function for ubiformatSascha Hauer2016-04-251-29/+54
| | | | | | | Factor out the code out of the main function to a ubiformat function to separate the command code from the ubiformat functionality. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: ubiformat: Pass around context dataSascha Hauer2016-04-251-120/+121
| | | | | | | Instead of using a static global context data struct, pass the data around. This is a first step to create a C API for ubiformat. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: Cleanly umount and detach the ubi before formatingMarkus Pargmann2016-04-081-2/+22
| | | | | | | | | | | | | | This was an open fixme for some time. ubiformat does not care about used ubi volumes or attached ubis. This patch adds functionality that umounts all filesystems that are mounted from this nand device. After that the ubi is detached. Then the normal ubiformat code reformats the ubi. If a ubi was detached previously, the code tries to reattach the ubi. Filesystems are not remounted. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: Use mtd-peb APISascha Hauer2016-04-061-91/+100
| | | | | | | | This changes ubiformat from the libmtd API to the mtd-peb API. This makes the libmtd API unnecessary and it can be removed in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: fix the subpage size hint on the error pathSascha Hauer2015-12-101-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | From mtd-utils commit: | commit 15685fe39f1665d53d8b316c8f837f20f8700d4b | Author: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> | Date: Mon Sep 8 15:05:54 2014 +0300 | | ubiformat: fix the subpage size hint on the error path | | David Binderman <dcb314@hotmail.com> reports that the following piece of looks | wrong: | | if (!args.subpage_size != mtd->min_io_size) | normsg("may be sub-page size is incorrect?"); | | I totally agree with him and I believe that we actually meant to have no | negation in fron to f 'args.subpage_size', so instead, the code should look | like this: | | if (args.subpage_size != mtd->min_io_size) | normsg("may be sub-page size is incorrect?"); | | Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: remove dead codeJan Remmet2015-09-291-5/+2
| | | | | | | divisor isn't used. Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: ubiformat: Document -y optionSascha Hauer2015-08-281-0/+1
| | | | | | This was missing in the help text. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: fix argument parserAlexander Richter2015-05-201-1/+1
| | | | | | | | - remove duplicate 'y' option - add missing 'Q' option Signed-off-by: Alexander Richter <alexander.richter@atsonline.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* move file helper functions to separate fileSascha Hauer2014-08-071-0/+1
| | | | | | | | | | We have our file helper functions in several places. Move them all to lib/libfile.c. With this we no longer have file helpers in fs/fs.c which contains the core fs functions and no functions in lib/libbb.c which are not from busybox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: avoid macros in help textJan Luebbe2014-06-261-5/+5
| | | | | | | To simplify parsing of the help strings, we need to avoid using macros there. Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
* commands: harmonize in-barebox documentationHolger Schurig2014-05-141-25/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does probably too much, but it's hard (and very cumbersome/time consuming) to break it out. What is does is this: * each command has one short description, e.g. "list MUX configuration" * made sure the short descriptions start lowercase * each command has one usage. That string contains just the options, e.g. "[-npn]". It's not part of the long help text. * that is, it doesn't say "[OPTIONS]" anymore, every usable option is listed by character in this (short) option string (the long description is in the long help text, as before) * help texts have been reworked, to make them - sometimes smaller - sometimes describe the options better - more often present themselves in a nicer format * all long help texts are now created with BUSYBOX_CMD_HELP_ macros, no more 'static const __maybe_unused char cmd_foobar_help[]' * made sure the long help texts starts uppercase * because cmdtp->name and cmdtp->opts together provide the new usage, all "Usage: foobar" texts have been removed from the long help texts * BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this is nicer in the source code * BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself * made sure no line gets longer than 77 characters * delibertely renamed cmdtp->usage, so that we can get compile-time errors (e.g. in out-of-tree modules that use register_command() * the 'help' command can now always emit the usage, even without compiled long help texts * 'help -v' gives a list of commands with their short description, this is similar like the old "help" command before my patchset * 'help -a' gives out help of all commands Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: group 'help' outputHolger Schurig2014-05-141-0/+1
| | | | | | | | | | | | | | | | | | | The old output of "help" was just producing a long list, that usually scrolled of the screen (even on a X11 terminal). This list is more compact, and also sorted by groups. The old output format (plus grouping) is now available with 'help -v'. Example: Information commands: ?, devinfo, help, iomem, meminfo, version Boot commands: boot, bootm, go, loadb, loads, loadx, loady, saves, uimage ... Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: check file sizeJan Weitzel2013-06-241-0/+5
| | | | | | | | | If size of a flash image file is 0 ubiformat silently formats the volume. Check size and abort if size == 0. This may be the case if an empty or tftp mounted file is used. Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* ubiformat: get buffer from mallocJan Weitzel2013-04-031-7/+15
| | | | | | | | | There was a erase block sized (here 131072) char buf array on the stack. Changed this to get the space from malloc preventing stack overflows. Also fix a wrong return without clean up. Signed-off-by: Jan Weitzel <j.weitzel@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mtd'Sascha Hauer2013-03-041-4/+4
|\ | | | | | | | | | | Conflicts: arch/arm/configs/eukrea_cpuimx27_defconfig drivers/mtd/core.c
| * libmtd: rename functions from mtd_* to libmtd_*Sascha Hauer2013-02-141-4/+4
| | | | | | | | | | | | | | | | | | | | The kernel nowadays has mtd_read/write and other functions. In barebox we also have these functions, but with a different prototype, namely they correspond to the libmtd userspace functions. Rename these functions to libmtd_* to avoid name clashes with future mtd updates. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ubiformat: open flash image readonlySascha Hauer2013-02-211-1/+1
|/ | | | | | | ubiformat only needs readonly access to the image to flash, so open it readonly. Opening r/w may fail for example on tftp servers. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* fixup! commands: add ubiformatSascha Hauer2013-01-091-0/+784
This adds the missing ubiformat.c file missing from: commit 5a29d4aea71336558e13eb6ad8e662781653ae56 Author: Wolfram Sang <w.sang@pengutronix.de> Date: Mon Dec 17 16:48:33 2012 +0100 commands: add ubiformat Imported from mtd-utils and stripped down to needed functionality. Based on an older version (1.4.5.) since the newer do use MEMWRITE interfaces which we don't have in barebox (yet). Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>