JetPack首次启动时系统服务流水

设备准备

设备

JetPack版本

Sample Rootfs版本

Jetson AGX Orin 64GB35.3.135.3.1

启动分析

启动顺序

执行apply_binaries.sh完成后进入rootfs目录中

查看/etc/systemd/system/default.target指向/lib/systemd/system/nv-oem-config.target,这表示系统会在启动时使用这个target与之对应的nv-oem-config.target.wants中包含了一些nv的服务,这些服务会在系统启动时加载,根据各服务的定义排序如下:

服务

启动脚本

作用

nvfb-early.service/etc/systemd/nvfb-early.sheraly firstboot脚本
nvpower.service/etc/systemd/nvpower.sh初始化电源设置
nvfancontrol.service/usr/sbin/nvfancontrol &风扇控制服务
nvweston.service/etc/systemd/nvweston.sh添加weston-launch用户组
nvpmodel.service/etc/systemd/nvpmodel.sh设置默认的powermodel
nv-oem-config.service

/etc/systemd/nv-oem-config.sh

/etc/systemd/nv-oem-config-post.sh

OEM配置服务
nv-oem-config-gui.service

/usr/sbin/nv-oem-config-firstboot

OEM的GUI配置模式
nv-oem-config-debconf@.service

OEM的文本配置模式,与GUI配置模式冲突

OEM流程图

各脚本详细运行过程

/etc/systemd/nvfb-early.sh

  1. 检查/etc/nv/nvfirstboot文件是否存在,若不存在则直接退出,实际用于检测是否为第一次启动
  2. 设置库路径:在update-alternatives中添加/etc/ld.so.conf.d/aarch64-linux-gnu_EGL.conf的/usr/lib/aarch64-linux-gnu/tegra-egl/ld.so.conf候选项
  3. 设置库路径:在update-alternatives中添加/etc/ld.so.conf.d/aarch64-linux-gnu_GL.conf的/usr/lib/aarch64-linux-gnu/tegra/ld.so.conf候选项
  4. 设置python:在update-alternatives中添加python程序的python2和python3两个候选
  5. 给NANO/TX2NX/XAVIER添加LIB_DIR
  6. 运行ldconfig
  7. 获取内存大小,如果小于4G,则使用lightdm作为默认的图形管理器
  8. 设置任何用户都可启动X server

/etc/systemd/nvpower.sh

  1. 从/proc/device-tree/compatible获取soc等信息,确认模组
  2. 设置/sys/power/state权限为0666
  3. 根据模组确认电源模式配置文件,并链接到/etc/nvpmodel.conf
  4. 根据soc确认风扇的配置文件,并链接到/etc/nvfancontrol.conf
  5. xavier部分设备特殊处理了cpu6和cpu7
  6. CPU设置
  7. 验证xavier-nx上的电源模式配置文件
  8. 设置xavier系列和orin系列产品的硬件监控(采集样本数512,采集间隔430ms)

/etc/systemd/nvweston.sh

  1. 创建了weston-launch用户组

/etc/systemd/nvpmodel.sh

  1. 设置powermode(/usr/sbin/nvpmodel -f /etc/nvpmodel.conf)

/etc/systemd/nv-oem-config.sh

  1. 获取cmdline
  2. 启动服务nv-l4t-usb-device-mode.service
  3. 加载nvresizefs、nvswap、nvpmodel、nvqspi-update、nvqspi-update的模板到debconf
  4. 确保/var/cache/debconf/config.dat与/var/cache/debconf/templates.dat文件不被其他进程使用
  5. 查询cmdline中是否存在自动配置的字段nv-auto-config,如果有则使用/nv_preseed.cfg文件来进行自动配置,并且自动配置时需要删除/usr/lib/ubiquity/plugins/nv*.py,因为oem-config中无法自动配置自定义的插件
  6. 在虚拟终端7上使用X server查询是否有显示器连接
  7. 如果有显示器连接则启动nv-oem-config-gui.service
  8. 如果没有显示器连接则从/etc/nv-oem-config.conf文件中获取串口设备号,设置串口并启动nv-oem-config-debconf@.service

