DemesneGH commented on PR #193:
URL: 
https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/193#issuecomment-2911805038

   Updates:
   - Reorganized scripts into a new `scripts/` directory with subfolders 
`setup/` and `debug/`.
   - Dockerfile now reuses `scripts/setup/`, also allowing developers to 
customize the build environment by running the setup scripts manually when they 
doesn't want to use our docker.
   - Quick Debug: A new debug workflow is introduced—see details in the section 
below.
   - The `README` has not been updated yet in this review stage. Please see the 
below workflow.
   
   Current workflow:
   --------------
   ### Quick Start Guide
   
   ```bash
   # Build the quick-start Docker image (use docker pull after publish)
   git clone https://github.com/apache/incubator-teaclave-trustzone-sdk.git && 
cd incubator-teaclave-trustzone-sdk
   docker build -f Dockerfile.quickstart -t teaclave-trustzone-sdk-quick-start .
   
   # Start the container
   docker run -it --rm \
     --name teaclave_sdk_dev \
     -v $(pwd):/root/teaclave_sdk_src \
     -w /root/teaclave_sdk_src \
     teaclave-trustzone-sdk-quick-start \
     bash
   ```
   
   Inside the container, build the `hello_world` example with the default 
`ARCH` setting:
   
   ```bash
   source environment
   make -C examples/hello_world-rs/
   ```
   
   **Optional**: Run a quick CI test:
   
   ```bash
   cd tests/ && ./test_hello_world.sh
   ```
   
   ### Run CA and TA in the Emulator
   
   By default, the test scripts use a `screen` session to run QEMU and capture 
the logs automatically.  
   For developers who want to **run the CA and TA manually**, use the **debug 
mode**. This mode gives you full visibility and control of QEMU and serial 
output, and **requires three terminals**:
   
   Currently, we have one terminal (**Terminal A**) for building and preparing 
the environment.
   
   Open two additional terminals:
   
   **Terminal B** – Boot guest rootfs:
   
   ```bash
   docker exec -it teaclave_sdk_dev 
/root/teaclave_sdk_src/scripts/emulator/boot_guest_rootfs.exp
   ```
   
   **Terminal C** – Listen on TA output:
   
   ```bash
   docker exec -it teaclave_sdk_dev 
/root/teaclave_sdk_src/scripts/emulator/listen_on_ta_output.sh
   ```
   
   Back in **Terminal A**, copy the built applications and launch QEMU in debug 
mode:
   
   ```bash
   cp 
examples/hello_world-rs/host/target/aarch64-unknown-linux-gnu/release/hello_world-rs
 $QEMU_HOST_SHARE_DIR
   cp 
examples/hello_world-rs/ta/target/aarch64-unknown-linux-gnu/release/133af0ca-bdab-11eb-9130-43bf7873bf67.ta
 $QEMU_HOST_SHARE_DIR
   cd scripts/emulator && DEBUG=1 ./optee-qemuv8.sh
   ```
   
   In **Terminal B** (inside QEMU guest):
   
   ```bash
   # ls
   133af0ca-bdab-11eb-9130-43bf7873bf67.ta
   hello_world-rs
   
   # Install and run
   cp 133af0ca-bdab-11eb-9130-43bf7873bf67.ta /lib/optee_armtz/
   ./hello_world-rs
   ```
   
   Expected output from guest vm:
   
   ```
   original value is 29
   inc value is 129
   dec value is 29
   Success
   ```
   
   ### Customize the Build Environment from Scratch
   
   If you prefer not to use our Docker image, you can set up the build 
environment manually by running the scripts in `scripts/setup/`:
   
   ```bash
   git clone https://github.com/apache/incubator-teaclave-trustzone-sdk.git && 
cd incubator-teaclave-trustzone-sdk
   cd scripts/setup
   
   source setup_env && \
     bash setup_optee_dependencies.sh && \
     bash setup_toolchain.sh && \
     bash build_optee_libraries.sh && \
     echo "source /root/teaclave_sdk_prebuilt/scripts/setup/setup_env" >> 
/root/.bashrc
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@teaclave.apache.org
For additional commands, e-mail: dev-h...@teaclave.apache.org

Reply via email to