summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2021-08-01sandbox: tpm: Split out common nvdata codeSimon Glass4-105/+172
We want to support nvdata in TPM2 as well. To avoid code duplicating the associated code, move it into a common file. Drop the special-case logic for the kernel space. This can be handled by the higher-level code now, i.e. in vboot itself. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-08-01common: board_r: print error if binman_init failsTim Harvey1-1/+7
Display an error if binman_init fails. Signed-off-by: Tim Harvey <tharvey@gateworks.com>
2021-08-01Merge https://source.denx.de/u-boot/custodians/u-boot-sunxiTom Rini5-4/+38
- Move the PSCI runtime code for H3/A23/A33 into SRAM - Pick the environment from the actual MMC boot device (SD card vs. eMMC) - Plus a small improvement from Icenowy, just for good measure.
2021-08-01sunxi: decide the inclusion of SCP by SCP_ADDR existenceIcenowy Zheng1-2/+2
There are more Allwinner SoCs that do not have a SCP now. When there's no SCP_ADDR macro defined, we can assume there's no SCP available. Drop the scp part of FIT description when SCP_ADDR does not exist. Signed-off-by: Icenowy Zheng <icenowy@sipeed.com> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2021-08-01sunxi: A23/A33/H3: Move sun8i secure monitor to SRAM A2Samuel Holland2-0/+21
So far for the H3, A23, and A33 SoCs, we use DRAM to hold the secure monitor code (providing PSCI runtime services). And while those SoCs do not have the secure SRAM B like older SoCs, there is enough (secure) SRAM A2 to put the monitor code and data in there instead. Follow the design of 64-bit SoCs and use the first part for the monitor, and the last 16 KiB for the SCP firmware. With this change, the monitor no longer needs to reserve a region in DRAM. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Andre Przywara <andre.przywara@arm.com> [Andre: amend commit message, fix R40 and V3s build] Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2021-08-01sunxi: Select environment MMC based on boot deviceSamuel Holland2-2/+15
Currently, the environment is always stored in eMMC if eMMC is enabled in the config. This means images written to SD and eMMC will cross- contaminate their environments unless the configuration is changed. By dropping the device number from the environment location string and implementing mmc_get_env_dev, we will always use the environment from the boot device when booting from SD/eMMC. Signed-off-by: Samuel Holland <samuel@sholland.org> Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
2021-07-31Merge https://source.denx.de/u-boot/custodians/u-boot-marvellTom Rini49-336/+730
- kwboot / kwbimage improvements reducing image size (Pali & Marek) - a37xx: pinctrl: Correct PWM pins definitions (Marek) - Convert the Dreamplug Ethernet and SATA to Driver Model (Tony) - serial: a37xx: DEBUG_UART improvements / fixes (Pali)
2021-07-31serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()Pali Rohár1-1/+3
Static inline function _debug_uart_init() should avoid calling external (non-inline) functions. Therefore do not call get_ref_clk() in _debug_uart_init() and reimplement its functionality without external function calls. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31serial: a37xx: Use CONFIG_BAUDRATE for initializing early debug UARTPali Rohár1-3/+2
CONFIG_BAUDRATE should be used for setting the baudrate for the early debug UART. This replaces current hardcoded 115200 value. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behun <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm: kirkwood: Dreamplug: Add DM SATA and remove IDE configsTony Dinh1-2/+10
- Enable DM SATA, removed IDE driver, and add SATA MV driver. - Use ethernet PHY names from device tree in default boot command Signed-off-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm: kirkwood: Dreamplug: Use Ethernet PHY name and address from device treeTony Dinh1-14/+48
In DM Ethernet, the old "egiga0" and 'egiga1" names are no longer valid, so replace these with Ethernet PHY names from device tree. Also, read Ethernet PHY address for each port from device tree. Signed-off-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm: kirkwood: Dreamplug: Add DM Ethernet and DM SATA configsTony Dinh1-0/+4
Add DM_ETH, SATA_MV and associated configs to dreamplug_defconfig Signed-off-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm64: a37xx: pinctrl: Correct PWM pins definitionsMarek Behún2-13/+12
The PWM pins on North Bridge on Armada 37xx can be configured into PWM or GPIO functions. When in PWM function, each pin can also be configured to drive low on 0 and tri-state on 1 (LED mode). The current definitions handle this by declaring two pin groups for each pin: - group "pwmN" with functions "pwm" and "gpio" - group "ledN_od" ("od" for open drain) with functions "led" and "gpio" This is semantically incorrect. The correct definition for each pin should be one group with three functions: "pwm", "led" and "gpio". Change the "pwmN" groups to support "led" function. Remove "ledN_od" groups. This cannot break backwards compatibility with older device trees: no device tree uses it since there is no PWM driver for this SOC yet. Also "ledN_od" groups are not even documented. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31kwbimage: Update help message about how to extract from an existing imagePali Rohár1-1/+1
Extracting is now supported by dumpimage, so mention it in help instead of `kwbimage -x`. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31kwbimage: Add support for extracting images via dumpimage toolPali Rohár1-8/+64
The kwbimage library does not support extracting subimages. Implement it. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm: mvebu: gdsys: Remove custom spl_board_init()Pali Rohár3-22/+1
The gdsys a38x config file (controlcenterdc_defconfig) uses BootROM to load U-Boot proper. Since it is now possible to do this via U-Boot SPL framework, we do not need to provide custom spl_board_init() which calls return_to_bootrom(). Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm: mvebu: Remove unused macro CONFIG_SYS_U_BOOT_OFFSPali Rohár12-51/+2
Macro CONFIG_SYS_U_BOOT_OFFS is set but not used anymore. Remove it. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31tools: kwbimage: Remove v1 kwbimage SPL padding to CONFIG_SYS_U_BOOT_OFFS bytesPali Rohár2-17/+0
This padding depends on board config file and therefore it makes the mkimage binary tool board specific, which is not correct. One cannot use mkimage tool built as a result for board A to generate images for board B, even if both A and B are on the same platform. This CONFIG_SYS_U_BOOT_OFFS padding was needed when kwbimage v1 contained SPL code which loaded U-Boot proper based on CONFIG_SYS_U_BOOT_OFFS, instead of reading correct offset from kwbimage header. Now that SPL code parses kwbimage header and deterinate correct offset, there is no need for this CONFIG_SYS_U_BOOT_OFFS padding anymore. By removing it we also reduce the size of SPL code and therefore also decrease the final size of v1 kwbimage. This means there is more space for U-Boot proper binary. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm: mvebu: Remove legacy U-Boot header from kwbimage v1 filesPali Rohár1-2/+2
The SPL code now already parses kwbimage v1 headers where all necessary information about how to load and execute U-Boot proper is present. The legacy 64-byte U-Boot header is not used anymore. Remove this 64-byte header by putting u-boot.bin binary (instead of u-boot.img) into kwbimage v1 and let SPL code or BootROM to load U-Boot directly at its execution address. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage headerPali Rohár28-69/+224
Now that proper load and execution addresses are set in v1 kwbimage we can use it for loading and booting U-Boot proper. Use the new spl_parse_board_header() function to implement parsing the kwbimage v1 header. Use information from this header to locate offset and size of the U-Boot proper binary, instead of using the legacy U-Boot header which is prepended to the U-Boot proper binary stored at fixed offset. This has the advantage that we do not need to relay on legacy U-Boot header anymore and therefore U-Boot proper binary can be stored at any offset, as is the case when loading & booting U-Boot proper by BootROM. The CONFIG_SYS_U_BOOT_OFFS option is therefore not used by SPL code anymore. Also allow to compile U-Boot SPL without CONFIG_SPL_SPI_FLASH_SUPPORT, CONFIG_SPL_MMC_SUPPORT or CONFIG_SPL_SATA_SUPPORT set. In this case BootROM is used for loading and executing U-Boot proper. This reduces the size of U-Boot's SPL image. By default these config options are enabled and so BootROM loading is not used. In some cases BootROM reads from SPI NOR at lower speed than U-Boot SPL. So people can decide whether they want to have smaller SPL binary at the cost of slower boot. Therefore dependency on CONFIG_SPL_DM_SPI, CONFIG_SPL_SPI_FLASH_SUPPORT, CONFIG_SPL_SPI_LOAD, CONFIG_SPL_SPI_SUPPORT, CONFIG_SPL_DM_GPIO, CONFIG_SPL_DM_MMC, CONFIG_SPL_GPIO_SUPPORT, CONFIG_SPL_LIBDISK_SUPPORT, CONFIG_SPL_MMC_SUPPORT, CONFIG_SPL_SATA_SUPPORT and CONFIG_SPL_LIBDISK_SUPPORT is changed from strict to related "imply" (which can be selectivelly turned off and causes booting via BootROM). Options CONFIG_SYS_SPI_U_BOOT_OFFS, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR and CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_DATA_PART_OFFSET have to to be set to zero as they define the location where kwbimage header starts. It is the location where BootROM expects start of the kwbimage from which it reads, parses and executes SPL part. The same applies to option CONFIG_SPL_SATA_RAW_U_BOOT_SECTOR, which has to be set to one. Update all config files to set correct values of these options and set CONFIG_SYS_U_BOOT_OFFS to the correct value - the offset where U-Boot proper starts. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31SPL: Add support for parsing board / BootROM specific image typesPali Rohár1-0/+9
Platform specific BootROM may use its own image type for loading SPL or U-Boot proper. In some cases it makes sense to not use BootROM supplied code for booting U-Boot proper but rather to use U-Boot SPL for this, e.g. when U-Boot SPL can load U-Boot proper faster than BootROM. In this case it is required for platform board code to parse and load U-Boot in BootROM specific image type. This change adds support for parsing platform / board / BootROM specific image types via weak function spl_parse_board_header() which is called before marking boot image as a raw. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31SPL: Add support for specifying offset between header and imagePali Rohár4-3/+28
Some image types (e.g. kwbimage v1) store the offset to SPL binary and offset to U-Boot proper binary in their headers. To avoid reading SPL binary when loading U-Boot proper, add support for specifying offset in struct spl_image_info, which defines the offset from the beginning of the header and the beginning of the executable data. Initial support is added only for SPI, MMC and SATA code. We can extend it later if needed. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31arm: mvebu: Use U-Boot's SPL BootROM framework for booting from NAND/UARTPali Rohár1-23/+24
Current code uses hack in board_init_f() which calls return_to_bootrom() to skip U-Boot SPL code and return back to BootROM to load U-Boot via UART or from NAND. This change migrates that hack from the board_init_f() function and changes it to return BOOT_DEVICE_BOOTROM instead of returning to BootROM directly, so that U-Boot's SPL framework is used for returning to BootROM. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31arm: mvebu: Implement return_to_bootrom() via U-Boot's SPL frameworkPali Rohár2-0/+16
U-Boot's SPL framework already has an API for loading U-Boot via BootROM. Implement the function board_return_to_bootrom() for mvebu SPL code. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31arm: mvebu: Mark return_to_bootrom() as a noreturn functionPali Rohár1-1/+1
This function does not return, so add the appropriate compiler flag. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31arm: mvebu: Fix return_to_bootrom()Pali Rohár1-1/+2
Register r0 should be set to return value 0x0 - NO_ERR. Set r0 with return value after all registers are restored from the stack, so that the return value is always correct. Signed-off-by: Pali Rohár <pali@kernel.org> Fixes: 944c7a317675 ("arm: mvebu: Add option to use UART xmodem protocol via kwboot") Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwboot: Fix checking image header versionPali Rohár1-1/+1
Function image_version() returns unsigned value, so it can never be negative. Explicitly check for two supported image versions: v0 and v1. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31tools: kwboot: Check for v1 header sizePali Rohár1-0/+5
Too small invalid headers may cause kwboot to crash. Check for header size of v1 images. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwboot: Cosmetic fix - add missing curly bracketsPali Rohár1-1/+2
Add missing curly brackets for this else statement. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwboot: Print trailing newline after terminal is terminatedPali Rohár1-0/+1
Print trailing newline as the last printed byte can be something different. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwboot: Fix restoring terminalPali Rohár1-1/+2
Call tcsetattr() only if the file descriptor is valid. It may be invalidated by previous lines (if it is not a tty descriptor). Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwboot: Fix wrong parameter passed to read()Pali Rohár1-1/+1
The 'buf' variable is a pointer and '_buf' is the array itself. Therefore we should pass sizeof(_buf) instead of sizeof(buf) to read(). Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: dumpimage: Show error message when trying to extract data from kwbimagePali Rohár1-0/+5
There is no code for extracting data from kwbimage, so show an error message when user tries this via e.g. dumpimage call: ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31tools: dumpimage: Fix crashing when trying to extract data from kwbimagePali Rohár1-1/+1
Trying to call the following command causes NULL pointer dereference in strlen(): ./tools/dumpimage -T kwbimage -o /tmp/out u-boot-spl.kwb Fix it by checking whether params->imagename is non-NULL before calling strlen(). Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31tools: kwbimage: Mark all BootROM structures __packedPali Rohár2-19/+19
These structures must have specific size without padding, so mark them as packed via the de-facto standard macro __packed. Also replace PACKED macro. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31tools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38XPali Rohár2-26/+0
The mkimage host tool can be used to generate kwbimage v1 image with secure header on host system for A38x plaform also when U-Boot is being compiled for different platform. So there is no reason to not allow compiling of mkimage/kwbimage with secure header support for e.g. x86-64 host. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Add support for a new DATA_DELAY commandPali Rohár1-1/+23
This command is supported only by v1 images and specifies a milliseconds delay after executing some set of DATA commands. The special string value SDRAM_SETUP instructs BootROM to setup SDRAM controller instead of executing delay. SDRAM_SETUP may be specified only once and after the last DATA command. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Add support for DATA command also for v1 imagesPali Rohár2-1/+58
The DATA command is already supported by mkimage for v0 images, but not for v1 images. BootROM code which executes v1 images also supports DATA command via an optional extended v1 header OPT_HDR_V1_REGISTER_TYPE. Implement support for DATA command for v1 images. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Don't parse PAYLOAD keywordPali Rohár1-13/+0
The PAYLOAD keyword does nothing. No code is using it and both mkimage and kwbimage completely ignore it. It looks like a relict from the past. The payload image itself can be specified only via -d parameter to mkimage. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Add support for more BINARY headersPali Rohár1-31/+28
The kwbimage v1 format supports multiple BINARY executable headers. Add support for it into mkimage/kwbimage tool. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Chris Packham <judge.packham@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Fix calculating size of binary headerPali Rohár1-9/+2
Binary header consist of: * 1 byte for header type * 3 bytes for header size * 1 byte for number of arguments * 3 reserved bytes * N*4 bytes for arguments * M bytes (aligned to 4 bytes) for executable data * 1 byte for information about next header * 3 reserved bytes The first four bytes are specified as sizeof(struct opt_hdr_v1) and the remaining bytes as ALIGN(s.st_size, 4) + (binarye->binary.nargs + 2) * sizeof(uint32_t) Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31tools: kwbimage: Change maximum number of arguments in binary header to 256Pali Rohár1-1/+1
The number is stored in one byte, so the maximum should be 255. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de>
2021-07-31tools: kwbimage: Use -a parameter (load address) for v1 imagesPali Rohár2-10/+2
The data part of v1 kwbimage currently contains U-Boot binary prepended by 64 bytes long Legacy U-Boot image header. This means that the load address is currently substracted by 64 bytes to ensure that U-Boot's entry point is at specified execution address. As mkimage has already separate arguments for load (-a) and execution (-e) address, there is no need to derive fixed load address from execution address. Therefore remove this load address hack from the kwbimage tool and support generating v1 kwbimage with arbitrary addresses for load and execution. Finally, calculate correct load address by caller for mkimage tool in Makefile. File u-boot-spl.kwb is always a v1 kwbimage and it is the only v1 kwbimage which U-Boot's build system generates. Remove also useless overwriting of destaddr for /binary.0 to the value which is already set on previous lines. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Cosmetic fix - remove redundant space characterMarek Behún1-1/+1
Remove this space, since the constants are indented by tabs. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Print size of binary header in kwbimage_print_header()Pali Rohár1-0/+24
The binary header in kwbimage contains executable SPL code. Print information about this binary header and not only information about it's data part. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Validate data checksum of v1 imagesPali Rohár1-0/+43
The data part of v1 images contains 32-bit checksum after the data. Validate whether this checksum is correct. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Validate extended headers of v1 imagesPali Rohár1-0/+29
Add basic checks for extended headers of v1 images. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Fix check for v0 extended header checksumPali Rohár1-7/+11
Extended header checksum for v0 image is present only in the case when extended header is present. Skip checksum validation if extended header is not present. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Don't crash when binary file name does not contain '/'Pali Rohár1-1/+1
In the case when the file name is specified relative to the current working directory, it does not contain '/' character and strrchr() returns NULL. The following strcmp() function then crashes on NULL pointer dereference. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>
2021-07-31tools: kwbimage: Fix generation of SATA, SDIO and PCIe imagesPali Rohár1-0/+25
SATA and SDIO images must be aligned to sector size (which in most cases is 512 bytes) and Source Address in main header is stored in number of sectors from the beginning of the drive. SATA image must be stored at sector 1 and SDIO image at sector 0. Source Address for PCIe image is not used and must be set to 0xFFFFFFFF. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Reviewed-by: Chris Packham <judge.packham@gmail.com> Tested-by: Chris Packham <judge.packham@gmail.com>