Commit graph

168 commits

Author SHA1 Message Date
Manish Pandey
a97e1f9747 Merge changes from topic "early_console" into integration
* changes:
  feat(stm32mp2): use early traces
  feat(st-bsec): use early traces
  refactor(st): replace STM32MP_EARLY_CONSOLE with EARLY_CONSOLE
  feat(console): introduce EARLY_CONSOLE
  feat(bl32): create an sp_min_setup function
2024-05-08 23:12:11 +02:00
Yann Gautier
94cad75a35 refactor(st): replace STM32MP_EARLY_CONSOLE with EARLY_CONSOLE
Now that EARLY_CONSOLE is generic, use it instead of the ST flag.
Remove stm32mp_setup_early_console() calls as it is done in common TF-A
code.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Icac29b62a6267303cb5c679d15847c013ead1d23
2024-04-24 15:44:28 +02:00
Yann Gautier
e494afc05f feat(stm32mp2): add ddr-fw parameter for fiptool
When generating fiptool for STM32MP2, a new parameter is added to
put DDR firmware inside the FIP.

To avoid duplicating fiptool platform files, move
tools/fiptool/plat_fiptool/st/stm32mp1 files in their parent directory
and move plat_def_fip_uuid.h in in plat/st/common/include.

Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com>
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I1dd796847869e2bfb6ee8c2bcef25c595fa5197a
2024-04-09 14:55:22 +02:00
laurenw-arm
f7c5ec1eb9 refactor(mbedtls): remove mbedtls 2.x support
Deprecation notice was sent to the community and no objection was
raised, so removing mbedtls 2.x support.

Change-Id: Id3eb98b55692df98aabe6a7c5a5ec910222c8abd
Signed-off-by: Lauren Wehrmeister <lauren.wehrmeister@arm.com>
2024-03-13 10:26:07 -05:00
Sughosh Ganu
8d08a1df1e style(fwu): change the metadata fields to align with specification
Change the names of some FWU metadata structure members to have them
align with the wording used in the corresponding specification. Use
the GUID type instead of UUID as the fields described in the
specification are GUIDs. Make corresponding changes to the code that
accesses these fields. No functional changes are introduced by the
patch.

Change-Id: Id3544ed1633811b0eeee2bf99477f9b7e6667044
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2024-03-01 14:40:05 +05:30
Sughosh Ganu
6166051426 feat(st): add logic to boot the platform from an alternate bank
In a few scenarios, there is a need to boot the platform from an
alernate bank which is not the active bank. Call the API
fwu_get_alernate_boot_bank() to select an alternate bank to boot the
platform from. Calling this API function might be required in a couple
of cases. One, in the unlikely scenario of the active bank being in an
invalid state, or if the number of times the platform boots in trial
state exceeds a pre-set count.

Also add a debug print that indicates the bank that
the platform is booting from.

Change-Id: I688406540e64d1719af8d5c121821f5bb6335c06
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2024-03-01 14:40:05 +05:30
Sughosh Ganu
6e99fee43e feat(st): add a function to clear the FWU trial state counter
Add an API stm32_clear_fwu_trial_boot_cnt() function to clear the
trial state counter. This is called in the corner case scenario when
the active index is in an Invalid state, thus needing a reset of the
trial state counter.

Change-Id: I2980135da88d0d947c222655c7958b51eb572d69
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2024-03-01 14:40:05 +05:30
Sughosh Ganu
588b01b5e4 feat(st): get the state of the active bank directly
With version 2 of the FWU metadata structure, the state that a bank is
in can be obtained from the bank_state field in the top level
structure. Read the state of the active bank by referencing this field
directly, instead of making an API call.

Change-Id: Ib22c56acbe172923b1323c544801ded81f1598ec
Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
2024-03-01 14:19:56 +05:30
Mark Dykes
ef68521971 Merge "build: use toolchain identifiers in conditions" into integration 2024-02-20 16:06:52 +01:00
Mark Dykes
60dd8069bf Merge "build: use new toolchain variables for tools" into integration 2024-02-20 16:06:35 +01:00
Chris Kay
8620bd0b93 build: use toolchain identifiers in conditions
The toolchain refactor change introduces the `${toolchain}-${tool}-id`
variables, which provide identifiers for all of the toolchain tools used
by the build system. This change replaces the various conditions that
are in use to identify these tools based on the path with a standard set
of comparisons against these new identifier variables.

