summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* state: select CRC32Lucas Stach2016-06-031-0/+1
| | | | | | | | The raw state backend uses crc32 unconditionally, so make sure it's present. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: select dependencies for defaultenv-2Lucas Stach2016-05-301-0/+3
| | | | | | | | | Now that GLOBALVAR and NVVAR are user visible options they need to be selected when selecting the global and nv command support which uses them. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* console: Fix initial value of baudrate parameterSascha Hauer2016-05-261-1/+1
| | | | | | | | The 'baudrate' parameter has the wrong value initially, it has to be set to CONFIG_BAUDRATE. Otherwise a devinfo shows a baudrate of 0 until actively changed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imd: make it work on big-endian machinesAntony Pavlov2016-05-231-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The commit commit 5e335773e0814173b40873a891964a7858d64688 Author: Sascha Hauer <s.hauer@pengutronix.de> Date: Tue Mar 29 10:06:46 2016 +0200 imd: use struct imd_header * as argument introduces additional imd type checks like this if (!imd_is_string(imd->type)) return NULL; These checks work incorrectly on any big-endian machine because the imd->type field needs addition conversion to little-endian byteorder before use. Here is the imd command output on big-endian qemu-malta: barebox:/ imd /dev/nor0.barebox release: <NULL> build: <NULL> This patch fixes the problem by adding necessary conversion via imd_read_type(). Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imx-bbu-nand-fcb: add missing newline characterStefan Christ2016-05-191-2/+2
| | | | | Signed-off-by: Stefan Christ <s.christ@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* reset_source: export reset_source_set_priorityAlexander Stein2016-05-131-1/+1
| | | | | | | | | | | In commit 4a7534bf07e ("reset-source: Allow different priorities") the function name changed from reset_source_set to reset_source_set_priority. Do that change in EXPORT_SYMBOL() accordingly. reset_source_set still exists but is a static inline now. Fixes: 4a7534bf07e ("reset-source: Allow different priorities") Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ubiformat'Sascha Hauer2016-05-093-0/+689
|\
| * ubiformat: use default values for ubi_ver and image_seqSascha Hauer2016-04-261-0/+6
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: ubiformat: move code to common/Sascha Hauer2016-04-263-0/+683
| | | | | | | | | | | | | | 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>
* | Merge branch 'for-next/misc'Sascha Hauer2016-05-095-21/+64
|\ \
| * | Kconfig: Create Kconfig symbol for NVVARSascha Hauer2016-04-282-2/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | nvvar support not only needs globalvar, but also persistent environment storage. Add a separate default-y option which depends on ENV_HANDLING for this case. Make the option visible to let the user decide whether he wants to have this option and add a help text to make this decision easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | Kconfig: Make ENV_HANDLING visibleSascha Hauer2016-04-281-5/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | ENV_HANDLING is usable even without explicit loadenv/saveenv command support. Instead of selecting this option from loadenv/saveenv, make this option visible. loadenv/saveenv can then depend on ENV_HANDLING rather than selecting it. This reduces Kconfig dependencies hassles. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | Kconfig: Make GLOBALVAR visibleSascha Hauer2016-04-281-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently global environment variables are only enabled when the "global" command is enabled. In fact, they could be used even with the "global" command disabled, so make the GLOBALVAR option visible. While at it, add a help text for this option. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | state: Fix Kconfig dependenciesSascha Hauer2016-04-281-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | State support does not need OF_BAREBOX_DRIVERS and never did, so drop the dependency there. It's the state driver which needs of_find_path(), since this symbol now is always enabled when OF is enabled, we don't have to add the dependency to the state driver, but instead can depend on OFDEVICE. We could depend on OF instead, but compiling the state driver without OFDEVICE makes no sense. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | whole tree: remove trailing whitespacesDu Huanpeng2016-04-212-4/+4
| | | | | | | | | | | | | | | Signed-off-by: Du Huanpeng <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | menu: add vi like key supportDu Huanpeng2016-04-191-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | add vi like key support: j: down k: up <Space>: select Signed-off-by: Du Huanpeng <u74147@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/include-cleanup'Sascha Hauer2016-05-0919-63/+67
|\ \ \
| * | | stdio: Replace FILE functions with filedescriptor functionsSascha Hauer2016-04-153-20/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have defined stdin, stdout and stderr as integer file descriptors, but normally they should be FILE *. Also fprintf, fputc and fputs take file descriptors instead of FILE *. As FILE * are inconvenient in the barebox environment replace the f* functions with the corresponding d* functions. dprintf is POSIX conform whereas dputc and dputs are barebox specific, but do not conflict with any stdc function. fgetc is unused and can be removed without replacing it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | stdio: replace fprintf(stderr,...) with eprintfSascha Hauer2016-04-151-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a shortcut for fprintf(stderr, so use it. This is done to be able to remove fprintf in the next step. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | stdio: rename getc to getcharSascha Hauer2016-04-154-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The function we have implemented as getc has the semantics of the standard function getchar, so rename it accorgingly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | string: Fix (v)asprintf prototypesSascha Hauer2016-04-1510-32/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | include: move crc specific stuff to crc.hSascha Hauer2016-04-155-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a crc.h, so move our crc function prototypes there to further cleanup common.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | include: move shell prototypes to shell.hSascha Hauer2016-04-152-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | We have a shell,h, so move shell specific prototypes there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | include: move run_command prototype to command.hSascha Hauer2016-04-152-0/+2
| |/ / | | | | | | | | | | | | | | | run_command fits much better into command.h, move it there. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/bootm'Sascha Hauer2016-05-094-37/+57
|\ \ \
| * | | blspec: push appendroot handling to bootmSascha Hauer2016-05-041-26/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The bootm code now can handle the adding of the root= option itself, so drop the code and let bootm do it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | bootm: Optionally add a root= option to Kernel command lineSascha Hauer2016-05-041-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It becomes a common case that the Kernel is loaded from the filesystem which later becomes the rootfs. This adds a possibility to let bootm automatically append the root= option to the kernel command line. This is done when global.bootm.appendroot is true. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | getenv_bool: use strtoboolSascha Hauer2016-04-291-11/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We now have a library function to convert a string to a boolean type. Use it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | globalvar: Allow to remove globalvarsSascha Hauer2016-04-291-0/+10
| | |/ | |/| | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/arm'Sascha Hauer2016-05-091-0/+12
|\ \ \ | |/ / |/| |
| * | move FLEXIBLE_BOOTARGS from commands/ to common/Sascha Hauer2016-04-251-0/+12
| |/ | | | | | | | | | | | | | | FLEXIBLE_BOOTARGS also works without command support being enabled. Move this option from commands/Kconfig to common/Kconfig so that it doesn't depend on COMMAND_SUPPORT. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | filetype: Fix booting ARM Linux Kernels with CONFIG_EFI enabledSascha Hauer2016-04-191-2/+3
| | | | | | | | | | | | | | | | When an ARM kernel is built with CONFIG_EFI enabled, then the kernel image also looks like a EXE file. Move ARM zImage detection before EXE detection so that the kernel is still detected as zImage. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fix erasing/protecting flashes with unspecified sizeSascha Hauer2016-04-191-1/+2
|/ | | | | | | | | | | | | | | | | fixes: 81737c1 mtd: Fix erasing of devices >4GiB Several places erased a complete flash partition passing ~0 as count to erase(). With the above commit count to erase was changed from an unsigned type to a signed type, so the (count > f->size - offset) check in erase() no longer triggers and the ~0 count is no longer adjusted to the whole device size. Among other things this results in saveenv failures on NOR flashes. This patch fixes this by introducing an explicit macro for erasing the whole device which is tested for in erase(). All other negative values are rejected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Giorgio <giorgio.nicole@arcor.de>
* Merge branch 'for-next/imx-bbu-nand-fcb'Sascha Hauer2016-04-082-153/+827
|\
| * imx-bbu-nand-fcb: Print error message when out of pebsSascha Hauer2016-04-081-1/+3
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * imx-bbu-nand-fcb: Make robust against power cutsSascha Hauer2016-04-081-31/+341
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes the update to Nand robust against power failures. With this we make sure that during every step of the update at least one of the two images on Nand is readable and valid. Also this patch makes it possible to refresh/repair the boot images on Nand. This may become necessary when a previous update has been interrupted due to a power cut, or when the number of bitflips is near to the number we can correct. This is also done in a way that allow power cuts at every step. We assume the following layout in the Nand flash: fwmaxsize = (n_blocks - 4) / 2 block 0 ---------------------- | FCB/DBBT 0 | 1 ---------------------- | FCB/DBBT 1 | 2 ---------------------- | FCB/DBBT 2 | 3 ---------------------- | FCB/DBBT 3 | 4 ---------------------- | Firmware slot 0 | 4 + fwmaxsize ---------------------- | Firmware slot 1 | ---------------------- When the layout found on the device differs from the above the update won't be robust, but nevertheless works. Since the layout is changed to the above during the update, the next update will be robust. Here's the strategy we use to implement a robust update: The FCBs contain pointers to the firmware slots in the Firmware1_startingPage and Firmware2_startingPage fields. Note that Firmware1_startingPage doesn't necessarily point to slot 0. We exchange the pointers during update to atomically switch between the old and the new firmware. - We read the first valid FCB and the firmware slots. - We check which firmware slot is currently used by the ROM: - if no FCB is found or its layout differs from the above layout, continue without robust update - if only one firmware slot is readable, the ROM uses it - if both slots are readable, the ROM will use slot 0 - Step 1: erase/update the slot currently unused by the ROM - Step 2: Update FCBs/DBBTs, thereby letting Firmware1_startingPage point to the slot we just updated. From this moment on the new firmware will be used and running a refresh/repair after a power failure after this step will complete the update. - Step 3: erase/update the other firmwre slot - Step 4: Eventually write FCBs/DBBTs again. This may become necessary when step 3 revealed new bad blocks. Refreshing the firmware which is needed when when blocks become unreadable due to read disturbance works the same way, only that the new firmware is the same as the old firmware and that it will only be written when reading from the device returns -EUCLEAN indicating that a block needs to be rewritten. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * imx-bbu-nand-fcb: Print error when writing blocks failsSascha Hauer2016-04-081-1/+3
| | | | | | | | | | | | | | When writing to a block fails the update handler fails relatively silent. Print an error message in this case. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * imx-bbu-nand-fcb: When writing firmware return new bad blocksSascha Hauer2016-04-081-2/+3
| | | | | | | | | | | | | | | | | | | | Positive return values of imx_bbu_write_firmware() so far indicate the last block that has been written to. This value is unused, so return values > 0 to indicate if there are new bad blocks. This information can be used in the next step to know if the DBBT has to be rewritten. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * imx-bbu-nand-fcb: Only write FCBs/DBBTs when necessarySascha Hauer2016-04-081-0/+230
| | | | | | | | | | | | | | | | Instead of writing the FCBs/DBBTs on every update write them only if they have changed or if a block needs cleanup (returns -EUCLEAN) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * imx-bbu-nand-fcb: erase on demandSascha Hauer2016-04-081-33/+14
| | | | | | | | | | | | | | | | Instead of erasing the whole partition on update entry, erase the areas separately when we actually want to write them. This is done as a step towards robust update. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * imx-bbu-nand-fcb: factor out a fcb write functionSascha Hauer2016-04-081-86/+172
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * imx-bbu-nand-fcb: Use mtd-peb API to write firmwareSascha Hauer2016-04-081-9/+35
| | | | | | | | | | | | | | | | With this patch we verify the firmware written to the NAND and thus can react on write failures. We torture the block and if it went bad we mark it as bad. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * imx-bbu-nand-fcb: factor out layout functionsSascha Hauer2016-04-081-20/+46
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * bbu: Allow to refresh/repair imagesSascha Hauer2016-04-081-1/+11
| | | | | | | | | | | | | | | | | | | | Some SoCs allow to store multiple boot images on a device in order to improve robustness. This adds a -r option to barebox_update to indicate we do not want to make an update but instead repair/refresh an existing image. Handlers which want to support this feature must set the BBU_HANDLER_CAN_REFRESH flag during registration. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/imx'Sascha Hauer2016-04-081-0/+1
|\ \
| * | common: Add EPROBE_DEFER to strerrorAndrey Smirnov2016-03-171-0/+1
| |/ | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: add dependency !SANDBOX on imd target toolAntony Pavlov2016-04-071-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The build of bareboximd-target tool fails on sandbox architecture: CC scripts/bareboximd-target /tmp/ccoGPulo.o: In function `imd_concat_strings': scripts/../common/imd.c:216: undefined reference to `barebox_malloc' /tmp/ccoGPulo.o: In function `read_file_2': scripts/bareboximd.c:68: undefined reference to `barebox_open' scripts/bareboximd.c:74: undefined reference to `barebox_lseek' scripts/bareboximd.c:84: undefined reference to `barebox_lseek' scripts/bareboximd.c:90: undefined reference to `barebox_malloc' scripts/bareboximd.c:99: undefined reference to `barebox_read' scripts/bareboximd.c:119: undefined reference to `barebox_free' scripts/bareboximd.c:121: undefined reference to `barebox_close' /tmp/ccoGPulo.o: In function `imd_command': scripts/../common/imd.c:292: undefined reference to `barebox_printf' scripts/../common/imd.c:319: undefined reference to `barebox_printf' scripts/../common/imd.c:322: undefined reference to `barebox_free' scripts/../common/imd.c:324: undefined reference to `barebox_printf' /tmp/ccoGPulo.o: In function `usage': scripts/bareboximd.c:134: undefined reference to `barebox_printf' collect2: error: ld returned 1 exit status scripts/Makefile:58: recipe for target 'scripts/bareboximd-target' failed See also commit d4aa01503348a033b1057d8a66c20a4f5819e01f Author: Alexander Aring <alex.aring@gmail.com> Date: Tue Nov 19 02:08:13 2013 +0100 common: add dependency !SANDBOX on target tools The build of target tools fails on sandbox architecture. We don't need any target tools in this case, so add a dependency. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Cc: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bbu: print and evaluate image MetadataSascha Hauer2016-04-061-0/+78
| | | | | | | | | | | | | | | | | | | | | | With imd we can store metadata in barebox images. Let's use this information to further verify that the image that is to be flashed is the correct one. This patch extracts the device tree compatible from the image and compares it with the one from the currently running barebox. If it doesn't match the update is aborted with a warning. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | imd: Add function to read parametersSascha Hauer2016-04-011-0/+31
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | imd: export functionsSascha Hauer2016-04-011-3/+27
| | | | | | | | | | | | | | To make the image metadata API usable for external users export some functions. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>