Commit graph

1930 commits

Author SHA1 Message Date
Michael Olbrich
872e6069d5 state: copy backend of_path string
Caching pointers to device tree nodes or names is not safe. The barebox
internal device tree may be changed by loading a new device tree or through
fixup handlers. As a result, the string may be deleted.
Use local copies of the full path instead.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-20 10:28:46 +02:00
Sascha Hauer
074a8fdc92 Merge branch 'for-next/socfpga' 2016-09-13 14:56:06 +02:00
Sascha Hauer
0e1892b2e9 Merge branch 'for-next/rockchip' 2016-09-13 14:56:05 +02:00
Sascha Hauer
dd534571bd Merge branch 'for-next/misc' 2016-09-13 14:56:05 +02:00
Sascha Hauer
6b8ae8f2e1 Merge branch 'for-next/menu' 2016-09-13 14:56:05 +02:00
Sascha Hauer
b2c398f440 Merge branch 'for-next/imx' 2016-09-13 14:56:04 +02:00
Alexander Kurz
f6ebdf2194 Add i.MX50 support
Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-12 08:23:09 +02:00
Sam Van Den Berge
a1109d78dd Fix small typo in common/Kconfig
Fix small typo frendly -> friendly

Signed-off-by: Sam Van Den Berge <sam.van.den.berge@telenet.be>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-05 08:53:24 +02:00
Andrey Smirnov
da1f91422c of_unflatten_dtb(): Check return value with IS_ERR
Of_unflatten_dtb returns a ERR_PTR value so checking it against NULL is
incorrect. Fix it in all of the places where this was happening.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-05 08:29:12 +02:00
Aleksey Kuleshov
bf2abf9050 rework menu so that it can support multiline titles
Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-05 08:26:47 +02:00
Sascha Hauer
79a2cc9fe6 blspec: Handle nfs:// pathes from boot
Fixes: cb47dde boot: Call blspec_scan_directory() only on strings containing an absolute path

