This is an automated email from the ASF dual-hosted git repository. yuanz pushed a commit to branch no-std in repository https://gitbox.apache.org/repos/asf/incubator-teaclave-trustzone-sdk.git
commit cd99800d8557a4712cda42b90199f0ec368f035f Author: Sumit Garg <[email protected]> AuthorDate: Fri Dec 29 18:51:08 2023 +0530 examples: Refactor build infrastructure Refactor OP-TEE rust examples build infrastructure to rather use standard environment variables like: - CROSS_COMPILE - TA_DEV_KIT_DIR With that remove any custom OPTEE_* environment variables. Signed-off-by: Sumit Garg <[email protected]> --- examples/acipher-rs/host/Makefile | 10 +++------- examples/acipher-rs/ta/Makefile | 20 +++++++------------- examples/acipher-rs/ta/build.rs | 20 ++++++++------------ examples/aes-rs/host/Makefile | 10 +++------- examples/aes-rs/ta/Makefile | 20 +++++++------------- examples/aes-rs/ta/build.rs | 20 ++++++++------------ examples/authentication-rs/host/Makefile | 10 +++------- examples/authentication-rs/ta/Makefile | 20 +++++++------------- examples/authentication-rs/ta/build.rs | 20 ++++++++------------ examples/big_int-rs/host/Makefile | 10 +++------- examples/big_int-rs/ta/Makefile | 20 +++++++------------- examples/big_int-rs/ta/build.rs | 20 ++++++++------------ examples/diffie_hellman-rs/host/Makefile | 10 +++------- examples/diffie_hellman-rs/ta/Makefile | 20 +++++++------------- examples/diffie_hellman-rs/ta/build.rs | 20 ++++++++------------ examples/digest-rs/host/Makefile | 10 +++------- examples/digest-rs/ta/Makefile | 20 +++++++------------- examples/digest-rs/ta/build.rs | 20 ++++++++------------ examples/hello_world-rs/host/Makefile | 10 +++------- examples/hello_world-rs/ta/Makefile | 20 +++++++------------- examples/hello_world-rs/ta/build.rs | 20 ++++++++------------ examples/hotp-rs/host/Makefile | 10 +++------- examples/hotp-rs/ta/Makefile | 20 +++++++------------- examples/hotp-rs/ta/build.rs | 20 ++++++++------------ examples/random-rs/host/Makefile | 10 +++------- examples/random-rs/ta/Makefile | 20 +++++++------------- examples/random-rs/ta/build.rs | 20 ++++++++------------ examples/secure_storage-rs/host/Makefile | 10 +++------- examples/secure_storage-rs/ta/Makefile | 20 +++++++------------- examples/secure_storage-rs/ta/build.rs | 20 ++++++++------------ examples/signature_verification-rs/host/Makefile | 10 +++------- examples/signature_verification-rs/ta/Makefile | 20 +++++++------------- examples/signature_verification-rs/ta/build.rs | 20 ++++++++------------ examples/supp_plugin-rs/host/Makefile | 10 +++------- examples/supp_plugin-rs/plugin/Makefile | 10 +++------- examples/supp_plugin-rs/ta/Makefile | 20 +++++++------------- examples/supp_plugin-rs/ta/build.rs | 20 ++++++++------------ examples/time-rs/host/Makefile | 10 +++------- examples/time-rs/ta/Makefile | 20 +++++++------------- examples/time-rs/ta/build.rs | 20 ++++++++------------ 40 files changed, 237 insertions(+), 423 deletions(-) diff --git a/examples/acipher-rs/host/Makefile b/examples/acipher-rs/host/Makefile index d30687d..836eb5f 100644 --- a/examples/acipher-rs/host/Makefile +++ b/examples/acipher-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := acipher-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/acipher-rs/ta/Makefile b/examples/acipher-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/acipher-rs/ta/Makefile +++ b/examples/acipher-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/acipher-rs/ta/build.rs b/examples/acipher-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/acipher-rs/ta/build.rs +++ b/examples/acipher-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/aes-rs/host/Makefile b/examples/aes-rs/host/Makefile index 9672825..4a62581 100644 --- a/examples/aes-rs/host/Makefile +++ b/examples/aes-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := aes-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/aes-rs/ta/Makefile b/examples/aes-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/aes-rs/ta/Makefile +++ b/examples/aes-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/aes-rs/ta/build.rs b/examples/aes-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/aes-rs/ta/build.rs +++ b/examples/aes-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/authentication-rs/host/Makefile b/examples/authentication-rs/host/Makefile index 9c05bd0..711ef5b 100644 --- a/examples/authentication-rs/host/Makefile +++ b/examples/authentication-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := authentication-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/authentication-rs/ta/Makefile b/examples/authentication-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/authentication-rs/ta/Makefile +++ b/examples/authentication-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/authentication-rs/ta/build.rs b/examples/authentication-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/authentication-rs/ta/build.rs +++ b/examples/authentication-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/big_int-rs/host/Makefile b/examples/big_int-rs/host/Makefile index db37c49..cd11317 100644 --- a/examples/big_int-rs/host/Makefile +++ b/examples/big_int-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := big_int-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/big_int-rs/ta/Makefile b/examples/big_int-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/big_int-rs/ta/Makefile +++ b/examples/big_int-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/big_int-rs/ta/build.rs b/examples/big_int-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/big_int-rs/ta/build.rs +++ b/examples/big_int-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/diffie_hellman-rs/host/Makefile b/examples/diffie_hellman-rs/host/Makefile index dcce1a5..cc0fffd 100644 --- a/examples/diffie_hellman-rs/host/Makefile +++ b/examples/diffie_hellman-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := diffie_hellman-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/diffie_hellman-rs/ta/Makefile b/examples/diffie_hellman-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/diffie_hellman-rs/ta/Makefile +++ b/examples/diffie_hellman-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/diffie_hellman-rs/ta/build.rs b/examples/diffie_hellman-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/diffie_hellman-rs/ta/build.rs +++ b/examples/diffie_hellman-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/digest-rs/host/Makefile b/examples/digest-rs/host/Makefile index ac7c5bc..ae76fda 100644 --- a/examples/digest-rs/host/Makefile +++ b/examples/digest-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := digest-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/digest-rs/ta/Makefile b/examples/digest-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/digest-rs/ta/Makefile +++ b/examples/digest-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/digest-rs/ta/build.rs b/examples/digest-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/digest-rs/ta/build.rs +++ b/examples/digest-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/hello_world-rs/host/Makefile b/examples/hello_world-rs/host/Makefile index 7512ada..f93bdab 100644 --- a/examples/hello_world-rs/host/Makefile +++ b/examples/hello_world-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := hello_world-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/hello_world-rs/ta/Makefile b/examples/hello_world-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/hello_world-rs/ta/Makefile +++ b/examples/hello_world-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/hello_world-rs/ta/build.rs b/examples/hello_world-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/hello_world-rs/ta/build.rs +++ b/examples/hello_world-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/hotp-rs/host/Makefile b/examples/hotp-rs/host/Makefile index d6aac49..6ebed56 100644 --- a/examples/hotp-rs/host/Makefile +++ b/examples/hotp-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := hotp-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/hotp-rs/ta/Makefile b/examples/hotp-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/hotp-rs/ta/Makefile +++ b/examples/hotp-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/hotp-rs/ta/build.rs b/examples/hotp-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/hotp-rs/ta/build.rs +++ b/examples/hotp-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/random-rs/host/Makefile b/examples/random-rs/host/Makefile index f6984c9..98f6b5f 100644 --- a/examples/random-rs/host/Makefile +++ b/examples/random-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := random-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/random-rs/ta/Makefile b/examples/random-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/random-rs/ta/Makefile +++ b/examples/random-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/random-rs/ta/build.rs b/examples/random-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/random-rs/ta/build.rs +++ b/examples/random-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/secure_storage-rs/host/Makefile b/examples/secure_storage-rs/host/Makefile index 602b98d..95d1664 100644 --- a/examples/secure_storage-rs/host/Makefile +++ b/examples/secure_storage-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := secure_storage-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/secure_storage-rs/ta/Makefile b/examples/secure_storage-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/secure_storage-rs/ta/Makefile +++ b/examples/secure_storage-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/secure_storage-rs/ta/build.rs b/examples/secure_storage-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/secure_storage-rs/ta/build.rs +++ b/examples/secure_storage-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/signature_verification-rs/host/Makefile b/examples/signature_verification-rs/host/Makefile index 42bdb8b..c87d3d2 100644 --- a/examples/signature_verification-rs/host/Makefile +++ b/examples/signature_verification-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := signature_verification-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/signature_verification-rs/ta/Makefile b/examples/signature_verification-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/signature_verification-rs/ta/Makefile +++ b/examples/signature_verification-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/signature_verification-rs/ta/build.rs b/examples/signature_verification-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/signature_verification-rs/ta/build.rs +++ b/examples/signature_verification-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/supp_plugin-rs/host/Makefile b/examples/supp_plugin-rs/host/Makefile index 5f21430..3986c93 100644 --- a/examples/supp_plugin-rs/host/Makefile +++ b/examples/supp_plugin-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := supp_plugin-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/supp_plugin-rs/plugin/Makefile b/examples/supp_plugin-rs/plugin/Makefile index fb35348..6f33775 100644 --- a/examples/supp_plugin-rs/plugin/Makefile +++ b/examples/supp_plugin-rs/plugin/Makefile @@ -19,18 +19,14 @@ NAME := syslog_plugin ARCH ?= aarch64 PLUGIN_UUID := `cat ../plugin_uuid.txt` -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/supp_plugin-rs/ta/Makefile b/examples/supp_plugin-rs/ta/Makefile index 49b5219..f185c5a 100644 --- a/examples/supp_plugin-rs/ta/Makefile +++ b/examples/supp_plugin-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../ta_uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/supp_plugin-rs/ta/build.rs b/examples/supp_plugin-rs/ta/build.rs index d63e893..e63b967 100644 --- a/examples/supp_plugin-rs/ta/build.rs +++ b/examples/supp_plugin-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); diff --git a/examples/time-rs/host/Makefile b/examples/time-rs/host/Makefile index e0b773e..98c26b6 100644 --- a/examples/time-rs/host/Makefile +++ b/examples/time-rs/host/Makefile @@ -18,18 +18,14 @@ NAME := time-rs ARCH ?= aarch64 -OPTEE_DIR ?= ../../../optee +OBJCOPY := $(CROSS_COMPILE)objcopy ifeq ($(ARCH), arm) - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf..linker=\"arm-linux-gnueabihf-gcc\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)gcc\" else - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-gcc\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)gcc\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release diff --git a/examples/time-rs/ta/Makefile b/examples/time-rs/ta/Makefile index 8a2faf4..a06cd97 100644 --- a/examples/time-rs/ta/Makefile +++ b/examples/time-rs/ta/Makefile @@ -15,26 +15,20 @@ # specific language governing permissions and limitations # under the License. -OPTEE_DIR ?= ../../../optee -OPTEE_OS_DIR ?= $(OPTEE_DIR)/optee_os UUID ?= $(shell cat "../uuid.txt") ARCH ?= aarch64 +OBJCOPY := $(CROSS_COMPILE)objcopy +TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem +SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py + ifeq ($(ARCH), arm) - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm32/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/aarch32/bin - OBJCOPY := $(OPTEE_BIN)/arm-linux-gnueabihf-objcopy TARGET := arm-unknown-linux-gnueabihf - LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"arm-linux-gnueabihf-ld.bfd\" + LINKER_CFG := target.arm-unknown-linux-gnueabihf.linker=\"$(CROSS_COMPILE)ld.bfd\" else - TA_SIGN_KEY ?= $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/keys/default_ta.pem - SIGN := $(OPTEE_OS_DIR)/out/arm/export-ta_arm64/scripts/sign_encrypt.py - OPTEE_BIN := $(OPTEE_DIR)/toolchains/$(ARCH)/bin - OBJCOPY := $(OPTEE_BIN)/aarch64-linux-gnu-objcopy TARGET := aarch64-unknown-linux-gnu - LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"aarch64-linux-gnu-ld.bfd\" + LINKER_CFG := target.aarch64-unknown-linux-gnu.linker=\"$(CROSS_COMPILE)ld.bfd\" endif OUT_DIR := $(CURDIR)/target/$(TARGET)/release @@ -42,7 +36,7 @@ OUT_DIR := $(CURDIR)/target/$(TARGET)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --verbose --config $(LINKER_CFG) + @cargo build --target $(TARGET) --release --config $(LINKER_CFG) strip: @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/time-rs/ta/build.rs b/examples/time-rs/ta/build.rs index d7f9b44..af0e5ab 100644 --- a/examples/time-rs/ta/build.rs +++ b/examples/time-rs/ta/build.rs @@ -43,26 +43,23 @@ fn main() -> std::io::Result<()> { time_low, time_mid, time_hi_and_version, clock_seq_and_node )?; - let optee_os_dir = env::var("OPTEE_OS_DIR").unwrap_or("../../../optee/optee_os".to_string()); + let optee_os_dir = env::var("TA_DEV_KIT_DIR").unwrap(); + let search_path = Path::new(&optee_os_dir).join("lib"); + let optee_os_path = &PathBuf::from(optee_os_dir.clone()); - let search_path = match env::var("ARCH") { - Ok(ref v) if v == "arm" => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm32/src/ta.ld.S"))?; - let f = BufReader::new(f); + let mut ta_lds = File::create(out.join("ta.lds"))?; + let f = File::open(optee_os_path.join("src/ta.ld.S"))?; + let f = BufReader::new(f); + match env::var("ARCH") { + Ok(ref v) if v == "arm" => { write!(ta_lds, "OUTPUT_FORMAT(\"elf32-littlearm\")\n")?; write!(ta_lds, "OUTPUT_ARCH(arm)\n")?; for line in f.lines() { write!(ta_lds, "{}\n", line?)?; } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm32/lib") }, _ => { - let mut ta_lds = File::create(out.join("ta.lds"))?; - let f = File::open(optee_os_path.join("out/arm/export-ta_arm64/src/ta.ld.S"))?; - let f = BufReader::new(f); - write!(ta_lds, "OUTPUT_FORMAT(\"elf64-littleaarch64\")\n")?; write!(ta_lds, "OUTPUT_ARCH(aarch64)\n")?; for line in f.lines() { @@ -74,7 +71,6 @@ fn main() -> std::io::Result<()> { write!(ta_lds, "{}\n", l)?; } } - Path::new(&optee_os_dir).join("out/arm/export-ta_arm64/lib") } }; println!("cargo:rustc-link-search={}", out.display()); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
