rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | TZ_BINARY = "tee.img" |
| 2 | ATF_RAW_BINARY="atf_raw.img" |
| 3 | ATF_SIGNED_BINARY="atf_signed.img" |
| 4 | |
| 5 | TZ_RAW_BINARY= "tz.raw.img" |
| 6 | TZ_SIGNED_BINARY = "tz_signed.img" |
| 7 | |
| 8 | TZ_TMP_SIGNED_BINARY = "tz_tmp_signed.img" |
| 9 | TZ_TMP_RAW_BINARY = "tz_tmp_raw.img" |
| 10 | TZ_TMP_BINARY = "tz_tmp.img" |
| 11 | |
| 12 | TRUSTEDOS_RAW_BINARY = "trusedos.img" |
| 13 | TRUSTEDOS_SIGNED_BINARY = "trusedos_signed.img" |
| 14 | |
| 15 | TZ_ASSEMBLE_OUT = "${DEPLOY_DIR}/images/${MACHINE}/trustzone" |
| 16 | TL_ALIGN_SIZE = "0xb000" |
| 17 | |
| 18 | TRUSTZONE_VERSION = "20200422" |
| 19 | |
| 20 | do_mkdir_assemble () { |
| 21 | mkdir -p ${TZ_ASSEMBLE_OUT} |
| 22 | } |
| 23 | addtask mkdir_assemble before do_compile after do_configure |
| 24 | |
| 25 | python __anonymous () { |
| 26 | tee_loadaddress = d.getVar('TRUSTZONE_LOADADDRESS', True) |
| 27 | tee_entrypoint = d.getVar('TRUSTZONE_ENTRYPOINT', True) |
| 28 | if tee_loadaddress is None or tee_entrypoint is None: |
| 29 | return |
| 30 | else: |
| 31 | tee_loadaddress = int(tee_loadaddress, 16) |
| 32 | tee_entrypoint = int(tee_entrypoint, 16) |
| 33 | |
| 34 | tl_align_size = int(d.getVar('TL_ALIGN_SIZE', True), 16) |
| 35 | tee_loadaddress = tee_loadaddress - tl_align_size |
| 36 | tee_loadaddress_str = hex(tee_loadaddress).replace('L', '') |
| 37 | d.setVar('TEE_LOADADDRESS', tee_loadaddress_str) |
| 38 | |
| 39 | tee_entrypoint = tee_entrypoint - tl_align_size |
| 40 | tee_entrypoint_str = hex(tee_entrypoint).replace('L', '') |
| 41 | d.setVar('TEE_ENTRYPOINT', tee_entrypoint_str) |
| 42 | |
| 43 | image_desc = d.getVar('DESCRIPTION', True) |
| 44 | if image_desc == 'ARM trusted firmware': |
| 45 | atf_src = d.getVar('MTK_SRC', True) |
| 46 | mach_type = d.getVar('MTK_MACH_TYPE', True) |
| 47 | tee_support = d.getVar('TEE_SUPPORT', True) |
| 48 | atf_ver = d.getVar('ATF_VER', True) |
| 49 | |
| 50 | if os.path.exists(atf_src+'/.git'): |
| 51 | bb.warn('please change your atf folder to new layout') |
| 52 | # backward to old atf layout |
| 53 | # change the mt8516 to v1.21 folder |
| 54 | # others remain the original path |
| 55 | if mach_type == "mt8516": |
| 56 | d.setVar('ATF_VER','1.21') |
| 57 | else: |
| 58 | # new atf layout, change to use folder atf_tbase |
| 59 | # if tee_support is tbase and atf version is 1.0 |
| 60 | if tee_support == 'tbase' and atf_ver == '1.0': |
| 61 | d.setVar('B',atf_src+'_'+tee_support) |
| 62 | else: |
| 63 | # change folder to CHIP_TYPE {mt2xxx/mt8xxx} |
| 64 | tgtplt = d.getVar('TARGET_PLATFORM', True) |
| 65 | if tgtplt[0:3] == "mt2": |
| 66 | d.setVar('CHIP_TYPE', tgtplt[0:3]+'xxx') |
| 67 | else: |
| 68 | atf_path = os.path.join(atf_src,"v"+atf_ver,tgtplt) |
| 69 | if os.path.exists(atf_path+'/.git'): |
| 70 | d.setVar('CHIP_TYPE', tgtplt) |
| 71 | else: |
| 72 | d.setVar('CHIP_TYPE', 'mt8xxx') |
| 73 | |
| 74 | if image_desc == 'TrustZone Image': |
| 75 | multilibs = d.getVar('MULTILIBS', True) |
| 76 | if multilibs == 'multilib:lib64': |
| 77 | d.appendVarFlag('do_cleansstate', 'depends', ' lib64-teeloader:do_cleansstate') |
| 78 | d.appendVarFlag('do_compile', 'depends', ' lib64-teeloader:do_deploy') |
| 79 | else: |
| 80 | d.appendVarFlag('do_cleansstate', 'depends', ' teeloader:do_cleansstate') |
| 81 | d.appendVarFlag('do_compile', 'depends', ' teeloader:do_deploy') |
| 82 | |
| 83 | atfsupport = d.getVar('ATF_SUPPORT', True) |
| 84 | if atfsupport == 'yes': |
| 85 | if multilibs == 'multilib:lib64': |
| 86 | d.appendVarFlag('do_cleansstate', 'depends', ' lib64-atf:do_cleansstate') |
| 87 | d.appendVarFlag('do_compile', 'depends', ' lib64-atf:do_deploy') |
| 88 | else: |
| 89 | d.appendVarFlag('do_cleansstate', 'depends', ' atf:do_cleansstate') |
| 90 | d.appendVarFlag('do_compile', 'depends', ' atf:do_deploy') |
| 91 | |
| 92 | tee_support = d.getVar('TEE_SUPPORT', True) |
| 93 | if tee_support is None: |
| 94 | tee_support = "mtee" |
| 95 | d.appendVarFlag('do_cleansstate', 'depends', ' tee-'+tee_support+':do_cleansstate') |
| 96 | d.appendVarFlag('do_compile', 'depends', ' tee-'+tee_support+':do_deploy') |
| 97 | if tee_support == 'optee': |
| 98 | if multilibs == 'multilib:lib64': |
| 99 | d.appendVarFlag('do_cleansstate', 'depends', ' lib64-optee-os:do_cleansstate') |
| 100 | d.appendVarFlag('do_compile', 'depends', ' lib64-optee-os:do_deploy') |
| 101 | else: |
| 102 | d.appendVarFlag('do_cleansstate', 'depends', ' optee-os:do_cleansstate') |
| 103 | d.appendVarFlag('do_compile', 'depends', ' optee-os:do_deploy') |
| 104 | elif tee_support != 'none': |
| 105 | if multilibs == 'multilib:lib64': |
| 106 | d.appendVarFlag('do_cleansstate', 'depends', ' lib64-tee-'+tee_support+':do_cleansstate') |
| 107 | d.appendVarFlag('do_compile', 'depends', ' lib64-tee-'+tee_support+':do_deploy') |
| 108 | else: |
| 109 | d.appendVarFlag('do_cleansstate', 'depends', ' tee-'+tee_support+':do_cleansstate') |
| 110 | d.appendVarFlag('do_compile', 'depends', ' tee-'+tee_support+':do_deploy') |
| 111 | |
| 112 | secure_boot_enable = d.getVar('SECURE_BOOT_ENABLE', True) |
| 113 | force_disable_tee_encryption = d.getVar('FORCE_DISABLE_TEE_ENCRYPTION', True) |
| 114 | if secure_boot_enable == 'yes' and force_disable_tee_encryption != 'yes' : |
| 115 | d.setVar("ATF_BINARY_SELECT", '${ATF_SIGNED_BINARY}') |
| 116 | d.setVar("TZ_BINARY_SELECT", '${TZ_SIGNED_BINARY}') |
| 117 | d.setVar("TRUSTEDOS_BINARY_SELECT", '${TRUSTEDOS_SIGNED_BINARY}') |
| 118 | else: |
| 119 | d.setVar("ATF_BINARY_SELECT", '${ATF_RAW_BINARY}') |
| 120 | d.setVar("TZ_BINARY_SELECT", '${TZ_RAW_BINARY}') |
| 121 | d.setVar("TRUSTEDOS_BINARY_SELECT", '${TRUSTEDOS_RAW_BINARY}') |
| 122 | } |