- 概述
Persistence subsystem 主要的功能就是处理持久化数据,持久化数据是在重启的时候存储在头部单元内,它包括信息娱乐系统生命周期内读取和修改的所有数据。持久化数据存储在非易失性存储器中,例如硬盘驱动器或闪存
Persistence Management 的几个组件:
Persistence Client Library
Persistence Administration Service
Persistence Common Object
Persistence Health Monitor
- 结构框架


- 组件1 Persistence Client Library
主要是提供API让外部的应用可以读写持久化数据,同时提供 API 插件,允许用户使用自定义存储解决方案扩展客户库
3.1 依赖
The client library has the following dependencies
build-time library dependencies;
automotive-dlt (http://projects.genivi.org/diagnostic-log-trace/)
Persistence Common Object (https://github.com/GENIVI/persistence-common-object.git) Add "--with_database=key-value-store" to the configure step The previous default backend Itzam/C and will not supported anymore.
dbus-1
check
unit test framework for C
used when configured with "--enable-tests" Ubuntu: use Synaptic package manager Or download http://check.sourceforge.net/
tools
autotools
libtool
3.2 编译
c
# build in SDK
eval ${OECORE_NATIVE_SYSROOT}/usr/bin/autoreconf -vi
./configure --host=aarch64-oe-linux --prefix=${OECORE_NATIVE_SYSROOT}/usr
make CFLAGS="-O2" CXXFLAGS="-O2"
make install
流程:
c
eval ${OECORE_NATIVE_SYSROOT}/usr/bin/autoreconf -vi
问题:
c
./configure --host=aarch64-oe-linux --prefix=${OECORE_NATIVE_SYSROOT}/usr
报错:
configure: error: Package requirements (automotive-dlt
libperscommon
dbus-1) were not met:
No package 'automotive-dlt' found
解决:
persistence-client-library-1.2.1/configure.ac
删除automotive-dlt,后续做一个假的进去

c
./configure --host=aarch64-oe-linux --prefix=${OECORE_NATIVE_SYSROOT}/usr
No package 'libperscommon' found
解决:
pkg-config 配置文件没有办法找到
方法一: 修改 PKG_CONFIG_PATH,新增新的查找路径
c
export PKG_CONFIG_PATH=${OECORE_NATIVE_SYSROOT}/xxx:$PKG_CONFIG_PATH
方法二:安装common的时候指定安装路径,这个路径是被 PKG_CONFIG_PATH 包含的
问题:
c
make
报错:
fatal error: persComRct.h: No such file or directory
但是persComRct.h在下面的路径里是存在的
../../sysroots/x86_64-oesdk-linux/usr/lib/include/persComRct.h
../../sysroots/x86_64-oesdk-linux/usr/include/persComRct.h
解决:
c
# 临时通过 make 命令指定CPPFLAGS路径
make CPPFLAGS="-I${OECORE_NATIVE_SYSROOT}/usr/include"
问题:
c
make CPPFLAGS="-I${OECORE_NATIVE_SYSROOT}/usr/include"
报错:
fatal error: gnu/stubs-32.h: No such file or directory
7 | # include <gnu/stubs-32.h>
代码或某个依赖库试图编译 32位 代码(如 -m32 选项被启用)。
但你的 交叉编译工具链(aarch64-oe-linux)是纯 64 位环境,没有安装 32 位兼容库(multilib 支持)。
解决
c
# 创建一个空的 stubs-32.h 文件
mkdir -p ${OECORE_NATIVE_SYSROOT}/usr/include/gnu
touch ${OECORE_NATIVE_SYSROOT}/usr/include/gnu/stubs-32.h
问题:
c
make CFLAGS="-O2"
persistence_client_library_dbus_cmd.c:224:35: error: 'fsync' undeclared (first use in this function)
224 | list_iterate(&gOpenFdList, &fsync);
解决:
c
先注释掉对应的行
问题:
c
sudo make install
libtool: install: aarch64-oe-linux-ranlib /home/nio/nioworkspace/SDK_ahsoka/sysroots/aarch64-oe-linux/usr/lib/libpersistence_client_library.a
../libtool: line 1886: aarch64-oe-linux-ranlib: command not found
解决:
c
which aarch64-oe-linux-gcc
检查 $PATH 是否包含工具链路径
export PATH=/home/nio/nioworkspace/SDK_ahsoka/sysroots/x86_64-pokysdk-linux/usr/bin/aarch64-oe-linux:$PATH
- 组件2 persistence-administrator
安装数据管理的基础架构
创建默认文件和文件夹结构
设置访问默认文件和文件夹结构的访问权限
部署默认数据
内部备份和还原数据库
提供c-api(persistence Armistress Administion Accriptation Access库)
git 仓库:https://github.com/GENIVI/persistence-administrator
4.2 依赖
json
node-state-manager
libsystemd
4.3 编译
c
./autogen.sh --host=aarch64-oe-linux --prefix=${OECORE_NATIVE_SYSROOT}/usr
报错
c
configure: error: Package requirements ( json >= 0.9 ) were not met:
No package 'json' found
4.3.1 Json 包集成
git仓库:https://github.com/json-c/json-c
c
mkdir build
cd build
../cmake-configure --prefix=${OECORE_TARGET_SYSROOT}/usr
make install
问题:
c
make
make[1]: *** No rule to make target '/org.genivi.NodeStateManager.Consumer.xml', needed by 'NodeStateConsumer.c'. Stop.
解决:



问题:
c
做了上述操作后报错:
Administrator/Makefile.am:80: error: comment following trailing backslash
Administrator/Makefile.am:33: warning: source file 'src/ssw_pers_admin_access_lib.c' is in a subdirectory,
Administrator/Makefile.am:33: but option 'subdir-objects' is disabled
解决:
c
这个错误是由于 Makefile.am 中存在格式问题(反斜杠 \ 后跟注释)和未启用 subdir-objects 选项导致的
问题:
c
make
报错:src/ssw_pers_admin_backup.c:59:1: error: parameter 'gSharedPublicRelativePath' is initialized
59 | const char* gSharedPublicRelativePath = PERS_ORG_SHARED_FOLDER_NAME PERS_ORG_PUBLIC_FOLDER_NAME_;
解决:
把下面这个注释掉,需要确保变量是全局作用域,如果这些变量出现在 函数参数列表,例如
c
void some_function(
const char* gSharedPublicRelativePath = PERS_ORG_SHARED_FOLDER_NAME PERS_ORG_PUBLIC_FOLDER_NAME_, // ❌ C 不允许参数默认值
const char* gSharedGroupRelativePath = PERS_ORG_SHARED_FOLDER_NAME PERS_ORG_GROUP_FOLDER_NAME_ "/" // ❌
) { ... }

问题:
c
make
报错
src/ssw_pers_admin_common.c:598:5: error: format not a string literal and no format arguments [-Werror=format-security]
598 | snprintf(pchParentPath, sizeof(pchParentPath), compressFrom);
解决:
c
//没有加 "%s"
snprintf(pchParentPath, sizeof(pchParentPath), "%s", compressFrom);
问题:
c
make
/home/nio/nioworkspace/SDK_ahsoka/sysroots/aarch64-oe-linux/usr/include/json/config.h:8:10: fatal error: cstddef: No such file or directory
8 | #include <cstddef>
解决:
c
cstddef是c++的库,persistence是C, 引用的也是json-c,include错了
修改:#include <josn/json.h> 改成 #include <json-c/json.h>
- 组件3 persistence-common-object
git仓库:https://github.com/GENIVI/persistence-common-object
PCL和PC使用的存储后端库来访问密钥/值和RCT数据
可以实施不同的存储机制,例如
itzam/C
Key-value store
IPC abstraction(planed)
5.1 依赖
The client library has the following dependencies
build-time library dependencies;
automotive-dlt (http://projects.genivi.org/diagnostic-log-trace/)
check
unit test framework for C
used when configured with "--enable-tests"
Itzam/C
tools
autotools
libtool
5.2 编译
c
#./autogen.sh --host=aarch64-oe-linux --prefix=${OECORE_NATIVE_SYSROOT}/usr
# 指定PC文件的安装地址,否则client安装识别不到
#./autogen.sh --host=aarch64-oe-linux --prefix=${OECORE_NATIVE_SYSROOT}/usr pkgconfigdir=${OECORE_NATIVE_SYSROOT}/usr/lib/pkgconfig
#上面的方式直接装到x86xxx下面了,是不对的 因为PKG_CONFIG_PATH是不包含x86xxx
#$ env | grep PKG_CONFIG_PATH
#PKG_CONFIG_PATH=/home/nio/nioworkspace/SDK_ahsoka/sysroots/aarch64-oe-linux/usr/lib/pkgconfig:/home/nio/nioworkspace/SDK_ahsoka/sysroots/aarch64-oe-linux/usr/share/pkgconfig
./autogen.sh --host=aarch64-oe-linux --prefix=${OECORE_TARGET_SYSROOT}/usr
make
make install

与DESTDIR 的区别:https://stackoverflow.com/questions/11307465/destdir-and-prefix-of-make
产物路径:

- 组件4 persistence-health-monitor
6.1 依赖
automotive-dlt
dbus-1
node-state-manager
6.2 编译
c
eval ${OECORE_NATIVE_SYSROOT}/usr/bin/autoreconf -vi
./configure --host=aarch64-oe-linux --prefix=${OECORE_NATIVE_SYSROOT}/usr
make
make install
- node-state-manager
git仓库:https://github.com/GENIVI/node-state-manager
7.1 依赖
dbus-1
libsystemd-daemon
persistence_client_library
7.2 编译
c
./autogen.sh --host=aarch64-oe-linux --prefix=${OECORE_NATIVE_SYSROOT}/usr
make
make install
报错:
c
configure: error: Package requirements (libsystemd-daemon >= 37 ) were not met:
No package 'libsystemd-daemon' found
解决:
注释掉
问题:
c
c
make
space/SDK_ahsoka/persistence/node-state-manager-2.0.0/NodeStateMachineStub/.libs/libNodeStateMachine.so -lgio-2.0 -lgobject-2.0 -lglib-2.0 -pthread
/home/nio/nioworkspace/SDK_ahsoka/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/11.5.0/ld: NodeStateManager-NodeStateManager.o: in function `NSM__enGetApplicationMode':
/home/nio/nioworkspace/SDK_ahsoka/persistence/node-state-manager-2.0.0/NodeStateManager/NodeStateManager.c:721: undefined reference to `pclKeyReadData'
/home/nio/nioworkspace/SDK_ahsoka/sysroots/x86_64-oesdk-linux/usr/libexec/aarch64-oe-linux/gcc/aarch64-oe-linux/11.5.0/ld: NodeStateManager-NodeStateManager.o: in function `NSM__enSetApplicationMode':
/home/nio/nioworkspace/SDK_ahsoka/persistence/node-state-manager-2.0.0/NodeStateManager/NodeStateManager.c:653: undefined reference to `pclKeyWriteData'
- Dlt
c
# 1. 加载 Yocto 的 SDK 环境
source /path/to/yocto/environment-setup-aarch64-oe-linux
# 2. 进入 dlt-daemon 项目目录
cd /path/to/dlt-daemon
mkdir build
cd build
# 3. 配置 CMake(安装路径 + 使用 SDK 工具链)
cmake .. -DWITH_MAN=OFF -DCMAKE_INSTALL_PREFIX=${OECORE_TARGET_SYSROOT}/usr
# 4. 编译并安装
make -j$(nproc)
make install