9
0
Fork 0
Commit Graph

2005 Commits

Author SHA1 Message Date
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
Sascha Hauer e91c234603 nvvar: Simplify by using nv_set()
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-06 10:07:32 +02:00
Alexander Shiyan 341aca3762 Add more files to .gitignore
This patch adds more generated files to ignore list.
...
shc@shc /home/git/barebox-github $ git status
На ветке imx51
Неотслеживаемые файлы:
  (используйте «git add <файл>…», чтобы добавить в то, что будет включено в коммит)

        common/barebox_default_env
        common/barebox_default_env.h
        include/asm
        scripts/basic/docproc

ничего не добавлено в коммит, но есть неотслеживаемые файлы (используйте "git add", чтобы отслеживать их)

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-05 09:02:40 +02:00
Alexander Shiyan 95543d98e7 common: Kconfig: Remove orphaned dependency LOAD_PBL_SRAM
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-28 08:02:12 +02:00
Lucas Stach 24d9dd9fa3 defaultenv-2: select BOOTM
defualtenv-2 selects CMD_BOOT, which in turn needs BOOTM.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-24 08:23:33 +02:00
Sascha Hauer 6bfb591cc1 Merge branch 'for-next/misc' 2016-06-14 09:13:41 +02:00
Sascha Hauer 2b948a834c Merge branch 'for-next/bootm' 2016-06-14 09:13:35 +02:00
Lucas Stach 3dae29d7d0 state: select CRC32
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>
2016-06-03 09:07:38 +02:00
Lucas Stach 0974830c3e common: select dependencies for defaultenv-2
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>
2016-05-30 07:03:33 +02:00
Sascha Hauer 4178dda706 console: Fix initial value of baudrate parameter
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>
2016-05-26 09:13:09 +02:00
Antony Pavlov fc71878c1f imd: make it work on big-endian machines
The commit

    commit 5e335773e0
    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>
