xref: /arm-trusted-firmware/docs/plat/qti-msm8916.rst (revision 91f16700b400a8c0651d24a598fc48ee2997a0d7)
1*91f16700SchasingluluQualcomm MSM8916
2*91f16700Schasinglulu================
3*91f16700SchasingluluThe MSM8916 platform port in TF-A supports multiple similar Qualcomm SoCs:
4*91f16700Schasinglulu
5*91f16700Schasinglulu+-----------------------+----------------+-------------------+-----------------+
6*91f16700Schasinglulu| System-on-Chip (SoC)  | TF-A Platform  | Application CPU   | Supports        |
7*91f16700Schasinglulu+=======================+================+===================+=================+
8*91f16700Schasinglulu| `Snapdragon 410`_     |``PLAT=msm8916``| 4x ARM Cortex-A53 | AArch64/AArch32 |
9*91f16700Schasinglulu| (MSM8x16, APQ8016(E)) |                |                   |                 |
10*91f16700Schasinglulu| (`DragonBoard 410c`_) |                |                   |                 |
11*91f16700Schasinglulu+-----------------------+----------------+-------------------+-----------------+
12*91f16700Schasinglulu| `Snapdragon 615`_     |``PLAT=msm8939``| 4x ARM Cortex-A53 | AArch64/AArch32 |
13*91f16700Schasinglulu| (MSM8x39, APQ8039)    |                | 4x ARM Cortex-A53 |                 |
14*91f16700Schasinglulu+-----------------------+----------------+-------------------+-----------------+
15*91f16700Schasinglulu| `Snapdragon 210`_     |``PLAT=msm8909``| 4x ARM Cortex-A7  | AArch32 only    |
16*91f16700Schasinglulu| (MSM8x09, APQ8009)    |                |                   |                 |
17*91f16700Schasinglulu+-----------------------+----------------+-------------------+-----------------+
18*91f16700Schasinglulu| `Snapdragon X5 Modem`_|``PLAT=mdm9607``| 1x ARM Cortex-A7  | AArch32 only    |
19*91f16700Schasinglulu| (MDM9x07)             |                |                   |                 |
20*91f16700Schasinglulu+-----------------------+----------------+-------------------+-----------------+
21*91f16700Schasinglulu
22*91f16700SchasingluluIt provides a minimal, community-maintained EL3 firmware and PSCI implementation,
23*91f16700Schasinglulubased on information from the public `Snapdragon 410E Technical Reference Manual`_
24*91f16700Schasinglulucombined with a lot of trial and error to actually make it work.
25*91f16700Schasinglulu
26*91f16700Schasinglulu.. note::
27*91f16700Schasinglulu	Unlike the :doc:`QTI SC7180/SC7280 <qti>` ports, this port does **not**
28*91f16700Schasinglulu	make use of a proprietary binary components (QTISECLIB). It is fully
29*91f16700Schasinglulu	open-source but therefore limited to publicly documented hardware
30*91f16700Schasinglulu	components.
31*91f16700Schasinglulu
32*91f16700SchasingluluFunctionality
33*91f16700Schasinglulu-------------
34*91f16700SchasingluluThe TF-A port is much more minimal compared to the original firmware and
35*91f16700Schasinglulutherefore expects the non-secure world (e.g. Linux) to manage more hardware,
36*91f16700Schasinglulusuch as the SMMUs and all remote processors (RPM, WCNSS, Venus, Modem).
37*91f16700SchasingluluEverything except modem is currently functional with a slightly modified version
38*91f16700Schasingluluof mainline Linux.
39*91f16700Schasinglulu
40*91f16700Schasinglulu.. warning::
41*91f16700Schasinglulu	This port is **not secure**. There is no special secure memory and the
42*91f16700Schasinglulu	used DRAM is available from both the non-secure and secure worlds.
43*91f16700Schasinglulu	Unfortunately, the hardware used for memory protection is not described
44*91f16700Schasinglulu	in the APQ8016E documentation.
45*91f16700Schasinglulu
46*91f16700SchasingluluThe port is primarily intended as a minimal PSCI implementation (without a
47*91f16700Schasingluluseparate secure world) where this limitation is not a big problem. Booting
48*91f16700Schasinglulusecondary CPU cores (PSCI ``CPU_ON``) is supported. Basic CPU core power
49*91f16700Schasinglulumanagement (``CPU_SUSPEND``) is functional but still work-in-progress and
50*91f16700Schasingluluwill be added later once ready.
51*91f16700Schasinglulu
52*91f16700SchasingluluBoot Flow
53*91f16700Schasinglulu---------
54*91f16700SchasingluluBL31 (AArch64) or BL32/SP_MIN (AArch32) replaces the original ``tz`` firmware
55*91f16700Schasingluluin the boot flow::
56*91f16700Schasinglulu
57*91f16700Schasinglulu	Boot ROM (PBL) -> SBL -> BL31 (EL3) -> U-Boot (EL2) -> Linux (EL2)
58*91f16700Schasinglulu
59*91f16700SchasingluluAfter initialization the normal world starts at a fixed entry address in EL2/HYP
60*91f16700Schasinglulumode, configured using ``PRELOADED_BL33_BASE``. At runtime, it is expected that
61*91f16700Schasingluluthe normal world bootloader was already loaded into RAM by a previous firmware
62*91f16700Schasinglulucomponent (usually SBL) and that it is capable of running in EL2/HYP mode.
63*91f16700Schasinglulu
64*91f16700Schasinglulu`U-Boot for DragonBoard 410c`_ is recommended if possible. The original Little
65*91f16700SchasingluluKernel-based bootloader from Qualcomm does not support EL2/HYP, but can be
66*91f16700Schasinglulubooted using an additional shim loader such as `tfalkstub`_.
67*91f16700Schasinglulu
68*91f16700SchasingluluBuild
69*91f16700Schasinglulu-----
70*91f16700SchasingluluIt is possible to build for either AArch64 or AArch32. Some platforms use 32-bit
71*91f16700SchasingluluCPUs that only support AArch32 (see table above). For all others AArch64 is the
72*91f16700Schasinglulupreferred build option.
73*91f16700Schasinglulu
74*91f16700SchasingluluAArch64 (BL31)
75*91f16700Schasinglulu^^^^^^^^^^^^^^
76*91f16700SchasingluluSetup the cross compiler for AArch64 and build BL31 for one of the platforms in
77*91f16700Schasingluluthe table above::
78*91f16700Schasinglulu
79*91f16700Schasinglulu	$ make CROSS_COMPILE=aarch64-none-elf- PLAT=...
80*91f16700Schasinglulu
81*91f16700SchasingluluThe BL31 ELF image is generated in ``build/$PLAT/release/bl31/bl31.elf``.
82*91f16700Schasinglulu
83*91f16700SchasingluluAArch32 (BL32/SP_MIN)
84*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^
85*91f16700SchasingluluSetup the cross compiler for AArch32 and build BL32 with SP_MIN for one of the
86*91f16700Schasingluluplatforms in the table above::
87*91f16700Schasinglulu
88*91f16700Schasinglulu	$ make CROSS_COMPILE=arm-none-eabi- PLAT=... ARCH=aarch32 AARCH32_SP=sp_min
89*91f16700Schasinglulu
90*91f16700SchasingluluThe BL32 ELF image is generated in ``build/$PLAT/release/bl32/bl32.elf``.
91*91f16700Schasinglulu
92*91f16700SchasingluluBuild Options
93*91f16700Schasinglulu-------------
94*91f16700SchasingluluSome options can be changed at build time by adding them to the make command line:
95*91f16700Schasinglulu
96*91f16700Schasinglulu * ``QTI_UART_NUM``: Number of UART controller to use for debug output and crash
97*91f16700Schasinglulu   reports. This must be the same UART as used by earlier boot firmware since
98*91f16700Schasinglulu   the UART controller does not get fully initialized at the moment. Defaults to
99*91f16700Schasinglulu   the usual debug UART used for the platform (see ``platform.mk``).
100*91f16700Schasinglulu * ``QTI_RUNTIME_UART``: By default (``0``) the UART is only used for the boot
101*91f16700Schasinglulu   process and critical crashes. If set to ``1`` it is also used for runtime
102*91f16700Schasinglulu   messages. Note that this option can only be used if the UART is reserved in
103*91f16700Schasinglulu   the normal world and the necessary clocks remain enabled.
104*91f16700Schasinglulu
105*91f16700SchasingluluThe memory region used for the different firmware components is not fixed and
106*91f16700Schasinglulucan be changed on the make command line. The default values match the addresses
107*91f16700Schasingluluused by the original firmware (see ``platform.mk``):
108*91f16700Schasinglulu
109*91f16700Schasinglulu * ``PRELOADED_BL33_BASE``: The entry address for the normal world. Usually
110*91f16700Schasinglulu   refers to the first bootloader (e.g. U-Boot).
111*91f16700Schasinglulu * ``BL31_BASE``: Base address for the BL31 firmware component. Must point to
112*91f16700Schasinglulu   a 64K-aligned memory region with at least 128 KiB space that is permanently
113*91f16700Schasinglulu   reserved in the normal world.
114*91f16700Schasinglulu * ``BL32_BASE``: Base address for the BL32 firmware component.
115*91f16700Schasinglulu
116*91f16700Schasinglulu   * **AArch32:** BL32 is used in place of BL31, so the option is equivalent to
117*91f16700Schasinglulu     ``BL31_BASE``.
118*91f16700Schasinglulu   * **AArch64:** Secure-EL1 Payload. Defaults to using 128 KiB of space
119*91f16700Schasinglulu     directly after BL31. For testing only, the port is primarily intended as
120*91f16700Schasinglulu     a minimal PSCI implementation without a separate secure world.
121*91f16700Schasinglulu
122*91f16700SchasingluluInstallation
123*91f16700Schasinglulu------------
124*91f16700SchasingluluThe ELF image must be "signed" before flashing it, even if the board has secure
125*91f16700Schasingluluboot disabled. In this case the signature does not provide any security,
126*91f16700Schasinglulubut it provides the firmware with required metadata.
127*91f16700Schasinglulu
128*91f16700SchasingluluThe `DragonBoard 410c`_ does not have secure boot enabled by default. In this
129*91f16700Schasinglulucase you can simply sign the ELF image using a randomly generated key. You can
130*91f16700Schasingluluuse e.g. `qtestsign`_::
131*91f16700Schasinglulu
132*91f16700Schasinglulu	$ ./qtestsign.py tz build/msm8916/release/bl31/bl31.elf
133*91f16700Schasinglulu
134*91f16700SchasingluluThen install the resulting ``build/msm8916/release/bl31/bl31-test-signed.mbn``
135*91f16700Schasingluluto the ``tz`` partition on the device. BL31 should be running after a reboot.
136*91f16700Schasinglulu
137*91f16700Schasinglulu.. note::
138*91f16700Schasinglulu	On AArch32 the ELF image is called ``bl32.elf``.
139*91f16700Schasinglulu	The installation procedure is identical.
140*91f16700Schasinglulu
141*91f16700Schasinglulu.. warning::
142*91f16700Schasinglulu	Do not flash incorrectly signed firmware on devices that have secure
143*91f16700Schasinglulu	boot enabled! Make sure that you have a way to recover the board in case
144*91f16700Schasinglulu	of problems (e.g. using EDL).
145*91f16700Schasinglulu
146*91f16700SchasingluluBoot Trace
147*91f16700Schasinglulu----------
148*91f16700Schasinglulu
149*91f16700SchasingluluAArch64 (BL31)
150*91f16700Schasinglulu^^^^^^^^^^^^^^
151*91f16700SchasingluluBL31 prints some lines on the debug console, which will usually look like this
152*91f16700Schasinglulu(with ``DEBUG=1``, otherwise only the ``NOTICE`` lines are shown)::
153*91f16700Schasinglulu
154*91f16700Schasinglulu	...
155*91f16700Schasinglulu	S - DDR Frequency, 400 MHz
156*91f16700Schasinglulu	NOTICE:  BL31: v2.6(debug):v2.6
157*91f16700Schasinglulu	NOTICE:  BL31: Built : 20:00:00, Dec 01 2021
158*91f16700Schasinglulu	INFO:    BL31: Platform setup start
159*91f16700Schasinglulu	INFO:    ARM GICv2 driver initialized
160*91f16700Schasinglulu	INFO:    BL31: Platform setup done
161*91f16700Schasinglulu	INFO:    BL31: Initializing runtime services
162*91f16700Schasinglulu	INFO:    BL31: cortex_a53: CPU workaround for 819472 was applied
163*91f16700Schasinglulu	INFO:    BL31: cortex_a53: CPU workaround for 824069 was applied
164*91f16700Schasinglulu	INFO:    BL31: cortex_a53: CPU workaround for 826319 was applied
165*91f16700Schasinglulu	INFO:    BL31: cortex_a53: CPU workaround for 827319 was applied
166*91f16700Schasinglulu	INFO:    BL31: cortex_a53: CPU workaround for 835769 was applied
167*91f16700Schasinglulu	INFO:    BL31: cortex_a53: CPU workaround for disable_non_temporal_hint was applied
168*91f16700Schasinglulu	INFO:    BL31: cortex_a53: CPU workaround for 843419 was applied
169*91f16700Schasinglulu	INFO:    BL31: cortex_a53: CPU workaround for 1530924 was applied
170*91f16700Schasinglulu	INFO:    BL31: Preparing for EL3 exit to normal world
171*91f16700Schasinglulu	INFO:    Entry point address = 0x8f600000
172*91f16700Schasinglulu	INFO:    SPSR = 0x3c9
173*91f16700Schasinglulu
174*91f16700Schasinglulu	U-Boot 2021.10 (Dec 01 2021 - 20:00:00 +0000)
175*91f16700Schasinglulu	Qualcomm-DragonBoard 410C
176*91f16700Schasinglulu	...
177*91f16700Schasinglulu
178*91f16700SchasingluluAArch32 (BL32/SP_MIN)
179*91f16700Schasinglulu^^^^^^^^^^^^^^^^^^^^^
180*91f16700SchasingluluBL32/SP_MIN prints some lines on the debug console, which will usually look like
181*91f16700Schasingluluthis (with ``DEBUG=1``, otherwise only the ``NOTICE`` lines are shown)::
182*91f16700Schasinglulu
183*91f16700Schasinglulu	...
184*91f16700Schasinglulu	S - DDR Frequency, 400 MHz
185*91f16700Schasinglulu	NOTICE:  SP_MIN: v2.8(debug):v2.8
186*91f16700Schasinglulu	NOTICE:  SP_MIN: Built : 23:03:31, Mar 31 2023
187*91f16700Schasinglulu	INFO:    SP_MIN: Platform setup start
188*91f16700Schasinglulu	INFO:    ARM GICv2 driver initialized
189*91f16700Schasinglulu	INFO:    SP_MIN: Platform setup done
190*91f16700Schasinglulu	INFO:    SP_MIN: Initializing runtime services
191*91f16700Schasinglulu	INFO:    BL32: cortex_a53: CPU workaround for 819472 was applied
192*91f16700Schasinglulu	INFO:    BL32: cortex_a53: CPU workaround for 824069 was applied
193*91f16700Schasinglulu	INFO:    BL32: cortex_a53: CPU workaround for 826319 was applied
194*91f16700Schasinglulu	INFO:    BL32: cortex_a53: CPU workaround for 827319 was applied
195*91f16700Schasinglulu	INFO:    BL32: cortex_a53: CPU workaround for disable_non_temporal_hint was applied
196*91f16700Schasinglulu	INFO:    SP_MIN: Preparing exit to normal world
197*91f16700Schasinglulu	INFO:    Entry point address = 0x86400000
198*91f16700Schasinglulu	INFO:    SPSR = 0x1da
199*91f16700Schasinglulu	Android Bootloader - UART_DM Initialized!!!
200*91f16700Schasinglulu	[0] welcome to lk
201*91f16700Schasinglulu	...
202*91f16700Schasinglulu
203*91f16700Schasinglulu.. _Snapdragon 210: https://www.qualcomm.com/products/snapdragon-processors-210
204*91f16700Schasinglulu.. _Snapdragon 410: https://www.qualcomm.com/products/snapdragon-processors-410
205*91f16700Schasinglulu.. _Snapdragon 615: https://www.qualcomm.com/products/snapdragon-processors-615
206*91f16700Schasinglulu.. _Snapdragon X5 Modem: https://www.qualcomm.com/products/snapdragon-modems-4g-lte-x5
207*91f16700Schasinglulu.. _DragonBoard 410c: https://www.96boards.org/product/dragonboard410c/
208*91f16700Schasinglulu.. _Snapdragon 410E Technical Reference Manual: https://developer.qualcomm.com/download/sd410/snapdragon-410e-technical-reference-manual.pdf
209*91f16700Schasinglulu.. _U-Boot for DragonBoard 410c: https://u-boot.readthedocs.io/en/latest/board/qualcomm/dragonboard410c.html
210*91f16700Schasinglulu.. _qtestsign: https://github.com/msm8916-mainline/qtestsign
211*91f16700Schasinglulu.. _tfalkstub: https://github.com/msm8916-mainline/tfalkstub
212