<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[【FAQ】全志R系列在Tina下如何设置optee-secure-storage默认保存路径]]></title><description><![CDATA[<p dir="auto"><strong>问题背景</strong><br />
optee REE SecureStorage的默认存储路径是 /data/tee，不符合客户自身的使用场景，需要进行更换。</p>
<p dir="auto"><strong>问题分析</strong><br />
首先，上官网查找相关资料，官网上介绍比较简单，没有具体说明。</p>
<pre><code>TEE File Structure in Linux File System
OP-TEE by default uses /data/tee/ as the secure storage space in the Linux file system. Each persistent object is assigned an internal identifier. It is an integer which is visible in the Linux file system as /data/tee/&lt;file number&gt;.

A directory file, /data/tee/dirf.db, lists all the objects that are in the secure storage. All normal world files are integrity protected and encrypted, as described below.
</code></pre>
<p dir="auto">接着分析，rootfs中的/data/tee目录原本是不存在的，但是启动到控制台后，默认就存在了，所以极有可能是在非安全端的后台应用程序tee-supplicant中进行创建的，打开其源码，进行搜索，结果如下</p>
<p dir="auto">x```<br />
xx@xxx:~/xxx/optee_client-3.7.0$ grep -r '/data/tee'<br />
<a href="http://config.mk" target="_blank" rel="noopener noreferrer nofollow ugc">config.mk</a>:CFG_TEE_FS_PARENT_PATH ?= /data/tee<br />
匹配到二进制文件 out/export/usr/sbin/tee-supplicant<br />
匹配到二进制文件 out/tee-supplicant/tee_supp_fs.o<br />
匹配到二进制文件 out/tee-supplicant/tee-supplicant<br />
匹配到二进制文件 ipkg-sunxi/optee-client-3.7/usr/sbin/tee-supplicant<br />
libteec/CMakeLists.txt:set (CFG_TEE_CLIENT_LOG_FILE "/data/tee/teec.log" CACHE STRING "Location of libteec log")<br />
tee-supplicant/CMakeLists.txt:set (CFG_TEE_FS_PARENT_PATH "/data/tee" CACHE STRING "Location of TEE filesystem (secure storage)")</p>
<pre><code>
可以看到，最后一行CMakeLists.txt有个宏变量 CFG_TEE_FS_PARENT_PATH ，其注释为TEE FS的路径，有可能是这个。接续迭代搜索，见下面流程，阅读代码，确认就是这个影响。

</code></pre>
<p dir="auto">xxx@xxx:~/xxx/optee_client-3.7.0$ grep -r 'CFG_TEE_FS_PARENT_PATH'</p>
<pre><code>tee-supplicant/tee_supplicant_android.mk:               -DTEE_FS_PARENT_PATH=\"$(CFG_TEE_FS_PARENT_PATH)\"
tee-supplicant/Makefile:                   -DTEE_FS_PARENT_PATH=\"$(CFG_TEE_FS_PARENT_PATH)\" \
tee-supplicant/CMakeLists.txt:set (CFG_TEE_FS_PARENT_PATH "/data/tee" CACHE STRING "Location of TEE filesystem (secure storage)")
tee-supplicant/CMakeLists.txt:  PRIVATE -DTEE_FS_PARENT_PATH="${CFG_TEE_FS_PARENT_PATH}"
...
xxx@xxx:~/xxx/optee_client-3.7.0$ grep -rn 'TEE_FS_PARENT_PATH'
tee-supplicant/src/tee_supp_fs.c:124:   n = snprintf(tee_fs_root, sizeof(tee_fs_root), "%s/", TEE_FS_PARENT_PATH);
</code></pre>
<p dir="auto">查看tee-supplicant/src/tee_supp_fs.c文件第124行，符合猜想。</p>
<pre><code>static int tee_supp_fs_init(void)
{
        size_t n = 0;
        mode_t mode = 0700;

        n = snprintf(tee_fs_root, sizeof(tee_fs_root), "%s/", TEE_FS_PARENT_PATH);
        if (n &gt;= sizeof(tee_fs_root))
                return -1;

        if (mkpath(tee_fs_root, mode) != 0)
                return -1;

        return 0;
}
</code></pre>
<p dir="auto"><strong>问题解决</strong><br />
config.mk与tee-supplicant/CMakeLists.txt都包含CFG_TEE_FS_PARENT_PATH，根据Tina下编译规则，发现这个包是用Makefile编译的，修改config.mk下的CFG_TEE_FS_PARENT_PATH为目标路径即可解决。</p>
]]></description><link>https://bbs.aw-ol.com/topic/1072/faq-全志r系列在tina下如何设置optee-secure-storage默认保存路径</link><generator>RSS for Node</generator><lastBuildDate>Sun, 08 Mar 2026 14:45:32 GMT</lastBuildDate><atom:link href="https://bbs.aw-ol.com/topic/1072.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 25 Feb 2022 03:16:25 GMT</pubDate><ttl>60</ttl></channel></rss>