9
0
Fork 0
Commit Graph

499 Commits

Author SHA1 Message Date
Sascha Hauer dd534571bd Merge branch 'for-next/misc' 2016-09-13 14:56:05 +02:00
Uwe Kleine-König bf6ddd6c4d xstrdup: don't panic on xstrdup(NULL)
Instead return just NULL. This matches the behaviour of kstrdup in the
kernel and xstrdup in busybox.

This fixes a panic with CONFIG_CMD_MAGICVAR=y and
CONFIG_CMD_MAGICVAR_HELP unset in magicvar_add() where description is
always NULL.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-12 08:15:47 +02:00
Aleksey Kuleshov eb2b2e2647 clarify strim function description
Signed-off-by: Aleksey Kuleshov <rndfax@yandex.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-22 07:47:30 +02:00
Sascha Hauer 94b1e5a321 Merge branch 'for-next/nv' 2016-08-03 08:08:23 +02:00
Sascha Hauer 70460e9723 getopt: Add support for '--' to stop option parsing
In some cases when commands have optional arguments it is necessary
to explicitly stop option parsing after the last nonpositonal option.
Add support for '--' to accomplish this as done in getopt(3) aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-25 10:30:19 +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 ca95c2bab9 Merge branch 'for-next/video' 2016-07-11 07:58:34 +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
Markus Pargmann 3d33f178cc libfile: Change write_full to be have const buf
write() uses a const pointer so write_full should do the same.

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
Enrico Jorns 90326eba5a vsprintf: fix handling of strp arg in asprintf
strp argument was ignored but should be forwarded to vasprintf() call in
order to make this funktion work as expected.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-07 09:16:41 +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
Andrey Smirnov aa750244ee video/edid: Move int_sqrt() out
Move int_sqrt() out of drivers/video/edid.c so that it is availible to
other parts of Barebox.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-30 08:33:53 +02:00
Andrey Smirnov 927176bc16 GUI: Add code to draw simple graphics
Add code to draw simple graphics, namely lines(solid or dashed) and
circles.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-30 08:33:53 +02:00
Andrey Smirnov 0cd1a51924 GUI: Add a function to draw vertical/horizontal bars
Add a function to draw solid vertical or horizontal bars.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-30 08:33:53 +02:00
Sascha Hauer 3dca2b0bf7 ubiformat: Fix formatting devices with unreadable areas
When parts of a Nand device are not readable due to excessive bit flips
we should not bail out with an error as this means we can never repair
the device by flashing a fresh image using ubiformat. Instead, treat a
failed read as a corrupt block and ignore the read failure.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-20 07:58:07 +02:00
Sascha Hauer 821de09b1f ubiformat: Ignore bitflip errors
Fixes: 1d88c66 ubiformat: Use mtd-peb API

bit flips are no error, when encountering them during scanning of a
device just ignore them.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-20 07:57:59 +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 a9b18674c0 parameter: Use strtobool
Use strtobool to convert the input string to a boolean type.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-04 11:58:46 +02:00
Sascha Hauer 22b8e9415d string: Introduce strtobool
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>
2016-04-29 11:29:25 +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 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 e1385b3399 move unlink_recursive declaration to libfile.h
unlink_recursive is a file utility function, so move the prototype to
libfile.h

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer 69858c74b2 move make_directory declaration to libfile.h
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>
2016-04-15 12:21:45 +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 48b205e323 show_progress: print spaces with %*s
Removes the need for include/linux/stringify.h in the progress
bar code.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer 4f17444ecc libfile: move open_and_lseek() to libfile
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>
2016-04-15 12:21:45 +02:00
Du Huanpeng b86834423f NULL: keep NULL definition in stddef.h only
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>
2016-04-14 08:00:26 +02:00
Renaud Barbier 97e553bc65 lib: declared buffer is too small to hold string
Displaying an unsigned 64-bit integer can be represented by up to 20
characters. The 20 bytes buffer reserved to store the formatted string
"%llu Bytes" is to small: (20 + 6) = 26. Hence, a bigger buffer is reserved
to hold this string.

Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-12 08:05:35 +02:00
Alexander Stein f01ed88aac Add list_sort from u-boot v2016.03
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>
2016-04-08 13:33:18 +02:00
Alexander Stein eb36388c15 rbtree: Update to u-boot v2016.03
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>
2016-04-08 13:33:18 +02:00
Sascha Hauer 3bafe5eac5 decompressors: Use malloc/free wrappers
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>
2016-04-08 13:33:18 +02:00
Sascha Hauer 81b52d93cb remove now unused libmtd
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>
2016-04-06 10:17:52 +02:00
Sascha Hauer 1d88c66977 ubiformat: Use mtd-peb API
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>
2016-04-06 10:17:52 +02:00
Sascha Hauer 30750ef990 mtd: rename mtd_all_ff -> mtd_buf_all_ff
To make clear this function checks a given buffer and not data on a mtd
device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-03-15 11:29:27 +01:00
Philipp Zabel 2b47e52795 process_escape_sequence: add support for \u
Expand the \u escape sequence to the user currently set in the
$global.user variable.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-02-17 13:50:45 +01:00
Sascha Hauer c073534880 Merge branch 'for-next/ratp' 2016-02-08 08:27:01 +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
Sascha Hauer bbdbda0a74 Add Reliable Asynchronous Transfer Protocol
This patch adds support for Reliable Asynchronous Transfer Protocol (RATP)
as described in RFC916.

