platform/kernel/u-boot.git
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-samsung
Tom Rini [Tue, 3 Aug 2021 13:07:01 +0000 (09:07 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-samsung

2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-x86
Tom Rini [Tue, 3 Aug 2021 01:35:50 +0000 (21:35 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-x86

- Fixed broken ICH SPI driver in software sequencer mode
- Added "m25p,fast-read" to SPI flash node for x86 boards
- Drop ROM_NEEDS_BLOBS and BUILD_ROM for x86 ROM builds
- Define a default TSC timer frequency for all x86 boards
- x86 MTRR MSR programming codes bug fixes
- x86 "hob" command bug fixes
- Don't program MTRR for DRAM for FSP1
- Move INIT_PHASE_END_FIRMWARE to FSP2
- Use external graphics card by default on Intel Crown Bay
- tangier: Fix DMA controller IRQ polarity in CSRT

2 years agoMerge branch '2021-08-02-numeric-input-cleanups'
Tom Rini [Mon, 2 Aug 2021 17:32:20 +0000 (13:32 -0400)]
Merge branch '2021-08-02-numeric-input-cleanups'

- Merge in a series that cleans up and makes more consistent how we deal
  with numeric input on the CLI.  This saves a few bytes in a lot of
  places.

2 years agolib: Allow using 0x when a decimal value is requested
Simon Glass [Sat, 24 Jul 2021 15:03:38 +0000 (09:03 -0600)]
lib: Allow using 0x when a decimal value is requested

U-Boot mostly uses hex for value input, largely because addresses are much
easier to understand in hex.

But in some cases a decimal value is requested, such as where the value is
small or hex does not make sense in the context. In these cases it is
sometimes useful to be able to provide a hex value in any case, if only to
resolve any ambiguity.

Add this functionality, for increased flexibility.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Add a note about number representation
Simon Glass [Sat, 24 Jul 2021 15:03:37 +0000 (09:03 -0600)]
doc: Add a note about number representation

Mention the default base of U-Boot in the command-line section. Add
examples for decimal and octal.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Convert command-line info to rST
Simon Glass [Sat, 24 Jul 2021 15:03:36 +0000 (09:03 -0600)]
doc: Convert command-line info to rST

Take this part of the README and put it into rST format.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agolib: Move common digit-parsing code into a function
Simon Glass [Sat, 24 Jul 2021 15:03:35 +0000 (09:03 -0600)]
lib: Move common digit-parsing code into a function

The code to convert a character into a digit is repeated twice in this
file. Factor it out into a separate function. This also makes the code a
little easier to read.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agolib: Add octal tests for simple_strtoul/l()
Simon Glass [Sat, 24 Jul 2021 15:03:34 +0000 (09:03 -0600)]
lib: Add octal tests for simple_strtoul/l()

This function support decoding octal but no tests are included yet.
Add some.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agolib: Add tests for simple_strtoull()
Simon Glass [Sat, 24 Jul 2021 15:03:33 +0000 (09:03 -0600)]
lib: Add tests for simple_strtoull()

Add some tests that check the behaviour of this function. These are the
same as for simple_strtoul() but with a few longer values.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agolib: Drop unnecessary check for hex digit
Simon Glass [Sat, 24 Jul 2021 15:03:32 +0000 (09:03 -0600)]
lib: Drop unnecessary check for hex digit

If we see 0x then we can assume this is the start of a hex value. It
does not seem necessary to check for a hex digit after that since it will
happen when parsing the value anyway.

Drop this check to simplify the code and reduce size. Add a few more test
cases for when a 0x prefix is used.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agolib: Comment the base parameter with simple_strtoul/l()
Simon Glass [Sat, 24 Jul 2021 15:03:31 +0000 (09:03 -0600)]
lib: Comment the base parameter with simple_strtoul/l()

This parameter is not documented properly since it does not cover the
meaning when the base is 0. Update this in both functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoglobal: Convert simple_strtoul() with decimal to dectoul()
Simon Glass [Sat, 24 Jul 2021 15:03:30 +0000 (09:03 -0600)]
global: Convert simple_strtoul() with decimal to dectoul()

It is a pain to have to specify the value 10 in each call. Add a new
dectoul() function and update the code to use it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agoglobal: Convert simple_strtoul() with hex to hextoul()
Simon Glass [Sat, 24 Jul 2021 15:03:29 +0000 (09:03 -0600)]
global: Convert simple_strtoul() with hex to hextoul()

It is a pain to have to specify the value 16 in each call. Add a new
hextoul() function and update the code to use it.

Add a proper comment to simple_strtoul() while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agohash: Ensure verification hex pairs are terminated
Simon Glass [Sat, 24 Jul 2021 15:03:28 +0000 (09:03 -0600)]
hash: Ensure verification hex pairs are terminated

This function seems to assume that the chr[] variable contains zeros at
the start, which is not always true. Use strlcpy() to be safe.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agox86: crownbay: Use external graphics card by default
Bin Meng [Mon, 2 Aug 2021 07:05:16 +0000 (15:05 +0800)]
x86: crownbay: Use external graphics card by default

The board routes the Integrated Graphics Device (IGD) to an LVDS
panel, which is less popular than a PCIe based graphics card.

Disable the IGD so that it does not show up in the PCI configuration
space as a VGA display controller, so we can use an external PCIe
graphics card with whatever cable we have.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: queensbay: Return directly if IGD / SDVO were already disabled
Bin Meng [Mon, 2 Aug 2021 07:05:15 +0000 (15:05 +0800)]
x86: queensbay: Return directly if IGD / SDVO were already disabled

Initialize 'igd' and 'sdvo' to NULL so that we just need to test
them against NULL later, to be compatible with that case that IGD
and SDVO devices were already in disabled state.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: fsp: Only FSP2 has INIT_PHASE_END_FIRMWARE
Bin Meng [Mon, 2 Aug 2021 09:45:22 +0000 (17:45 +0800)]
x86: fsp: Only FSP2 has INIT_PHASE_END_FIRMWARE

For FSP1, there is no such INIT_PHASE_END_FIRMWARE.

Move board_final_cleanup() to fsp2 directory.

Fixes: 7c73cea44290 ("x86: Notify the FSP of the 'end firmware' event")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
Tested-by: Simon Glass <sjg@chromium.org>
2 years agox86: fsp: Don't program MTRR for DRAM for FSP1
Bin Meng [Mon, 2 Aug 2021 09:45:21 +0000 (17:45 +0800)]
x86: fsp: Don't program MTRR for DRAM for FSP1

There are several outstanding issues as to why this does not apply
to FSP1:

* For FSP1, the system memory and reserved memory used by FSP are
  already programmed in the MTRR by FSP.
* The 'mtrr_top' mistakenly includes TSEG memory range that has the
  same RES_MEM_RESERVED resource type. Its address is programmed
  and reported by FSP to be near the top of 4 GiB space, which is
  not what we want for SDRAM.
* The call to mtrr_add_request() is not guaranteed to have its size
  to be exactly the power of 2. This causes reserved bits of the
  IA32_MTRR_PHYSMASK register to be written which generates #GP.

For FSP2, it seems this is necessary as without this, U-Boot boot
process on Chromebook Coral goes very slowly.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
Tested-by: Simon Glass <sjg@chromium.org>
2 years agoMerge tag 'efi-2021-10-rc2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Tom Rini [Mon, 2 Aug 2021 12:54:23 +0000 (08:54 -0400)]
Merge tag 'efi-2021-10-rc2' of https://source.denx.de/u-boot/custodians/u-boot-efi

Pull request for efi-2021-10-rc2

Documentation:

* handle 'make htmldocs' warnings as errors
* add missing board/ti/index.rst

Bug fixes:

* avoid buffer overrun in TrueType console
* lib: disable CONFIG_SPL_HEXDUMP by default

2 years agoMerge tag 'mmc-2021-7-30' of https://source.denx.de/u-boot/custodians/u-boot-mmc
Tom Rini [Mon, 2 Aug 2021 12:53:58 +0000 (08:53 -0400)]
Merge tag 'mmc-2021-7-30' of https://source.denx.de/u-boot/custodians/u-boot-mmc

pl180_mmci update and cleanup
fix rpmb routing memory alignment

2 years agox86: cmd: hob: Fix display of resource type for system memory
Bin Meng [Sat, 31 Jul 2021 08:45:28 +0000 (16:45 +0800)]
x86: cmd: hob: Fix display of resource type for system memory

The resource type for system memory is currently displayed as
"unknown", which is wrong.

Fixes: 51af144eb7a0 ("x86: Allow showing details about a HOB entry")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
Tested-by: Simon Glass <sjg@chromium.org>
2 years agox86: cmd: hob: Fix the command usage and help messages
Bin Meng [Sat, 31 Jul 2021 08:45:27 +0000 (16:45 +0800)]
x86: cmd: hob: Fix the command usage and help messages

At present the hob command usage and help messages are messed up
in a single line. They should be separated.

This was a regression introduced when [seq] and [-v] were added
to the command.

Fixes: d11544dfa9f4 ("x86: hob: Add way to show a single hob entry")
Fixes: 51af144eb7a0 ("x86: Allow showing details about a HOB entry")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
Tested-by: Simon Glass <sjg@chromium.org>
2 years agox86: mtrr: Abort if requested size is not power of 2
Bin Meng [Sat, 31 Jul 2021 08:45:26 +0000 (16:45 +0800)]
x86: mtrr: Abort if requested size is not power of 2

The size parameter of mtrr_add_request() and mtrr_set_next_var()
shall be power of 2, otherwise the logic creates a mask that does
not meet the requirement of IA32_MTRR_PHYSMASK register.

Programming such a mask value to IA32_MTRR_PHYSMASK generates #GP.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
Tested-by: Simon Glass <sjg@chromium.org>
2 years agox86: mtrr: Skip MSRs that were already programmed in mtrr_commit()
Bin Meng [Sat, 31 Jul 2021 08:45:25 +0000 (16:45 +0800)]
x86: mtrr: Skip MSRs that were already programmed in mtrr_commit()

At present mtrr_commit() programs the MTRR MSRs starting from
index 0, which may overwrite MSRs that were already programmed
by previous boot stage or FSP.

Switch to call mtrr_set_next_var() instead.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
Tested-by: Simon Glass <sjg@chromium.org>
2 years agox86: mtrr: Do not clear the unused ones in mtrr_commit()
Bin Meng [Sat, 31 Jul 2021 08:45:24 +0000 (16:45 +0800)]
x86: mtrr: Do not clear the unused ones in mtrr_commit()

Current mtrr_commit() logic assumes that MTRR MSRs are programmed
consecutively from index 0 to its maximum number, and whenever it
detects an unused one, it clears all other MTRRs starting from that
one. However this may not always be the case.

In fact, the clear is not much helpful because these MTRRs come out
of reset as disabled already. Drop the clear codes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested on chromebook_coral, chromebook_samus, chromebook_link, minnowmax
Tested-by: Simon Glass <sjg@chromium.org>
2 years agox86: dts: Define a default TSC timer frequency
Bin Meng [Wed, 28 Jul 2021 04:00:23 +0000 (12:00 +0800)]
x86: dts: Define a default TSC timer frequency

If for some reason, TSC timer frequency cannot be determined from
hardware, nor is it specified in the device tree, U-Boot will panic
resulting in endless reset during boot.

Let's define a default TSC timer frequency using the Kconfig value
CONFIG_X86_TSC_TIMER_FREQ (note: #include must be used instead of
/include/ otherwise the macro is not pre-processed).

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: tsc: Rename X86_TSC_TIMER_EARLY_FREQ to X86_TSC_TIMER_FREQ
Bin Meng [Wed, 28 Jul 2021 04:00:22 +0000 (12:00 +0800)]
x86: tsc: Rename X86_TSC_TIMER_EARLY_FREQ to X86_TSC_TIMER_FREQ

Currently there are two places to specify the x86 TSC timer frequency
with one in Kconfig used for early timer and the other one in device
tree used when the frequency cannot be determined from hardware.

This may potentially create an inconsistent config where the 2 values
do not match. Let's use the one specified in Kconfig in the device
tree as well.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: kconfig: Drop ROM_NEEDS_BLOBS and BUILD_ROM
Bin Meng [Tue, 27 Jul 2021 15:15:39 +0000 (23:15 +0800)]
x86: kconfig: Drop ROM_NEEDS_BLOBS and BUILD_ROM

These 2 options are no longer needed as now binman is used to build
u-boot.rom.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: crownbay: Adjust VGA rom address
Bin Meng [Tue, 27 Jul 2021 13:30:02 +0000 (21:30 +0800)]
x86: crownbay: Adjust VGA rom address

binman complains when binary blobs are present:

  Node '/binman/rom/intel-vga': Offset 0xfff90000 (4294508544) overlaps
  with previous entry '/binman/rom/u-boot-dtb-with-ucode' ending at
  0xfff9204c (4294516812)

Adjust VGA rom address to 0xfffa0000 so that u-boot.rom image can be
successfully built again.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: tangier: Fix DMA controller IRQ polarity in CSRT
Andy Shevchenko [Fri, 30 Jul 2021 20:15:44 +0000 (23:15 +0300)]
x86: tangier: Fix DMA controller IRQ polarity in CSRT

IRQ polarity in CSRT has the same definition as by ACPI specification
chapter 19.6.64 "Interrupt (Interrupt Resource Descriptor Macro)", i.e.
ActiveHigh is 0, and ActiveLow is 1. On Intel Tangier the DMA controller
IRQ polarity is ActiveHigh.

Note, in DSDT (see southcluster.asl) it's described correctly.

Fixes: 5e99fde34a77 ("x86: tangier: Populate CSRT for shared DMA controller")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: dts: Add "m25p,fast-read" to SPI flash node
Bin Meng [Thu, 29 Jul 2021 12:18:23 +0000 (20:18 +0800)]
x86: dts: Add "m25p,fast-read" to SPI flash node

Except ICH7 SPI, all SPI flashes connected to ICH9 / Fast SPI should
have "m25p,fast-read" property present in their DT nodes.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agox86: crownbay: Disable CONFIG_SPI_FLASH_SMART_HWCAPS
Bin Meng [Wed, 28 Jul 2021 10:28:57 +0000 (18:28 +0800)]
x86: crownbay: Disable CONFIG_SPI_FLASH_SMART_HWCAPS

Since commit 71025f013ccb ("mtd: spi-nor-core: Rework hwcaps selection")
SPI flash on Intel Crown Bay board does not work anymore.

Disable CONFIG_SPI_FLASH_SMART_HWCAPS until a proper fix is made to
the spi-nor core.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agospi: ich: Limit slave->max_read_size
Bin Meng [Wed, 28 Jul 2021 10:28:56 +0000 (18:28 +0800)]
spi: ich: Limit slave->max_read_size

Since commit 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
(in v2020.04-rc1), SPI flash read no longer works with ICH SPI controller
in software sequencer mode.

ICH controller can only transfer a small number of bytes at once.
Before commit 43c145b8b3ee, the logic happens to make sure data.nbytes
is limited to slave->max_write_size but after commit 43c145b8b3ee
data.nbytes is no longer limited because slave->max_read_size is not
initialized with a valid number.

Fixes: 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agoefi_loader: typo cerificate
Heinrich Schuchardt [Mon, 2 Aug 2021 06:21:12 +0000 (08:21 +0200)]
efi_loader: typo cerificate

%s/cerificate/certificate/

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agodoc: add graphviz imagemagick as build dependencies
Heinrich Schuchardt [Sun, 1 Aug 2021 21:29:20 +0000 (23:29 +0200)]
doc: add graphviz imagemagick as build dependencies

'make htmldocs' requires graphviz and imagemagick (at least with Sphinx
3.5.4).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agodoc: handle 'make htmldocs' warnings as errors
Heinrich Schuchardt [Sun, 1 Aug 2021 20:11:39 +0000 (22:11 +0200)]
doc: handle 'make htmldocs' warnings as errors

Parameter -W for sphinx-build turns build warnings into errors. This helps
us to avoid bad patches passing Gitlab CI.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agodoc: add missing board/ti/index.rst
Heinrich Schuchardt [Sun, 1 Aug 2021 20:09:44 +0000 (22:09 +0200)]
doc: add missing board/ti/index.rst

Commit 8baeeecbe305 ("doc: board: Move j721e document to doc/board/ti/
directory") introduced 'make htmldocs' build errors due to a missing
file board/ti/index.rst.

Fixes: 8baeeecbe305 ("doc: board: Move j721e document to doc/board/ti/ directory")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agoMerge tag 'dm-pull-1aug21' of https://source.denx.de/u-boot/custodians/u-boot-dm
Tom Rini [Sun, 1 Aug 2021 18:41:22 +0000 (14:41 -0400)]
Merge tag 'dm-pull-1aug21' of https://source.denx.de/u-boot/custodians/u-boot-dm

sandbox TPM-emulator improvements
rST documentation and fixes for moveconfig
handle empty 'ranges' property in dtoc
patman warning for invalid tag
clean-ups to 'fdt add' command

2 years agodtoc: Support widening a bool value
Simon Glass [Thu, 29 Jul 2021 01:23:11 +0000 (19:23 -0600)]
dtoc: Support widening a bool value

At present if we see 'ranges' property (with no value) we assume it is a
boolean, as per the devicetree spec.

But another node may define 'ranges' with a value, forcing us to widen it
to an int array. At present this is not supported and causes an error.

Fix this and add some test cases.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
2 years agodtoc: Fix widening an int array to an int
Simon Glass [Thu, 29 Jul 2021 01:23:10 +0000 (19:23 -0600)]
dtoc: Fix widening an int array to an int

An int array can hold a single int so we should not need to do anything
in the widening operation. However due to a quirk in the code, an int[3]
widened with an int produced an int[4]. Fix this and add a test.

Fix a comment typo while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
2 years agodtoc: Rename is_wider_than() to reduce confusion
Simon Glass [Thu, 29 Jul 2021 01:23:09 +0000 (19:23 -0600)]
dtoc: Rename is_wider_than() to reduce confusion

The current name is confusing because the logic is actually backwards from
what you might expect. Rename it to needs_widening() and update the
comments.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: Reduce keyed autoboot delay
Simon Glass [Sat, 24 Jul 2021 21:14:39 +0000 (15:14 -0600)]
sandbox: Reduce keyed autoboot delay

The autoboot tests are a recent addition to U-Boot, providing much-needed
coverage in this area.

A side effect of the keyed autoboot test is that this feature is enabled
in sandbox always. This changes the autoboot prompt and confuses the
pytests. Some tests become slower, for example the vboot tests take about
27s now instead of 3s.

We don't actually need this feature enabled to be able to run the tests.
Add a switch to allow sandbox to turn it on and off as needed. Use this
in the one test that needs it.

Add a command-line flag in case this is desired in normal use.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 25c8b9f298e ("test: add first autoboot unit tests")
Reviewed-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
2 years agomoveconfig: Update to newer kconfiglib
Simon Glass [Thu, 22 Jul 2021 03:35:53 +0000 (21:35 -0600)]
moveconfig: Update to newer kconfiglib

Some of the more advanced features of this tool don't work anymore since
kconfiglib was update. Update the code accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Fix up outdated moveconfig docs
Simon Glass [Thu, 22 Jul 2021 03:35:52 +0000 (21:35 -0600)]
doc: Fix up outdated moveconfig docs

The examples here are a bit messed up since the command does not match
the documentation. Use a different example instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Add docs for the moveconfig tool
Simon Glass [Thu, 22 Jul 2021 03:35:51 +0000 (21:35 -0600)]
doc: Add docs for the moveconfig tool

Move these docs into htmldocs so they can be read there.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Move coccinelle into its own section
Simon Glass [Thu, 22 Jul 2021 03:35:50 +0000 (21:35 -0600)]
doc: Move coccinelle into its own section

This tool has nothing to do with testing. It is for refactoring code
automatically using a 'semantic patch' tool.

Create a new section for 'refactoring' and move it into there. It is
likely that other topics may fall under the same heading, such as
using moveconfig and search/replace tools.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agodoc: Create an intro section for testing
Simon Glass [Thu, 22 Jul 2021 03:35:49 +0000 (21:35 -0600)]
doc: Create an intro section for testing

At present this information is hidden away. Make it more visible by
putting it first, in an intro section.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agopatman: add warning for invalid tag
Patrick Delaunay [Thu, 22 Jul 2021 14:51:42 +0000 (16:51 +0200)]
patman: add warning for invalid tag

Add a error in patman tool when the commit message contents an invalid
tag "Serie-.*" instead of "Series-.*".

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agofdt: Show the type of devicetree with fdt addr
Simon Glass [Wed, 21 Jul 2021 20:55:26 +0000 (14:55 -0600)]
fdt: Show the type of devicetree with fdt addr

It seems useful to show whether the address of the Control or Working
devicetree is being shown. Add support for this. Drop the confusing 0x
prefix since the command itself only accepts hex.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agofdt: Tidy up the code a bit with fdt addr
Simon Glass [Wed, 21 Jul 2021 20:55:25 +0000 (14:55 -0600)]
fdt: Tidy up the code a bit with fdt addr

Clean up the code a little before changing it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Support extending a PCR multiple times
Simon Glass [Sun, 18 Jul 2021 20:18:06 +0000 (14:18 -0600)]
sandbox: tpm: Support extending a PCR multiple times

It is fairly easy to handle this case and it makes the emulator more
useful, since PCRs are commonly extended several times.

Add support for this, using U-Boot's sha256 support.

For now sandbox only supports a single PCR, but that is enough for the
tests that currently exist.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Correct handling of SANDBOX_TPM_PCR_NB
Simon Glass [Sun, 18 Jul 2021 20:18:05 +0000 (14:18 -0600)]
sandbox: tpm: Correct handling of SANDBOX_TPM_PCR_NB

This is the number of PCRs, so the current check is off by one. Also the
map itself should not be checked, just the resulting pcr_index, to avoid
confusing people who read the code.

Fix these problems.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Support storing device state in tpm2
Simon Glass [Sun, 18 Jul 2021 20:18:04 +0000 (14:18 -0600)]
sandbox: tpm: Support storing device state in tpm2

At present the tpm2 emulator does not support storing the device state.
Add this so we can handle the normal vboot flow through the sandbox
executables (VPL->SPL etc.) with the TPM contents staying in place.

Note: sandbox has not yet been converted to use livetree for the state
information, since livetree does not yet support writing to the tree.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Support nvdata in TPM2
Simon Glass [Sun, 18 Jul 2021 20:18:03 +0000 (14:18 -0600)]
sandbox: tpm: Support nvdata in TPM2

Add support for this feature in the TPM2 emulator, to support Chromium OS
vboot.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Track whether the state is valid
Simon Glass [Sun, 18 Jul 2021 20:18:02 +0000 (14:18 -0600)]
sandbox: tpm: Track whether the state is valid

Add checking as to whether the current TPM state is valid, so we can
implement reading/writing the state.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Finish comments for struct sandbox_tpm2
Simon Glass [Sun, 18 Jul 2021 20:18:01 +0000 (14:18 -0600)]
sandbox: tpm: Finish comments for struct sandbox_tpm2

Tidy up the missing comments for this struct.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Correct handling of get-capability
Simon Glass [Sun, 18 Jul 2021 20:18:00 +0000 (14:18 -0600)]
sandbox: tpm: Correct handling of get-capability

This function current handles the kernel case incorrectly. Fix it, and
use the shorter TPM_HDR_LEN while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Support the define-space command
Simon Glass [Sun, 18 Jul 2021 20:17:59 +0000 (14:17 -0600)]
sandbox: tpm: Support the define-space command

Add support for this command, moving away from the previous approach of
hard-coding the initial data in the driver, now that the kernel-space data
has to be set up by the higher-level vboot code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Tidy up reading and writing of device state
Simon Glass [Sun, 18 Jul 2021 20:17:58 +0000 (14:17 -0600)]
sandbox: tpm: Tidy up reading and writing of device state

At present this code assumes that the TPM data has been read but this may
not be the case. Refactor the code to use a separate pointer so we know
the current state of the data.

Add error checking for the data size.

Signed-off-by: Simon Glass <sjg@chromium.org>
2 years agosandbox: tpm: Split out common nvdata code
Simon Glass [Sun, 18 Jul 2021 20:17:57 +0000 (14:17 -0600)]
sandbox: tpm: Split out common nvdata code

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>
2 years agocommon: board_r: print error if binman_init fails
Tim Harvey [Fri, 16 Jul 2021 22:44:12 +0000 (15:44 -0700)]
common: board_r: print error if binman_init fails

Display an error if binman_init fails.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
2 years agodoc: riscv: flashing SiFive boards
Heinrich Schuchardt [Wed, 28 Jul 2021 08:52:53 +0000 (10:52 +0200)]
doc: riscv: flashing SiFive boards

We should not use /dev/sda and /dev/sdb in our examples. Users might
inadvertently mess up their workstation. Use /dev/sdX instead.

Remove console output like '# ' and '> ' which makes copying hard.

Set example language to bash for correct syntax-highlighting.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
iewed-by: Bin Meng <bmeng.cn@gmail.com>

2 years agolib: disable CONFIG_SPL_HEXDUMP by default
Heinrich Schuchardt [Sat, 24 Jul 2021 15:35:46 +0000 (17:35 +0200)]
lib: disable CONFIG_SPL_HEXDUMP by default

CONFIG_HEXDUMP is needed to display UEFI variables using 'printenv -e'.

Enabling CONFIG_SPL_HEXDUMP only makes sense for debugging purposes.
Hence CONFIG_SPL_HEXDUMP should not be enabled by default.

The following boards currently have CONFIG_SPL_HEXDUMP=y. This includes
boards that don't use SPL at all.

axm_defconfig
imx8mm-cl-iot-gate_defconfig
imx8mm_venice_defconfig
imxrt1020-evk_defconfig
imxrt1050-evk_defconfig
kontron_sl28_defconfig
kp_imx53_defconfig
lx2160ardb_tfa_stmm_defconfig
mt7622_rfb_defconfig
octeon_ebb7304_defconfig
octeon_nic23_defconfig
qemu_arm64_defconfig
qemu_arm_defconfig
qemu-riscv32_defconfig
qemu-riscv32_smode_defconfig
qemu-riscv64_defconfig
qemu-riscv64_smode_defconfig
qemu-x86_64_defconfig
qemu-x86_defconfig
sandbox64_defconfig
sandbox_defconfig
stm32mp15_basic_defconfig
stm32mp15_trusted_defconfig
synquacer_developerbox_defconfig
taurus_defconfig
xilinx_versal_virt_defconfig

The patch only keeps it enabled on

sandbox_spl_defconfig

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2 years agovideo: buffer overrun in TrueType console
Heinrich Schuchardt [Sun, 28 Feb 2021 20:42:51 +0000 (21:42 +0100)]
video: buffer overrun in TrueType console

When scrolling the TrueType console a buffer overrun occurs.

Fixes: a29b012037cc ("video: Add a console driver that uses TrueType fonts")
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-sunxi
Tom Rini [Sun, 1 Aug 2021 00:51:24 +0000 (20:51 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-sunxi

- 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.

2 years agosunxi: decide the inclusion of SCP by SCP_ADDR existence
Icenowy Zheng [Thu, 22 Jul 2021 06:30:03 +0000 (14:30 +0800)]
sunxi: decide the inclusion of SCP by SCP_ADDR existence

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>
2 years agosunxi: A23/A33/H3: Move sun8i secure monitor to SRAM A2
Samuel Holland [Mon, 19 Apr 2021 03:21:41 +0000 (22:21 -0500)]
sunxi: A23/A33/H3: Move sun8i secure monitor to SRAM A2

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>
2 years agosunxi: Select environment MMC based on boot device
Samuel Holland [Mon, 19 Apr 2021 03:16:21 +0000 (22:16 -0500)]
sunxi: Select environment MMC based on boot device

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>
2 years agoMerge https://source.denx.de/u-boot/custodians/u-boot-marvell
Tom Rini [Sat, 31 Jul 2021 12:18:14 +0000 (08:18 -0400)]
Merge https://source.denx.de/u-boot/custodians/u-boot-marvell

- 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)

2 years agoserial: a37xx: Do not call get_ref_clk() in _debug_uart_init()
Pali Rohár [Mon, 26 Jul 2021 12:58:59 +0000 (14:58 +0200)]
serial: a37xx: Do not call get_ref_clk() in _debug_uart_init()

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>
2 years agoserial: a37xx: Use CONFIG_BAUDRATE for initializing early debug UART
Pali Rohár [Mon, 26 Jul 2021 12:58:58 +0000 (14:58 +0200)]
serial: a37xx: Use CONFIG_BAUDRATE for initializing early debug UART

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>
2 years agoarm: kirkwood: Dreamplug: Add DM SATA and remove IDE configs
Tony Dinh [Mon, 26 Jul 2021 06:01:20 +0000 (23:01 -0700)]
arm: kirkwood: Dreamplug: Add DM SATA and remove IDE configs

- 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>
2 years agoarm: kirkwood: Dreamplug: Use Ethernet PHY name and address from device tree
Tony Dinh [Mon, 26 Jul 2021 06:01:19 +0000 (23:01 -0700)]
arm: kirkwood: Dreamplug: Use Ethernet PHY name and address from device tree

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>
2 years agoarm: kirkwood: Dreamplug: Add DM Ethernet and DM SATA configs
Tony Dinh [Mon, 26 Jul 2021 06:01:18 +0000 (23:01 -0700)]
arm: kirkwood: Dreamplug: Add DM Ethernet and DM SATA configs

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>
2 years agoarm64: a37xx: pinctrl: Correct PWM pins definitions
Marek Behún [Fri, 23 Jul 2021 17:57:11 +0000 (19:57 +0200)]
arm64: a37xx: pinctrl: Correct PWM pins definitions

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>
2 years agokwbimage: Update help message about how to extract from an existing image
Pali Rohár [Fri, 23 Jul 2021 09:14:35 +0000 (11:14 +0200)]
kwbimage: Update help message about how to extract from an existing image

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>
2 years agokwbimage: Add support for extracting images via dumpimage tool
Pali Rohár [Fri, 23 Jul 2021 09:14:34 +0000 (11:14 +0200)]
kwbimage: Add support for extracting images via dumpimage tool

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>
2 years agoarm: mvebu: gdsys: Remove custom spl_board_init()
Pali Rohár [Fri, 23 Jul 2021 09:14:33 +0000 (11:14 +0200)]
arm: mvebu: gdsys: Remove custom spl_board_init()

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>
2 years agoarm: mvebu: Remove unused macro CONFIG_SYS_U_BOOT_OFFS
Pali Rohár [Fri, 23 Jul 2021 09:14:32 +0000 (11:14 +0200)]
arm: mvebu: Remove unused macro CONFIG_SYS_U_BOOT_OFFS

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>
2 years agotools: kwbimage: Remove v1 kwbimage SPL padding to CONFIG_SYS_U_BOOT_OFFS bytes
Pali Rohár [Fri, 23 Jul 2021 09:14:31 +0000 (11:14 +0200)]
tools: kwbimage: Remove v1 kwbimage SPL padding to CONFIG_SYS_U_BOOT_OFFS bytes

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>
2 years agoarm: mvebu: Remove legacy U-Boot header from kwbimage v1 files
Pali Rohár [Fri, 23 Jul 2021 09:14:30 +0000 (11:14 +0200)]
arm: mvebu: Remove legacy U-Boot header from kwbimage v1 files

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>
2 years agoarm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header
Pali Rohár [Fri, 23 Jul 2021 09:14:29 +0000 (11:14 +0200)]
arm: mvebu: Load U-Boot proper binary in SPL code based on kwbimage header

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>
2 years agoSPL: Add support for parsing board / BootROM specific image types
Pali Rohár [Fri, 23 Jul 2021 09:14:28 +0000 (11:14 +0200)]
SPL: Add support for parsing board / BootROM specific image types

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>
2 years agoSPL: Add support for specifying offset between header and image
Pali Rohár [Fri, 23 Jul 2021 09:14:27 +0000 (11:14 +0200)]
SPL: Add support for specifying offset between header and image

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>
2 years agoarm: mvebu: Use U-Boot's SPL BootROM framework for booting from NAND/UART
Pali Rohár [Fri, 23 Jul 2021 09:14:26 +0000 (11:14 +0200)]
arm: mvebu: Use U-Boot's SPL BootROM framework for booting from NAND/UART

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>
2 years agoarm: mvebu: Implement return_to_bootrom() via U-Boot's SPL framework
Pali Rohár [Fri, 23 Jul 2021 09:14:25 +0000 (11:14 +0200)]
arm: mvebu: Implement return_to_bootrom() via U-Boot's SPL framework

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>
2 years agoarm: mvebu: Mark return_to_bootrom() as a noreturn function
Pali Rohár [Fri, 23 Jul 2021 09:14:24 +0000 (11:14 +0200)]
arm: mvebu: Mark return_to_bootrom() as a noreturn function

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>
2 years agoarm: mvebu: Fix return_to_bootrom()
Pali Rohár [Fri, 23 Jul 2021 09:14:23 +0000 (11:14 +0200)]
arm: mvebu: Fix return_to_bootrom()

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>
2 years agotools: kwboot: Fix checking image header version
Pali Rohár [Fri, 23 Jul 2021 09:14:22 +0000 (11:14 +0200)]
tools: kwboot: Fix checking image header version

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>
2 years agotools: kwboot: Check for v1 header size
Pali Rohár [Fri, 23 Jul 2021 09:14:21 +0000 (11:14 +0200)]
tools: kwboot: Check for v1 header size

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>
2 years agotools: kwboot: Cosmetic fix - add missing curly brackets
Pali Rohár [Fri, 23 Jul 2021 09:14:20 +0000 (11:14 +0200)]
tools: kwboot: Cosmetic fix - add missing curly brackets

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>
2 years agotools: kwboot: Print trailing newline after terminal is terminated
Pali Rohár [Fri, 23 Jul 2021 09:14:19 +0000 (11:14 +0200)]
tools: kwboot: Print trailing newline after terminal is terminated

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>
2 years agotools: kwboot: Fix restoring terminal
Pali Rohár [Fri, 23 Jul 2021 09:14:18 +0000 (11:14 +0200)]
tools: kwboot: Fix restoring terminal

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>
2 years agotools: kwboot: Fix wrong parameter passed to read()
Pali Rohár [Fri, 23 Jul 2021 09:14:17 +0000 (11:14 +0200)]
tools: kwboot: Fix wrong parameter passed to read()

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>
2 years agotools: dumpimage: Show error message when trying to extract data from kwbimage
Pali Rohár [Fri, 23 Jul 2021 09:14:16 +0000 (11:14 +0200)]
tools: dumpimage: Show error message when trying to extract data from kwbimage

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>
2 years agotools: dumpimage: Fix crashing when trying to extract data from kwbimage
Pali Rohár [Fri, 23 Jul 2021 09:14:15 +0000 (11:14 +0200)]
tools: dumpimage: Fix crashing when trying to extract data from kwbimage

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>
2 years agotools: kwbimage: Mark all BootROM structures __packed
Pali Rohár [Fri, 23 Jul 2021 09:14:14 +0000 (11:14 +0200)]
tools: kwbimage: Mark all BootROM structures __packed

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>
2 years agotools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38X
Pali Rohár [Fri, 23 Jul 2021 09:14:13 +0000 (11:14 +0200)]
tools: kwbimage: Do not hide usage of secure header under CONFIG_ARMADA_38X

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>
2 years agotools: kwbimage: Add support for a new DATA_DELAY command
Pali Rohár [Fri, 23 Jul 2021 09:14:12 +0000 (11:14 +0200)]
tools: kwbimage: Add support for a new DATA_DELAY command

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>
2 years agotools: kwbimage: Add support for DATA command also for v1 images
Pali Rohár [Fri, 23 Jul 2021 09:14:11 +0000 (11:14 +0200)]
tools: kwbimage: Add support for DATA command also for v1 images

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>