2016-05-23 09:33:21 +02:00
Stefan Christ b47a5a7ed6 imx-bbu-nand-fcb: add missing newline character
Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-19 08:39:41 +02:00
Alexander Stein e9add3ae57 reset_source: export reset_source_set_priority
In commit 4a7534bf07 ("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: 4a7534bf07 ("reset-source: Allow different priorities")
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-13 12:02:09 +02:00
Sascha Hauer d323e9f6e7 bootm: make verbosity controllable via global variable
When the bootm code is not called directly by the bootm command it is
useful to control the verbosity with a globalvar. This introduces
global.bootm.verbose for this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-11 08:16:31 +02:00
Sascha Hauer 403c5169e9 bootm: Move magicvar descriptions to common/bootm.c
Now that the bootm code can be used without the command, we have to
move the magicvar descriptions from the command code to the common
bootm code aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-11 08:11:26 +02:00
Sascha Hauer 6922e0f005 bootm: Add verify mode "available"
The verify "available" mode checks whatever is available in the
booted image, so when an image has a signature, it is checked and
must be correct and when an image is hashed, it is also checked
for correctness.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 16:02:13 +02:00
Sascha Hauer b9b0fd6c75 bootm: set bootm_verify_mode to correct value
When CONFIG_BOOTM_FORCE_SIGNED_IMAGES is enabled bootm_verify_mode
shall be forced to "signature", so set bootm_verify_mode to this
value during startup. Otherwise it shows up as "<NULL>" in devinfo.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 16:00:04 +02:00
Sascha Hauer f55bf3c280 bootm: fit: Print error when image is not signed
when fit is configured to force signed images then print an error
message when an unsigned image is opened to give the user a clue
what went wrong.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 15:36:45 +02:00
Sascha Hauer c06573f9d1 bootm: fit: Print error when image is not hashed
When fit is configured to check hashes print an error when an image
does not contain hashes instead of failing silently.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 15:35:36 +02:00
Sascha Hauer 97cfccda76 bootm: Add missing BOOTM_FORCE_SIGNED_IMAGES option
The code already tests for this option, but it does not
yet exist. Add the option to force using signed images.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 15:34:25 +02:00
Sascha Hauer 7839011f61 bootm: Move bootm options to common/Kconfig
bootm has a C API, so the bootm options have to depend on the
option providing the bootm code (CONFIG_BOOTM), not on the
option providing the command (CONFIG_CMD_BOOTM). Fixing the
dependencies makes it possible to fully use bootm from C without
enabling the bootm command support.
This also removes the CMD_ prefix from the options which means
we have to update the defconfigs aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 14:51:58 +02:00
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
Sascha Hauer d69ea86d79 Merge branch 'for-next/doc' 2016-03-11 10:49:43 +01:00
Sascha Hauer 330dc0a6b7 Merge branch 'for-next/bbu' 2016-03-11 10:49:35 +01:00
Markus Pargmann 0240fd3f84 fastboot: Add a ARM Barebox filetype handler
This will automatically call barebox_update for the transfered file if
it is an ARM Barebox image and the destination file is defined by some
update handler.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-11 08:06:05 +01:00
Sascha Hauer a1d621cbe3 imx-bbu-nand-fcb: Remove double write of first fcb
The first FCB page was written twice. One time is enough, drop the
second write.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-04 08:31:42 +01:00
Sascha Hauer 97407dad80 imx-bbu-nand-fcb: optimize check for bad block loop
The argument passed to dbbt_data_create() contains the number of blocks,
not the last block. This means we can exit the loop with '<' instead of
'<='

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-04 08:28:34 +01:00
Lucas Stach 4189af5812 ratp: use proper defines for BAREBOX_CMD
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-04 07:54:58 +01:00
Lucas Stach 3969140abd bbu: use correct printf format specifier for size_t
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-04 07:54:58 +01:00
Teresa Remmet 153c34b347 common: oftree: Add function to register set status fixup
Added a function to register a fixup to enable or disable
device tree nodes.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-01 08:25:42 +01:00
Sascha Hauer fc5af2afc5 bootm: Fix booting uImages
This fixes:
0a37e22d (bootm: use names instead of numbers for image parts)

This commit switches to strings for the image numbers for better FIT
image support (which uses names instead of numbers). These strings
may be NULL when no image number is given. They are used uninitialzed
in several places. Introduce a wrapper function to convert the string
into a number. Check for NULL here in which case we return 0 which
is the correct value.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-25 13:29:05 +01:00
Markus Pargmann 7290110f1a bbu: Add function to check if an update handler exists
This adds a function to check for the existence of an update handler
based on the supplied bbu_data.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-18 16:10:11 +01:00
Markus Pargmann 473da9de5b bbu: Add barebox_update search by device
bbu_data includes a devicefile information. Add the possibility to make
an update based on the given devicefile. This is in addition to the
normal search for a barebox update handler by its name.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-18 16:10:11 +01:00
Harald Welte f1f8f5556a bootm: Free allocated fdt buffer in error path
It seems like there is a memory leak in an error path of
bootm_open_oftree_uimage() where the memory allocated for the fdt is not
released again.

Signed-off-by: Harald Welte <laforge@gnumonks.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-18 12:58:20 +01:00
Harald Welte 2b480855e6 Print error message if of_state_fixup() fails
If of_state_fixup() fails for some reason, boot/bootm will fail, too

However, it is completely unclear where the error has happened, and to
the user it rather seems like the kernel device tree loaded from some
file was broken/corrupt, not that in fact some fixup routine was
failing.

Adding a meaningful error message can help debugging significantly.

Signed-off-by: Harald Welte <laforge@gnumonks.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-18 12:57:44 +01:00
Lucas Stach 1a180cd3b6 bootm: parse initrd and oftree into correct struct members
The code parsing the oftree and initrd file names is clearly wrong,
leading to bootm not loading oftree or initrd files any more.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-15 07:32:35 +01:00
Lucas Stach b80ff0f035 bootm: restore load DT message for plain oftree files
This message was dropped when reorganizing the DT loading code,
and it's really confusing to miss this.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-15 07:32:35 +01:00
Sascha Hauer 6656c5ffe3 blspec: ignore lines beginning with '#'
According to the bootloader spec these should be treated as comments.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-11 16:00:34 +01:00
Sascha Hauer 0aae1dc98c blspec: Do not crash on config files without newline on last line
When the last line in a config file has no newline then 'next' is NULL
on the the loop iteration. Check that before derefencing 'next'.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-11 16:00:27 +01:00
Lucas Stach 0fe011b6ff ratp-console: select CRC16 and POLLER, depend on CONSOLE_FULL
RATP console selects RATP, which in turn selects CRC16, but those
chains don't work in Kconfig, so select CRC16 also from the
console option.

Also fix build errors by depending on CONSOLE_FULL and selecting
POLLER.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-11 13:56:00 +01:00
Sascha Hauer 46989182d5 bootm: Fix resource_size_t format specifier
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-11 11:25:32 +01:00
Robert Schwebel 3869d56a77 ratp: remove unused ratp_close command
This is a leftover from development, remove.

Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-10 08:18:22 +01:00
Sascha Hauer c073534880 Merge branch 'for-next/ratp' 2016-02-08 08:27:01 +01:00
Sascha Hauer 1379a5ef1e Merge branch 'for-next/misc' 2016-02-08 08:26:43 +01:00
Sascha Hauer 05261801e9 Merge branch 'for-next/input' 2016-02-08 08:26:35 +01:00
Sascha Hauer 436481a993 bootm: Add option to force booting signed images
With CONFIG_BOOTM_FORCE_SIGNED_IMAGES the bootm code will refuse to boot
unsigned images. Since currently FIT is the only image type which
supports signing, this means with this option we enforce using FIT
images. All additionally passed in device trees and initrds will be
ignored, so that only the ones from the FIT image can be used.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2016-01-26 22:45:42 +01:00
Jan Luebbe ac55adb321 bootm: add initial FIT support
This implementation is inspired by U-Boot's FIT support. Instead of
using libfdt (which does not exist in barebox), configuration signatures
are verified by using a simplified DT parser based on barebox's own
code.

Currently, only signed configurations with hashed images are supported,
as the other variants are less useful for verified boot. Compatible FIT
images can be created using U-Boot's mkimage tool.

Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:42 +01:00
Sascha Hauer ebb1160cdd bootm: make verifying/hashing configurable
So long struct bootm_data.verify is a bool which enables CRC checking
(hashing). Extend this to a enum and add support for signature checking
in the same option. This also adds the corresponding globalvar and a
-s option to bootm.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:42 +01:00
Sascha Hauer bc94fb379a bootm: Initialize bootm_data defaults in single place
Both the bootm and the boot code initialize the struct bootm_data
with defaults from the bootm global variables. Create a common
function for doing this.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:40 +01:00
Sascha Hauer a8531386ff bootm: move oftree code together
The device tree code is distributed in several places in the bootm code.
Move it all together in bootm_load_devicetree().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:40 +01:00
Sascha Hauer aded35ece4 bootm: move initrd code together
The initrd code is distributed in several places in the bootm code.
Move it all together in bootm_load_initrd().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:40 +01:00
Sascha Hauer 3f0835e074 bootm: Push dryrun to handlers
We can make the dryrun option more useful by calling into the handlers.
With this we can detect more cases that can go wrong during boot.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-26 22:45:36 +01:00
Sascha Hauer 0a37e22d63 bootm: use names instead of numbers for image parts
The uImage format uses numbers for to identify the different
parts of a image, but the FIT image format uses names. To better
integrate the FIT image format into bootm always use names and
convert them to numbers when necessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-22 08:15:15 +01:00
Sascha Hauer 0bb6e4c533 bootm: introduce bootm_get_os_size
ARM do_bootm_linux is not only called with uImages but also with
raw images, so we can't use uimage_get_size() here. Introduce
bootm_get_os_size() which handles the different image types.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-22 08:15:15 +01:00
Sascha Hauer 3c0cf270c2 bootm: Do not call uimage_close twice
uimage_close() is called on bootm cleanup, so do not close it
in the failure path in bootm_open_os_uimage().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-22 08:15:15 +01:00
Sascha Hauer 2660573374 barebox remote control
This adds the ability to control barebox over serial lines. The regular
console is designed for human input and is unsuitable for controlling
barebox from scripts since characters can be lost on both ends, the data
stream contains escape sequences and the prompt cannot be easily matched
upon.
This approach is based on the RATP protocol. RATP packages start with a
binary 0x01 which does not occur in normal console data. Whenever a
0x01 character is detected in the console barebox goes into RATP mode.
The RATP packets contain a simple structure with a command/respone
type and data for that type. Currently defined types are:

BB_RATP_TYPE_COMMAND (host->barebox):
	Execute a command in the shell
BB_RATP_TYPE_COMMAND_RETURN (barebox->host)
	Sends return value of the command back to the host, also means
	barebox is ready for the next command
BB_RATP_TYPE_CONSOLEMSG (barebox->host)
	Console message from barebox

Planned but not yet implemented are:

BB_RATP_TYPE_PING (host->barebox)
BB_RATP_TYPE_PONG (barebox->host)
	For testing purposes
BB_RATP_TYPE_GETENV (host->barebox)
BB_RATP_TYPE_GETENV_RETURN (barebox->host)
	Get values of environment variables

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
2016-01-18 09:25:09 +01:00
Marc Kleine-Budde 54522f547f state: hmac: fix error message that algo is displayed
This patch moves the error message about missing crypto support so that the
used crypto algo is printed. Without this patch the algo is always shown as a
NULL pointer.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-18 08:24:55 +01:00
Sascha Hauer e2306ada3e Convert users of PRINTF_CONVERSION_RESOURCE to %pa
printf now supports printing resource_size_t directly, convert
all users of the previously used PRINTF_CONVERSION_RESOURCE over
to %pa.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-15 15:33:59 +01:00
Sascha Hauer efd9601e15 poller: Fix async poller
The async poller does not work as expected since it can happen that
the async poller is removed from the list of pollers while we are
iterating over the list. Even list_for_each_entry_safe does not help
here since we may remove the next list element, but
list_for_each_entry_safe only allows to remove the current list element.

Rework the async poller so that it is registered with the poller
framework on registration and then is only marked as active with
poller_call_async(). This way we do not have to do list manipulations
while running the pollers.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-13 15:55:23 +01:00
Sascha Hauer 0332f49a4a hush: fix indentation
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-11 13:31:57 +01:00
Sascha Hauer e07d90b760 hush: Initialize struct p_context
The hush context must be initialized before it is used. Add
initialization where necessary.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-11 13:15:04 +01:00
Sascha Hauer 1b59b573e4 Merge branch 'for-next/rtc' 2016-01-11 13:11:08 +01:00
Sascha Hauer 70ef1cef5c Merge branch 'for-next/pstore' 2016-01-11 13:11:07 +01:00
Sascha Hauer ab96ba298b partition: Create links with partition names
When a partition has a name create a link to the original partition
rather than registering a second cdev.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:55 +01:00
Sascha Hauer 3cff8948ff state: implement signed int support
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:55 +01:00
Trent Piepho 5e3069f3f9 partitions/efi: Add partuuid to partition description
In commit bc31d85c6e the partition UUID
was added to the partition struct and thence to the cdev(s) for the
partition.  But just for DOS partitions.  Do this for GPT aka EFI
partitions too.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:55 +01:00
Sascha Hauer 6eb5d78419 hwclock command: use format like the Linux tool does
Print three-letter abbreviations of the days and months.

With a fixup by Andrey Smirnov:
| common/date.c: Fix off-by-one error
|
| As per http://pubs.opengroup.org/onlinepubs/007908775/xsh/time.h.html
| 'tm_wday' is zero indexed with zero representing Sunday, this is also
| corroborated by the code in rtc_time_to_tm() which used 4 to represent
| Thursday.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-07 08:45:12 +01:00
Zahari Doychev 295a5f8e4b environment: allow saving of symbolic link changes
Currently it is not possible to change symbolic links in the default
environment. For example if the default environment contains the
link "current_boot -> mmc" then the following does not work:

$ rm current_boot
$ ln net current_boot
$ saveenv

After reset the link is still pointing to "mmc" and this error appears:

"symlink: /env/boot/current_boot -> net : error -17"

The patch fixes the above problem and moves the "ENV_FLAG_NO_OVERWRITE"
to enable handling of symbolic links in this case too.

Signed-off-by: Zahari Doychev <zahari.doychev@linux.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-17 10:48:18 +01:00
Markus Pargmann 160d2ed0ba fs: Add pstore filesystem
pstore is a persistent storage filesystem used for RAMOOPS. It is used
to store console logs, panics, ftrace and other information in case of a
crash/panic/oops/reboot.

pstore is implemented for barebox as a read-only filesystem at the
moment. It may be extended later on. The idea is to provide a way to
extract essential data from the last running kernel.

Most of the code is copied from the kernel. However this is only a
lightweight implementation without real write support yet.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-10 08:49:52 +01:00
Sascha Hauer 2ae9bbba07 Merge branch 'for-next/state' 2015-12-08 08:29:02 +01:00
Sascha Hauer 9fdf56c8d4 Merge branch 'for-next/omap' 2015-12-08 08:28:41 +01:00
Sascha Hauer 24f1c994cc Merge branch 'for-next/misc' 2015-12-08 08:28:07 +01:00
Sascha Hauer 5e79364a66 Merge branch 'for-next/console' 2015-12-08 08:27:20 +01:00
Sascha Hauer fe68ba4526 Merge branch 'for-next/arm' 2015-12-08 08:27:08 +01:00
Trent Piepho a2b3a25417 ARM: Remove do_execute and thumb2_execute
In commit 104a6a7ccf support was added
for Thumb2.  It added do_execute() as a way to provide arch dependent
calling veneers for use in "go" and thumb2_execute() as the thumb2 to
arm veneer.

But thumb2_execute() isn't necessary as gcc generates a proper calling
sequence from a standard function pointer call.  Thumb2 barebox is
compiled with the AAPCS ABI which requires this.

It also had a bug and didn't pass the arguments properly, but code
execute via "go" rarely uses arguments so this wasn't very noticeable.

Since thumb2 was always the only user of do_execute(), go ahead and
delete that too.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-07 10:44:45 +01:00
Sascha Hauer c85ef6a776 Revert "memtest: move error handling to end of function"
While this simplifies the code as is I got the request to continue on
errors in memtest, which can be better implemented when the messages are
printed inline and not at the end of the function.

This reverts commit 4ff9e28abc.
2015-12-04 08:01:59 +01:00
Antony Pavlov cf0dd1196b environment: support env on at24 eeprom
unprotect(), erase() and protect() return EOPNOTSUPP errno code
for at24 I2C eeproms, so envfs_save() doesn't store data
to these eeproms without this patch.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-01 09:59:05 +01:00