summaryrefslogtreecommitdiffstats
path: root/common
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/misc'Sascha Hauer2022-08-116-93/+150
|\
| * FIT: add first support for compressed imagesAhmad Fatoum2022-08-111-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FIT image contents are often compressed, but we got by so far, because a compressed initramfs is usually meant to be decompressed by the kernel (and so has compression = "none") and arm32 kernels had their own decompresser embedded. On ARM64, bootloader is responsible for uncompressing kernel, so we should properly process the compression property we so far ignored. The decompression isn't as efficient as one would hope for, because the FIT format only describes length of the compressed data. We thus have two options: - define an output size up-front, e.g. by guessing the uncompressed buffer size for decompression or hardcoding it (e.g. U-Boot's CONFIG_SYS_BOOTM_LEN). - Uncompress to a file descriptor We choose the second one to play it safe, but it comes with worse performance because of extra memory copies. Intention is to go with first option for the kernel image: We know how much size we can spare for the kernel image and can have bootm_load_os uncompress there directly without intermittent memory copies. This would involve slight change to the barebox decompresser API to align it with the kernel's, which allows to have it accept and observe an output buffer size. So far, we had the kernel PREBOOT API, which lacks such a parameter, but that's an optimization for another day. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220809091946.3906847-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * kbuild: make FIT public key overwritableStefano Manni2022-08-091-0/+17
| | | | | | | | | | | | | | | | | | | | | | The path to the public key used to verify FIT images can be specified with Kconfig variable. For a better build system integration we also want to be able to specify the path in environment variables. Signed-off-by: Stefano Manni <stefano.manni@gmail.com> Link: https://lore.barebox.org/02bcbd486b7f41e5dc86bf9d228dcbf6e1fe9957.camel@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * boot: allow booting by bootspec absolute pathAhmad Fatoum2022-08-092-1/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When multiple bootloader spec files are available, the first match in lexical order will be the one to autoboot. Users can customize which one to use interactively via boot -m, but no means to select a different by default exists. Allow for this by having the boot command not only accept a directory to search for bootloader spec entries in, but also the path of a single bootloader spec file. This aligns it with what we have for bootscripts, where both directories containing boot scripts and the path to a specific boot script is understood. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220724184807.2123459-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * blspec: iterate over entries in lexical orderAhmad Fatoum2022-08-091-33/+10
| | | | | | | | | | | | | | | | | | | | We already iterate over boot scripts in lexical order, so it makes sense to do the same for bootspec entries. This way, it's stable which boot entry will be taken, when multiple match. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220724184807.2123459-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * blspec: refactor to prepare for booting by file pathAhmad Fatoum2022-08-091-54/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The blspec boot entry provider currently feeds the path into blspec_scan_directory, which will fail to collect an boot entry when given a regular file. In preparation for allowing to boot a specific blspec file by path, refactor the code pertaining to a single file into a blspec_scan_file function and move parse_nfs_url which applies equally to files and directories into the callsite. There is one other callsite of blspec_scan_directory in blspec_scan_cdev, but that one will never handle NFS paths, so it's fine to skip calling parse_nfs_url there. No functional change intended. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220724184807.2123459-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: boot: support preselecting boot entry in menuAhmad Fatoum2022-08-081-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | boot -m -t 3 already opens a boot menu with a countdown of 3 seconds before selecting the first element. So far, only way to influence preselection was shifting around boot entries, so they are iterated over differently. Add a new -M option that works analogously to -m, but takes an integer index of the boot menu entry to preselect. This allows simple customizable interactive boots: #!/bin/sh boot -M "$nv.bootmenu_default" -t 3 mmc0.0 With mmc0.0 containing multiple bootloader spec files that would be iterated over in lexical order. The index is 1-based like the index displayed in the boot menu. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220726054136.267069-1-ahmad@a3f.at Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * booti: add debug prints for kernel header parsingAhmad Fatoum2022-08-081-0/+7
| | | | | | | | | | | | | | | | | | This proved useful in a debugging session, so make them easily available with a #define DEBUG for future developers. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220808065556.453090-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * commands: of_dump: support limiting size of printed propertiesAhmad Fatoum2022-08-082-2/+2
| | | | | | | | | | | | | | | | | | | | FIT images can have properties with very long values. Make it possible to use of_dump to inspect them by adding a -P option that restricts how much of the value is printed. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220808065639.453483-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * common: bootm: print error in case of appendroot failedMarco Felsch2022-07-051-1/+4
| | | | | | | | | | | | | | | | | | | | Inform the user that appendroot failed instead of silently dropping the request. This makes the debugging easier e.g. if nt-signature wasn't set correctly. Signed-off-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20220704141809.457135-1-m.felsch@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/imx'Sascha Hauer2022-08-111-14/+10
|\ \
| * | pbl: generalize fsl i2c_early API into pbl_i2cAhmad Fatoum2022-08-081-14/+10
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | The prebootloader is inherently board-specific, so it's natural to hardcode the i2c driver used and we only support fsl_i2c at the moment anyway. For abstractions used by different prebootloaders though (e.g. PMIC writing, SPD EEPROM decoding), it would be good for generic code to use a pbl_i2c abstraction, so it can be reused across PBLs using different I2C controllers. Add such an abstraction and use it where appropriate. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20220805125413.1046239-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/efi'Sascha Hauer2022-08-111-0/+1
|\ \
| * | partitions: efi: register guid device parameter for disk GUIDAhmad Fatoum2022-07-051-0/+1
| |/ | | | | | | | | | | | | | | | | | | | | | | | | We already register an nt_signature parameter for MBR partitions. Register an equivalent guid parameter for GPT partitions as well. This is less critical because disk GUID isn't used for root= Linux boot argument computation, as each partition has its own PARTUUID. It's still useful to allow shell scripts to check against it to detect e.g. a factory flash image. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220630124035.4019644-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/compression'Sascha Hauer2022-08-111-14/+9
|\ \
| * | pbl: make USE_COMPRESSED_DTB a PBL-only featureAhmad Fatoum2022-07-141-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All in-tree boards that reference __dtb_z_ symbols are already multi-image capable and allow us to compress barebox proper by having the prebootloader decompress it using the algorithm specified by the CONFIG_IMAGE_COMPRESSION_* option. DTB on the other hand, is handled specially and the optional compression is always using LZO. It makes sense to use the same CONFIG_IMAGE_COMPRESSION_* options for the DT too to make build system integration easier. To avoid special casing non-PBL support which lacks this options, just drop USE_COMPRESSED_DTB there. If linking barebox for your downstream board is broken by this: - If not multi-image capable, consider porting it to use ENTRY_FUNCTION(_WITHSTACK) instead - If you are using __dtb_z_* in barebox proper, use normal __dtb_ and compress barebox as a whole instead with CONFIG_IMAGE_COMPRESSION_* Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220713095730.1878941-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: don't allow compressing in-barebox binaries againAhmad Fatoum2022-07-141-8/+9
| |/ | | | | | | | | | | | | | | | | | | | | For barebox with a prebootloader, we can compress barebox proper as a whole and it makes no sense to compress the environment on its own again. The choice already defaulted to this, but the user could still override it. Ensure that this double compression can't happen. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220713095730.1878941-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootsource: allow DT aliases and bootrom numbering to differAhmad Fatoum2022-08-091-26/+75
| | | | | | | | | | | | | | | | | | | | | | | | So far, we had no explicit mapping table between bootsource_instance and device id numbering in barebox and mostly depended on DT aliases reflecting the numbering of the bootrom. Add a new bootsource_set() that optionally consults a mapping table in the DT to arrive at the correct numbers. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220720055042.3510276-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | bootsource: rename existing bootsource_set to bootsource_set_rawAhmad Fatoum2022-08-091-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patterns like [ "$bootsource" = mmc ] && boot mmc$bootsource_instance expect that ${bootsource_instance} and MMC aliases align, which may not always be the case. In preparation for adding a new bootsource_set function that consults an optional mapping table from bootrom bootsource_instance to board-specific device numbering, rename all existing instances to bootsource_set_raw. While at it, clean up the legacy split into bootsource_set and bootsource_set_instance and have the new bootsource_set_raw accept both arguments at once. No functional change intended. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220720055042.3510276-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: machine_id: guard against digest algo being unavailableAhmad Fatoum2022-08-091-0/+5
| | | | | | | | | | | | | | | | | | | | All callsites of digest_alloc(_by_algo) check for NULL pointer before proceeding except for machine_id_set_globalvar(). Fix this to fail more gracefully instead of the crash I ran into. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220808062010.390394-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: machine_id: simplify early exitAhmad Fatoum2022-08-091-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We don't need the goto if we haven't done anything to clean up anyway. also globalvar_add_simple("machine_id", NULL) is a no-op when we have just called globalvar_add_simple above with an actual argument. It doesn't clean the parameter, nor should it, because the code is executed for the successful code as well and there is nothing that can fail that late. This slightly alters behavior: Whereas before $global.machine_id was always defined when CONFIG_MACHINE_ID is enabled, it's now only defined when it's non-empty. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220808062010.390394-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: don't fixup empty serial/machine_compatible stringsAhmad Fatoum2022-08-081-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no point in fixing up an empty string into the kernel device tree, yet this can happen when globalvar_add_simple_string() is called for the variable at least once as the function replaces NULL with an allocated empty string. globalvar_add_simple_string() was called unconditionally for of.kernel.add_machine_compatible, which in turn led to always fixing up an empty string as the top-most compatible. Resolve this by having barebox_get_(of_machine_compatible|serial_number) return NULL for the empty string as well. Fixes: 81dd24a0946c ("of: add generic of_prepend_machine_compatible()") Fixes: f6756e9ce6f2 ("common: add $global.serial_number with device tree fixup") Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220718114824.2632364-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | USB: gadget: fastboot: allow exporting only barebox update handlerAhmad Fatoum2022-08-081-0/+2
| | | | | | | | | | | | | | | | | | Exporting only the bbu handler and nothing else over fastboot via usbgadget -A '' -b used to work. Restore this. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220730094615.1762042-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | file_list: factor out file_list_newAhmad Fatoum2022-08-081-6/+13
|/ | | | | | | | | | We have the sequence for creating a new file_list at two places and follow-up commit will add a third one outside of the file, so it's a good occasion to use a common helper. No functional change. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220730094615.1762042-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/rpi4'Sascha Hauer2022-06-291-0/+7
|\
| * ARM: rpi: add debug_ll support for Raspberry Pi 4Ahmad Fatoum2022-06-171-0/+7
| | | | | | | | | | | | | | | | | | | | | | The mini uart (Pins 8/10) is the primary UART on the Raspberry Pi 4 and can be set up in firmware by specifying enable_uart=1 in the config.txt. Add a DEBUG_LL implementation to use this for early debugging. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220609055922.667016-20-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2022-06-2912-50/+77
|\ \
| * | state: don't report error for -ENOMEDIUMAhmad Fatoum2022-06-211-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 863a2251393e ("state: make first boot less verbose"), state_load returns -ENOMEDIUM instead of -ENOENT if we detect a first load because all buckets are zero. This case is expected and shouldn't warrant an error message, so adjust callers appropriately. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220620071936.1460295-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | treewide: Use pr_setenv() where appropriateSascha Hauer2022-06-212-14/+3
| | | | | | | | | | | | | | | | | | | | | We now have pr_setenv() which is a setenv() variant that takes a format string. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | env: Introduce pr_setenv()Sascha Hauer2022-06-211-2/+30
| | | | | | | | | | | | | | | | | | | | | | | | It's a common pattern to (ba)sprintf to a string and then call setenv() with this string. Introduce pr_setenv() as a shortcut to simplify this pattern. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | bootchooser: rename pr_setenv() to bc_setenv()Sascha Hauer2022-06-201-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | We are about to introduce a generic function names pr_setenv(), so rename the existent bootchooser specific function to bc_setenv(). For consistency, rename pr_getenv() accordingly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | fastboot: always try barebox_update handler for bbu- partitionsAhmad Fatoum2022-06-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, fastboot barebox_update code was only entered when filetype_is_barebox_image() returned true, a function exclusively used for fastboot. Align this with normal barebox_update from the command line by leaving the decision on whether the image is correctly to the barebox_update handler if the user explicitly targets a bbu- fastboot partition. We keep the old check OR-ed to maintain backwards-compatibility for invoking barebox_update for non bbu- fastboot partitions. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220609130936.3616309-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | of: request reserved memory regions so other code can'tAhmad Fatoum2022-06-151-3/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new of_reserved_mem_walk that can be used to request reserved memory regions. This avoids e.g. bootm trying to place the kernel into a reserved region. Signed-off-by: Rouven Czerwinski <r.czerwinski@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220609111810.2454588-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | read_file: Pass NULL for the size parameter if the return value is not usedAlexander Shiyan2022-06-101-2/+1
| | | | | | | | | | | | | | | | | | Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220609072629.15723-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: add help text for CONFIG_STATEAhmad Fatoum2022-06-101-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | While we have extensive documentation for state, some sentences in the kconfig are a good thing. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220609060923.670163-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | common: reset_source: Remove of_get_reset_source_priority()Alexander Shiyan2022-06-101-17/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | of_get_reset_source_priority() has no users, so it can be safely removed. Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220608051244.2318-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | treewide: Remove duplicate incudesAlexander Shiyan2022-06-103-4/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix warning fwterated by checkincludes.pl: ./net/nfs.c: libgen.h is included more than once. ./net/ifup.c: globalvar.h is included more than once. ./crypto/rsa.c: asm/types.h is included more than once. ./lib/decompress_unlz4.c: linux/decompress/mm.h is included more than once. ./scripts/stb_image.h: stdio.h is included more than once. ./scripts/kwbimage.c: unistd.h is included more than once. ./scripts/common.c: sys/types.h is included more than once. ./scripts/bareboximd.c: sys/types.h is included more than once. ./scripts/bareboximd.c: sys/mman.h is included more than once. ./fs/pstore/ram_core.c: linux/rslib.h is included more than once. ./fs/pstore/fs.c: fs.h is included more than once. ./fs/pstore/fs.c: linux/pstore.h is included more than once. ./fs/nfs.c: fs.h is included more than once. ./fs/uimagefs.c: fs.h is included more than once. ./fs/fs.c: command.h is included more than once. ./arch/sandbox/board/hostfile.c: linux/err.h is included more than once. ./arch/sandbox/board/devices.c: mach/linux.h is included more than once. ./arch/sandbox/os/common.c: signal.h is included more than once. ./arch/arm/boards/zii-imx51-rdu1/board.c: envfs.h is included more than once. ./arch/arm/boards/imx233-olinuxino/imx23-olinuxino.c: generated/mach-types.h is ./arch/arm/mach-stm32mp/ddrctrl.c: mach/stm32.h is included more than once. ./arch/arm/mach-imx/cpu_init.c: common.h is included more than once. ./arch/arm/mach-imx/imx8m.c: mach/imx8m-ccm-regs.h is included more than once. ./common/efi/payload/init.c: efi.h is included more than once. ./common/state/backend_format_raw.c: common.h is included more than once. ./common/state/backend_format_raw.c: crc.h is included more than once. ./common/hush.c: libbb.h is included more than once. ./drivers/spi/atmel-quadspi.c: linux/clk.h is included more than once. ./drivers/spi/atmel-quadspi.c: linux/err.h is included more than once. ./drivers/net/virtio.c: net.h is included more than once. ./drivers/net/phy/phy.c: linux/phy.h is included more than once. ./drivers/net/cpsw.c: net.h is included more than once. ./drivers/virtio/virtio_pci_common.h: linux/list.h is included more than once. ./drivers/usb/host/ohci-hcd.c: dma.h is included more than once. ./drivers/usb/gadget/fsl_udc.c: dma.h is included more than once. ./drivers/nvmem/eeprom_93xx46.c: spi/spi.h is included more than once. ./drivers/nvmem/eeprom_93xx46.c: of.h is included more than once. ./drivers/video/imx-ipu-v3/imx-ldb.c: linux/clk.h is included more than once. ./drivers/video/imx-ipu-v3/imx-hdmi.c: linux/clk.h is included more than once. ./drivers/video/omap.c: common.h is included more than once. ./drivers/mtd/nand/nand_s3c24xx.c: asm/sections.h is included more than once. ./drivers/clk/imx/clk-imx6sx.c: linux/clk.h is included more than once. ./drivers/clk/imx/clk-imx6sl.c: linux/clk.h is included more than once. ./commands/bootm.c: of.h is included more than once. Signed-off-by: Alexander Shiyan <eagle.alexander923@gmail.com> Link: https://lore.barebox.org/20220607051957.2497-1-eagle.alexander923@gmail.com Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * | block: set S_IFBLK for block devices instead of S_IFCHRAhmad Fatoum2022-06-101-0/+8
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In barebox, block devices are a special case of character devices. Nevertheless, differentiation can be useful to allow scripts iterating over all block devices without accounting for naming, e.g. for dev in /dev/*; do test -b $dev && echo $dev: blockdevice done Add the necessary support. This will break scripts that assume test -c blockdevice to be true, but that's a quite improbable check. Tested-by: Jules Maselbas <jmaselbas@kalray.eu> Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Link: https://lore.barebox.org/20220602195916.9061-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/earlycon'Sascha Hauer2022-06-292-0/+41
|\ \
| * | console: add new $global.bootm.earlycon parameterAhmad Fatoum2022-06-092-0/+41
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox already fixes up a suitable console= parameter if it can determine one into the kernel command line. This doesn't help with early Linux issues, which can instead be debugged by the earlycon mechanism. For earlycon to work, the kernel DT must have a stdout-path or the user needs to explicitly specify what driver to use and how to access it (base address, optionally access_type). Make this easier by just having barebox fix up the needed information when $global.bootm.earlycon is true and the barebox serial driver provides the needed information. If the serial driver doesn't, a plain "earlycon" parameter will be fixed up. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220523092526.791716-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | ARM64/RISC-V: booti: support global.bootm.image.loadaddrAhmad Fatoum2022-06-091-6/+24
| | | | | | | | | | | | | | | | | | | | So far $global.bootm.image.loadaddr was ignored. Fix this, so user code may explicitly decide placement if needed. barebox will still sanity check the address and align it if necessary, but won't go below it. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220603072612.1580380-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | fastboot: support TF-A FSBL and FIP images for barebox updateAhmad Fatoum2022-06-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Newly added stm32mp_bbu_mmc_fip_register() accepts two kinds of barebox images: A FIP image containing barebox as well as a FIP image preceded by TF-A as a STM32 FSBL image. Inform filetype_is_barebox_image of these file types, so the handler can be invoked via fastboot when global.fastboot.bbu=1. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-8-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | filetype: differentiate between STM32MP FSBL and SSBL imagesAhmad Fatoum2022-06-031-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We have some special handling for legacy (non-FIP) STM32 images: We have a bootm handler for chainloading and an update handler for use with GPT ssbl partitions. Both aren't applicable to the TF-A image used as FSBL. As barebox always has 0x00000000 at offset 0xfc and TF-A alrways has 0x10000000, we can use that to differentiate between the two images to make sure we refuse TF-A images when barebox images are expected. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220602090133.3190450-6-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>
* tlsf: fix internal overflow trying to allocate big buffersAhmad Fatoum2022-05-241-3/+16
| | | | | | | | | | | | | | | | The function adjust_request_size() has an unhandled failure mode: If aligning a buffer up overflows SIZE_MAX, it will compute a way to short buffer instead of propagating an error. Fix this by returning 0 in this case and checking for 0 whereever the function is called. 0 is a safe choice for an error code, because the function returns at least block_size_min on success and 0 was already an error code (that was just never handled). Reported-by: Jonas Martin <j.martin@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220523062756.774153-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/rsa'Sascha Hauer2022-05-191-30/+21
|\
| * fit: try other keys as fallbackSascha Hauer2022-05-041-14/+22
| | | | | | | | | | | | | | | | | | So far the rsa key and the image signature must have a matching key-name-hint. Relax that by trying other available keys when the key-name-hints don't match or when the matching key can't verify the signature. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>