summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* imd: change disabled checksum tag info to debugHEADmasterSteffen Trumtrar4 days1-1/+1
| | | | | | | | | | | When the checksum tag is disabled the CRC is most likely invalid. And if the checksum tag is disabled and the CRC is actually invalid the user doesn't care for it anyway. This information only confuses the user so make it a debug message. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* image-sparse: change retlen to size_tSteffen Trumtrar4 days1-1/+1
| | | | | | | | retlen can potentially overflow. Also, write_full() in fastboot_handle_sparse() expects size_t anyway. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/spdx'Sascha Hauer2020-12-1149-500/+49
|\
| * common: replace license statements with SPDX-License-IdentifiersAhmad Fatoum2020-11-2748-480/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | For all files in common/ that already have a license text: - Replace with appropriate SPDX-License-Identifier - Remove empty comment lines around replacement - remove comment completely if only thing remaining is name of file without description Reviewed-by: Roland Hieber <rhi@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: dummy_malloc: remove unintended GPL2 eCos-exception-2.0Ahmad Fatoum2020-11-271-20/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Apparently, the file should be GPL-2.0-only without exceptions: On 24.11.20 09:44, Sascha Hauer wrote[1]: > This looks like I accidently copied the wrong header. I don't think I > did this on purpose. It doesn't make much sense to me when compiling > against dummy malloc is different than compiling against tlsf malloc > or dlmalloc. As dropping exceptions is no relicense, it's ok to do here without acknowledgement from all authors. Do so. [1]: <20201124084434.GC14718@pengutronix.de> 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>
* | Merge branch 'for-next/misc'Sascha Hauer2020-12-1110-43/+80
|\ \
| * | boot: introduce option to pass barebox-enabled watchdog to systemdAhmad Fatoum2020-11-303-3/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Like Linux, barebox supports co-existence of multiple watchdog devices. On boot, barebox enables only the default watchdog, which is defined as the watchdog with highest non-zero priority. The kernel handles all watchdogs the same and defers to userspace, which watchdogs to service. It can be useful to have barebox tell the system, which watchdog it activated, so it can service the same. Having this feature behind a global variable adds 354 bytes to a LZO compressed THUMB2 barebox. Users can opt out by toggling the Kconfig option, which defaults to off. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: implement and use parse_assignment helperAhmad Fatoum2020-11-273-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have the split by '=' snippet at multiple locations that parse key=value pairs. Consolidate them to a single location. This makes code a bit easier to read at the cost of an extra 8 bytes (LZO-compressed THUMB2 barebox, static inline version is bigger). No functional change. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | hush: remove non-functional codeAhmad Fatoum2020-11-271-8/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | name is unused except for printing and value is modified, but never read back. They currently serve no purpose, so drop them. The actual splitting by '=' happens in set_local_var later. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: boot: include blspec path name in entry titleAhmad Fatoum2020-11-241-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox linux-appendroot option having the same bootspec file in different partitions. boot -m will display the same title though, which doesn't help readability. Append the name of the config file to make the menu more useful in that case. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | commands: boot: display each list entry in a separate lineAhmad Fatoum2020-11-241-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | The boot entry lines could get quite long for bootspec entries and then follow-up commit will make them even longer, thus split the lines into two lines and indent the second. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | boot: drop uneeded header #includesAhmad Fatoum2020-11-241-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Boot entry providers register themselves, so there is no need for the common boot code to know about bootchooser or blspec or include their headers. Remove them as well as other headers that aren't strictly necessary and, if needed, include headers they include directly. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | bootm: adapt help text and naming for bootm.provide_machine_idAhmad Fatoum2020-11-233-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Kconfig help text as well the function name machine_id_set_bootarg() suggest that enabling the Kconfig option is sufficient to have barebox pass the machine id to the kernel. This is not the case, so change the naming/documentation to make this clearer. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Bastian Krause <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | setenv: align with POSIX in handling of setenv(var, "")Ahmad Fatoum2020-11-231-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | setenv(var, "") to delete var is a barebox idiosyncrasy. Previous commit added unsetenv and changed all users of setenv(var, ""), so lets set the behavior of setenv to what's expected: set var to the empty string. Previously, "" was turned into NULL, which meant it wasn't possible to set variables to the empty string from the shell. This is now possible. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | imd command: Bail out when crc generation/check failsSascha Hauer2020-12-071-4/+9
| |/ |/| | | | | | | | | | | Generating a IMD crc can fail, so bail out with an error when it fails. Also, when checking a IMD crc the result should be told to the caller. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | usbgadget: autostart: don't print error on repeated nv.usbgadget.autostart=1Ahmad Fatoum2020-11-241-2/+8
|/ | | | | | | | | | | | | | | | | | | | | | nvvar_add results in two calls to dev_set_param: - once when the existing global variable is found and set - once more when setting the nv variable This results in an annoying but ultimately harmless message on startup: ERROR: USB multi gadget already registered ERROR: failed to create nv variable usbgadget.autostart: Device or resource busy Avoid this by ignoring usbgadget.autostart=1 after it succeeded once. This issue should only affect $global.usbgadget.autostart, because all other global variables are "simple" meaning that they have no setters triggered. Fixes: 5a5c5178e7dc ("usbgadget: autostart: support delayed usbgadget.autostart=1") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common/Makefile: Fix dependencySascha Hauer2020-11-131-1/+1
| | | | | | | | | pbl object files have been renamed from pbl-*.o to *.pbl.o. Fix another place which hasn't been renamed. Fixes: ff047395b9 ("kbuild: rename pbl object pbl-*.o to *.pbl.o") Reported-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nv: fix use-after-free when clearing from shellAhmad Fatoum2020-11-131-8/+4
| | | | | | | | | | | | | | | | | When we use hush to set the same nv.var twice to the empty string: $ nv.user= $ nv.user= nv_set is called twice with a NULL val argument leading to a double free and accompanied memory corruption. Reorder the code, so p->value is freed just once. Fixes: fa4c41ba60af ("nvvar: when setting a nvvar to NULL just free the content") Cc: Holger Assmann <has@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* uimage: disable zero page when loading to SDRAM at address 0x0Michael Tretter2020-10-221-2/+19
| | | | | | | | | | | | | | | | If the SDRAM is mapped to address 0x0 and an image should be loaded to to the SDRAM without offset, Barebox would normally trap the access as a null pointer. However, since Linux kernel commit cfa7ede20f13 ("arm64: set TEXT_OFFSET to 0x0 in preparation for removing it entirely") no offset is the default for arm64. Therefore, copying the image to 0x0 of the SDRAM is necessary. Disable the zero page trap for copying an image to address 0x0. Signed-off-by: Michael Tretter <m.tretter@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/reboot-mode' into masterSascha Hauer2020-10-143-3/+24
|\
| * Merge branch 'for-next/magicvar-unique-id' into for-next/reboot-modeSascha Hauer2020-10-0712-67/+52
| |\
| * | defaultenv: provide defaults for generic reboot modesAhmad Fatoum2020-09-292-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While reboot mode magic identifiers can be very board specific, we can settle on common names to allow some generic reboot mode handling: - loader -> drop to bootloader shell on next boot - bootloader -> enable fastboot on next boot - recovery -> display barebox boot menu Boot modes loader and bootloader are admittedly a bit ambiguous, but this nomenclature was chosen, because it's already in use on Android and Rockchip systems. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | usbgadget: autostart: support delayed usbgadget.autostart=1Ahmad Fatoum2020-09-291-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, global.usbgadget.autostart=1 from the shell was without effect, because the variable is only evaluated once at postenvironment_initcall. Use the new globalvar_add_bool() to allow acting on the variable being true at any time. This is necessary for scripts that want to enable the usbgadget autostart functionality selectively without themselves hardcoding the particularities of what is exported. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/percent_pe' into masterSascha Hauer2020-10-143-6/+3
|\ \ \
| * | | treewide: replace strerror(-PTR_ERR(errno)) with %pe format specifierAhmad Fatoum2020-09-291-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using %pe instead of PTR_ERR has the benefit of being less verbose and less error-prone (no negation necessary) while potentially reducing code size. Make use of it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | vsprintf: retire strerrorp in favor of %peAhmad Fatoum2020-09-292-4/+2
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | strerrorp() is only used along with printf. We now have a format specifier for printing error pointers directly, so use that and remove strerrorp. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/misc' into masterSascha Hauer2020-10-144-4/+6
|\ \ \
| * | | shutdown: flush console on barebox shutdownLucas Stach2020-10-021-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Same as in the poweroff and restart path, we should make sure to properly drain the console devices when shutting down barebox. This fixes serial console corruption when the software running after barebox changes the peripheral configuration before all the characters have drained out of the FIFO. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | common: debug_ll: remove reference to undefined Kconfig optionAhmad Fatoum2020-10-011-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The code was copied from the kernel, but we don't support the imx6sl. Drop the left-over. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | Kallsyms: Cleanup whitespacesSascha Hauer2020-09-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 96028fb099 ("Kallsyms: Also resolve global variables") introduced some whitespaces where should have been tabs. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | common: misc: support strerror(err) for all err <= MAX_ERRNOAhmad Fatoum2020-09-281-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a _LAST_ERRNO of 3 decimal digits. strerror(_LAST_ERRNO) is ok, but it's still possible that some code passes a non-error code int, which will overflow the static buffer. Play it safe and bump up the buffer size to at least 11 characters. This is enough to represent all integers, with only 7 characters more static storage. This way strerror(some_int_passed_by_mistake) will not invoke UB. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | | Merge branch 'for-next/magicvar-unique-id' into masterSascha Hauer2020-10-1412-70/+54
|\ \ \ \ | | |_|/ | |/| |
| * | | magicvar: Replace BAREBOX_MAGICVAR_NAMED with BAREBOX_MAGICVARSascha Hauer2020-10-0212-67/+52
| | |/ | |/| | | | | | | | | | | | | | | | | | | BAREBOX_MAGICVAR now generates a unique identifier automatically, so we can convert users of BAREBOX_MAGICVAR_NAMED to the simpler BAREBOX_MAGICVAR macro. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/clang-analyzer' into masterSascha Hauer2020-10-143-3/+3
|\ \ \
| * | | blspec: fix dead assignmentAhmad Fatoum2020-10-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cdev is assigned for each loop iteration and consumed inside. The initial value is never read, so drop it. Reported-by: clang-analyzer-10 Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | common: memsize: eliminate dead storeAhmad Fatoum2020-10-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The assignment to val at this location serves no purpose, drop it to reduce clutter. Reported-by: clang-analyzer-10 Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | | globalvar: fix uninitialized read of variable when no nvvars existAhmad Fatoum2020-10-021-1/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | When there are no nvvars, the function returns an uninitialized ret, return 0 in this case instead. Reported-by: clang-analyzer-10 Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | | Merge branch 'for-next/buildsystem-version' into masterSascha Hauer2020-10-144-0/+16
|\ \ \ | |/ / |/| |
| * | imd: add buildsystem version to metadataSteffen Trumtrar2020-09-282-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | To have information about the exact state of a barebox binary from userspace, add the buildsystem version to the IMD. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: globalvar: add variable for buildsystem_version_stringSteffen Trumtrar2020-09-281-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | Now that the buildsystem version is available, make it accessible as a global variable for runtime usage. If the buildsystem version is not present (i.e. empty), don't add the variable at all. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: print buildsystem version in barebox bannerSteffen Trumtrar2020-09-251-0/+6
| |/ | | | | | | | | | | | | | | | | When the barebox banner is enabled and printed during startup, also show information about the buildsystem version: the exact state of the barebox binary and its config. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | lib: kasan: migrate Kconfig option to Debugging menuAhmad Fatoum2020-09-291-0/+1
|/ | | | | | | | UBSAN and ASAN as well as other debugging aids are all in the Debugging menu. Relocate KASAN to be there as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/protonic' into masterSascha Hauer2020-09-251-0/+18
|\
| * common: console_common: add of_console_get_by_alias() helperOleksij Rempel2020-08-241-0/+18
| | | | | | | | | | | | | | Add helper function to get console device by devicetree alias Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/net' into masterSascha Hauer2020-09-2510-35/+572
|\ \
| * | workqueues: Add support for delayed workSascha Hauer2020-09-141-0/+3
| | | | | | | | | | | | | | | | | | | | | Sometimes it's necessary to do some work after a delay. Add support for this case. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fs: Warn when filesystem operations are called from a pollerSascha Hauer2020-08-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Filesystem operations possibly call into arbitrary devices, so shouldn't be used from a poller. This patch sprinkles some WARN_ONCE() when this happens. One exception is when the file which is accessed is on ramfs which doesn't have any dependencies to devices. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fastboot net: implement fastboot over UDPEdmund Henniges2020-08-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements the UDP variant of the fastboot protocol. The only way to start the service for now is to compile with CONFIG_FASTBOOT_NET_ON_BOOT. The service will bind to the network interface that provides the IPv4 gateway. Sending an OKAY packet before performing a restart is necessary since contrary to USB the host will not notice when a UDP server disappears. 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>
| * | fastboot: init list head in commonSascha Hauer2020-08-191-0/+2
| | | | | | | | | | | | | | | | | | | | | The list of variables can be initialized in common code, no need to do the in the different implementations. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fastboot: Add fastboot_abort()Sascha Hauer2020-08-191-0/+12
| | | | | | | | | | | | | | | | | | Add fastboot_abort() to allow aborting the current session. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>