9
0
Fork 0
Commit Graph

1860 Commits

Author SHA1 Message Date
Uwe Kleine-König 9efa564805 partitions: dos: add partuuid string for logical partitions
Commit bc31d85c6e ("cdev: Add partuuid string to struct cdev") added
partuuid strings for dos partitions but only for the (up to) four
primary partitions. Do the same for the logical partitions. Their
numbers start at 5 independently of the number of available primary
partitions.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 08:13:33 +02:00
Sascha Hauer 06f5a7c9ad Merge branch 'for-next/ubiformat' 2016-05-09 08:50:02 +02:00
Sascha Hauer 4cb8e17aa3 Merge branch 'for-next/misc' 2016-05-09 08:49:43 +02:00
Sascha Hauer 55aca0a48c Merge branch 'for-next/include-cleanup' 2016-05-09 08:49:42 +02:00
Sascha Hauer 8e2df29b5f Merge branch 'for-next/bootm' 2016-05-09 08:49:42 +02:00
Sascha Hauer 23debc6fd9 Merge branch 'for-next/arm' 2016-05-09 08:49:42 +02:00
Sascha Hauer a91ce459de blspec: push appendroot handling to bootm
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>
2016-05-04 11:58:46 +02:00
Sascha Hauer f66990af3c bootm: Optionally add a root= option to Kernel command line
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>
2016-05-04 11:58:46 +02:00
Sascha Hauer a66b7f8afd getenv_bool: use strtobool
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>
2016-04-29 11:29:25 +02:00
Sascha Hauer 941056dad1 globalvar: Allow to remove globalvars
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-29 11:29:25 +02:00
Sascha Hauer acd643788b Kconfig: Create Kconfig symbol for NVVAR
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>
2016-04-28 16:43:15 +02:00
Sascha Hauer 9a7b5d4cdc Kconfig: Make ENV_HANDLING visible
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>
2016-04-28 16:43:15 +02:00
Sascha Hauer 5c32248bec Kconfig: Make GLOBALVAR visible
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>
2016-04-28 16:43:15 +02:00
Sascha Hauer b61d301cf6 state: Fix Kconfig dependencies
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>
2016-04-28 16:43:14 +02:00
Sascha Hauer c17e8cf262 ubiformat: use default values for ubi_ver and image_seq
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-26 09:24:57 +02:00
Sascha Hauer 893228f66c commands: ubiformat: move code to common/
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>
2016-04-26 08:08:25 +02:00
Sascha Hauer 4ec00a9b3d move FLEXIBLE_BOOTARGS from commands/ to common/
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>
2016-04-25 13:37:38 +02:00
Du Huanpeng fe03b34fbe whole tree: remove trailing whitespaces
Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-21 15:17:52 +02:00
Sascha Hauer 50de03c8d3 filetype: Fix booting ARM Linux Kernels with CONFIG_EFI enabled
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>
2016-04-19 10:56:16 +02:00
Sascha Hauer cb8cf33ce8 fix erasing/protecting flashes with unspecified size
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>
2016-04-19 08:26:51 +02:00
Du Huanpeng 484a088f78 menu: add vi like key support
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>
2016-04-19 08:12:46 +02:00
Sascha Hauer 5559bfd271 stdio: Replace FILE functions with filedescriptor functions
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>
2016-04-15 12:21:46 +02:00
Sascha Hauer 473d6f8a7a stdio: replace fprintf(stderr,...) with eprintf
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>
2016-04-15 12:21:46 +02:00
Sascha Hauer 01f8f60cf0 stdio: rename getc to getchar
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>
2016-04-15 12:21:46 +02:00
Sascha Hauer 947fb5adf8 string: Fix (v)asprintf prototypes
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>
2016-04-15 12:21:45 +02:00
Sascha Hauer db33f32842 include: move crc specific stuff to crc.h
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>
2016-04-15 12:21:44 +02:00
Sascha Hauer 4e9f324d37 include: move shell prototypes to shell.h
We have a shell,h, so move shell specific prototypes there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer ea5aeb986c include: move run_command prototype to command.h
run_command fits much better into command.h, move it there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer fd50a8d758 Merge branch 'for-next/imx-bbu-nand-fcb' 2016-04-08 13:37:28 +02:00
Sascha Hauer 0d3f88a6db Merge branch 'for-next/imx' 2016-04-08 13:37:28 +02:00
Sascha Hauer 60f2c23684 imx-bbu-nand-fcb: Print error message when out of pebs
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:35:32 +02:00
Sascha Hauer b52c174b2d imx-bbu-nand-fcb: Make robust against power cuts
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>
2016-04-08 13:35:32 +02:00
Sascha Hauer ab603a5e30 imx-bbu-nand-fcb: Print error when writing blocks fails
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>
2016-04-08 13:35:32 +02:00
Sascha Hauer 5c9b26378e imx-bbu-nand-fcb: When writing firmware return new bad blocks
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>
2016-04-08 13:35:32 +02:00
Sascha Hauer 9ec9e1b5de imx-bbu-nand-fcb: Only write FCBs/DBBTs when necessary
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>
2016-04-08 13:35:32 +02:00
Sascha Hauer 678617ecaf imx-bbu-nand-fcb: erase on demand
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>
2016-04-08 13:35:32 +02:00
Sascha Hauer 14fd7e9478 imx-bbu-nand-fcb: factor out a fcb write function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:35:32 +02:00
Sascha Hauer f6f7bccaa1 imx-bbu-nand-fcb: Use mtd-peb API to write firmware
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>
2016-04-08 13:35:32 +02:00
Sascha Hauer c5532a2d36 imx-bbu-nand-fcb: factor out layout functions
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-08 13:35:32 +02:00
Sascha Hauer fa61152d97 bbu: Allow to refresh/repair images
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>
2016-04-08 13:35:32 +02:00
Antony Pavlov b3d5c43cb8 common: add dependency !SANDBOX on imd target tool
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 d4aa015033
    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>
2016-04-07 13:54:56 +02:00
Sascha Hauer 0e4f92570e bbu: print and evaluate image Metadata
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>
2016-04-06 15:41:15 +02:00
Sascha Hauer 7f73e64e8b imd: Add function to read parameters
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-01 10:38:55 +02:00
Sascha Hauer b8837986a0 imd: export functions
To make the image metadata API usable for external users export
some functions.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-01 10:38:55 +02:00
Sascha Hauer 439d683051 imd: rename imd_search_validate to imd_get
The name is more suitable for what the function does. Also let the
function return a pointer to the imd data found in the buffer.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-01 10:38:55 +02:00
Sascha Hauer 31f63c9749 imd: string returned from imd_string_data should be const
imd_string_data() returns the original data, so the string should be
const.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-01 10:38:54 +02:00
Sascha Hauer 5e335773e0 imd: use struct imd_header * as argument
imd_concat_strings() and imd_string_data() are easier to handle when
they take a struct imd_header * instead of a struct imd_entry_string *.
Change this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-29 10:07:45 +02:00
Andrey Smirnov 12728df947 common: Add EPROBE_DEFER to strerror
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-17 08:23:05 +01:00
Sascha Hauer 251ae23e9f Merge branch 'for-next/mtd' 2016-03-11 10:49:50 +01:00
Sascha Hauer 034d4ddcb6 Merge branch 'for-next/misc' 2016-03-11 10:49:50 +01:00