隨著 ARM TrustZone 技術因其安全性優勢而被廣泛應用於物聯網與 嵌入式裝置,越來越多人工智慧應用也逐漸整合至此類平台。常見應 用包括影像辨識、語音處理與智慧感測等,需在終端裝置上即時執行 推論任務,以提升效率並保障資料隱私。然而,此類裝置常受限於系 統資源,尤其在隔離執行環境中,記憶體空間相對不足,對 AI 推論等 高資源需求的應用構成挑戰。為此,我們提出 FlexTEE,一套支援執 行期記憶體擴充的安全機制,可於系統運行期間,將富執行環境中的 空閒記憶體動態分配給 TEE,並透過記憶體存取權限的嚴格管理,確 保整體系統的安全性。FlexTEE 可與 OP-TEE 無縫整合,TA 無需額外 修改即可使用擴充後的安全記憶體。最後,我們在 Raspberry Pi 3 開發 板上實作 FlexTEE,並實際運行 DNN 模型以測試其性能開銷。;With the growing adoption of ARM TrustZone technology in IoT and em bedded systems due to its security advantages, an increasing number of AI applications are being integrated into such platforms. Common use cases in clude image recognition, speech processing, and smart sensing, which require real-time inference on edge devices to improve efficiency and protect data privacy. However, these devices are often limited in system resources, espe cially within the Trusted Execution Environment (TEE), where constrained memory capacity poses challenges for resource-intensive workloads such as AI inference. To address this issue, we propose FlexTEE, a secure runtime memory expansion mechanism that dynamically allocates unused memory from the Rich Execution Environment (REE) to the TEE during system oper ation, while enforcing strict access control to ensure overall system security. FlexTEE integrates seamlessly with OP-TEE, allowing Trusted Applications (TAs) to utilize the expanded secure memory without any code modifications. Finally, we implement FlexTEE on a Raspberry Pi 3 development board and evaluate its performance overhead by running a deep neural network (DNN) model in practice.