Change-Id: Ib60e592359fa6e415c19a012e68d660f87436ca7
Signed-off-by: Chris Kay <chris.kay@arm.com>
2024-02-06 11:14:52 +00:00
Chris Kay
ffb7742125 build: use new toolchain variables for tools
This change migrates the values of `CC`, `CPP`, `AS` and other toolchain
variables to the new `$(toolchain)-$(tool)` variables, which were
introduced by the toolchain refactor patch. These variables should be
equivalent to the values that they're replacing.

Change-Id: I644fe4ce82ef1894bed129ddb4b6ab94fb04985d
Signed-off-by: Chris Kay <chris.kay@arm.com>
2024-02-06 11:14:52 +00:00
Yann Gautier
9883833c90 refactor(st): move macros to common folder
As these definitions will be the same for STM32MP1 and STM32MP2, move
PLATFORM_MTD_MAX_PAGE_SIZE and DWL_BUFFER_SIZE macro definition to the
file: plat/st/common/include/stm32mp_common.h

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I480669d009d15fec753298f47b136e34fa240132
2024-02-05 09:25:02 +01:00
Yann Gautier
3007c72844 feat(st): do not directly call BSEC functions in common code
When STM32MP2 boots on Cortex-M33, the Cortex-A35 do no more have access
to BSEC peripheral. New static inline stm32_otp_* wrappers are added,
which just redirect to BSEC functions.

While at it remove a useless bsec.h include.

Change-Id: Ie0f917c02e48acf456634f455dae41805bf6adbf
Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
2024-01-18 11:30:42 +01:00
Yann Gautier
189db9486d feat(st): use stm32_get_otp_value_from_idx() in BL31
The shadowing of the OTP is done in BL2.
As for BL32 on AARCH32 systems, stm32_get_otp_value_from_idx()
should also use bsec_read_otp() in BL31.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: Ib406cfc154339e6d3cde3c925bc6e9416d77b689
2024-01-18 11:30:42 +01:00
Yann Gautier
9cd784db55 refactor(st): update test for closed chip
The function stm32mp_is_closed_device() is replaced with
stm32mp_check_closed_device(), which return an uint32_t, either
STM32MP_CHIP_SEC_OPEN or STM32MP_CHIP_SEC_CLOSED.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: Ie0790cdc36c4b6522083bc1f0e7c38e8061e6adf
2024-01-18 11:30:42 +01:00
Manish Pandey
13f54450c9 Merge "fix(st): properly check LOADADDR" into integration 2023-10-25 09:38:41 +02:00
Manish Pandey
3018854b5f Merge changes from topic "gcc_linker_aarch32" into integration
* changes:
  feat(st): support gcc as linker
  fix(build): allow gcc linker on Aarch32 platforms
2023-10-23 17:59:26 +02:00
Yann Gautier
9f72f5eac8 fix(st): properly check LOADADDR
LOADADDR variable is retrieved from line starting with RAM in map file.
But if the build path contains RAM, this keywords will appear several
times and the grep will fail. Correct that by really checking the line
starting with RAM thanks to grep '^RAM'.

Change-Id: I2ce23edb5255028b1a56ba45c16569a42ae21ae2
Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/tf-a/+/328648
2023-10-23 11:56:30 +02:00
Yann Gautier
7762531216 feat(st): support gcc as linker
One of the internal make rules for ST platforms uses the linker, but
with dedicated options for ld. Adapt the rule to check if the linker
is gcc and use updated options.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: If566dccfa329f9d34a80673a60c6fadd642a0231
2023-10-16 13:47:59 +02:00
laurenw-arm
6f3ca8ada6 fix(st): setting default KEY_SIZE
Setting default KEY_SIZE to 256 for ECDSA since it is currently being
set to 2048 by make_helpers/defaults.mk, which is an invalid size for
ECDSA

