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