Communication over RS232 is often unreliable as characters are lost or
misinterpreted. This protocol allows for a reliable packet based communication
over serial lines.

The implementation simply follows the state machine described in the RFC
text with one exception. RFC916 uses a plain checksum for the
transferred data. We decided to use CRC16 for greater robustness. Since
this is the only RFC916 implementation we currently know of interoperability
with other implementations should not matter.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Andrey Smirnov <andrew.smirnov@gmail.com>
2016-01-18 09:25:04 +01:00
Sascha Hauer 7f2e215fcf vsprintf: Add support for %pa
Add support for the %pa format specifier to print phys_addr_t,
dma_addr_t and resource_size_t.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-15 15:32:29 +01:00
Sascha Hauer 70ef1cef5c Merge branch 'for-next/pstore' 2016-01-11 13:11:07 +01:00
Sascha Hauer b9a2512aaa Merge branch 'for-next/misc' 2016-01-11 13:11:06 +01:00
Sascha Hauer 1cc4ba2aa1 readline: Fix potential buffer overflow in command history
Cursor up copies the last line into the buffer without checking if it
fits into the current buffer. Fix this using safe_strncpy.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:56 +01:00
Sascha Hauer e3ae12a418 readline: Fix potential buffer overflow
cread_add_char doesn't take the trailing '\0' into account, so adding
it at the end of readline can overflow the buffer.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-01-08 08:30:56 +01:00
Trent Piepho a3544b162e bootstrap: constify strings
Various parameters for device names, etc.  should be const strings.

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
Trent Piepho 1d31baf145 bootstrap: Boot barebox with kernel calling convention
In commit 8e3ddc13eb the bootm code was
changed to boot barebox using the same calling convention as the
kernel.  Which on ARM is to pass three arguments which are zero, an
architecture code, and a params pointer.

A 2nd stage barebox can be booted using lib/bootstrap, which is
different code from bootm.  This code just leaves garbage in the first
three parameters and so doesn't follow the convention.

Change it to be compatible with the ARM kernel booting convention.
This just sends a zero for the architecture, since the code for
architectures depends on boot[zmu] and something using bootstrap
wouldn't have those too.  And it just passes NULL for the params since
we don't have a way to pass a device tree from the preloader.

All users of bootstrap are ARM based, but the code is in lib so a
non-ARM board might someday make use of it.  If the current code would
work for them, then the change here will be ok too.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-12-14 11:13:32 +01:00
Markus Pargmann 899b3822d2 lib: Import reed solomon code from kernel
reed solomon code is used by RAMOOPS to check and fix data stored in
volatile memory.

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
Markus Pargmann 647fba8ee3 vsprintf: Add scnprintf from kernel
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 24f1c994cc Merge branch 'for-next/misc' 2015-12-08 08:28:07 +01:00