xref: /rk3399_ARM-atf/docs/plat/qti-msm8916.rst (revision fa145398b7efe1d4f5cf520e2ada56ae48f4aeac)
1*fa145398SStephan GerholdQualcomm Snapdragon 410 (MSM8916/APQ8016)
2*fa145398SStephan Gerhold=========================================
3*fa145398SStephan Gerhold
4*fa145398SStephan GerholdThe `Qualcomm Snapdragon 410`_ is Qualcomm's first 64-bit SoC, released in 2014
5*fa145398SStephan Gerholdwith four ARM Cortex-A53 cores. There are differents variants (MSM8916,
6*fa145398SStephan GerholdAPQ8016(E), ...) that are all very similar. A popular device based on APQ8016E
7*fa145398SStephan Gerholdis the `DragonBoard 410c`_ single-board computer, but the SoC is also used in
8*fa145398SStephan Gerholdvarious mid-range smartphones/tablets.
9*fa145398SStephan Gerhold
10*fa145398SStephan GerholdThe TF-A/BL31 port for MSM8916 provides a minimal, community-maintained
11*fa145398SStephan GerholdEL3 firmware. It is primarily based on information from the public
12*fa145398SStephan Gerhold`Snapdragon 410E Technical Reference Manual`_ combined with a lot of
13*fa145398SStephan Gerholdtrial and error to actually make it work.
14*fa145398SStephan Gerhold
15*fa145398SStephan Gerhold.. note::
16*fa145398SStephan Gerhold	Unlike the :doc:`QTI SC7180/SC7280 <qti>` ports, this port does **not**
17*fa145398SStephan Gerhold	make use of a proprietary binary components (QTISECLIB). It is fully
18*fa145398SStephan Gerhold	open-source but therefore limited to publicly documented hardware
19*fa145398SStephan Gerhold	components.
20*fa145398SStephan Gerhold
21*fa145398SStephan GerholdFunctionality
22*fa145398SStephan Gerhold-------------
23*fa145398SStephan Gerhold
24*fa145398SStephan GerholdThe BL31 port is much more minimal compared to the original firmware and
25*fa145398SStephan Gerholdtherefore expects the non-secure world (e.g. Linux) to manage more hardware,
26*fa145398SStephan Gerholdsuch as the SMMUs and all remote processors (RPM, WCNSS, Venus, Modem).
27*fa145398SStephan GerholdEverything except modem is currently functional with a slightly modified version
28*fa145398SStephan Gerholdof mainline Linux.
29*fa145398SStephan Gerhold
30*fa145398SStephan Gerhold.. warning::
31*fa145398SStephan Gerhold	This port is **not secure**. There is no special secure memory and the
32*fa145398SStephan Gerhold	used DRAM is available from both the non-secure and secure worlds.
33*fa145398SStephan Gerhold	Unfortunately, the hardware used for memory protection is not described
34*fa145398SStephan Gerhold	in the APQ8016E documentation.
35*fa145398SStephan Gerhold
36*fa145398SStephan GerholdThe port is primarily intended as a minimal PSCI implementation (without a
37*fa145398SStephan Gerholdseparate secure world) where this limitation is not a big problem. Booting
38*fa145398SStephan Gerholdsecondary CPU cores (PSCI ``CPU_ON``) is supported. Basic CPU core power
39*fa145398SStephan Gerholdmanagement (``CPU_SUSPEND``) is functional but still work-in-progress and
40*fa145398SStephan Gerholdwill be added later once ready.
41*fa145398SStephan Gerhold
42*fa145398SStephan GerholdBoot Flow
43*fa145398SStephan Gerhold---------
44*fa145398SStephan GerholdBL31 replaces the original ``tz`` firmware in the boot flow::
45*fa145398SStephan Gerhold
46*fa145398SStephan Gerhold	Boot ROM (PBL) -> SBL -> BL31 (EL3) -> U-Boot (EL2) -> Linux (EL2)
47*fa145398SStephan Gerhold
48*fa145398SStephan GerholdBy default, BL31 enters the non-secure world in EL2 AArch64 state at address
49*fa145398SStephan Gerhold``0x8f600000``. The original hypervisor firmware (``hyp``) is not used, you can
50*fa145398SStephan Gerholduse KVM or another hypervisor. The entry address is fixed in the BL31 binary
51*fa145398SStephan Gerholdbut can be changed using the ``PRELOADED_BL33_BASE`` make file parameter.
52*fa145398SStephan Gerhold
53*fa145398SStephan GerholdUsing an AArch64 bootloader (such as `U-Boot for DragonBoard 410c`_) is
54*fa145398SStephan Gerholdrecommended. AArch32 bootloaders (such as the original Little Kernel bootloader
55*fa145398SStephan Gerholdfrom Qualcomm) are not directly supported, although it is possible to use an EL2
56*fa145398SStephan Gerholdshim loader to temporarily switch to AArch32 state.
57*fa145398SStephan Gerhold
58*fa145398SStephan GerholdInstallation
59*fa145398SStephan Gerhold------------
60*fa145398SStephan GerholdFirst, setup the cross compiler for AArch64 and build TF-A for ``msm8916``::
61*fa145398SStephan Gerhold
62*fa145398SStephan Gerhold	$ make CROSS_COMPILE=aarch64-linux-gnu- PLAT=msm8916
63*fa145398SStephan Gerhold
64*fa145398SStephan GerholdThe BL31 ELF image is generated in ``build/msm8916/release/bl31/bl31.elf``.
65*fa145398SStephan GerholdThis image must be "signed" before flashing it, even if the board has secure
66*fa145398SStephan Gerholdboot disabled. In this case the signature does not provide any security,
67*fa145398SStephan Gerholdbut it provides the firmware with required metadata.
68*fa145398SStephan Gerhold
69*fa145398SStephan GerholdThe `DragonBoard 410c`_ does not have secure boot enabled by default. In this
70*fa145398SStephan Gerholdcase you can simply sign the ELF image using a randomly generated key. You can
71*fa145398SStephan Gerholduse e.g. `qtestsign`_::
72*fa145398SStephan Gerhold
73*fa145398SStephan Gerhold	$ ./qtestsign.py tz build/msm8916/release/bl31/bl31.elf
74*fa145398SStephan Gerhold
75*fa145398SStephan GerholdThen install the resulting ``build/msm8916/release/bl31/bl31-test-signed.mbn``
76*fa145398SStephan Gerholdto the ``tz`` partition on the device. BL31 should be running after a reboot.
77*fa145398SStephan Gerhold
78*fa145398SStephan Gerhold.. warning::
79*fa145398SStephan Gerhold	Do not flash incorrectly signed firmware on devices that have secure
80*fa145398SStephan Gerhold	boot enabled! Make sure that you have a way to recover the board in case
81*fa145398SStephan Gerhold	of problems (e.g. using EDL).
82*fa145398SStephan Gerhold
83*fa145398SStephan GerholdBoot Trace
84*fa145398SStephan Gerhold----------
85*fa145398SStephan GerholdBL31 prints some lines on the debug console UART2, which will usually look like
86*fa145398SStephan Gerholdthis (with ``DEBUG=1``, otherwise only the ``NOTICE`` lines are shown)::
87*fa145398SStephan Gerhold
88*fa145398SStephan Gerhold	...
89*fa145398SStephan Gerhold	S - DDR Frequency, 400 MHz
90*fa145398SStephan Gerhold	NOTICE:  BL31: v2.6(debug):v2.6
91*fa145398SStephan Gerhold	NOTICE:  BL31: Built : 20:00:00, Dec 01 2021
92*fa145398SStephan Gerhold	INFO:    BL31: Platform setup start
93*fa145398SStephan Gerhold	INFO:    ARM GICv2 driver initialized
94*fa145398SStephan Gerhold	INFO:    BL31: Platform setup done
95*fa145398SStephan Gerhold	INFO:    BL31: Initializing runtime services
96*fa145398SStephan Gerhold	INFO:    BL31: cortex_a53: CPU workaround for 819472 was applied
97*fa145398SStephan Gerhold	INFO:    BL31: cortex_a53: CPU workaround for 824069 was applied
98*fa145398SStephan Gerhold	INFO:    BL31: cortex_a53: CPU workaround for 826319 was applied
99*fa145398SStephan Gerhold	INFO:    BL31: cortex_a53: CPU workaround for 827319 was applied
100*fa145398SStephan Gerhold	INFO:    BL31: cortex_a53: CPU workaround for 835769 was applied
101*fa145398SStephan Gerhold	INFO:    BL31: cortex_a53: CPU workaround for disable_non_temporal_hint was applied
102*fa145398SStephan Gerhold	INFO:    BL31: cortex_a53: CPU workaround for 843419 was applied
103*fa145398SStephan Gerhold	INFO:    BL31: cortex_a53: CPU workaround for 1530924 was applied
104*fa145398SStephan Gerhold	INFO:    BL31: Preparing for EL3 exit to normal world
105*fa145398SStephan Gerhold	INFO:    Entry point address = 0x8f600000
106*fa145398SStephan Gerhold	INFO:    SPSR = 0x3c9
107*fa145398SStephan Gerhold
108*fa145398SStephan Gerhold	U-Boot 2021.10 (Dec 01 2021 - 20:00:00 +0000)
109*fa145398SStephan Gerhold	Qualcomm-DragonBoard 410C
110*fa145398SStephan Gerhold	...
111*fa145398SStephan Gerhold
112*fa145398SStephan Gerhold.. _Qualcomm Snapdragon 410: https://www.qualcomm.com/products/snapdragon-processors-410
113*fa145398SStephan Gerhold.. _DragonBoard 410c: https://www.96boards.org/product/dragonboard410c/
114*fa145398SStephan Gerhold.. _Snapdragon 410E Technical Reference Manual: https://developer.qualcomm.com/download/sd410/snapdragon-410e-technical-reference-manual.pdf
115*fa145398SStephan Gerhold.. _U-Boot for DragonBoard 410c: https://u-boot.readthedocs.io/en/latest/board/qualcomm/dragonboard410c.html
116*fa145398SStephan Gerhold.. _qtestsign: https://github.com/msm8916-mainline/qtestsign
117