Change-Id: I4c0edf714dcd2a31d5e50ea060b1b5348167387d
Signed-off-by: Lauren Wehrmeister <lauren.wehrmeister@arm.com>
2023-10-13 10:12:57 -05:00
Yann Gautier
77ce6a561e fix(st): enable RTC clock before accessing nv counter
The plat_get_nv_ctr() retrieves the non-volatile counter value from
TAMP_COUNTR register in RTCTAMP peripheral. The clock needs to be
enabled before accessing it.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: I2e9fc2c7ac516d6f8624cc6c9d442ee85629bf9a
2023-09-27 18:41:46 +02:00
Yann Gautier
5c506c7375 fix(st): update comment on encryption key
On STM32MP2, the encryption key is 32 bytes, the key duplication
(done for 16 bytes OTP) is not done. Update the comment to precise that.

Change-Id: I6fc4d652fdd462808918e85f6e5bd0d68d10d436
Yann Gautier <yann.gautier@foss.st.com>
2023-09-27 18:41:46 +02:00
Yann Gautier
76e4fab000 fix(st): allow crypto lib compilation in aarch64
Cast len with size_t, as it is unsigned long on Aarch64, and no more
unsigned int. Changing functions prototypes will not help as
.verify_signature awaits an unsigned int for its last parameter.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: I9332fd46301a9653af917802788fd97fe7c8a162
2023-09-27 16:21:58 +02:00
Yann Gautier
6fef0f67e4 fix(st-uart): allow 64 bit compilation
Change a %x in %zx to print a size_t variable.

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: I27ac3739f4a2ec3b33c34d2257fa858cbd1aae6a
2023-09-27 16:21:58 +02:00
Yann Gautier
a2500ab7ab fix(st): reduce MMC block_buffer
This buffer used by io_block should be the size on one block (512 bytes)
not 512*4 due to the use of uint32_t. Change that to uint8_t. This
reduces the size of BSS by 1.5KiB.

Change-Id: I8492f13f5386679b0c81efba66911422412782f9
Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
2023-09-27 16:21:58 +02:00
Sebastien PASDELOUP
2a4abe0b37 fix(st): update dt_get_ddr_size() type
Move to size_t to ensure a generic algorithm whatever the platform
architecture.

Signed-off-by: Nicolas Le Bayon <nicolas.le.bayon@st.com>
Change-Id: I7879367849ed86750dcff2b6a15f4b998bf6da18
Signed-off-by: Sebastien PASDELOUP <sebastien.pasdeloup-ext@st.com>
2023-09-27 16:21:58 +02:00
Yann Gautier
954048f436 refactor(st): move plat_image_load.c
This file is common for ST platforms, move it to plat/st/common/.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I7cefbc7f857d4ea63320042988c86d28e8a3cc09
2023-09-08 10:56:49 +02:00
Yann Gautier
b4939bef12 refactor(st): move some storage definitions to common part
Those storage macros are common to all STM32MPU chips, move them to
plat/st/common/include/stm32mp_io_storage.h

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: Id20ec00ba65edf9ec7a3a89adfda307c954c3cb6
2023-09-08 10:56:49 +02:00
Yann Gautier
dad7181698 feat(st): allow AARCH64 compilation for common code
Use read_sctlr_el3() for aarch64 code instead of read_sctlr().

Change-Id: I17b5d1f8cb2918de6ab1d2d56c15cabca0ed43fd
Signed-off-by: Yann Gautier <yann.gautier@st.com>
2023-09-08 10:56:49 +02:00
Yann Gautier
b0ce402457 refactor(st): rename QSPI macros
To have a more generic code, remove the Q from the *QSPI macros.

