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>
We want to extend the functionality of the ubi detach function,
but we don't want to change the original detach function to make
UBI updates easier. This adds a barebox specific detach function
which encapsulates the original UBI function. Also this makes the
original ubi detach function internal to ubi.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
umount on Linux can be used on a mount pathes and device pathes. This
patch adds this functionality to barebox.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
We need to be able to umount specific filesystems while iterating all of
them. This helper gives us a safe macro to do so.
Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
This updated code supports recovering from unclean unmounts when write
buffer size is larger than 8. Linux uses takes information into
consideration when checking for writes.
The following list shows the changes for each file done compared to
u-boot v2016.03 code.
Makefile
* Add gc.o, do not include header as in u-boot
budget.c:
* Replace __UBOOT__ with __BAREBOX__
debug.c:
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
* Replace current->pid with 0
debug.h
* Replace __UBOOT__ with __BAREBOX__
* Add "0 &&" to ubifs_assert condition check
U-Boot essentially disabled pr_crit output and dump_stack() is defined
to do { } while (0), so ubifs_assert does nothing despite condition.
gc.c:
* Replace __UBOOT__ with __BAREBOX__
io.c:
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
key.h:
* No changes
log.c:
* No changes
lprops.c:
* Replace __UBOOT__ with __BAREBOX__
lpt.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
* Remove #include <ubi_uboot.h>
lpt_commit.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
master.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
* Remove #include <ubi_uboot.h>
misc.h
* Replace __UBOOT__ with __BAREBOX__
* Add #ifndef __BAREBOX__ around unneeded ubifs_current_time
orphan.c
* No changes
recovery.c
* Replace __UBOOT__ with __BAREBOX__
replay.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
sb.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
* Remove #include <ubi_uboot.h>
* rp_uid and rp_gid are still uid_t, not kuid_t, so remove .val
scan.c
* Replace __UBOOT__ with __BAREBOX__
super.c:
* Replaced current->pid with 0
* Replaced __UBOOT__ with __BAREBOX__
* Removed #include <ubi_uboot.h>
* Removed #include <memalign.h>
* Added #include <init.h>
* Replaced malloc_cache_aligned with kzalloc
* Replaced I_LOCK with I_SYNC
* i_uid and i_gid are still uid_t, not kuid_t, so remove .val
* Replaced string "U-Boot" with "Barebox"
* Add #ifndef __BAREBOX__ around open_ubi, sb_test, sb_set, ubifs_mount,
kill_ubifs_super, ubifs_fs_type
* Do not call ubi_open_volume or ubi_close_volume in ubifs_fill_super
Those will already be handled in ubifs_probe
* Replaced uboot_ubifs_mount with new ubifs_get_super implementation using
existing functions alloc_super, alloc_ubifs_info
tnc.c
* Replace __UBOOT__ with __BAREBOX__
* Remove #include <linux/compat.h>
tnc_misc.c
* Replace __UBOOT__ with __BAREBOX__
ubifs-media.h
* Replace __UBOOT__ with __BAREBOX__
ubifs.c:
* Replaced __UBOOT__ with __BAREBOX__
* Adjusted header includes
* Removed DECLARE_GLOBAL_DATA_PTR
* Add static struct z_stream_s variable
* Add struct ubifs_priv delcaration
* Replaced zunzip with deflate_decompress call
* Add ifdef for disabling ZLIB and/or LZO support
* Replaced malloc_cache_aligned with kzalloc
* Added #ifndef __BAREBOX__ around filldir, ubifs_printdir,
ubifs_set_blk_dev, ubifs_ls, ubifs_exists, ubifs_size, do_readpage,
ubifs_read, ubifs_close, ubifs_load
* Make parameter filename const char* in ubifs_findfile
* Add UBIFS fs_driver_d implementation
* Add zlib_decomp_init, ubifs_init
ubifs.h:
* Replaced __UBOOT__ with __BAREBOX__
* Adjusted header includes
* Added old #define crc32
* Added helper around kmem*
* Added XATTR_LIST_MAX define
* Added #ifndef __BAREBOX__ around current_fs_time struct inode,
struct super_block, file_system_type, dentry and friends which barebox
already has
* Added #ifndef __BAREBOX__ around write_inode in super_operations to avoid
declaration of writeback_control
* Change rp_uid and rp_gid to uid_t and gui_t
* Added struct device_d to struct ubifs_info
* Added forward declaration of ubifs_get_super
linux/fs.h:
* Make struct inode's i_nlink a union containing a non-const int __i_nlink
while making i_nlink a const int
linux/fs.h:
* Add s_remove_count
linux/fs.h:
* Convert struct super_block.s_instances and
struct file_system_type.fs_supers to hlist_head
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
They call xzalloc and malloc respectively.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
If kfree/vfree is called where free is a already variable name, code will
not compile.
Also both take a const* in Linux kernel code.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This will also be used by upcoming UBIFS update.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This is required by upcoming UBIFS update.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Include <linux/types.h> instead of uapi/linux/types.h.
This is required for READ_ONCE and WRITE_ONCE for upcoming atomic_t.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This is needed by upcoming UBIFS update.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This is required by UBIFS update.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This is needed by upcoming list_sort implementation.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This adds (among others) rbtree_postorder_for_each_entry_safe which is
required by the upcoming UBIFS update.
Changes to u-boot source:
* Adding include <module.h> for EXPORT_SYMBOL*
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The decompressors are used both in a regular image and also for image
decompression. Both need different malloc implementations. Using
malloc/free directly in the decompressor code easily leads to include
file conflicts, so use MALLOC/FREE which can be defined correctly for
the two different usecases.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
This adds a command to flip bits in a Nand flash. This is useful for
testing purposes to check if flipped bits are corrected and if the
driver returns the correct number of bitflips.
The command writes a configurable number of bitflips to a single Nand
page. If the -r option is not given the results are reproducible, so
calling the same command twice will revert the bitflips.
The command uses the raw read/write Nand operations which are probably
less tested than the regular read/write operations, so the command may
produce surprising results.
As of writing the command has been tested with the GPMI Nand driver and
the imx-nand driver with fixes posted.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The only user of libmtd was ubiformat which now uses the mtd-peb API,
so remove the now unused libmtd.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This changes ubiformat from the libmtd API to the mtd-peb API. This
makes the libmtd API unnecessary and it can be removed in the next
step.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Code which properly wants to handle Nand flash has to work
in a block based way since blocks are the entities that are erased or
may become bad. The regular mtd API works based on offsets in the device
which introduces unhandy 64bit arithmetics and the requirement to align
buffers to blocks.
This introduces the mtd peb API (PEB for physical Erase Block) which
allows the users to work in a block oriented way. The API is heavily
inspired by the UBI IO layer and in fact can replace parts thereof
later.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
All i.MX images are nowadays built with the imx-image tool, so we do not
need the header files and Kconfig options anymore. Remove them.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
MTD_DEBUG was only used by the i.MX Nand driver and is now unused.
Remove the mtd specific debug defines.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
mtd_[read|write|erase] are input functions to the mtd subsystem, so
check for valid input data here rather than relying on the drivers doing
this. The checks are copied from the Kernel as of 4.5-rc5
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
Passing phy configuration to the ep93xx_eth driver was not supported yet
and will be added with this patch. When no pdata is passed, the probably
broken default of phy_addr = 0 will be used to maintain compatibility
with the previous implementation.
Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
dev_request_mem_region returns a void * which shall be checked with
IS_ERR(), but in some cases the valid pointer returned clashes with
error values. This is especially the case on some Atmel SoCs.
This introduces dev_request_mem_resource which returns a struct resource
instead which in any case can be checked with IS_ERR(). It's the drivers
responsibility then to get the IOMEM pointer from the resource.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>