This commit introduced a check if the path contains a '/' at the
beginning. For booting a bootloader spec entry from NFS we have to
test the path for starting with "nfs://" aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-29 17:37:12 +02:00
Wadim Egorov
4372a3ed06 ARM: rockchip: Add early debug support for RK3288
Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-26 07:28:31 +02:00
Alexander Kurz
6b40ff8c7e Kconfig: defaultenv-2 select CMD_TEST
CMD_TEST is required for scripts in defaultenv-2, e.g. automount.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-22 07:49:46 +02:00
Aleksey Kuleshov
d0b8f4e075 properly remove menu entry
Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 09:13:27 +02:00
Aleksey Kuleshov
5397742078 fix double free
it already gets free in bootentries_free
no need to do this in ->release method

Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 09:12:59 +02:00
Steffen Trumtrar
1047fa8ab4 filetype: add new filetype for SoCFPGA xload image
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 08:19:25 +02:00
Renaud Barbier
39391164e5 bbu: parameters are inverted in error message
The error message warning the user that the image is too big for
the device has its parameters in the wrong order. Swap the two
parameters so that the output makes sense.

Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 08:18:32 +02:00
Sascha Hauer
94b1e5a321 Merge branch 'for-next/nv' 2016-08-03 08:08:23 +02:00
Sascha Hauer
b927df0329 Merge branch 'for-next/misc' 2016-08-03 08:08:23 +02:00
Sascha Hauer
94e7bdcd9a Merge branch 'for-next/boot' 2016-08-03 08:08:22 +02:00
Sascha Hauer
16dc0b0b48 blspec: Turn message back to debug level
Normally one should not be interested that the blspec code scans
a directory. In case blspec is not actively used it might even be
confusing, so lower priority of the message in blspec_scan_directory()
to pr_debug.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:36 +02:00
Sascha Hauer
80c5692ff8 boot: add single quotes when printing boot target names
It's nicer to read when target names have quotes around them, it
makes it clear that this is a string passed in somewhere.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:36 +02:00
Sascha Hauer
89c8ac578f boot: Move code to common/
Normally code in commands/ shall only do the option parsing whereas the
functionality shall be in common/ to make the code usable from C aswell.
Do this in the boot code aswell, move it to common/boot.c and add the
function prototypes to include/boot.h

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:35 +02:00
Sascha Hauer
86a4036ba2 blspec: Make blspec_boot static
Since blspec_boot is now only used locally we can make it static. Move
it up to avoid a static declaration.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:35 +02:00
Sascha Hauer
e113fa5f1d blspec: separate bootentries from blspec entries
This completes the separation of the blspec code from the boot
code. With this the boot code only handles generic boot entries
of type struct bootentry which are embedded into the type
(blspec/bootscript) specific structs.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:35 +02:00
Sascha Hauer
ff6bc08801 bootentries: Add title/description
We currently have to special case blspec entries vs. boot scripts
in the common boot code since we want to print different informations
about them. This adds a 'title' and 'description' which can be filled
in with different information by bootscripts and blspec entries and
so we get rid of the special handling.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:35 +02:00
Sascha Hauer
0d054f3303 blspec: factor out a struct bootentry
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:35 +02:00
Sascha Hauer
dbc1894b42 blpec: rename struct lspec -> bootentries
The code in common/boot.c collects the different boot entries in
lists of type struct blspec, eventhough many of them may not be
bootloader spec entries but for example boot scripts. This is the first
step of separating the data structures from boot entries and bootloader
spec: As struct blspec is merely a container for collecting boot entries
We simply rename struct blspec to struct bootentries. No functional change.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:34 +02:00
Sascha Hauer
4d85cb974a include: Move bulk of boot.h to bootm.h
The majority of the stuff currently in include/boot.h is about bootm
code implemented common/bootm.c. To be more consistent move it to a
new file include/bootm.h.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:31 +02:00
Lucas Stach
f3895311ef state: only build circular backend if MTD is enabled
The circular backend depends on MTD symbols and is only useful
if MTD is present. Exclude it from the build if MTD is not enabled.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-25 10:21:16 +02:00
Sascha Hauer
e844f9c60d nv: Allow wildcards when removing NV vars
With this patch 'nv -r' can also take "*" and "?" wildcards for nv
variables. This makes it easier to remove multiple nv variables.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-25 10:15:45 +02:00
Sascha Hauer
04d6b35b5d lib: Add Kconfig symbol for FNMATCH
fnmatch is useful on its own, so make a separate Kconfig symbol
and select it from GLOB.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-25 10:14:18 +02:00
Sascha Hauer
333378d4e4 blspec: Remove once/default handling
This is widely unused and in the way of subsequent cleanups. If you are
indeed using it please complain on the list, we'll find a solution to
add it back in a different way.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-22 14:41:35 +02:00
Sascha Hauer
7c76559023 blspec: remove unused blspec_boot_devicename
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-22 13:23:38 +02:00
Sascha Hauer
a435c13e88 state: Save on shutdown
The state framework is meant for storing persistent variables. To
make the state more persistent automatically save it on shutdown.
This is now the default behaviour, but can be disabled using a
'save_on_shutdown' variable attached to the state.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-22 12:44:22 +02:00
Sascha Hauer
75926bc33d nv: Use dev_remove_param to delete nv variable
dev_remove_param() is exactly for the purpose of removing a device
parameter, so use this function instead of open coding the
functionality.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-22 12:27:23 +02:00
Sascha Hauer
3fadbdae1f nv: Save nv variables on shutdown
With this patch nv variables are automatically saved whenever barebox
shuts down (that is 'reset' is executed or a kernel is started). With
this the additional 'saveenv' step becomes unnecessary.

The nv variables are stored in the environment and the estasblished
behaviour is that files in the environment must be manually saved
using 'saveenv'. This behaviour shall be kept for now, so this patch
cannot just call 'saveenv' since that would save the modified
environment files aswell. Instead we read the environment from the
device, modifiy the nv variables and save the environment back.

Since this changes a long existing behaviour messages are printed the
first time a nv variable is modified and during shutdown when the
variables are actually saved.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-22 12:27:22 +02:00
Sascha Hauer
b9ac9a9785 nv: Do not save nv variables while loading
When reading nv variables from the storage in /env/nv we do
not need to write back the value to the file we just read from.
Optimize this a bit and make it unnecessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-22 12:05:39 +02:00
Sascha Hauer
e77acea709 Merge branch 'for-next/state' 2016-07-11 07:58:34 +02:00
Sascha Hauer
202cda9475 Merge branch 'for-next/nvdevvars' 2016-07-11 07:58:34 +02:00
Sascha Hauer
f64075972b Merge branch 'for-next/misc' 2016-07-11 07:58:33 +02:00
Sascha Hauer
3203cdfa7b Merge branch 'for-next/arm64' 2016-07-11 07:58:32 +02:00
Sascha Hauer
28d7f7878c Merge branch 'for-next/arm' 2016-07-11 07:58:32 +02:00
Michael Grzeschik
e703d1ed73 state: also append backend storage stridesize
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-08 08:59:31 +02:00
Markus Pargmann
c999b507da state: Refactor state framework
The state framework grew organically over the time. Unfortunately the
architecture and abstractions disappeared during this period.

This patch refactors the framework to recreate the abstractions. The
main focus was the backend with its storage. The main use-case was to
offer better NAND support with less erase cycles and interchangeable
data formats (dtb,raw).

