Skip to content

Commit

Permalink
Remove git submodules (#63)
Browse files Browse the repository at this point in the history
* Remove git submodules

- Remove git submodules optee/ and rust/
- Initialize optee/ and rust/ submodules in setup.sh
- Update ci.yml

* Update the getting started documentation

* Remove .gitmodules
  • Loading branch information
DemesneGH committed Mar 17, 2022
1 parent 220fc84 commit c0b5801
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Expand Up @@ -37,6 +37,7 @@ jobs:
ln -sf /root/.cargo ~/.cargo
- name: Building
run: |
./setup.sh &&
source environment &&
make optee &&
. ~/.cargo/env &&
Expand All @@ -62,6 +63,7 @@ jobs:
ln -sf /root/.cargo ~/.cargo
- name: Building
run: |
./setup.sh &&
source environment &&
make optee &&
. ~/.cargo/env &&
Expand Down
21 changes: 0 additions & 21 deletions .gitmodules

This file was deleted.

46 changes: 33 additions & 13 deletions README.md
Expand Up @@ -14,8 +14,10 @@ crates). Teaclave TrustZone SDK is a sub-project of [Apache Teaclave (incubating

## Getting started

To get started, you need to clone the project, initialize related submodules,
and install building dependencies (The complete list of prerequisites can be found here: [OP-TEE Prerequisites](https://optee.readthedocs.io/en/latest/building/prerequisites.html)).
#### 1. Clone the project and install building dependencies

The complete list of prerequisites can be found here: [OP-TEE Prerequisites](https://optee.readthedocs.io/en/latest/building/prerequisites.html).

Alternatively, you can use a docker container built with our [Dockerfile](Dockerfile).

``` sh
Expand All @@ -32,16 +34,11 @@ $ sudo apt-get install android-tools-adb android-tools-fastboot autoconf \
# clone the project
$ git clone git@github.com:apache/incubator-teaclave-trustzone-sdk.git
$ cd incubator-teaclave-trustzone-sdk
# initialize related submodules and install Rust environment
$ ./setup.sh
```

By default, the `OPTEE_DIR` is `incubator-teaclave-trustzone-sdk/optee/`.
``` sh
# initialize OP-TEE submodule
$ git submodule update --init -- optee
```
If you already have [OP-TEE repository](https://github.com/OP-TEE)
#### 2. Install Rust environment and initialize related submodules

* By default, the `OPTEE_DIR` is `incubator-teaclave-trustzone-sdk/optee/`.If you already have [OP-TEE repository](https://github.com/OP-TEE)
cloned, you can set OP-TEE root directory:

``` sh
Expand All @@ -51,6 +48,16 @@ $ export OPTEE_DIR=path/to/your/optee/root/directory
Note that your OPTEE root directory should have `build/`, `optee_os/` and
`optee_client/` as sub-directory.



* Run the script as follows to install Rust environment and set up submodules in `optee/` and `rust/`.

```
$ ./setup.sh
```

#### 3. Set environment variables

Before building examples, the environment should be properly setup.

``` sh
Expand All @@ -65,28 +72,41 @@ $ export ARCH=arm
$ source environment
```

#### 4. Build OP-TEE libraries

Then, download ARM toolchains and build OP-TEE libraries. Note that the OP-TEE
target is QEMUv8, and you can modify the Makefile to other targets accordingly.

``` sh
$ make optee
```

At last, you can get started with our examples.
#### 5. Build Rust examples

Run this command to build all Rust examples:

``` sh
$ make examples
```

Collect all example CAs and TAs to `/incubator-teaclave-trustzone-sdk/out`:

``` sh
$ make examples-install
```

#### 6. Run Rust examples

Please read detailed
[instructions](https://teaclave.apache.org/trustzone-sdk-docs/getting-started-with-optee-for-qemu-armv8/)
to run these examples on OP-TEE for QEMU. For other supported devices, please find
more documents [here](https://optee.readthedocs.io/en/latest/general/platforms.html).

## Documentation

- [Getting Started with OPTEE for QEMU ARMv8](docs/getting-started-with-optee-for-qemu-armv8.md)
- [Overview of OP-TEE Rust Examples](docs/overview-of-optee-rust-examples.md)
- [Getting Started with OPTEE for QEMU ARMv8](https://teaclave.apache.org/trustzone-sdk-docs/getting-started-with-optee-for-qemu-armv8/)
- [Overview of OP-TEE Rust Examples](https://teaclave.apache.org/trustzone-sdk-docs/overview-of-optee-rust-examples/)
- [Debugging OP-TEE TA](https://teaclave.apache.org/trustzone-sdk-docs/debugging-optee-ta.md/)
- [Host API Reference](https://teaclave.apache.org/api-docs/trustzone-sdk/optee-teec/)
- [TA API Reference](https://teaclave.apache.org/api-docs/trustzone-sdk/optee-utee/)

Expand Down
1 change: 0 additions & 1 deletion optee/build
Submodule build deleted from 6a868e
1 change: 0 additions & 1 deletion optee/optee_client
Submodule optee_client deleted from 06db73
1 change: 0 additions & 1 deletion optee/optee_os
Submodule optee_os deleted from d0b742
1 change: 0 additions & 1 deletion rust/compiler-builtins
Submodule compiler-builtins deleted from 45a2e4
1 change: 0 additions & 1 deletion rust/libc
Submodule libc deleted from 1ddfbb
1 change: 0 additions & 1 deletion rust/rust
Submodule rust deleted from 6abda6
88 changes: 84 additions & 4 deletions setup.sh
Expand Up @@ -17,6 +17,9 @@
# specific language governing permissions and limitations
# under the License.

set -xe

##########################################
# install Rust and select a proper version
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2021-09-20
source $HOME/.cargo/env
Expand All @@ -27,7 +30,84 @@ rustup default 1.44.0 && cargo +1.44.0 install xargo
# switch to nightly
rustup default nightly-2021-09-20

# initialize Teaclave TrustZone SDK submodule
git submodule update --init -- rust
cd rust/compiler-builtins && git submodule update --init libm
cd ../rust && git submodule update --init library/stdarch && git submodule update --init library/backtrace
########################################################
# initialize submodules: optee_os / optee_client / build
OPTEE_RELEASE_VERSION=3.16.0

if [[ -z $OPTEE_DIR ]] || [[ $OPTEE_DIR==$PWD/optee ]]
then
OPTEE_DIR=$PWD/optee
echo optee dir: $OPTEE_DIR
OPTEE_SUBMODULES=("optee_os" "optee_client" "build")

if [ ! -d $OPTEE_DIR ]
then
mkdir $OPTEE_DIR
else
rm -r $OPTEE_DIR/*
fi

# download optee release
echo "Downloading optee release..."
for submodule in ${OPTEE_SUBMODULES[*]}
do
echo "Downloading $submodule..."
curl --retry 5 -s -S \
-L https://github.com/OP-TEE/$submodule/archive/refs/tags/$OPTEE_RELEASE_VERSION.tar.gz \
-o $OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz
if [ ! $? -eq 0 ]
then
rm $OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz && \
echo "Download failed" && \
exit 1
fi
echo "Uncompressing $submodule..."
mkdir -p $OPTEE_DIR/$submodule && \
tar zxf $OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz \
-C $OPTEE_DIR/$submodule --strip-components 1
if [ ! $? -eq 0 ]
then
rm $OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz && \
rm -r $OPTEE_DIR/$submodule && \
echo "Downloaded file is damaged" && \
exit 1
fi
rm $OPTEE_DIR/$OPTEE_RELEASE_VERSION.tar.gz
done
echo "Download finished"
else
echo "OPTEE_DIR has been set, omit to download optee submodules"
fi


########################################################
# initialize submodules: rust / compiler-builtins / libc
RUST_COMMIT_ID=6abda667852184641149d34da4730d96ba4f7d31
COMPILER_BUILTINS_COMMIT_ID=45a2e4996fe732172004b292b07397f9a02265ab
LIBC_COMMIT_ID=1ddfbbbc190bec0f5ec32b08e97585b34d0c6b09

if [ ! -d rust/ ]
then
mkdir rust/
else
rm -r rust/*
fi

cd rust

git clone https://github.com/mesalock-linux/rust.git && \
(cd rust && \
git checkout $RUST_COMMIT_ID && \
git submodule update --init library/stdarch && \
git submodule update --init library/backtrace)

git clone https://github.com/mesalock-linux/compiler-builtins.git && \
(cd compiler-builtins && \
git checkout $COMPILER_BUILTINS_COMMIT_ID && \
git submodule update --init libm)

git clone https://github.com/mesalock-linux/libc.git && \
(cd libc && \
git checkout $LIBC_COMMIT_ID)

echo "Rust submodules initialized"

0 comments on commit c0b5801

Please sign in to comment.