systemctl 显示二进制文件的不同行为

发布于 2025-01-16 15:58:19 字数 943 浏览 3 评论 0原文

我开发了一款 OTA(无线)管理器,它在内部使用“swupdate”命令来更新固件。此 swupdate 由 OTA 管理器代码内的“system()”函数应用。

我的二进制文件按预期工作,并且如果我直接从控制台运行二进制文件 ota_manager,“swupdate”命令工作正常

我为我的二进制文件创建了一个 systemctl 服务,如下所示:

[Unit]
Description=OTA manager service
After=syslogd.service

[Service]
Type=simple
ExecStart=/usr/bin/ota_manager

[Install]
WantedBy=multi-user.target

如果我运行此服务,swupdate 命令总是失败并出现错误

SWUPDATE failed [0] ERROR handlers/archive_handler.c : extract : 110 : archive_read_next_header(): Pathname can't be converted from UTF-8 to current locale

我正在检查 swupdate 错误,但我不认为这是 swupdate 问题,因为如果我在控制台上手动应用命令或者直接从控制台运行 ota_manager 二进制文件,它工作正常。 看来是 systemctl 造成了这个问题。

我正在使用基于 NXP IMX6ULL 的定制硬件和 Hardknott 版本 Yocto OS(5.10 内核)。 注意:我已经验证了与 Warrior 版本 Yocto OS(4.19 内核)相同的代码,并且相同的代码也可以在 systemctl 服务中正常工作。

这里有人有指点吗?

I have developed one OTA(Over The Air) manager which uses "swupdate" command internally to update the firmware. This swupdate is applied by "system()" function inside OTA manager code.

My binary is working as expected and "swupdate" command is working fine if I run my binary ota_manager directly from console.

I have created one systemctl service for my binary as below:

[Unit]
Description=OTA manager service
After=syslogd.service

[Service]
Type=simple
ExecStart=/usr/bin/ota_manager

[Install]
WantedBy=multi-user.target

If I run this service, swupdate command is always failing with error:

SWUPDATE failed [0] ERROR handlers/archive_handler.c : extract : 110 : archive_read_next_header(): Pathname can't be converted from UTF-8 to current locale

I am checking swupdate error but I don't think it is a swupdate issue as it is working fine if I apply the command manually on the console or I run ota_manager binary directly from the console.
It is looking like systemctl is creating the issue.

I am using NXP IMX6ULL based custom hardware with hardknott version Yocto OS(5.10 kernel).
Note: I have validated same with warrior version Yocto OS(4.19 kernel) and same code is working fine with systemctl service as well.

Do anyone has any pointers here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤星 2025-01-23 15:58:20

找到根本原因:

  • “swupdate”命令需要将“locale”设置设置为环境变量,因此如果未设置它们,则会出现此类错误。
  • 在我的网关中,该环境变量被设置为控制台的自定义配置文件。因此 swupdate 命令在控制台中工作正常
  • 如果 swupdate 命令作为应用程序的“system()”调用提供,则它在后台子 shell 中运行,其中未加载此自定义配置文件,因此不存在“locale”环境变量。

Found root cause:

  • "swupdate" command requires "locale" settings to be set as environment variables so if they are not set it gives such kind of error.
  • In my gateway, that environment variables were set as a custom profile of console. So swupdate command works fine from console
  • If swupdate command provided as "system()" call from application, it was running in background sub shell in which this custom profile was not loaded and so "locale" environment variables were not present.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文