Change-Id: I2fa94b54054036c2175df3dfddcb76eec1119ad2
Signed-off-by: Yann Gautier <yann.gautier@st.com>
2023-09-08 10:56:49 +02:00
Nicolas Toromanoff
dfbadfd96b feat(stm32mp1): add FWU with boot from NOR-SPI
Refactor the SDCARD/EMMC FWU, to add the NOR-SPI use case.
SPI-NOR FWU won't use a real partition uuid to find the correct FIP,
but the UUID from metadata will correspond with a hardcoded offset in
the NOR.
While at it change some __unused keywords to __maybe_unused to ease
checkpatch.pl analysis.

Signed-off-by: Frank Bodammer <frank.bodammer@siemens.com>
Signed-off-by: Nicolas Toromanoff <nicolas.toromanoff@foss.st.com>
Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I2fe56ba8534a3c5dfaf8aeb16e7b286909883cc2
2023-06-22 11:37:00 +02:00
Yann Gautier
a9cb7d002d fix(st): flush UART at the end of uart_read()
Add a flush to ensure that the programmer get time to read the last
command sent.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Ic1f718d2754f27945f12c04563663b46274810a7
2023-05-30 15:39:50 +02:00
Yann Gautier
dee99f10b1 refactor(auth)!: unify REGISTER_CRYPTO_LIB
Have only one definition for REGISTER_CRYPTO_LIB macro, with all the
possible fields. Worst case adds 4 u64 to crypto_lib_desc.
While at it, correct some MISRA violations:
MC3R1.R12.1: (advisory) The precedence of operators within expressions
should be made explicit.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I1342a20e6eef2354753182c2a81ff959e03e5c81
2023-04-21 09:46:01 +01:00
Yann Gautier
4ac5b3949d refactor(auth): replace plat_convert_pk
Following discussions in the reviews of the patch that introduced
plat_convert_pk() function [1], it was decided to deprecate it to
avoid weak function declaration.
A new optional function pointer convert_pk is added to crypto_lib_desc_t.
A new function crypto_mod_convert_pk() will either call
crypto_lib_desc.convert_pk() if it is defined, or do the same
as what was done by the weak function otherwise.

[1] https://review.trustedfirmware.org/c/TF-A/trusted-firmware-a/+/17174

Signed-off-by: Yann Gautier <yann.gautier@foss.st.com>
Change-Id: I9358867f8bfd5e96b5ee238c066877da368e43c6
2023-04-21 09:46:01 +01:00
Yann Gautier
38ac8bbbe4 feat(st): mandate dtc version 1.4.7
To be able to use /omit-if-no-ref/ in DT files, the dtc version should
be at least 1.4.7. Update the makefile rule that checks dtc version.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I06bde289cf359a7383694e4c86991dfba781e7d7
2023-03-15 18:08:26 +01:00
Yann Gautier
9e1e82fce0 refactor(st): move mbedtls config files
The files stm32mp_mbedtls_config-{2,3}.h are moved to
plat/st/common/include directory as they could be shared with other ST
platforms. Their prefixes are changed from stm32mp1 to stm32mp.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I86e39481b6c8d2689c59eb9a351b77b3d6233b08
2023-03-15 18:08:26 +01:00
Yann Gautier
a430382ff7 refactor(st): add common mk files
Group configuration that could be common to several ST platforms.
Two common makefiles are created: common.mk for definitions and files
to compile, and common_rules.mk that gathers makefile compilation rules.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I7ea9b75c78e7d916854cdd984bbf921b1a46ebc4
2023-03-15 18:08:26 +01:00
Manish Pandey
7f31629d5d Merge changes from topic "deprecate_io_drivers" into integration
* changes:
  refactor(st): remove unused io_mmc driver
  docs: deprecate io_dummy driver
2023-01-16 16:45:37 +01:00
Yann Gautier
992dba08f1 refactor(st): move board info in common code
Create a function stm32_display_board_info() that will display ST
board information, from a parameter taken from OTP fuse. The code
is just moved from STM32MP1 part to common directory.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I9e12fe98b5aabc7791cf2c9d48a38fbf2b219f9e
2023-01-04 16:46:07 +01:00
Yann Gautier
c27d8c00fd refactor(st): move GIC code to common directory
The GIC v2 initialization code could be shared to other ST platforms.
The stm32mp1_gic.c file is then moved to common directory, and renamed
stm32mp_gic.c.
The functions are also prefixed with stm32mp_gic.

