aboutsummaryrefslogtreecommitdiff
path: root/tools/kwboot.c
AgeCommit message (Collapse)AuthorFilesLines
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: kwbimage: Mark all BootROM structures __packedPali Rohár1-7/+1
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>
2018-09-19tools: kwboot: Make kwboot more robust on a38xJon Nettleton1-4/+10
This patch accomplishes 2 things to make the kwboot procedure on the a38x more reliable. 1) We fill the tty with 1K of the magic bootparam. This helps with the timing of where the microcode picks up in the read of the line to ensure we actually catch the break to go into recovery mode 2) Before starting the xmodem transfer we sleep for 2 seconds and then flush the line. This allows all the magic bootparam to be flushed from the line and makes the xmodem transfer reliable and removes the Bad message failures. Signed-off-by: Jon Nettleton <jon@solid-run.com> Signed-off-by: Baruch Siach <baruch@tkos.co.il> Reviewed-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Stefan Roese <sr@denx.de>
2018-08-07tools: kwboot: properly quit when read() returns 0Willy Tarreau1-2/+2
When kwboot is attached to a terminal which disappears such as one connected via an unplugged USB cable, read() returns 0, making kwboot loop until a key is pressed in the terminal. The only case where read() may return 0 here is when the terminal is closed anyway, so let's properly handle this one and report is similar to other errors. Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Stefan Roese <sr@denx.de>
2018-08-07tools: kwboot: unbreak terminal-only modeWilly Tarreau1-1/+1
Commit 84899e2 ("tools/kwboot: Sync with latest barebox version to support Armada XP") accidently broke the terminal-only mode (-t) by removing the test on the bootmsg. Thus even when trying to use kwboot as a plain terminal, it asks to reboot the target. This commit simply reintroduces the lost test so that it is possible again to use kwboot to attach to the target system's console. Signed-off-by: Willy Tarreau <w@1wt.eu> Signed-off-by: Stefan Roese <sr@denx.de>
2017-02-17tools: kwboot: don't adjust destaddr when patching the imageChris Packham1-8/+0
Commit 94084eea3bd3 ("tools: kwbimage: Fix dest addr") changed kwbimage to do this adjustment. So now the adjustment in kwboot is not needed (and would prevent UART booting for images generated by the new kwbimage). Remove the destaddr adjustment in kwboot. Signed-off-by: Chris Packham <judge.packham@gmail.com> Signed-off-by: Stefan Roese <sr@denx.de>
2016-08-26tools: kwboot: patch destaddr only for SoCs with header version 1Simon Baatz1-8/+8
Commit f4db6c976cf ("arm: mvebu: Add runtime detection of UART (xmodem) boot-mode") added a change to hdr->destaddr when dynamically patching an image for UART boot mode. With this change, kwboot ceases to work on Kirkwood. Thus, let's change hdr->destaddr only when we are patching an image with header version 1 (Orion and Kirkwood use header version 0). Signed-off-by: Simon Baatz <gmbnomis@gmail.com> Fixes: f4db6c976cf ("arm: mvebu: Add runtime detection of UART (xmodem) boot-mode") Cc: Stefan Roese <sr@denx.de> Cc: Luka Perkov <luka.perkov@sartura.hr> Cc: Kevin Smith <kevin.smith@elecsyscorp.com> Signed-off-by: Stefan Roese <sr@denx.de>
2016-03-24tools: kwboot: Add xmodem timeout optionKevin Smith1-2/+9
Add command-line specification of xmodem timeout. If the binary header needs to take a while to do something (e.g. DDR ECC scrubbing), the xmodem transfer can time out. Add a configurable xmodem block timeout to allow transfers with slow binary headers to succeed. Signed-off-by: Kevin Smith <kevin.smith@elecsyscorp.com> Cc: Stefan Roese <sr@denx.de> Signed-off-by: Stefan Roese <sr@denx.de>
2016-03-24tools: kwboot: Clean up usage textKevin Smith1-1/+1
Usage text was getting unwieldy and somewhat incorrect. The usage summary implied that some options were mutually exclusive (e.g. -q or -s). Clean up the summary to just include the important ones, and include a generic "[OPTIONS]" instead. Signed-off-by: Kevin Smith <kevin.smith@elecsyscorp.com> Cc: Stefan Roese <sr@denx.de> Signed-off-by: Stefan Roese <sr@denx.de>
2016-01-14arm: mvebu: Add runtime detection of UART (xmodem) boot-modeStefan Roese1-2/+12
This patch adds runtime detection of the Marvell UART boot-mode (xmodem protocol). If this boot-mode is detected, SPL will return to the BootROM to continue the UART booting. With this patch its now possible, to generate a U-Boot image that can be booted either from the strapped boot-device (e.g. SPI NOR, MMC, etc) or via the xmodem protocol from the UART. In the UART case, the kwboot tool will dynamically insert the UART boot-device type into the image. And also patch the load address in the header, so that the mkimage header will be skipped (as its not expected by the Marvell BootROM). This simplifies the development for Armada XP / 38x based boards. As no special images need to be generated by selecting the MVEBU_BOOTROM_UARTBOOT Kconfig option. Since the Kconfig option MVEBU_BOOTROM_UARTBOOT is not needed any more, its now completely removed. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Luka Perkov <luka.perkov@sartura.hr> Cc: Dirk Eibach <dirk.eibach@gdsys.cc> Cc: Phil Sutter <phil@nwl.cc> Cc: Kevin Smith <kevin.smith@elecsyscorp.com>
2015-10-01tools: kwboot: Add support for UART boot mode patching for Armada XP/38xStefan Roese1-10/+27
Currently, kwboot only allows dynamic UART boot mode patching for SoCs with header version 0 (Orion, Kirkwood). This patch now enables this "-p" feature also for SoCs with header version 1 (Armada XP / 38x etc). With this its possible now to use the UART boot mode without on images that are generated for other boot devices, like SPI. So no need to change BOOT_FROM to "uart" for UART xmodem booting any more. Signed-off-by: Stefan Roese <sr@denx.de> Tested-by: Kevin Smith <kevin.smith@elecsyscorp.com> Cc: Luka Perkov <luka.perkov@sartura.hr> Cc: Dirk Eibach <eibach@gdsys.de>
2015-06-14tools/kwboot: Add parameters to set delay and timeout via cmdlineStefan Roese1-2/+12
To support the Armada 38x, new values for the request-delay and the response-timeout are needed. As the values already implemented in this tool (for Kirkwood and Armada XP) don't seem to work here. To make this more flexible, lets add make those 2 parameters configurable via the cmdline. Here the new parameters: -q <req-delay>: use specific request-delay -s <resp-timeo>: use specific response-timeout For the Marvell DB-88F6820 these values are known to work: One board: -q 2 -s 1 2nd board: -q 5 -s 5 So this seems to be even board specific. But with this patch now those values can be specified and tested via the cmdline. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Kevin Smith <kevin.smith@elecsyscorp.com> Cc: Dirk Eibach <dirk.eibach@gdsys.cc> Cc: Luka Perkov <luka.perkov@sartura.hr>
2014-10-23tools/kwboot: Sync with latest barebox version to support Armada XPStefan Roese1-14/+97
The barebox version of the kwboot tool has evolved a bit. To support Armada XP and Dove. Additionally a few minor fixes have been applied. So lets sync with the latest barebox version. Please note that the main difference between both versions now is, that the U-Boot version still supports the -p option, to dynamically patch an image for UART boot mode. I didn't test it now though. Signed-off-by: Stefan Roese <sr@denx.de> Tested-by: Luka Perkov <luka@openwrt.org>
2012-07-07kwboot: boot kirkwood SoCs over a serial linkLuka Perkov1-0/+742
The kwboot program boots boards based on Marvell's Kirkwood platform via Xmodem over their integrated UART. Signed-off-by: Daniel Stodden <daniel.stodden@googlemail.com> Acked-by: Luka Perkov <uboot@lukaperkov.net> Tested-By: Holger Brunck <holger.brunck@keymile.com> Tested-By: David Purdy <david.c.purdy@gmail.com> Tested-by: Simon Guinot <simon.guinot@sequanux.org>