summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)Author
2021-10-01tools: kwbimage: Update comments describing kwbimage v1 structuresPali Rohár
These structures are relevant for several other platforms, mention them all. Signed-off-by: Pali Rohár <[email protected]> Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwbimage: Refactor kwbimage header size determinationMarek Behún
Add functions kwbheader_size() and kwbheader_size_for_csum(). Refactor code determining header size to use these functions. Refactor header checksum determining function. Remove stuff that is not needed anymore. This simplifies the code a little and fixes one instance of validating header size meant for checksum instead of whole header size. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwbimage: Refactor image_version()Marek Behún
Rename this function to kwbimage_version() and don't cast argument if not needed. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Patch destination address to DDR area for SPI imagePali Rohár
SPI/NOR kwbimage may have destination address set to 0xFFFFFFFF, which means that the image is not downloaded to DDR but rather it is executed directly from SPI/NOR. In this case execution address is set to SPI/NOR area. When patching image to UART type, change destination and execution addresses from SPI/NOR XIP area to DDR area 0x00800000 (which is default for A38x). Signed-off-by: Pali Rohár <[email protected]> [ refactored ] Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Patch source address in image headerPali Rohár
Some image types have source address in non-bytes unit; for example for SATA images, it is in 512 B units. We need to multiply by unit size when patching image type to UART. Signed-off-by: Pali Rohár <[email protected]> [ refactored ] Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Don't patch image header if signedPali Rohár
It is not possible to modify image with secure header due to cryptographic signature. Signed-off-by: Pali Rohár <[email protected]> [ refactored ] Signed-off-by: Marek Behún <[email protected]>
2021-10-01tools: kwbimage: Simplify iteration over version 1 optional headersMarek Behún
Create macro for_each_opt_hdr_v1 and functions opt_hdr_v1_size(), opt_hdr_v1_valid_size(), opt_hdr_v1_ext(), opt_hdr_v1_first() and opt_hdr_v1_next() to simplify iteration over version 1 optional headers. This prevents ugly code repetition and makes it nicer to read. Signed-off-by: Marek Behún <[email protected]>
2021-10-01tools: kwboot: Always call kwboot_img_patch_hdr()Pali Rohár
The kwboot_img_patch_hdr() function already decides if header patching is needed. Always call this function and deprecate the unneeded command line option `-p`. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Properly finish xmodem transferPali Rohár
After kwboot sends EOT, BootROM sends back ACK. Add code for handling this and retry sending EOT on error. Signed-off-by: Pali Rohár <[email protected]> [ refactored ] Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Prevent waiting indefinitely if no xmodem reply is receivedMarek Behún
Currently if BootROM fails to respond with ACK/NAK to a xmodem block, we will be waiting indefinitely for such response. Make sure that we only wait at most 1 second (blk_rsp_timeo) for ACK/NAK for each block in case non-xmodem text output is not being expected. Interpret this timeout expiration as NAK, to try to send the block again. On the other hand, if timeout expires without ACK while some non-xmodem output was already received (DDR training output, for example), we know that the block was received, since the code is being executed, so in this case exit with ETIMEDOUT. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Allow greater timeout when executing header codeMarek Behún
When executing header code (which contains U-Boot SPL in most cases), wait 10s after every non-xmodem character received (i.e. printed by U-Boot SPL) before timing out. Sometimes DDR training, which runs in SPL, may be slow. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Print new line after SPL outputMarek Behún
There is no separation between output from the code from binary header (U-Boot SPL in most cases) and subsequent kwboot output. Print '\n' to make distinguishing these two easier. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Allow non-xmodem text output from BootROM only in a specific casePali Rohár
When sending image header / image data, BootROM does not send any non-xmodem text output. We should therefore interpret unknown bytes in the xmodem protocol as errors and resend current packet. This should improve the transfer in case there are errors on the UART line. Text output from BootROM may only happen after whole image header is sent and before ACK for the last packet of image header is received. In this case BootROM may execute code from the image, which may interact with UART (U-Boot SPL, for example, prints stuff on UART). Print received non-xmodem output from BootROM only in this case. Signed-off-by: Pali Rohár <[email protected]> [ refactored & simplified ] Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Use a function to check whether received byte is a Xmodem replyMarek Behún
This is a non-functional change that should make the code more readable. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Split sending image into header and data stagesPali Rohár
This change is required to implement other features in kwboot. Split sending header and data parts of the image into two stages. Signed-off-by: Pali Rohár <[email protected]> [ refactored ] Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Print newline on error when progress was not completedPali Rohár
When progress was not completed, current terminal position is in progress bar. So print newline before printing error message to make error message more readable. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Fix printing progressPali Rohár
Ensure that `pos` is still in range up to the `width` so printing 100% works also for bigger images. After printing 100% progress reset it to zero, so that next progressbar can be started. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Fix comparison of integers with different sizeMarek Behún
The compiler complains that we are comparing int with size_t when compiled with -W. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Fix return type of kwboot_xm_makeblock() functionPali Rohár
Function kwboot_xm_makeblock() always returns length of xmodem block. It is always non-negative and calculated from variable with size_t type. Set return type of this function to size_t and remove dead code which checks for negative value. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Fix kwboot_xm_sendblock() function when kwboot_tty_recv() failsPali Rohár
When kwboot_tty_recv() fails or times out, it does not set the `c` variable to NAK. The variable is then compared, while it holds either an undefined value or a value from previous iteration. Set `c` to NAK so that the other side will try to resend current block, and remove the now unnecessary break. In other failure cases return immediately. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Print version information headerPali Rohár
Print kwboot's (U-Boot's) version when printing usage. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Refactor and fix writing bufferMarek Behún
There are 3 instances in kwboot.c where we need to write() a given buffer whole (iteratively writing until all data are written), and 2 of those instances are wrong, for they do not increment the buffer pointer. Refactor the code into a new function kwboot_write() where it is fixed. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Make the quit sequence buffer constMarek Behún
This buffer is never written to. Make it const. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwboot: Fix buffer overflow in kwboot_terminal()Marek Behún
The `in` variable is set to -1 in kwboot_terminal() if stdin is not a tty. In this case we should not look whether -1 is set in fd_set, for it can lead to a buffer overflow, which can be reproduced with echo "xyz" | ./tools/kwboot -t /dev/ttyUSB0 Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-10-01tools: kwbimage: Fix printf format warningMarek Behún
On 32-bit ARM the compiler complains: tools/kwbimage.c:547: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ Fix this by using %zu instead of %lu format specifier. Signed-off-by: Marek Behún <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-09-30WS cleanup: remove SPACE(s) followed by TABWolfgang Denk
Signed-off-by: Wolfgang Denk <[email protected]>
2021-09-30WS cleanup: remove trailing white spaceWolfgang Denk
Signed-off-by: Wolfgang Denk <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-09-27Merge tag 'dm-pull-next-27sep21' of ↵Tom Rini
https://source.denx.de/u-boot/custodians/u-boot-dm into next Various of-platdata improvements, including CONFIG_OF_REAL
2021-09-27Merge tag 'v2021.10-rc5' into nextTom Rini
Prepare v2021.10-rc5
2021-09-25irq: Tidy up of-platdata irq supportSimon Glass
This function is available but not exported. More generally it does not really work as intended. Reimplement it and add a sandbox test too. Signed-off-by: Simon Glass <[email protected]>
2021-09-24tools: Handle PAGER containing argumentsPaul Barker
When printing full help output from a tool, we should be able to handle a PAGER variable which includes arguments, e.g. PAGER='less -F'. Signed-off-by: Paul Barker <[email protected]>
2021-09-24tools: Refactor full help printingPaul Barker
Collect the code for printing the full help message of patman, buildman and binman into a single function in patman.tools. Signed-off-by: Paul Barker <[email protected]>
2021-09-18Revert "mkeficapsule: Remove dtb related options"Simon Glass
This reverts commit f86caab058ff062ce72b24cd1ab9ec1253cc1352. Signed-off-by: Simon Glass <[email protected]>
2021-09-16Merge tag 'v2021.10-rc4' into nextTom Rini
Prepare v2021.10-rc4 Signed-off-by: Tom Rini <[email protected]> # gpg: Signature made Tue 14 Sep 2021 06:58:32 PM EDT # gpg: using RSA key 1A3C7F70E08FAB1707809BBF147C39FF9634B72C # gpg: Good signature from "Thomas Rini <[email protected]>" [ultimate] # Conflicts: # board/Arcturus/ucp1020/spl.c # cmd/mvebu/Kconfig # common/Kconfig.boot # common/image-fit.c # configs/UCP1020_defconfig # configs/sifive_unmatched_defconfig # drivers/pci/Kconfig # include/configs/UCP1020.h # include/configs/sifive-unmatched.h # lib/Makefile # scripts/config_whitelist.txt
2021-09-11tools: docker: Build and install genimageBin Meng
genimage [1] is a tool to create flash/disk images. This is required by some targets, e.g.: sifive_unleashed, to generate sdcard or spi-nor images for real hardware, as well as U-Boot CI testing. [1] https://github.com/pengutronix/genimage Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2021-09-11tools: docker: Bump up QEMU version to 6.1.0Bin Meng
At present U-Boot CI testing is still using QEMU 4.2.0 which is pretty old. Let's bump up to QEMU 6.1.0. ninja-build is added as the prerequisite required by QEMU 6.1.0. Note there is a bug in QEMU 6.1.0 Xilinx Zynq UART emulation codes. A quick fix [1] was posted on QEMU mailing list but it it too late for 6.1.0 release. Let's manually apply the bug fix on top of the v6.1.0 release tag at the time being. [1] http://patchwork.ozlabs.org/project/qemu-devel/patch/[email protected]/ Signed-off-by: Bin Meng <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2021-09-11Dockerfile: Update to latest "focal" tagTom Rini
Reviewed-by: Bin Meng <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2021-09-10tools: k3_fit_atf: Fix DM binary FIT load addressesSuman Anna
The DM binary runs on the MCU R5F Core0 after R5 SPL on J721E and J7200 SoCs. The binary is built alongside the TFA, OPTEE and A72 SPL binaries and included in the tispl.bin FIT image. The R5 SPL loads the DM binary at 0xA0000000 address, based on the value used in the FIT image build script. The DM binary though is an ELF image and not a regular binary file, and so is processed further to load the actual program segments using the U-Boot's standard ELF loader library. The DM binary does leverage a certain portion of DDR for its program segments, and typically reserves 16 MB of DDR at 0xA0000000 with the 1st MB used for IPC between Linux and the remote processor, and remaining memory for firmware segments. This can cause an incomplete loading of the program segments if the DM binary is larger than 1 MB, due to overlap of the initial loaded binary and the actual program segments. Fix this by using the address 0x89000000, which matches the current "addr_mcur5f0_0load" env variable used by R5 SPL before the DM firmware inclusion into the tispl.bin. Fixes: df5363a67f35 ("tools: k3_fit_atf: add DM binary to the FIT image") Signed-off-by: Suman Anna <[email protected]>
2021-09-04net: Rename SPL_NET_SUPPORT to SPL_NETSimon Glass
Rename this option so that CONFIG_IS_ENABLED can be used with it. Signed-off-by: Simon Glass <[email protected]>
2021-09-04mmc: Rename MMC_SUPPORT to MMCSimon Glass
Rename these options so that CONFIG_IS_ENABLED can be used with them. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Jaehoon Chung <[email protected]> [trini: Fixup some incorrect renames] Signed-off-by: Tom Rini <[email protected]>
2021-09-02tools: env: Handle shorter read callsThibault Ferrante
On some cases, the actual number of bytes read can be shorter than what was requested. This can be handled gracefully by taking this difference into account instead of exiting. Signed-off-by: Thibault Ferrante <[email protected]>
2021-09-01mkimage: clarify error message for empty input filesThomas Hebb
Currently, an empty imput file causes `mmap()` to fail, and you get an error like "mkimage: Can't read file.img: Invalid argument", which is extremely unintuitive and hard to diagnose if you don't know what to look for. Add an explicit check for an empty file and provide a clear error message instead. We already bounds check the image size when listing and re-signing existing images, so we only need this check here, when opening data files going into a image. Signed-off-by: Thomas Hebb <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-09-01tools: kwbimage: Remove comment about unimplemented register headers in v1 ↵Pali Rohár
images Support for register headers in v1 images was implemented in commit 02ba70ad6822 ("tools: kwbimage: Add support for DATA command also for v1 images"). So remove old comment. Signed-off-by: Pali Rohár <[email protected]> Fixes: 02ba70ad6822 ("tools: kwbimage: Add support for DATA command also for v1 images") Reviewed-by: Stefan Roese <[email protected]>
2021-09-01kwbimage: check return value of image_get_csk_indexHeinrich Schuchardt
image_get_csk_index() may return -1 in case of an error. Don't use this value as index. This resolves Coverity CID 338488 Memory - illegal accesses (NEGATIVE_RETURNS) Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Stefan Roese <[email protected]> Reviewed-by: Pali Rohár <[email protected]>
2021-09-01kwbimage: check fopen() return valueHeinrich Schuchardt
Always check the return value of fopen(). This resolves Coverity CID 338491: Null pointer dereferences (NULL_RETURNS) Signed-off-by: Heinrich Schuchardt <[email protected]> Reviewed-by: Stefan Roese <[email protected]> Reviewed-by: Pali Rohár <[email protected]>
2021-09-01tools: kwbimage: Use IBR_HDR_* constants instead of raw numbersPali Rohár
There are already IBR_HDR_* constants for these numbers, so use them. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-09-01tools: kwbimage: Verify size of image dataPali Rohár
Part of image data is 4 byte checksum, so every image must contain at least 4 bytes. Verify it to prevent memory corruptions. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-09-01tools: kwbimage: Verify size of v0 image headerPali Rohár
Check that extended image header size is not larger than file size. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-09-01tools: kwbimage: Verify supported image versionPali Rohár
Only image versions 0 and 1 are supported. Verify it in kwbimage_verify_header() function. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Stefan Roese <[email protected]>
2021-08-08dtoc: Correct the intarray-widening test caseSimon Glass
This case was intended to check that widening an int array with an int does nothing. Fix it. Reported-by: Walter Lozano <[email protected]> Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Walter Lozano <[email protected]>