This replaces the reset_cpu() function which every SoC or board must
provide with registered handlers. This makes it possible to have multiple
reset functions for boards which have multiple ways to reset the machine.
Also boards which have no way at all to reset the machine no longer
have to provide a dummy reset_cpu() function.
The problem this solves is that some machines have external PMICs or
similar to reset the system which have to be preferred over the
internal SoC reset, because the PMIC can reset not only the SoC but also
the external devices.
To pick the right way to reset a machine each handler has a priority. The
default priority is 100 and all currently existing restart handlers are
registered with this priority. of_get_restart_priority() allows to retrieve
the priority from the device tree which makes it possible for boards to
give certain restart handlers a higher priority in order to use this one
instead of the default one.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This patch factors out the wait-for-key-press loop from the shell command
"timeout" into a sparate file, so that it can be used from C, too.
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This patch adds a framework to describe, access, store and restore a set of
variables. A state variable set can be fully described in a devicetree node.
This node could be part of the regular devicetree blob or it could be an extra
devicetree solely for the state. The state variable set contains variables of
different types and a place to store the variable set.
For more information see:
Documentation/devicetree/bindings/barebox/barebox,state.rst
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
with not the rest of the implementation
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The PBL has console support now, so add memory_display support aswell
which can be a good debugging aid.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This framework handles a list of registered Firmware programming handlers
to unify a firmware programming interface by hiding the details how
to program a specific Firmware in its handler. This is created with FPGAs
in mind but should be usable for other devices aswell.
A user has two possibilities to load a firmware. A device file is create
under /dev/ which can be used to copy a firmware to. Additionally a
firmwareload command is introduced which can list the registered firmware
handlers and also to upload a firmware.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
It's often useful to get some information about a barebox image
before starting or flashing it. This patch introduces barebox
Image MetaData (IMD). When enabled a barebox image will contain
a list of tags containing the desired information. We have tags
for:
- the barebox release (2014.07.0-00160-g035de50-dirty)
- the build timestamp (#741 Mon Jul 28 15:08:54 CEST 2014)
- the board model the image is intended for
- the device tree toplevel compatible property
Also there is an additional generic key-value store which stores
parameters for which no dedicated tag exists. In this patch it
is used for the memory size an image supports.
Since there is no fixed offset in a barebox image which can be
used for storing the information, the metadata is stored somewhere
in the image and found by iterating over the image. This works
for most image types, but obviously not for SoC images which are
encoded or encrypted in some way.
There is a 'imd' tool compiled from the same sources for barebox,
for the compile host and for the target, so the metadata information
is available whereever needed.
For device tree boards the model and of_compatible tags are automatically
generated.
Example output of the imd tool for a Phytec phyFLEX image:
build: #889 Wed Jul 30 16:08:54 CEST 2014
release: 2014.07.0-00167-g6b2070d-dirty
parameter: memsize=1024
of_compatible: phytec,imx6x-pbab01 phytec,imx6dl-pfla02 fsl,imx6dl
model: Phytec phyFLEX-i.MX6 Duallite Carrier-Board
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The dfu command parses a string which contains a list of
devices and flags. This format is useful for other users
aswell, so add common helper functions to parse it and
let the dfu command use this format.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Creating menus from the shell using the regular 'menu' command is rather
complicated. This adds a 'menutree' command which creates a menu from
a directory structure. In the directory structure each directory corresponds
to a single menu entry. The directory contains the following files:
title - A file containing the title of the entry as shown in the menu
box - If present, the entry is a 'bool' entry. The file contains a variable
name from which the current state of the bool is taken from and saved
to.
action - if present this file contains a shell script which is executed when
when the entry is selected.
If neither 'box' or 'action' are present this entry is considered a submenu
containing more entries.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
We can compile barebox for multiple boards at once, but currently
they all share a single default environment. This patch adds a
defaultenv_append() which boards can call to customize the default
environment during runtime. Each board now generate default environment
snippets using bbenv-y and add them during runtime with defaultenv_append()
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The default environment buffer is an unsigned char array and thus
may be unaligned. Some decompression algorithms expect the buffer
to be sufficiently aligned for u32 accesses. We make this sure by
copying the default env to a temporary buffer. Instead of doing this
just add a __aligned(4) to the default environment.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Instead of asking explicitly for the default environment compression
type ask for the in-barebox default compression type. This also adds
a DEFAULT_COMPRESSION_SUFFIX make variable which can be used together
with the wildcard rules for compressed files to generate compressed
files without explicitly support each compression type.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Finding out whether to rebuild the environment is a difficult task
since we have to track all files in a directory. Instead of trying
this, just rebuild the environment during every build and only if
it differs to the last one overwrite the target. This way make
only sees a change when the environment is changed.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
In the case where CONFIG_PASSWORD is off, CONFIG_PASSWORD_DEFAULT is
undefined. As undefined is not "", this causes make to call find -type f.
If there is a filename containing a :, make will complain about having
"multiple target patterns"
Signed-off-by: Jan Luebbe <jlu@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The Bootloader Specification describes a way how kernels can
be installed on devices and how they can be started by the bootloader.
The bootloader spec is currently supported by (x86) gummiboot and
by systemd which provides a kernel-install script. With the bootloader
spec it's possible for the Operating system to install a new kernel
without knowing about the bootloader and for the bootloader it's possible
to discover and start Operating Systems on a media without being
configured.
For more details about the spec see:
http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/
This patch adds barebox support for the spec. It enhances the 'boot'
command so that not only boot script names can be given, but also
devices containing bootloader spec entries. With this it's possible
to call the 'boot' command like: 'boot sd emmc net'. It would then
first look for bootloader spec entries on the (removable) sd card,
then, is nothing is found, on the internal emmc and if still
unsuccessful would call the 'net' bootscript.
The bootloader Spec currently doesn't specify which entry should be
default if multiple entries are found on a single device. Therefore
barebox currently has two extensions of the spec. The $BOOT diretory
can contain a file named 'default'. If present, the content of the
file is treated as a filename under $BOOT/loader/entries/ which is
used as default. Similarly if a file named 'once' is present, the
entry is started once and the file is removed afterwards. This is
useful for testing if a newly installed kernel works before making
it the default.
As on ARM and other Architectures a devicetree has to be specified
for the kernel, the 'devicetree' property is used to specify a
devicetree. Like 'kernel' and 'initrd' this also contains a pth
relative to $BOOT.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
even if the env is broken you will have a password
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The code calculates the DDR2 SPD checksum as per JEDEC standard
No 21-C Appendix X (revision 1.2)
The code is based on the equivalent files from U-Boot version
git-a71d45d.
Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Much of the bootm code is implemented in the command itself. Move
it to a common place to be able to call it from C aswell.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Add mem_test routine. Useful to detect timing problems if someone
porting a new device to barebox. This test includes a data bus test,
address bus test and integrity check of memory.
This mem_test routine has as parameter start and end address of testing
space. The last parameter can skip the integrity check.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
memory_display is a function which should generally be available.
Currently it depends on memory command support being compiled in,
so move the function to a separate file.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This patch seperates the imx independent from the arch independent code. The
following functions and enums are renamed:
- imx_bootsource() -> bootsource_get()
- imx_set_bootsource() -> bootsource_set()
- enum imx_bootsource -> enum bootsource
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
so we can support multiple format
use filetpye to detect the parser to use
Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The different console implementations share a good amount of code,
share this in console_common.c.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
this will allow to have no console support
Use full for bootstrap as we can save 6.5 KiB (barebox.bin) and
3.8 KiB (zbarebox.bin lzo) on at91sam9263 as example vs console simple
As on bootstrap we have often very limited size.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Currently in-system update means to write an arbitrary file to
an arbitrary device. There is no sanity check if the flashed image
is of the right type or will fit onto the device. Furthermore some
SoCs need a special preparation step for their images before
flashing them.
This adds a barebox in-system update infrastructure. Boards can
register update handlers which know how to make the board bootable.
The available handlers can be listed to be able to select one,
different force levels give the user the chance to know it better.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
When a build with a compressed default environment is done and then
environment compression is disabled, barebox_default_env.h is not
regenerated because its dependency (now barebox_default_env) is still
up to date. This results in a corrupt default environment.
This patch fixes this by adding a cmd_env_h and changing barebox_default_env.h
to FORCE. As a side effect barebox_default_env.h is no longer generated in
include/generated/ but in common/ as we have to add barebox_default_env.h to
$(targets) (extra-y).
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The dependencies for generating the environment do not work properly:
- If files are removed from the defaultenv, a subsequent make will not
update the default environment.
- If CONFIG_DEFAULT_ENVIRONMENT_PATH changes, the default environment
also will not be regenerated.
This patch fixes this by introducing a cmd_env which has the content of
$(ENV_FILES) in the command so that the if_changed mechanism recognizes
a change when $(ENV_FILE) changes. This also results in a nice " ENV "
string in the build process.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The CLEAN_FILES in common/Makefile are unused. All generated files
are removed from the toplevel Makefile.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Both the uimage command and the bootm command need uImage support, so
add a Kconfig symbol for it to be able to select it properly.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Many architectures support a way to detect why the bootloader is running.
This patch adds a global variable to be able to use the cause in some kind of
shell code to do special things on demand. For example to do an emergency boot,
when the last boot fails and the watchdog reactivate the hanging system.
Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>