Some network devices, especially when connected to a switch, are
connected via a fixed link. This patch adds support for a fixed phy
configured through device tree.
TODO: Add support for the "speed" and "full-duplex" properties.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com>
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>
We have at least two places which convert a string to a boolean type,
so create a common function for this. strtobool treats
- any positive (nonzero) number as true
- "0" as false
- "true" (case insensitive) as true
- "false" (case insensitive) as false
Every other value results in an error and the input *val is not
modified. The caller is expected to initialize *val with the correct
default before calling strtobool.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
I.MX6+ version of the silicon exposed PCIe core's reset signal as a bit
in one of the control registers. As a result using old, pre-i.MX6+,
reset sequence on i.MX6+ leads to Barebox hanging during startup. Using
exposed reset bit instead solves the problem.
This commit is based on portions of commit
c34068d48273e24d392d9a49a38be807954420ed
in http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Port of_match_device() and of_device_get_match_data() from Linux kernel
code.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
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>
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>
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>
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>
This moves the function prototypes in include/fs.h which also exist
in the libc to the locations they would have in libc.
With this it becomes easier to share code between barebox and userspace
since the usual libc include files will exist. Also users of the libc
functions no longer have to include the barebox internal fs.h header.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
As a utility function for file handling make_directory() is well
suited for libfile. Move it there.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>
libfile is a collection of helpers for handling files. open_and_lseek()
is a perfect match for this, so move it there.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
according to C99 standard, the definition of wchar_t
should go stddef.h
this patch also remove wchar_t local definition and
use stddef.h instead.
Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
remove other local definition of NULL, use
#include <linux/stddef.h>
instead.
I use this command to search NULL definition,
grep -R "define\s*\<NULL\>"
hope there are no more definition of NULL.
from ISO/IEC 9899:TC3:
The macros are
NULL
which expands to an implementation-defined null pointer constant;
Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
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>