aboutsummaryrefslogtreecommitdiff
path: root/common
AgeCommit message (Collapse)AuthorFilesLines
2021-07-23test: add first autoboot unit testsSteffen Jaeckel2-1/+6
This adds tests for the crypt-based and plain SHA256-based password hashing algorithms in the autoboot flow. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-23common: add support to fallback to plain SHA256Steffen Jaeckel2-1/+29
In case crypt-based hashing is enabled this will be the default mechanism that is used. If a user wants to have support for both, the environment variable `bootstopusesha256` can be set to `true` to allow plain SHA256 based hashing of the password. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-23common: add AUTOBOOT_FLUSH_STDIN optionSteffen Jaeckel2-0/+20
The key-sequence based unlock mechanisms are sensitive to junk symbols that could have been sent to stdin and are still waiting to be retrieved. Enabling this option will read all symbols off stdin before displaying the autoboot prompt (and starting to read the password from stdin). Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-23common: allow disabling of timeout for password entrySteffen Jaeckel2-1/+19
In case a user has to enter a complicated password it is sometimes desireable to give the user more time than the default timeout. Enabling this feature will disable the timeout entirely in case the user presses the <Enter> key before entering any other character. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-23common: Rename macro appropriatelySteffen Jaeckel1-8/+8
While doing code-review internally this got nitpicked by 2 reviewers, so I decided to include this here. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
2021-07-23common: integrate crypt-based passwordsSteffen Jaeckel2-14/+105
Hook into the autoboot flow as an alternative to the existing mechanisms. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
2021-07-23Kconfig.boot: Make 0x0 the default SYS_TEXT_BASE for POSITION_INDEPENDENTTom Rini1-0/+1
When we build U-Boot with POSITION_INDEPENDENT we must have SYS_TEXT_BASE be set to zero. Make this the default in that case. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Mark Kettenis <kettenis@openbsd.org>
2021-07-23fit: Allow external data for FDTsJohn Keeping1-1/+2
Switch to fit_image_get_data_and_size() for consistency with all other data loaded from FIT. Signed-off-by: John Keeping <john@metanate.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-23spl: use CONFIG_IS_ENABLED(LOAD_FIT_FULL)John Keeping1-2/+2
It's possible that LOAD_FIT_FULL will have different values for TPL and SPL, in which case just checking CONFIG_SPL_LOAD_FIT_FULL causes this to be compiled in to the TPL even though functions and struct members it depends on are not. Use CONFIG_IS_ENABLED() to ensure the correct TPL/SPL variant is checked. Signed-off-by: John Keeping <john@metanate.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-21log: Allow padding of the function nameSimon Glass2-1/+9
At present when function names are logged, the output is a little hard to read since every function is a different length. Add a way to pad the names so that the log messages line up vertically. This doesn't work if the function name is very long, but it makes a big difference in most cases. Use 20 characters as a default since this covers the vast majority of functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21spl: Provide more information on boot failureSimon Glass2-16/+42
If SPL fails to boot, try to provide an error code to indicate what is wrong. For example, if a uclass is missing, this can return -EPFNOSUPPORT (-96) which provides useful information. Add a helper for accessing the image-loader name so we can drop the use of #ifdefs in this code. Put this feature behind a CONFIG_SHOW_ERRORS option to avoid increasing the code size. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21image: Allow @ in node names when not using signaturesSimon Glass1-1/+1
If signature verification is not in use we don't need to worry about the risk of using @ in node names. Update fit_image_verify() to allow it if the function is not enabled. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21bloblist: Correct condition in bloblist_addrec()Simon Glass1-1/+1
It is possible to add a blob that ends at the end of the bloblist, but at present this is not supported. Fix it and add a regression test for this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21bloblist: Support resizing a blobSimon Glass1-2/+69
Sometimes a blob needs to expand, e.g. because it needs to hold more log data. Add support for this. Note that the bloblist must have sufficient spare space for this to work. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21sandbox: Adjust the bloblist default addressSimon Glass1-1/+1
Move this down to provide more space for the bloblist. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-17Merge branch '2021-07-16-cleanup-image-support'Tom Rini4-76/+32
- A large rework of the logic around supporting various image types/formats and sharing between the host and target.
2021-07-17Merge tag 'u-boot-imx-20210717' of ↵WIP/17Jul2021Tom Rini1-13/+24
https://gitlab.denx.de/u-boot/custodians/u-boot-imx i.MX ---- - mx7ulp : fix WDOG - imx8 : Phytec - USB3 support for i.MX8 CI: https://source.denx.de/u-boot/custodians/u-boot-imx/-/pipelines/8277
2021-07-16image: Add support for relocating crypto_algos in linker listsAlexandru Gagniuc1-0/+13
Function pointers from crypto_algos array are relocated, when NEEDS_MANUAL_RELOC is set. This relocation doesn't happen if the algo is placed in a linker list. Implement this relocation. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Michal Simek <michal.simek@xilinx.com>
2021-07-16image: image-sig.c: Remove crypto_algos arrayAlexandru Gagniuc1-21/+0
Crytographic algorithms (currently RSA), are stored in linker lists. The crypto_algos array is unused, so remove it, and any logic associated with it. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-16image: rsa: Move verification algorithm to a linker listAlexandru Gagniuc1-10/+0
Move the RSA verification crytpo_algo structure out of the crypto_algos array, and into a linker list. Although it appears we are adding an #ifdef to rsa-verify.c, the gains outweigh this small inconvenience. This is because rsa_verify() is defined differently based on #ifdefs. This change allows us to have a single definition of rsa_verify(). Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-16image: Add support for placing crypto_algo in linker listsAlexandru Gagniuc1-0/+9
The purpose of this change is to enable crypto algorithms to be placed in linker lists, rather than be declared as a static array. The goal is to remove the crypto_algos array in a subsequent patch. Create a new linker list named "cryptos", and search it when image_get_crypto_algo() is invoked. NOTE that adding support for manual relocation of crypto_algos within linker lists is beyond the scope of this patch. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-16common: image-sig.c: Remove host-specific logic and #ifdefsAlexandru Gagniuc1-37/+2
Remove any ifdefs in image-sig.c that were previously used to differentiate from the host code. Note that all code dedicated to relocating ->sign() and ->add_verify_data)_ can be safely removed, as signing is not supported target-side. NOTE that although it appears we are removing ecdsa256 support, this is intentional. ecdsa_verify() is a no-op on the target, and is currently only used by host code. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-16image: Drop IMAGE_ENABLE_BEST_MATCHSimon Glass1-1/+1
This is not needed with Kconfig, since we can use IS_ENABLED() easily enough. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-16image: Drop IMAGE_ENABLE_SHAxxxSimon Glass1-3/+3
We already have a host Kconfig for these SHA options. Use CONFIG_IS_ENABLED(SHAxxx) directly in the code shared with the host build, so we can drop the unnecessary indirections. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-16image: Drop IMAGE_ENABLE_SHA1Simon Glass1-1/+1
We already have a host Kconfig for SHA1. Use CONFIG_IS_ENABLED(SHA1) directly in the code shared with the host build, so we can drop the unnecessary indirection. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-16Kconfig: Rename SPL_MD5_SUPPORT to SPL_MD5Simon Glass1-1/+1
Drop the _SUPPORT suffix so we can use CONFIG_IS_ENABLED() with this option. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-16Kconfig: Rename SPL_CRC32_SUPPORT to SPL_CRC32Simon Glass1-2/+2
Drop the _SUPPORT suffix so we can use CONFIG_IS_ENABLED() with this option. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-16image: Rename CONFIG_FIT_ENABLE_RSASSA_PSS_SUPPORTSimon Glass2-3/+3
Drop the ENABLE and SUPPORT parts of this, which are redundant. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-16image: Rename SPL_SHAxxx_SUPPORT to SPL_FIT_SHAxxxSimon Glass1-4/+4
These option are named inconsistently with other SPL options, thus making them incompatible with the CONFIG_IS_ENABLED() macro. Rename them. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-16image: Shorten FIT_ENABLE_SHAxxx_SUPPORTSimon Glass1-3/+3
The ENABLE part of this name is redundant, since all boolean Kconfig options serve to enable something. The SUPPORT part is also redundant since Kconfigs can be assumed to enable support for something. Together they just serve to make these options overly long and inconsistent with other options. Rename FIT_ENABLE_SHAxxx_SUPPORT to FIT_SHAxxx Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-15image: android: Automatically detect more compression typesStephan Gerhold1-1/+1
At the moment android_image_get_kcomp() can automatically detect LZ4 compressed kernels and the compression specified in uImages. However, especially on ARM64 Linux is often compressed with GZIP. Attempting to boot an Android image with a GZIP compressed kernel image currently results in a very strange crash, e.g. Starting kernel ... "Synchronous Abort" handler, esr 0x02000000 ... Code: 5555d555 55555d55 555f5555 5d555d55 (00088b1f) Note the 1f8b, which are the "magic" bytes for GZIP images. U-Boot already has the image_decomp_type() function that checks for the magic bytes of bzip2, gzip, lzma and lzo. It's easy to make use of it here to increase the chance that we do the right thing and the user does not become confused with strange crashes. This allows booting Android boot images that contain GZIP-compressed kernel images. Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
2021-07-15fit: Load DTO into temporary buffer and ignore load addressMarek Vasut1-4/+28
The current fitImage DTO implementation expects each fitImage image subnode containing DTO to have 'load' property, pointing somewhere into memory where the DTO will be loaded. The address in the 'load' property must be different then the base DT load address and there must be sufficient amount of space between those two addresses. Selecting and using such hard-coded addresses is fragile, error prone and difficult to port even across devices with the same SoC and different DRAM sizes. The DTO cannot be applied in-place because fdt_overlay_apply_verbose() modifies the DTO when applying it onto the base DT, so if the DTO was used in place within the fitImage, call to fdt_overlay_apply_verbose() would corrupt the fitImage. Instead of copying the DTO to a specific hard-coded load address, allocate a buffer, copy the DTO into that buffer, apply the DTO onto the base DT, and free the buffer. The upside of this approach is that it is no longer necessary to select and hard-code specific DTO load address into the DTO. The slight downside is the new malloc()/free() overhead for each DTO, but that is negligible (*). (*) on iMX8MM/MN and STM32MP1 Signed-off-by: Marek Vasut <marex@denx.de> Cc: Pantelis Antoniou <pantelis.antoniou@konsulko.com> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> [trini: Add <linux/sizes.h>] Signed-off-by: Tom Rini <trini@konsulko.com>
2021-07-14board-info: Call sysinfo_detect() before sysinfo_get_str()Marek Vasut1-2/+6
The sysinfo_get_str() implementation checks whether the sysinfo was even detected. In U-Boot proper, sysinfo_detect() is not called anywhere but on one specific board. Call sysinfo_detect() before sysinfo_get_str() to make sure the sysinfo is detected and sysinfo_get_str() returns valid value instead of -EPERM. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-14board-info: Use sysinfo_get()Marek Vasut1-1/+1
Replace uclass_first_device_err(UCLASS_SYSINFO, &dev) with sysinfo_get(&dev). The board_info code may use sysinfo to print board information, so use the sysinfo functions consistently. The sysinfo_get() is internally implemented as return uclass_first_device_err(UCLASS_SYSINFO, &dev) anyway, so there is no functional change. Signed-off-by: Marek Vasut <marek.vasut+renesas@gmail.com> Cc: Marcel Ziswiler <marcel.ziswiler@toradex.com> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-10spl: mmc: Factor out eMMC boot partition selection codeMarek Vasut1-13/+24
Factor out eMMC boot partition selection code into default_spl_mmc_emmc_boot_partition() function and implement weak spl_mmc_emmc_boot_partition(), so that architecture or board code can override the eMMC boot partition selection. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Faiz Abbas <faiz_abbas@ti.com> Cc: Harald Seiler <hws@denx.de> Cc: Lokesh Vutla <lokeshvutla@ti.com> Cc: Simon Glass <sjg@chromium.org> Cc: Fabio Estevam <festevam@gmail.com> Cc: Peng Fan <peng.fan@nxp.com> Cc: Stefano Babic <sbabic@denx.de> Cc: Ye Li <ye.li@nxp.com> Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
2021-07-07Merge tag 'dm-pull-6jul21' of https://source.denx.de/u-boot/custodians/u-boot-dmWIP/07Jul2021Tom Rini1-1/+3
various minor sandbox improvements
2021-07-07bootstage: Eliminate when not enabledTom Rini2-0/+4
When we do not have bootstage enabled, rather than include an empty dummy function, we just don't reference it. This saves us space in some tight builds. This also shows a few cases where show_boot_progress was incorrectly guarded before. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-07-06sandbox: don't refer to symbol _initHeinrich Schuchardt1-1/+3
GCC provides a symbol _init in crti.o on x86_64 and aarch64 but not on RISC-V. The following lines leads to a build error for sandbox_defconfig on RISC-V due to the missing symbol: common/board_f.c:269: #elif defined(CONFIG_SANDBOX) || defined(CONFIG_EFI_APP) gd->mon_len = (ulong)&_end - (ulong)_init; The sandbox code is not copied into the memory allocated using mmap(). Hence we can safely use gd->mon_len = 0 to avoid the reference to _init. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Rick Chen <rick@andestech.com>
2021-07-05Merge branch 'next'Tom Rini6-16/+66
2021-07-02autoboot: fix MENUKEYDa Xue1-1/+1
replace CONFIG_AUTOBOOT_USE_MENUKEY with CONFIG_AUTOBOOT_MENUKEY Signed-off-by: Da Xue <da@libre.computer>
2021-07-01Merge tag 'xilinx-for-v2021.10' of ↵WIP/01Jul2021-nextTom Rini2-2/+5
https://source.denx.de/u-boot/custodians/u-boot-microblaze into next Xilinx changes for v2021.10 clk: - Add driver for Xilinx Clocking Wizard IP fdt: - Also record architecture in /fit-images net: - Fix plat/priv data handling in axi emac - Add support for 10G/25G speeds pca953x: - Add missing dependency on i2c serial: - Fix dependencies for DEBUG uart for pl010/pl011 - Add setconfig option for cadence serial driver watchdog: - Add cadence wdt expire now function zynq: - Update DT bindings to reflect the latest state and descriptions zynqmp: - Update DT bindings to reflect the latest state and descriptions - SPL: Add support for ECC DRAM initialization - Fix R5 core 1 handling logic - Enable firmware driver for mini configurations - Enable secure boot, regulators, wdt - Add support xck devices and 67dr - Add psu init for sm/smk-k26 SOMs - Add handling for MMC seq number via mmc_get_env_dev() - Handle reserved memory locations - Add support for u-boot.itb generation for secure OS - Handle BL32 handoffs for secure OS - Add support for 64bit addresses for u-boot.its generation - Change eeprom handling via nvmem aliases
2021-06-28Merge tag 'v2021.07-rc5' into nextTom Rini2-4/+14
Prepare v2021.07-rc5 # gpg: Signature made Mon 28 Jun 2021 03:39:36 PM EDT # gpg: using RSA key 1A3C7F70E08FAB1707809BBF147C39FF9634B72C # gpg: Good signature from "Thomas Rini <trini@konsulko.com>" [ultimate] # Conflicts: # configs/am64x_evm_r5_defconfig
2021-06-23malloc: add SPDX license identifiersHeinrich Schuchardt1-0/+10
The original code is in the public domain. Licenses/README states that the general license for U-Boot is GPL 2.0+. So we can mark the malloc code as GPL 2.0+ too. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-23spl: fit: Also record architecture in /fit-imagesMichal Simek2-2/+5
On ARM64 secure OS can run as 64bit or 32bit that's why it is necessary to record information about architecture that other code can read it and properly pass it to TF-A and start in 64bit or 32bit mode. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-22autoboot: fix typos of CONFIG_AUTOBOOT_USE_MENUKEYDa Xue1-4/+4
Replace typo CONFIG_USE_AUTOBOOT_MENUKEY with CONFIG_AUTOBOOT_USE_MENUKEY as when they were introduced initially there was some mismatch in which name was used where. Fixes: 8fc31e23aa83 ("autoboot: Rename CONFIG_MENUKEY to CONFIG_AUTOBOOT_MENUKEY") Signed-off-by: Da Xue <da@libre.computer>
2021-06-11common: fit: Update board_fit_image_post_process() to pass fit and node_offsetLokesh Vutla2-2/+2
board_fit_image_post_process() passes only start and size of the image, but type of the image is not passed. So pass fit and node_offset, to derive information about image to be processed. Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com> Signed-off-by: Tero Kristo <kristo@kernel.org>
2021-06-08log: Add support for logging a bufferSimon Glass1-0/+30
The print_buffer() function is very useful for debugging. Add a version of this in the log system also. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08console: Report an error when output buffer is exhaustedSimon Glass1-4/+14
If the console output buffer is exhausted, characters are silently dropped from the end. Detect this condition and report an error when reading back the characters. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-07image-fdt: save no-map parameter of reserve-memoryPatrick Delaunay1-8/+15
Save the 'no-map' information present in 'reserved-memory' node to allow correct handling when the MMU is configured in board to avoid speculative access. This binding is defined in doc/device-tree-bindings/reserved-memory/reserved-memory.txt Additional properties: ... no-map (optional) - empty property - Indicates the operating system must not create a virtual mapping of the region as part of its standard mapping of system memory, nor permit speculative access to it under any circumstances other than under the control of the device driver using the region. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-05-31board: sifive: add HiFive Unmatched board supportGreen Wan1-2/+2
Add defconfig and board support for HiFive Unmatched. Signed-off-by: Green Wan <green.wan@sifive.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Rick Chen <rick@andestech.com>