summaryrefslogtreecommitdiffstats
path: root/common/bbu.c
Commit message (Collapse)AuthorAgeFilesLines
* bbu: Emit a message about what happens also when -y is givenUwe Kleine-König2024-02-231-6/+12
| | | | | | | | | | | | To inform the user which device is updated using which handler, also emit a message with -y. Also update the wording to make the output more similar between the different cases. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Link: https://lore.barebox.org/20240221103334.1925850-2-u.kleine-koenig@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: create a standard bbu handler for eMMC bootSascha Hauer2024-02-131-5/+33
| | | | | | | | | | | This adds a standard bbu handler to be used when an update is just a matter of writing an image to the eMMC boot partitions. As these may also want to set the BBU_FLAG_MMC_BOOT_ACK flag, it is moved up one level to struct bbu_handler::flags to make it configurable when struct bbu_data is not yet instantiated. Link: https://lore.barebox.org/20240208075217.697668-1-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: make it possible to check multiple of-compatiblesMarco Felsch2023-04-041-13/+28
| | | | | | | | | | | | | It is possible that one barebox can rule multiple platforms e.g. multiple platform revision each has a dedicated device tree and of compatible. While it is possible to add multiple of-compatibles via IMD_USED_OF() (see: zii-imx8mq-dev) we didn't allowed it to flash it without 'force'. Fix this by check all possible IMD_TYPE_OF_COMPATIBLE image metadata types. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20230228-v2023-02-0-topic-flexspi-v2-2-3d33126d2434@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: fix exporting i.MX NAND bbu handler over fastbootAhmad Fatoum2022-09-301-19/+18
| | | | | | | | | | | | | | | | | handler->devicefile for i.MX NAND is nand0.barebox, which lacks a /dev/ prefix. This is ok for detection, as device_detect_by_name expects the cdev name and devpath_to_name() will strip a /dev/ if available. For stat() however, we need to add back /dev/, otherwise the file can't be found. Rework the code to do that. This fixes an issue where usbgadget -A '' -b would not export a i.MX NAND barebox update handler. Fixes: 726a802456bc ("common: bbu: only add available handlers") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220928085622.2677478-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: export bbu_std_file_handler for use in custom handlersAhmad Fatoum2022-06-031-13/+20
| | | | | | | | | | | bbu_register_std_file_update() registers an update handler that updates a single file, usually a partition. Depending on SoC, we may want to compute the file path at install time. To save custom bbu code the hassle of reimplementing bbu_std_file_handler(), export it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-5-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: add flag for enabling eMMC boot ackAhmad Fatoum2022-06-031-1/+16
| | | | | | | | | | | | | | bbu_mmcboot_handler() already takes care to switch $mmc.boot to the freshly read inactive partition. On some SoCs like the STM32MP1, this is not enough, but the boot ack bit must be set as well, so the BootROM can communicate with the eMMC. Have this happen as part of the eMMC boot switch after a successful update if bbu_data::flags has BBU_FLAG_MMC_BOOT_ACK set. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: use free(NULL) to simplify function cleanupAhmad Fatoum2022-06-031-8/+5
| | | | | | | | | | We will add a third allocated string in a follow up commit, so instead of having a third label to selectively free it, just initialize all the pointers to NULL and free them unconditionally to simplify the code. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: move barebox_update eMMC boot handling into common codeAhmad Fatoum2022-06-031-0/+55
| | | | | | | | | | | | | Like with the i.MX, the STM32MP1 BootROM also consults the EXT_CSD_PARTITION_CONFIG register to find out what to boot. The barebox_update code used for atomic update on i.MX is thus useful to the STM32MP as well, so move the boot switching part to a generic location. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: bbu: add pr_fmtRouven Czerwinski2021-06-211-0/+3
| | | | | | | | This makes it easier to identify where messages are coming from. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210618120557.2192098-2-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: bbu: only add available handlersRouven Czerwinski2021-06-211-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | A board may have multiple handlers registered: registered update handlers: SD -> /dev/mmc0.barebox * eMMC -> /dev/mmc1 However when using the usbgadget with the -b command line argument, fastboot will stat all devicefiles listed in the handlers and will fail if i.e. the SD card is not available: usbgadget -A /dev/mmc1(root) -b udc0: registering UDC driver [g_multi] multi_bind: creating Fastboot function ERROR: g_multi udc0: failed to start g_multi: -2 usbgadget: No such file or directory To fix this, check the availability of handlers before adding them to the list and skip those that are not available with an info level message. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Link: https://lore.barebox.org/20210618120557.2192098-1-r.czerwinski@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: add function to directly add handlers into file_listAhmad Fatoum2021-05-121-9/+15
| | | | | | | | | | | bbu_handlers_iterate() is only used for merging handlers into a file_list. This can be useful for other update mechanisms as well. Export a bbu_append_handlers_to_file_list that does this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20210503114901.13095-14-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* extend the test in bbu_std_file_handler() to also check for -ENOTSUP.jameszxj2021-02-241-1/+1
| | | | | | | extend the test in bbu_std_file_handler() to also check for -ENOTSUP. Signed-off-by: zhengxiaojun <jameszxj at gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: replace license statements with SPDX-License-IdentifiersAhmad Fatoum2020-11-271-9/+1
| | | | | | | | | | | | | 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>
* treewide: remove references to CREDITSUwe Kleine-König2020-04-271-3/+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: fix typos found with codespellYegor Yefremov2020-03-231-1/+1
| | | | | Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: bbu: add support for imd checksumSteffen Trumtrar2020-02-101-0/+4
| | | | | | | | | Add support for verifying an image by use of the imd checksum. If the checksum that is saved in the image and the one that is calculated over the image differ, barebox_update aborts. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: In bbu_register_std_file_update detect device before accessing itSascha Hauer2019-05-101-0/+2
| | | | | | | The device the standard file update handler writes to may not be present before detecting it, so as a first step detect it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: bbu_register_std_file_update should take const char*Sascha Hauer2019-05-101-1/+1
| | | | | | String arguments to bbu_register_std_file_update should be const. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: Simplify bbu_find_handler_by_device()Andrey Smirnov2018-10-081-9/+5
| | | | | | | | | Simplify bbu_find_handler_by_device() by making use of devpath_to_name() as well as some basic recursion to avoid coding the same loop twice. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: Add "handler" parameter to barebox_update()Andrey Smirnov2018-10-081-10/+1
| | | | | | | | | | | | Add "handler" parameter to barebox_update() and remove the code that was respondible for header lookup before. With this change finding appropriate handler is caller's responsibility, which makes it possible to implement custom handler lookup/existence check, chache it, and then re-use it without calling handler_find_by_* functions for the second time. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: Expose bbu_find_handler_by_*() functionsAndrey Smirnov2018-10-081-19/+5
| | | | | | | | | | | | Expose bbu_find_handler_by_device() and bbu_find_handler_by_name() as public functions and convert the only user of barebox_update_handler_exists() to use the former function instead. With this done, barebox_update_handler_exists() is no longer used anywhere in the code and can be removed. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: Report update failures explicitlyAndrey Smirnov2018-08-311-6/+6
| | | | | | | | | Change the code of barebox_update() to explicitly log that update failed instead of failing silently (unless update was interrupted) and relying on user checking the return code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: Remove logical negation in barebox_update_handler_exists()Andrey Smirnov2018-08-311-1/+1
| | | | | | | | | Returning !bbu_find_handler() from barebox_update_handler_exists() would return the opposite result from what the name of that funciton implies. Drop the "!" to make it behave as expected. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* imd: Make all pointers into image constSascha Hauer2018-01-301-2/+2
| | | | | | | The IMD code should be readonly and never modify any pointers. Make all pointers const so that const pointers can be passed in to IMD. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: Add function to iterate over registered handlersSascha Hauer2017-09-271-0/+15
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: Search for cdev names aswellSascha Hauer2017-03-101-0/+9
| | | | | | | | In bbu_find_handler_by_device() search for cdev names aswell since some update handlers are registered with their cdev name and not the full path. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: parameters are inverted in error messageRenaud Barbier2016-08-181-2/+2
| | | | | | | | | The error message warning the user that the image is too big for the device has its parameters in the wrong order. Swap the two parameters so that the output makes sense. Signed-off-by: Renaud Barbier <renaud.barbier@ge.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/imx-bbu-nand-fcb'Sascha Hauer2016-04-081-1/+11
|\
| * bbu: Allow to refresh/repair imagesSascha Hauer2016-04-081-1/+11
| | | | | | | | | | | | | | | | | | | | 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>
* | bbu: print and evaluate image MetadataSascha Hauer2016-04-061-0/+78
|/ | | | | | | | | | | 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>
* Merge branch 'for-next/bbu'Sascha Hauer2016-03-111-1/+33
|\
| * bbu: Add function to check if an update handler existsMarkus Pargmann2016-02-181-0/+14
| | | | | | | | | | | | | | | | This adds a function to check for the existence of an update handler based on the supplied bbu_data. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * bbu: Add barebox_update search by deviceMarkus Pargmann2016-02-181-1/+19
| | | | | | | | | | | | | | | | | | bbu_data includes a devicefile information. Add the possibility to make an update based on the given devicefile. This is in addition to the normal search for a barebox update handler by its name. Signed-off-by: Markus Pargmann <mpa@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bbu: use correct printf format specifier for size_tLucas Stach2016-03-041-1/+1
|/ | | | | Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: Add a standard file-to-device-copy handlerSascha Hauer2015-07-011-0/+113
| | | | | | | | The most standard update handler will simply copy a file to a device. This can be shared across several users, so add a standard handler for this operation. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* bbu: make bbu confirm a bit more verboseLucas Stach2015-03-041-1/+3
| | | | | | | It is a lot more user friendly if we give a bit more feedback. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* barebox update: fix finding default handlerSascha Hauer2012-12-031-5/+8
| | | | | | | It was not possible to register another handler when already a default handler is registered. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Add in-system barebox update infrastructureSascha Hauer2012-10-171-0/+150
Currently in-system update means to write an arbitrary file to an arbitrary device. There is no sanity check if the flashed image is of the right type or will fit onto the device. Furthermore some SoCs need a special preparation step for their images before flashing them. This adds a barebox in-system update infrastructure. Boards can register update handlers which know how to make the board bootable. The available handlers can be listed to be able to select one, different force levels give the user the chance to know it better. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>