meta-st-stm32mp/recipes-security/optee/optee-os
Romuald JEANNE 48713aae88 OPTEE-OS-STM32MP: update archiver to manage dt config
When provided device tree is not one of the embedded one in official source
code, we need to set the right configuration switch:
CFG_STM32MP13=1 or CFG_STM32MP15=y
And also we need to manage the DRAM size to configure.

Change-Id: I7d3dc67b89ce2ff1c6330d3ce1b07a5e4344eb61
Signed-off-by: Romuald JEANNE <romuald.jeanne@st.com>
2022-06-23 10:47:25 +02:00
..
0001-3.16.0-stm32mp-r1.patch OPTEE: 3.16.0-stm32mp1-r1 2022-06-21 10:18:08 +02:00
README.HOW_TO.txt OPTEE-OS-STM32MP: update archiver to manage dt config 2022-06-23 10:47:25 +02:00
fonts.tar.gz OPTEE: 3.16.0-stm32mp1-r1 2022-06-21 10:18:08 +02:00

README.HOW_TO.txt

Compilation of Optee-os (Trusted Execution Environment):
1. Pre-requisite
2. Initialize cross-compilation via SDK
3. Prepare optee-os source code
4. Manage optee-os source code
5. Compile optee-os source code
6. Update software on board

----------------
1. Pre-requisite
----------------
OpenSTLinux SDK must be installed.

If you have never configured you git configuration:
    $ git config --global user.name "your_name"
    $ git config --global user.email "your_email@example.com"

---------------------------------------
2. Initialize cross-compilation via SDK
---------------------------------------
 Source SDK environment:
    $ source <path to SDK>/environment-setup-cortexa7t2hf-neon-vfpv4-ostl-linux-gnueabi

 To verify if your cross-compilation environment have put in place:
    $ set | grep CROSS
    CROSS_COMPILE=arm-ostl-linux-gnueabi-

Warning: the environment are valid only on the shell session where you have
 sourced the sdk environment.

--------------------------
3. Prepare optee-os source
--------------------------
If not already done, extract the sources from Developer Package tarball, for example:
$ tar xfJ en.SOURCES-stm32mp1-*.tar.xz

In the optee-os source directory (sources/*/##BP##-##PR##),
you have one optee-os source tarball, the patches and one Makefile:
   - ##BP##-##PR##.tar.xz
   - 00*.patch
   - Makefile.sdk

If you would like to have a git management for the source code move to
to section 4 [Management of optee-os source code with GIT].

Otherwise, to manage optee-os source code without git, you must extract the
tarball now and apply the patch:

    $> tar xf ##BP##-##PR##.tar.xz
    $> cd ##BP##
    $> tar xfz ../fonts.tar.gz
    $> for p in `ls -1 ../*.patch`; do patch -p1 < $p; done

You can now move to section 5 [Compile optee-os source code].

---------------------------------------
4. Manage optee-os source code with GIT
---------------------------------------
If you like to have a better management of change made on optee-os source,
you have 3 solutions to use git

4.1 Get STMicroelectronics optee-os source from GitHub
------------------------------------------------------
    URL: https://github.com/STMicroelectronics/optee_os.git
    Branch: ##ARCHIVER_ST_BRANCH##
    Revision: ##ARCHIVER_ST_REVISION##

    $ git clone https://github.com/STMicroelectronics/optee_os.git
    $ git checkout -b WORKING ##ARCHIVER_ST_REVISION##

4.2 Create Git from tarball
---------------------------
    $ cd <optee-os source>
    $ test -d .git || git init . && git add . && git commit -m "optee-os source code" && git gc
    $ git checkout -b WORKING
    $ tar xfz ../fonts.tar.gz
    $ for p in `ls -1 ../*.patch`; do git am $p; done

MANDATORY: You must update sources
    $ cd <directory to optee-os source code>
    $ chmod 755 scripts/bin_to_c.py

4.3 Get Git from community and apply STMicroelectronics patches
---------------------------------------------------------------
* With the optee-os source code from the OP-TEE git repositories:
    URL: git://github.com/OP-TEE/optee_os.git
    Branch: ##ARCHIVER_COMMUNITY_BRANCH##
    Revision: ##ARCHIVER_COMMUNITY_REVISION##

    $ git clone git://github.com/OP-TEE/optee_os.git
    $ cd optee_os
    $ git checkout -b WORKING ##ARCHIVER_COMMUNITY_REVISION##
    $ tar xfz <path to patch>/fonts.tar.gz
    $ for p in `ls -1 <path to patch>/*.patch`; do git am $p; done

MANDATORY: You must update sources
    $ cd <directory to optee-os source code>
    $ chmod 755 scripts/bin_to_c.py

-------------------------------
5. Compile optee-os source code
-------------------------------
Since OpenSTLinux activates FIP by default, FIP_artifacts directory path must be specified before launching compilation
  - In case of using SOURCES-xxxx.tar.gz of Developer package the FIP_DEPLOYDIR_ROOT must be set as below:
    $> export FIP_DEPLOYDIR_ROOT=$PWD/../../FIP_artifacts

To compile optee-os source code with default embedded config:
    $> make -f $PWD/../Makefile.sdk all
You can check the configuration throught 'help' target:
    $ make -f $PWD/../Makefile.sdk help

To compile only one of the provided devicetree:
    $ make -f $PWD/../Makefile.sdk CFG_EMBED_DTB_SOURCE_FILE=stm32mp157f-ev1 all
For a specific devicetree file you need to force not only the devicetree but also the DRAM size settings:
    $ make -f $PWD/../Makefile.sdk CFG_EMBED_DTB_SOURCE_FILE=<your_devicetree> OPTEE_DRAMSIZE=<dram_size_value_in_hexadecimal> all

By default, the build results for this component are available in $PWD/../deploy directory.
If needed, this deploy directory can be specified by added "DEPLOYDIR=<your_deploy_dir_path>" compilation option to the build command line above.
In case DEPLOYDIR=$FIP_DEPLOYDIR_ROOT/optee it overwrites files directly in FIP artifacts directory.

The generated FIP images are available in $FIP_DEPLOYDIR_ROOT/fip

---------------------------
6. Update software on board
---------------------------
Please use STM32CubeProgrammer and only tick the ssbl-boot and fip partitions (more informations on the wiki website http://wiki.st.com/stm32mpu)