nv-oem-config-debconf@.service中的脚本

  1. 运行/usr/lib/nvidia/license/nvlicense-templates.sh用于设置license
  2. 加载nvlicense的模板到deconf
  3. 以debconf_ui为前端显示启动nv-oem-config-firstboot

nv-oem-config-firstboot

  1. 删除/var/lib/kdm/kdmsts并重置用户名密码
  2. 如果是KDE桌面,需要在/etc/sddm.conf中添加#original_oem_version
  3. 运行deconf中配置的oem-config/early_command
  4. 非debug模式下,如果前端显示为debconf_ui,直接运行/usr/sbin/oem-config-wrapper
  5. 如果连接了显示器,则在虚拟终端7上启动/usr/bin/ubiquity-dm用于启动桌面环境,并运行/usr/sbin/oem-config-wrapper
  6. 如果配置了删除命令(oem-config/remove,默认是true),删除用于配置的oem用户
  7. 设置默认的target到graphical.target
  8. 禁用服务nv-oem-config-debconf.service、nv-oem-config-gui.service、nv-oem-config.service、nv-oem-config.target并删除
  9. 停止所有与graphical.target有冲突的服务并立即切换到graphical.target
  10. debug模式则调出bash

/usr/sbin/oem-config-wrapper

  1. 运行oem-config,这里的oem-config其实是个软连接,实际运行了ubiquity
  2. ubiquity根据插件的优先级和顺序依次展示需要配置的页面
  3. 根据前端显示类型调用oem-config-remove或oem-config-remove-gtk,作用是删除ubiquity、ubiquity-casper、ubiquity-ubuntu-artwork、ubiquity-slideshow-*、oem-config-slideshow-*等安装包并删除/etc/systemd/system/ubiquity.service服务

/etc/systemd/nv-oem-config-post.sh

  1. 切换target完成后,重启tty服务
  2. 如果设置了wifi,启动wifi网络
  3. 重启nv-l4t-usb-device-mode.service
  4. 删除配置文件/lib/systemd/system/nv-oem-config*.* 、/usr/sbin/nv-oem-config-firstboot、/etc/systemd/nv-oem-config*.sh、rm -f /etc/nv-oem-config.conf.*

启动对比

启动过程对比

主要对比启动时使用到的nv相关的服务

Jetson AGX Orin首次启动

Jetson AGX Orin常规启动

订制rootfs首次启动

订制rootfs常规启动

nvpower.service
nv-l4t-usb-device-mode-runtime.service
nvfb-udev.service
nv_nvsciipc_init.service
nv.service
nvfb-early.service
nvphs.service
nv-l4t-usb-device-mode.service
nvpmodel.service
nv-l4t-bootloader-config.service
nvfb.service
nv-oem-config-gui.service

nvfb.service
nvfb-early.service
nv_nvsciipc_init.service
nvfb-udev.service
nvphs.service
nv-l4t-bootloader-config.service
nvpower.service
nv-l4t-usb-device-mode-runtime.service
nv-l4t-usb-device-mode.service
nvpmodel.service

nvfb-udev.service
nv_nvsciipc_init.service
nvpower.service
nv.service
nvphs.service
nv-l4t-bootloader-config.service
nvpmodel.service
nv-l4t-usb-device-mode.service
nvfb-early.service
nvfb.service

nvfb-udev.service
nvfb.service
nvfb-early.service
nv_nvsciipc_init.service
nvpower.service
nvphs.service
nv.service
nv-l4t-bootloader-config.service
nv-l4t-usb-device-mode.service
nvpmodel.service

可以看到在常规启动时两者服务几乎一致,有出入的服务为nv-l4t-usb-device-mode-runtime.service和nv.service

  • nv-l4t-usb-device-mode-runtime.service和nv-l4t-usb-device-mode.service这两个服务运行的脚本是一致的
  • nv.service中的脚本运行一次和多次是没有影响的,所以开机启动也没问题

首次启动时,相差的服务即为nv-oem-config-gui.service,订制的rootfs中已经集成了一部分,与开发板还有一些不同:

  • 开发板可设置APP分区的大小
  • 开发板可设置是否安装chromium browser
  • 开发板在运行oem完成后会删除ubiquity、ubiquity-casper、ubiquity-ubuntu-artwork、ubiquity-slideshow-*、oem-config-slideshow-*等安装包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值