The general architecture now has a backend which consists of a data
format and storage. The storage consists of multiple storage buckets
each holding exactly one copy of the state data. A data format describes
a data serialization for the state framework. This can be either dtb or
raw. A storage bucket is a storage location which is used to store any
data. There is a (new) circular type which writes changes behind the
last written data and therefore reduces the number of erases. The other
type is a direct bucket which writes directly to a storage offset for
all non-erase storage.

Furthermore this patch splits up all classes into different files in a
subdirectory.

This is currently all in one patch as I can't see a good way to split
the changes up without having a non-working state framework in between.

The following diagram shows the new architecture roughly:

           .----------.
           |  state   |
           '----------'
                 |
                 |
                 v
  .----------------------------.
  |       state_backend        |
  |----------------------------|
  | + state_load(*state);      |
  | + state_save(*state);      |
  | + state_backend_init(...); |
  |                            |
  |                            |
  '----------------------------'
    |            |                   The format describes
    |            |                   how the state data
    |            '------------->     is serialized
    |   .--------------------------------------------.
    |   |      state_backend_format <INTERFACE>      |
    |   |--------------------------------------------|
    |   | + verify(*format, magic, *buf, len);       |
    |   | + pack(*format, *state, **buf, len);       |
    |   | + unpack(*format, *state, *buf, len);      |
    |   | + get_packed_len(*format, *state);         |
    |   | + free(*format);                           |
    |   '--------------------------------------------'
    |              ^                      ^
    |              *                      *
    |              *                      *
    |   .--------------------. .--------------------.
    |   | backend_format_dtb | | backend_format_raw |
    |   '--------------------' '--------------------'
    |
    |
    |
    v
.----------------------------------------------------------.
|                  state_backend_storage                   |
|----------------------------------------------------------|
| + init(...);                                             |
| + free(*storage);                                        |
| + read(*storage, *format, magic, **buf, *len, len_hint); |
| + write(*storage, *buf, len);                            |
| + restore_consistency(*storage, *buf, len);              |
'----------------------------------------------------------'
                              |
     The backend storage is responsible to manage multiple
     data copies and distribute them onto several buckets.
     Read data is verified against the given format to
     ensure that the read data is correct.
                              |
                              |
                              |
                              |
                              |
                              v
        .------------------------------------------.
        | state_backend_storage_bucket <INTERFACE> |
        |------------------------------------------|
        | + init(*bucket);                         |
        | + write(*bucket, *buf, len);             |
        | + read(*bucket, **buf, len_hint);        |
        | + free(*bucket);                         |
        '------------------------------------------'
                      ^     ^      ^
                     *      *       *
                    *       *        *
 A storage bucket represents*exactly one data copy at one
 data location. A circular b*cket writes any new data to
 the end of the bucket (for *educed erases on NAND). A
 direct bucket directly writ*s at one location.
               *            *             *
              *             *              *
             *              *               *
 .-----------------------.  *  .-------------------------.
 | backend_bucket_direct |  *  | backend_bucket_circular |
 '-----------------------'  *  '-------------------------'
             ^              *               ^
             |              *               |
             |              *               |
             |              *               |
             |  .-----------------------.   |
             '--| backend_bucket_cached |---'
                '-----------------------'
             A backend_bucket_cached is a transparent
             bucket that directly uses another bucket
             as backend device and caches all accesses.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-08 08:59:31 +02:00
Lucas Stach
aab6861314 imx-bbu-nand-fcb: avoid double free of dbbt_entries
The error path properly frees them already.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-07 09:36:31 +02:00
Lucas Stach
ff06cdf26d imx-bbu-nand-fcb: don't drop error return code
bit_to_flip might be negative if any uncorrectable bitflips
occured. Use int instead of unsigned type in order to properly
propagate the error.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-07 09:36:31 +02:00
Raphael Poggi
940511012a uimage: add define for ARM64 architecture
Signed-off-by: Raphael Poggi <poggi.raph@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-06 11:23:50 +02:00
Sascha Hauer
699b4f8025 Introduce non volatile device variables
Non volatile device variables are used to make device parameters
persistent. They are like normal non volatile variables, but set
the values of the device parameters with the corresponding name.
Every nv variable beginning with nv.dev is a non volatile device
variable. They have the form nv.dev.<devname>.<paramname> and act
on the parameter <paramname> of the device named <devname>.

The non volatile device variables are designated for example for
video modes, ethernet device ip addresses or mtd partitioning.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-06 10:09:29 +02:00
Sascha Hauer
b17973f8ba nvvar: Simplify by using dev_set_param()
The combination of get_param_by_name()/param->set() can be replaced
by using dev_set_param()

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-06 10:07:32 +02:00