Change-Id: I60820823b470217d3a95cc569f941c2cb923dfa9
Signed-off-by: Yann Gautier <yann.gautier@st.com>
2023-01-04 16:43:12 +01:00
Yann Gautier
d8da13e543 refactor(st): move boot backup register management
This backup register used to pass boot information to BL33, has the
same mapping for ST platforms. Its management can then be moved to
common directory.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Ic873f099c1f87c6ba2825b4946365ae6a9687798
2023-01-04 16:42:49 +01:00
Yann Gautier
6954495992 refactor(st): remove unused io_mmc driver
This driver was used when STM32MP_USE_STM32IMAGE was enabled. This flag
is now removed, so the ST io_mmc driver can now be removed.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I3c1280dec8926b921534c81e143e86cfe6d4ee0d
2022-12-19 09:13:41 +01:00
Yann Gautier
70a422ba83 fix(st-crypto): set get_plain_pk_from_asn1() static
The issue is triggered when enabling -Wmissing-prototypes warning:
plat/st/common/stm32mp_crypto_lib.c:81:5: warning:
 no previous prototype for 'get_plain_pk_from_asn1'
 [-Wmissing-prototypes]
   81 | int get_plain_pk_from_asn1(void *pk_ptr, unsigned int pk_len,
      |     ^~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Ia36bbaba6e187ab47c203ddf0d7d017b210545cf
2022-12-13 10:54:07 +01:00
Yann Gautier
d1d8a9bad0 fix(st): make metadata_block_spec static
This issue was triggered by sparse tool:
plat/st/common/stm32mp_fconf_io.c:31:17: warning:
 symbol 'metadata_block_spec' was not declared. Should it be static?

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I283d15792ed0e7ac5181e18aaf54010a0e61b370
2022-12-13 09:48:56 +01:00
Yann Gautier
377846b65e fix(st): include utils.h to solve compilation error
If compiling with STM32MP13 with DECRYPTION_SUPPORT != none, there is
a compilation error:
plat/st/common/stm32mp_crypto_lib.c:
 In function 'plat_get_enc_key_info':
plat/st/common/stm32mp_crypto_lib.c:532:25:
 error: implicit declaration of function 'zeromem'
 [-Werror=implicit-function-declaration]
  532 |                         zeromem(key, *key_len);
      |                         ^~~~~~~

Adding #include <lib/utils.h> solves the error.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I0a20c5632f0379612149333e69875369d4cfca15
2022-12-12 15:15:38 +01:00
Yann Gautier
45d2d495e7 fix(st): use Boolean type for tests
This corrects MISRA C2012-14.4
The controlling expression of an if statement and the controlling
expression of an iteration-statement shall have essentially Boolean type.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Ibed7b87b50959f03dc5550dfaffacafd1d79feee
2022-12-07 14:20:01 +01:00
Yann Gautier
0ebaf22289 fix(st): rework secure-status check in fdt_get_status()
This corrects MISRA C2012-15.7:
All if...else if constructs shall be terminated with an else statement.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I3d893d0db0a448323270086923563147008c59b9
2022-12-07 14:20:01 +01:00
Yann Gautier
e7d75448b9 fix(st): use indices when counting GPIOs in DT
Fix MISRA C2012-18.4:
The +, -, += and -= operators should not be applied to an expression
of pointer type.
While at it, avoid computing twice the same value, by removing the
initial value computation outside the loop.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: Iabfe587bf72535541c94bfa341de10148aa58030
2022-12-07 14:20:01 +01:00
Yann Gautier
9c1aa1253c fix(st): add U suffix for unsigned numbers
This corrects MISRA c2012-7.2 violation:
A "u" or "U" suffix shall be applied to all integer constants that are
represented in an unsigned type.

Signed-off-by: Yann Gautier <yann.gautier@st.com>
Change-Id: I92b394572528e7179a314bbad4a032fd65053861
2022-12-07 14:20:01 +01:00