aboutsummaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)AuthorFilesLines
2022-03-04tools: kwboot: Update references with public linksPali Rohár1-3/+28
Public documents about BootROM of some Marvell SoCs are available in the public Web Archive. Put this information into source code. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Update doc about AvantaPali Rohár1-3/+3
Testes proved that current kwboot version supports also Avanta SoCs. It looks like that Avanta SoCs are using same kwbimage format as Armada. Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Update usagePali Rohár1-3/+4
Add all supported Armada SoCs and document -b and -d options in usage. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Add support for backspace key in mini terminalPali Rohár2-14/+97
Marvell BootROM recognize only '\b' byte as backspace. Use terminfo for retrieving current backspace sequence and replace any occurrence of backspace sequence by the '\b' byte. Reading terminfo database is possible via tigetstr() function from system library libtinfo.so.*. So link kwboot with -ltinfo. Normally terminfo functions are in <term.h> system header file. But this header file conflicts with U-Boot "termios_linux.h" header file. So declare terminfo functions manually. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Fix sending and processing debug message pattern (-d option)Pali Rohár1-16/+123
-d option is currently broken. In most cases BootROM does not detect this message pattern. For sending debug message pattern it is needed to do same steps as for boot message pattern. Implement sending debug message pattern via same separate thread like it is for boot message pattern. Checking if BootROM entered into UART debug mode is different than detecting UART boot mode. When in boot mode, BootROM sends xmodem NAK bytes. When in debug mode, BootROM activates console echo and reply back every written byte (extept \r\n which is interpreted as executing command and \b which is interpreting as removing the last sent byte). So in kwboot, check that BootROM send back at least 4 debug message patterns as a echo reply for debug message patterns which kwboot is sending in the loop. Then there is another observation, if host writes too many bytes (as command) then BootROM command line buffer may overflow after trying to execute such long command. To workaround this overflow, it is enough to remove bytes from the input line buffer by sending 3 \b bytes for every sent character. So do it. With this change, it is possbile to enter into the UART debug mode with kwboot -d option. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Use separate thread for sending boot message patternPali Rohár2-19/+104
After BootROM successfully detects boot message pattern on UART it waits until host stop sending data on UART. For example Armada 385 BootROM requires that host does not send anything on UART at least 24 ms. If host is still sending something then BootROM waits (possibly infinitely). BootROM successfully detects boot message pattern if it receives it in small period of time after power on. So to ensure that host put BootROM into UART boot mode, host must send continuous stream of boot message pattern with a small gap (for A385 at least 24 ms) after series of pattern. But this gap cannot be too often or too long to ensure that it does not cover whole BootROM time window when it is detecting for boot message pattern. Therefore it is needed to do following steps in cycle without any delay: 1. send series of boot message pattern over UART 2. wait until kernel transmit all data 3. sleep small period of time At the same time, host needs to monitor input queue, data received on the UART and checking if it contains NAK byte by which BootROM informs that xmodem transfer is ready. But it is not possible to wait until kernel transmit all data on UART and at the same time in the one process to also wait for input data. This is limitation of POSIX tty API and also by linux kernel that it does not provide asynchronous function for waiting until all data are transmitted. There is only synchronous variant tcdrain(). So to correctly implement this handshake on systems with linux kernel, it is needed to use tcdrain() in separate thread. Implement sending of boot message pattern in one thread and reading of reply in the main thread. Use pthread library for threads. This change makes UART booting on Armada 385 more reliable. It is possible to start kwboot and power on board after minute and kwboot correctly put board into UART boot mode. Old implementation without separate thread has an issue that it read just one byte from UART input queue and then it send 128 message pattern to the output queue. If some noise was on UART then kwboot was not able to read BootROM response as its input queue was just overflowed and kwboot was sending more data than receiving. This change basically fixed above issue too. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Cleanup bootmsg and debugmsg variablesPali Rohár1-17/+14
Function kwboot_debugmsg() is always called with kwboot_msg_debug as msg and function kwboot_bootmsg() with kwboot_msg_debug as msg. Function kwboot_bootmsg() is never called with NULL msg. Simplify, cleanup and remove dead code. No functional change. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Remove msg_req_delayPali Rohár1-6/+1
Variable msg_req_delay is set but never used. So completely remove it. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Check for return value of kwboot_tty_send() and tcflush()Pali Rohár1-11/+19
Failure of kwboot_tty_send() and tcflush() functions is fatal, it does not make sense to continue. So return error back to the caller like in other places where are called these functions. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Tested-by: Stefan Roese <sr@denx.de>
2022-03-04tools: kwboot: Fix quitting terminalPali Rohár1-2/+2
Sometimes kwboot after quitting terminal prints error message: terminal: Bad address This is caused by trying to call write() syscall with count of (size_t)-1 bytes. When quit sequence is split into more read() calls then number of input bytes (nin) at the end of cycle can underflow and be negative. Fix it. Fixes: de7514046ea5 ("tools: kwboot: Fix detection of quit esc sequence") Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de>
2022-03-03Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriqTom Rini2-3/+10
Update and fixes for sl28, lx2, pblimage generation for some powerpc products
2022-02-28tools: mkimage/dumpimage: Allow to use -l with -TPali Rohár4-50/+36
Currently -l option for mkimage and dumpimage ignores option -T and always tries to autodetect image type. With this change it is possible to tell mkimage and dumpimage to parse image file as specific type (and not random autodetected type). This allows to use mkimage -l or dumpimage -l as tool for validating image. params.type for -l option is now by default initialized to zero (IH_TYPE_INVALID) instead of IH_TYPE_KERNEL. imagetool_get_type() for IH_TYPE_INVALID returns NULL, which is assigned to tparams. mkimage and dumpimage code is extended to handle tparams with NULL for -l option. And imagetool_verify_print_header() is extended to do validation via tparams if is not NULL. Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-02-28tools: pblimage: fix image header verification functionHou Zhiqiang2-3/+10
The Layerscape platforms have different RCW header value from FSL PowerPC platforms, the current image header verification callback is only working on PowerPC, it will fail on Layerscape, this patch is to fix this issue. This is a historical problem and exposed by the following patch: http://patchwork.ozlabs.org/project/uboot/patch/20220114173443.9877-1-pali@kernel.org Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com> Reviewed-by: Priyanka Jain <priyanka.jain@nxp.com>
2022-02-26tools: mkeficapsule: remove duplicated codeAKASHI Takahiro1-2/+0
That code is mistakenly duplicated due to copy-and-paste error. Just remove it. Fixes: CID 348360 Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-02-22binman: Allow different operations in FIT generator nodesSimon Glass5-49/+274
At present we only support expanding out FDT nodes. Make the operation into an @operation property, so that others can be supported. Re-arrange and tidy up the documentation so that it has separate headings for each topic. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Tidy up the docs a little with fitSimon Glass2-14/+16
Add a few quotes and clarify the data property. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: fit: Refactor to reduce function sizeSimon Glass1-43/+71
Split subnode and property processing into separate functions to make the _AddNode() function a little smaller. Tweak a few comments. This does not change any functionality. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Move entry-data collection into a Entry methodSimon Glass3-10/+118
Collecting the data from a list of entries and putting it in a file is a useful operation that will be needed by other entry types. Put this into a method in the Entry class. Add some documentation about how to collect data for an entry type. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Add a ELF test file with disjoint text sectionsSimon Glass3-1/+56
Add a file that has two text sections at different addresses, so we can test this behaviour in binman, once added. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Support a list of strings with the mkimage etypeSimon Glass3-4/+26
At present the 'args' property of the mkimage entry type is a string. This makes it difficult to include CONFIG options in that property. In particular, this does not work: args = "-n CONFIG_SYS_SOC -E" since the preprocessor does not operate within strings, nor does this: args = "-n" CONFIG_SYS_SOC" "-E" since the device tree compiler does not understand string concatenation. With this new feature, we can do: args = "-n", CONFIG_SYS_SOC, "-E"; Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Add to the TODOSimon Glass1-0/+8
Add some ideas that have come to mind recently. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Add support for TEE BL32Roger Quadros5-0/+61
Add an entry for OP-TEE Trusted OS 'BL32' payload. This is required by platforms using Cortex-A cores with TrustZone technology. Signed-off-by: Roger Quadros <rogerq@kernel.org> Reviewed-by: Simon Glass <sjg@chromium.org> Add missing-blob-help, renumber the test file, update entry-docs: Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22elf: Add a way to read segment information from an ELF fileSimon Glass2-2/+66
Add a function which reads the segments and the entry address. Also fix a comment nit in the tests while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Update docs to indicate mkimage is supportedSimon Glass1-2/+2
Now that there is a mkimage entry-type, update the docs to remove the future reference. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support reading a list of argumentsSimon Glass3-0/+28
It is helpful to support a string or stringlist containing a list of space-separated arguments, for example: args = "-n fred", "-a", "123"; This resolves to the list: -n fred -a 123 which can be passed to a program as arguments. Add a helper to do the required processing. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Allow deleting nodes and adding them in the same syncSimon Glass2-0/+13
This does not work at present, since the current algorithm assumes that either there are no nodes or all nodes have an offset. If a node is new, but an old node is still in the tree, then syncing fails due to this assumption. Fix it and add a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support deleting a nodeSimon Glass2-0/+26
Add a function to delete a node. This is synced to the tree when requested. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22dtoc: Support adding a string list to a device treeSimon Glass2-0/+26
Add a new function to add a string list. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22moveconfig: Allow regex matches when finding combinationsSimon Glass1-2/+22
It is useful to be able to search for CONFIG options that match a regex, such as this, which lists boards which define SPL_FIT_GENERATOR and anything not starting with ROCKCHIP: ./tools/moveconfig.py -f SPL_FIT_GENERATOR ~ROCKCHIP.* Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22moveconfig: Show the config name rather than the defconfigSimon Glass1-1/+14
The _defconfig suffix is unnecessary when showing matching boards. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Correct the error message for a bad hash algorithmSimon Glass2-2/+2
This shows an internal type at present, rather than the algorithm name. Fix it and update the test to catch this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-02-22binman: Update image positions of FIT subentriesAlper Nebi Yasak2-0/+163
Binman keeps track of positions of each entry in the final image, but currently this data is wrong for things included in FIT entries, especially since a previous patch makes FIT a subclass of Section and inherit its implementation. There are three ways to put data into a FIT image. It can be directly included as a "data" property, or it can be external to the FIT image represented by an offset-size pair of properties. This external offset is either "data-position" from the start of the FIT or "data-offset" from the end of the FIT, and the size is "data-size" for both. However, binman doesn't use the "data-offset" method while building FIT entries. According to the Section docstring, its subclasses should calculate and set the correct offsets and sizes in SetImagePos() method. Do this for FIT subentries for the three ways mentioned above, and add tests for the two ways binman can pack them in. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Skip processing "hash" subnodes of FIT subsectionsAlper Nebi Yasak4-14/+97
Binman's FIT entry type can have image subentries with "hash" subnodes intended to be processed by mkimage, but not binman. However, the Entry class and any subclass that reuses its implementation tries to process these unconditionally. This can lead to an error when boards specify hash algorithms that binman doesn't support, but mkimage supports. Let entries skip processing these "hash" subnodes based on an instance variable, and set this instance variable for FIT subsections. Also re-enable processing of calculated and missing properties of FIT entries which was disabled to mitigate this issue. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-02-21Merge tag 'xilinx-for-v2022.04-rc3' of ↵Tom Rini1-0/+2
https://gitlab.denx.de/u-boot/custodians/u-boot-microblaze Xilinx changes for v2022.04-rc3 microblaze: - Fix exception handler zynqmp: - Show information about secure images - DT changes (som u-boot file removal) - Fix zynqmp_pm_cfg_obj_convert.py - Fix platform boot xilinx: - Fix bootm_size calculation - Remove GPIO_EXTRA_HEADER selection power: - Add zynqmp power management driver scsi: - Add phy support to ceva driver zynq qspi: - Fix unaligned accesses and check baudrate setup - Add support for spi memory operations net: - Fix 64bit calculation in axi_emac video: - Add missing gpio dependency for seps driver
2022-02-17tools: kwbimage: Add me as an author of kwbimagePali Rohár1-0/+2
Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-17tools: kwbimage: Fix help how to extract DDR3 training codePali Rohár1-1/+1
First binary executable header is extracted by '-p 1' argument. Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-17tools: kwbimage: Add support for NAND_BLKSZ and NAND_BADBLK_LOCATION for v0 ↵Pali Rohár1-0/+6
images These two commands are currently not processed when generating v0 images. Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-17tools: kwbimage: Do not show mkimage error message in dumpimagePali Rohár1-1/+1
When pflag is set then kwbimage was invoked by dumpimage and not mkimage. So do not show mkimage error message in this case. Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-17tools: kwbimage: Add support for dumping extended and binary v0 headersPali Rohár2-12/+179
dumpimage is now able to successfully parse and dump content of the Dove bootloader image. Note that support for generating these extended parts of v0 images is not included yet. Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-17tools: kwbimage: Fix calculating size of kwbimage v0 headerPali Rohár1-1/+13
Extended and binary headers are optional and are part of the image header. Fixes kwboot to determinate correct length of Dove images. Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-17tools: kwbimage: Define structures for extended kwbimage v0 headersPali Rohár1-9/+42
They are used by Marvell Dove 88AP510 BootROM. After the main header is a list of optional extended headers and after that is a list of optional binary executable headers. Between each two extended headers is additional 0x20 byte long padding. Original Kirkwood SoCs support only one extended header and no binary executable header. Extension of struct ext_hdr_v0 is backward compatible with the old definition. Only reserved[] fields are changed. Signed-off-by: Pali Rohár <pali@kernel.org> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-17tools: kwbimage: Fix dumping DATA registers for v0 imagesPali Rohár1-2/+4
End of DATA register section is indicated by zero value in both raddr and rdata. So do not stop dumping registers with non-zero address and zero value. And also print end of DATA registers section. Fixes: 1a8e6b63e24f ("tools: kwbimage: Dump kwbimage config file on '-p -1' option") Signed-off-by: Pali Rohár <pali@kernel.org> Reported-by: Tony Dinh <mibodhi@gmail.com> Tested-by: Tony Dinh <mibodhi@gmail.com> Reviewed-by: Stefan Roese <sr@denx.de>
2022-02-15tools/zynqmp_pm_cfg_obj_convert.py: fix build with Vivado 2021.xLuca Ceresoli1-0/+2
This tool fails with a pm_cfg_obj.c file generated by Vitis 2021.2. This is because that version of Vitis added the PM_CONFIG_OBJECT_TYPE_BASE that was not previously generated, thus the script does not implement it. Reported-by: Neal Frager <nealf@xilinx.com> [report: https://lists.buildroot.org/pipermail/buildroot/2022-February/636639.html] Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net> Link: https://lore.kernel.org/r/20220212125121.3398547-1-luca@lucaceresoli.net Signed-off-by: Michal Simek <michal.simek@xilinx.com>
2022-02-11Merge tag 'efi-2022-04-rc2-4' of ↵Tom Rini4-56/+532
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2022-04-rc2-4 Documentation: * mkeficapsule man-page UEFI changes: * add support for signing images to mkeficapsule * add support for user define capsule GUID * adjust unit tests for capsules * fix UEFI image signature validation in case of multiple signatures
2022-02-11tools: mkeficapsule: allow for specifying GUID explicitlyAKASHI Takahiro2-24/+63
The existing options, "--fit" and "--raw," are only used to put a proper GUID in a capsule header, where GUID identifies a particular FMP (Firmware Management Protocol) driver which then would handle the firmware binary in a capsule. In fact, mkeficapsule does the exact same job in creating a capsule file whatever the firmware binary type is. To prepare for the future extension, the command syntax will be a bit modified to allow users to specify arbitrary GUID for their own FMP driver. OLD: [--fit <image> | --raw <image>] <capsule file> NEW: [--fit | --raw | --guid <guid-string>] <image> <capsule file> Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-02-11tools: mkeficapsule: add firmware image signingAKASHI Takahiro3-34/+464
With this enhancement, mkeficapsule will be able to sign a capsule file when it is created. A signature added will be used later in the verification at FMP's SetImage() call. To do that, we need specify additional command parameters: -monotonic-cout <count> : monotonic count -private-key <private key file> : private key file -certificate <certificate file> : certificate file Only when all of those parameters are given, a signature will be added to a capsule file. Users are expected to maintain and increment the monotonic count at every time of the update for each firmware image. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-02-11tools: build mkeficapsule with tools-only_defconfigAKASHI Takahiro2-2/+9
Add CONFIG_TOOLS_MKEFICAPSULE. Then we want to always build mkeficapsule if tools-only_defconfig is used. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-02-11fw_env: simplify logic & code paths in the fw_env_open()Rafał Miłecki1-46/+31
Environment variables can be stored in two formats: 1. Single entry with header containing CRC32 2. Two entries with extra flags field in each entry header For that reason fw_env_open() has two main code paths and there are pointers for CRC32/flags/data. Previous implementation was a bit hard to follow: 1. It was checking for used format twice (in reversed order each time) 2. It was setting "environment" global struct fields to some temporary values that required extra comments explaining it This change simplifies that code: 1. It introduces two clear code paths 2. It sets "environment" global struct fields values only once it really knows them To be fair there are *two* crc32() calls now and an extra pointer variable but that should be cheap enough and worth it. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2022-02-11fw_env: make flash_io() take buffer as an argumentRafał Miłecki1-16/+16
It's usually easier to understand code & follow it if all arguments are passed explicitly. Many coding styles also discourage using global variables. Behaviour of flash_io() was a bit unintuitive as it was writing to a buffer referenced in a global struct. That required developers to remember how it works and sometimes required hacking "environment" global struct variable to read data into a proper buffer. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
2022-02-11mkimage: Improve documentation of algo-name parameterJan Kiszka1-1/+3
Addresses the feedback provided on 5902a397d029 ("mkimage: Allow to specify the signature algorithm on the command line") which raced with the merge. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Simon Glass <sjg@chromium.org>