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>
cdev.c exists in the kernel UBI code, but barebox has completely
different content in this file. rename it to barebox.c to reduce the
number of merge conflicts. Also with the name barebox.c we now have
a place to put other barebox specific UBI code to.
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>
Currently max_write_size is set to minimal I/O size. Set to buffer size
read from flash. Required by UBIFS recovery which uses max_write_size
for error detection.
Signed-off-by: Alexander Stein <alexander.stein@systec-electronic.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
writebufsize is zero initialized, set actual value during init.
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>
In v4.2-rc3 the "fsl,imx1-gpt" compatible was replaced with
"fsl,imx21-gpt" so i.MX27 currently ends up without clocksource. Fix
this.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Automatically mount the path that is also used for net booting by
default to /mnt/nfs.
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
Part of the barebox code and variables are put in separate sections
(.barebox* and .initcall*). When this code is compiled as position
independent code then the compiler creates corresponding .rela.barebox* and
.rela.initcall* sections with the relocation table entries.
These sections don't match the .rela.data* wildcard in the linker script.
As a result, they are not added to the .rela section during linking but are
added individually after it instead. And when the EFI binary is created
from the ELF binary, these sections are not copied.
This has two side effects:
1. The corresponding relocations are not handled by the generic relocation
code. 'fixup_tables()' was added to do these relocations manually.
2. In the DYNAMIC section, the RELASZ entry contains the total size of
relocations in bytes. This includes the .rela.barebox* and .rela.initcall*
sections. This value is not modified when the EFI binary is created. So the
value is too large.
The generic relocation code in _relocate() used this value when iterating
over all relocation entries. With the wrong RELASZ value it iterates beyond
the end of the .rela section into uninitialized memory. After power-on this
memory is zero and the relocation code interprets this as 'nothing to do',
so there is no visible effect. After a soft reset, random data in that area
may produce a seemingly valid relocation entry, a random address is
modified and barebox crashes.
This patch adds the .rela.barebox* and .rela.initcall* sections to the
normal .rela section. The RELASZ now contains the correct size and the
generic relocation code works correctly. 'fixup_tables()' must be removed
at the same time to avoid relocating these entries twice.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
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>
This makes the UBI debug options configurable. This make the debug
options actually available to the user and also allows the compiler
to optimize away the debug code when the options are disabled.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The mtd-peb API provides a torture test derived from the UBI torture
test. Use it. Since the mtd-peb variant of the torture test will also
mark a block as bad when the test fails this also makes a separate
ubi_io_mark_bad unnecessary.
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>
Empirical observations show that configuring INTCN=1, ECLK=0, EGFIL=0,
DOSF=1 on DS1341 put the chip in the mode where it draws the least
amount fo current.
Add code to configure DS1341 in such a way in case Barebox is the last
code that runs on the processor before being shut down.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Check obtianed time for validity before returning it to the caller
the same way other RTC drivers do.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The binary image generated by barebox contains an instruction at the
very beginning to jump over the header. However, when the image is
written to a SD card and the first 512 bytes are skipped in order to
preserve the partition table then this jump instruction is lost. Instead
of relying on the jump instruction at the image beginning calculate
the image entry from the i.MX header instead of relying on the beginning
of the image being the entry point.
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>
On i.MX6 a single chipselect can have 4GiB. In this case the calculation
for CS0_end overflows the 7 bit field. Clamp it to 127, the maximum
supported value.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
On i.MX6 a single chipselect can have 4GiB, which overflows a 32bit
type, so imx6_mmdc_sdram_size() must return a u64 to support this case.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>