summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/ratp'Sascha Hauer2020-06-111-1/+16
|\
| * ratp: Remove unnecessary poller_call()Sascha Hauer2020-05-201-1/+0
| | | | | | | | | | | | | | poller_call() is called by is_timeout(), no need to do this again in a timeout loop. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * ratp: Test if console exists before using itSascha Hauer2020-05-201-0/+16
| | | | | | | | | | | | | | | | Consoles can be unregistered, this happens for example when barebox implements the barebox serial USB gadget. Before using the console we have to explicitly test if the pointer is still valid each time. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2020-06-112-1/+15
|\ \
| * | password: Fix warning with empty default passwordDavid Dgien2020-06-031-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When CONFIG_PASSWORD_DEFAULT is unset, the default_passwd buffer is set to the empty string. The read_default_passwd() function wants to read at least two characters from that buffer, causing GCC to generate an array bounds warning: barebox/common/password.c: In function 'login': barebox/common/password.c:173:5: warning: array subscript [1, 2147483647] is outside array bounds of 'const char[1]' [-Warray-bounds] In file included from barebox/common/password.c:30: include/generated/passwd.h:1:19: note: while referencing 'default_passwd' Add an ARRAY_SIZE check to default_passwd so that the loop is optimized away and the warning is no longer generated. Since the read_default_passwd() function is only called when default_passwd is not the empty string, this is not a functional change. Signed-off-by: David Dgien <dgienda125@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | password: don't export read_default_passwd()Uwe Kleine-König2020-06-031-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | This function is used only in common/password.c itself, so it doesn't need to be exported. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | blspec: Allow the "options" key to be given multiple timesRobert Karszniewicz2020-06-031-0/+12
| |/ | | | | | | | | | | | | | | | | The Boot Loader Spec says: "This key is optional and may appear more than once in which case all specified parameters are used in the order they are listed." Signed-off-by: Robert Karszniewicz <r.karszniewicz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/kbuild'Sascha Hauer2020-06-111-0/+1
|\ \
| * | kconfig: add 'option modules' to allow tristate options to become mMasahiro Yamada2020-05-201-0/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 18895514dc5e ("kconfig: update to v3.18-rc6"), tristate symbols cannot become 'm'. In old days of Linux, CONFIG_MODULES was the special option hard-coded in Kconfig. The current Kconfig does not know which option is it. You need to specify 'option modules' to teach Kconfig that it is the module support switch. Add 'option modules' to revive the module builds. Fixes: 18895514dc5e ("kconfig: update to v3.18-rc6") Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fastboot: Use unique tempfile nameSascha Hauer2020-05-201-9/+12
| | | | | | | | | | | | | | | | With fastboot over ethernet we now can have two instances of fastboot running in parallel. Make sure that both instances use a different temporary file to store data so that they do not influence each other. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fastboot: don't close fd 0 when downloading to ramDaniel Glöckner2020-05-201-1/+2
| | | | | | | | | | | | | | | | | | When downloading to a buffer, download_fd is never assigned a valid file descriptor. We should therefore avoid calling close on the value found in that variable. Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fastboot: split generic code from USB gadgetEdmund Henniges2020-05-203-0/+998
| | | | | | | | | | | | | | | | | | | | | | | | | | The fastboot specification describes other protocols beyond USB. Allow these to reuse the generic parts of the existing fastboot code when they are implemented. Most of the changes in common/fastboot.c are due to the renaming of struct f_fastboot *f_fb to struct fastboot *fb. Signed-off-by: Edmund Henniges <eh@emlix.com> Signed-off-by: Daniel Glöckner <dg@emlix.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | poller: Add a poller commandSascha Hauer2020-05-201-0/+71
| | | | | | | | | | | | | | The poller command allows to print which pollers are registered and also how many times we can run the registered pollers in one second. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | poller: Give pollers a nameSascha Hauer2020-05-203-5/+7
|/ | | | | | It helps debugging when pollers have a name, so give them one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mxs'Sascha Hauer2020-05-141-0/+4
|\
| * filetype: Add filetype for i.MX23/28 SD card imagesSascha Hauer2020-05-061-0/+4
| | | | | | | | | | | | | | Add a filetype for i.MX23/28 SD card images so that they can be detected. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2020-05-1439-120/+46
|\ \
| * | common.h: move and rename lregion_overlap()Masahiro Yamada2020-05-051-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lregion_overlap() is only used by common/startup.c There is no need to define it in include/common.h While I was here, I also renamed it to region_overlap(), and got rid of the 'inline' keyword. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: imd: handle error in imd_write_crc32Steffen Trumtrar2020-05-051-1/+6
| | | | | | | | | | | | | | | | | | | | | Don't just ignore the return value of write_file. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | treewide: remove references to CREDITSUwe Kleine-König2020-04-2738-112/+0
| | | | | | | | | | | | | | | | | | | | | | | | The CREDITS file was removed from barebox in 2015 by commit 6570288f2d97 ("Remove the CREDITS file"). Remove references to it from several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: bootm: Enforce CONFIG_BOOTM_FORCE_SIGNED_IMAGES for TEE binsAlbert Schwarzkopf2020-04-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, unsigned TEE binaries can be booted. This patch ensures that CONFIG_BOOTM_FORCE_SIGNED_IMAGES is also enforced for TEE binaries. Signed-off-by: Albert Schwarzkopf <a.schwarzkopf@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | startup: add $global.autoboot to make behavior configurableAhmad Fatoum2020-04-271-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We already have a global_autoboot_state variable that controls barebox init behavior on startup: * ABORT abort and fall into shell * MENU display boot menu * BOOT boot immediately, only abortable via ctrl+c during init * COUNTDOWN regular boot after count down Exporting this as a device parameter allows us to support some different boot scenarios: * COUNTDOWN is the default * ABORT boot always while debugging * display MENU by default (e.g. for graphical boots) * BOOT while ignoring external code calling console_countdown_abort() Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | startup: don't clobber original autoboot stateAhmad Fatoum2020-04-271-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | do_autoboot_countdown changes autoboot state if the user presses m for menu or ctrl+c to abort during count down. This is an internal detail and doesn't need to be reflected in the state of the global variable. This will improve UX when exporting the variable in the follow-up commit, because on a regular boot it $autoboot will expand to countdown instead of abort/boot/menu dependent on prior user input. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | startup: rename AUTOBOOT_UNKNOWN to more descriptive AUTOBOOT_COUNTDOWNAhmad Fatoum2020-04-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | If we export the autoboot state variable for customization, having unknown as default is not so helpful. Rename it to what actually happens (abortable countdown). Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | Add magicvar description for autoboot variablesSascha Hauer2020-04-271-0/+8
| |/ | | | | | | | | | | | | global.autoboot_abort_key and global.autoboot_timeout lack a magicvar description. Add one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/kconfig'Sascha Hauer2020-05-141-3/+0
|\ \
| * | treewide: Kconfig: remove some unused symbolsAhmad Fatoum2020-04-291-3/+0
| |/ | | | | | | | | | | | | | | All these symbols are defined, but unused anywhere in the barebox tree. Remove them. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/kbuild'Sascha Hauer2020-05-143-5/+3
|\ \
| * | kbuild: sync filechk rule with Linux 5.7-rc2Masahiro Yamada2020-05-041-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The 'filechk' in the latest Linux works more simply, reliably. - Do not show CHK every time - Delete the *.tmp file when the filechk_$(1) fails - Do not open the first prerequisite. This is unneeded in most cases. I deleted pointeless dependency on Makefile. Also delete the meaningless assignment to 'targets' because filechk does not generate .cmd file. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | image: support 'powerpc' for mkimage architectureMasahiro Yamada2020-05-041-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, the -A option of mkimage is determined based on $(SRCARCH). I want to rename arch/ppc/ to arch/powerpc/. Support 'powerpc' for the -A option of mkimage beforehand, otherwise the barebox.uimage build would be broken. common/image.c in U-Boot supports both 'powerpc' and 'ppc' for the name of IH_ARCH_PPC. Let's do likewise in barebox. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | kbuild: make DEFCONFIG_LIST workMasahiro Yamada2020-04-271-2/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Most of the Kconfig commands (except defconfig and all*config) read the .config file as a base set of CONFIG options. When it does not exist, the files in DEFCONFIG_LIST are searched in this order and loaded if found. This is not working for barebox because ARCH_DEFCONFIG is not set by anyone, nor arch/$(ARCH)/defconfig exists. Fix this. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | drivers: add COMPILE_TEST prompts for some off-by-default optionsAhmad Fatoum2020-05-081-2/+2
| | | | | | | | | | | | | | | | | | | | | | Some Kconfig options we have are promptless and off-by-default and instead can only be enabled by being selected from platform options. For some of those that aren't compile testable, add a new COMPILE_TEST-only prompt. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: introduce COMPILE_TEST option for build-testingAhmad Fatoum2020-05-081-0/+13
|/ | | | | | | | | | | | | | Compile-time analysis may help us catch latent bugs in barebox. For this to be most effective, we need an easy way to compile as much of barebox as possible. Giving all driver options prompts would do this, but at the cost of making user experience worse, by asking them about drivers for HW that's clearly not relevant to the platform they selected. Do as Linux does and provide a default-off COMPILE_TEST option, which we can use to make extra drivers selectable. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2020-04-1619-36/+40
|\
| * common: fix typos found with codespellYegor Yefremov2020-03-2318-36/+36
| | | | | | | | | | Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: oftree: trim leading spaces from bootargsClement Leger2020-03-231-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | When barebox concatenates all dynamic bootargs string for linux, if they are empty, the resulting string might be composed of only spaces. Currently, there is no check for such string and it leads to overwriting bootargs in the device tree by an empty string. To avoid this behavior, use skip_spaces to trim leading spaces and then check if the string is empty. If so, simply returns and don't patch device tree bootargs. Signed-off-by: Clement Leger <cleger@kalray.eu> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/arm'Sascha Hauer2020-04-161-3/+18
|\ \
| * | ARM: bootm: Add some printfs when request_sdram_region() failsSascha Hauer2020-03-251-3/+18
| |/ | | | | | | | | | | | | request_sdram_region() can fail in which case it's interesting which region we tried to request. Add some printfs for it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* / imd: Use %zu for printing size_tSascha Hauer2020-04-011-1/+1
|/ | | | | | To avoid compiler warnings Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/stm32'Sascha Hauer2020-03-181-3/+3
|\
| * reset_source: introduce reset_source_to_stringAhmad Fatoum2020-02-191-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a few places where driver code prints reset_source_name() to console after setting the reset source. This working is probe order dependent, because reset_source_name() prints the highest priority reset_source so far, which doesn't necessarily have to be the one that was just computed. Implement reset_source_to_string, so drivers can be migrated to use it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2020-03-182-4/+5
|\ \
| * | state: treat state with all-invalid buckets as dirtyAhmad Fatoum2020-03-091-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The state.dirty flag controls whether state_save will actually persist state. It is cleared when we successfully load or save state and set on writing a state parameter. When the state however becomes corrupt during barebox runtime and state.dirty == 0, reinitializing the state to defaults is quite cumbersome: 1. We reset twice. After the first reset, the dirty flag is reset and before the second, state_save will reinitialize to defaults 2. We write any state variable and then run the state -s command Both workarounds are quite obscure, improve the user experience by having state -l set the dirty flag when it fails, so a subsequent state -s may persist the default values to state. Steps to reproduce: barebox$ state -l state: Using bucket 0@0x00000000 barebox$ memcpy -s /dev/zero -d /dev/eeprom0.state 0 0 0x400 barebox$ state -s barebox$ state -l ERROR: state: No meta data header found ERROR: state: No meta data header found ERROR: state: No meta data header found ERROR: state: Failed to find any valid state copy in any bucket ERROR: state: Failed to read state with format raw, -2 state: No such file or directory Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | state: backend_storage: deal gracefully with runtime bucket corruptionAhmad Fatoum2020-03-091-0/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Corrupting an already selected bucket and then reading it again will crash barebox when it attempts the refresh: barebox$ state -l barebox$ mw -d /dev/eeprom0.state 0 0x42 barebox$ state -l ERROR: state: No meta data header found state: Using bucket 1@0x00000040 unable to handle NULL pointer dereference at address 0x00000000 pc : [<4fe4f1ea>] lr : [<4fe0bcb1>] sp : 4ffefd5c ip : 00000000 fp : 2ff68f04 r10: 4ffefdc8 r9 : 4b434d63 r8 : 30155f50 r7 : 00000024 r6 : 2ff68b60 r5 : 2ff68e90 r4 : 00000000 r3 : 00000024 r2 : 00000024 r1 : 30155f50 r0 : 00000000 Flags: Nzcv IRQs off FIQs off Mode SVC_32 WARNING: [<4fe4f1ea>] (memcmp+0x14/0x1a) from [<4fe0bcb1>] (bucket_refresh.isra.0+0x4d/0x78) WARNING: [<4fe0bcb1>] (bucket_refresh.isra.0+0x4d/0x78) from [<4fe0be1d>] (state_storage_read+0xd1/0x104) WARNING: [<4fe0be1d>] (state_storage_read+0xd1/0x104) from [<4fe0a5bd>] (state_do_load+0x1d/0x78) WARNING: [<4fe0a5bd>] (state_do_load+0x1d/0x78) from [<4fe04137>] (execute_command+0x23/0x4c) The memcmp called here is an optimization to skip I/O if the used bucket and the one to be refreshed compare equal. Unfortunately, if the now corrupt bucket was previously the used one, bucket->len will hold the old value and we'll run into a NULL pointer dereference. While this is quite inconvenient, it appears it doesn't affect correctness: after the reset, the corrupt bucket will be refreshed as expected. Improve upon this by setting the length to zero when we are NULLing the buffer. The zero length of the corrupted bucket will then compare unequal to used_bucket->len in bucket_refresh() and ensure we will always refresh the buffer if it becomes corrupted without an intermittent reset. Fixes: 238008b4bd8f ("state: Drop cache bucket") Cc: Enrico Jörns <ejo@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/block'Sascha Hauer2020-03-181-2/+23
|\ \ | |/ |/|
| * Revert "block: Adjust cache sizes"Ahmad Fatoum2020-03-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On 12/13/19 2:12 PM, Sascha Hauer wrote: > On Tue, Dec 10, 2019 at 03:44:52PM +0100, Hubert Feurstein wrote: >> With v2015.06.0 the indicated progress of the copy command is very >> smooth. Calling "cp -v /dev/zero /dev/mmc3.root" takes about 80 >> seconds for 256MB. But with v2019.12.0 the progress is very bumpy and >> the copy takes about 280 seconds. >> >> I've tracked this down to this commit which destroys the performance: >> "block: Adjust cache sizes" (b6fef20c1215c6ef0004f6af4a9c4b77af51dc43) > > We could just revert this patch. I can't find any workload that gets > faster with b6fef20c1215. It's rather the other way round. Do this by reverting commit b6fef20c1215c6ef0004f6af4a9c4b77af51dc43. Reported-by: Hubert Feurstein <h.feurstein@gmail.com> Suggested-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * block: Implement discard_rangeSascha Hauer2020-02-141-0/+21
| | | | | | | | | | | | | | | | This implements the discard_range hook. When a range of data is discarded then we do not have to read it from the device and can pass a zeroed buffer instead. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/parameter'Sascha Hauer2020-02-183-23/+23
|\ \
| * | globalvar: Allow NULL pointers to be returned by dev_add_param()Christian Eggers2020-01-271-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The following commit will change the return value of dev_add_param() from -ENOSYS to NULL if CONFIG_PARAMETER is disabled. After that, building without CONFIG_PARAMETER will return a NULL pointer to __nvvar_add() instead of an error. Signed-off-by: Christian Eggers <ceggers@arri.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | state: remove param member from state_uint32, state_enum32, state_macChristian Eggers2020-01-272-11/+8
| | | | | | | | | | | | | | | | | | | | | After adding the parameter, the pointer isn't required anymore. Signed-off-by: Christian Eggers <ceggers@arri.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>