TegraPwmDxe 驱动PWM5点亮背光问题

Jetson Orin Nano 8G + 自制载板,R36.4.3版本。

背光使用的是GPIO13(PWM5)引脚,目前修改设备树,在启动linux后的背光功能已经正常。(编译dts后,cp $DEVDIR/source/kernel-devicetree/generic-dts/dtbs/tegra234-p3768-0000+p3767-0003-nv.dtb 到目标板 /boot/dtb/下,并在extlinux.conf中用FDT指定该dtb,功能pass)

下一步是想在linux启动前,让背光能点亮。我已经下载了edk2代码,在TegraPwmDxe.c中加入了调试打印信息,编译后替换到$DEVDIR/bootloader/uefi_jetson.bin,flash QSPI后,在控制台串口已经能显示调试信息。我想继续验证UEFI所载入的dtb信息,于是cp $DEVDIR/source/kernel-devicetree/generic-dts/dtbs/*.dtb $DEVDIR/kernel/dtb/ 再次flash QSPI,不能进入linux系统。

我的疑问:
1,UEFI载入的dtb是不是$DEVDIR/kernel/dtb/tegra234-p3768-0000+p3767-0003-nv.dtb,能不能直接使用kernel的dtb?
2,flash QSPI 后为什么会不能进入系统,是我替换了不该修改的部分吗?

*** Please note that this reply is generated by LLM automatically ***

The provided information is related to the NVIDIA Jetson Orin Nano series, specifically the Jetson Orin Nano 8GB module (P3767-0003).

The question seems to be asking about the configuration and flashing process of the Jetson Orin Nano 8GB module.

Here’s a comprehensive answer:

The Jetson Orin Nano 8GB module (P3767-0003) is a commercial module that is part of the NVIDIA Jetson Orin Nano series. It is compatible with the Jetson Orin Nano Developer Kit (P3766), which includes the P3767-0005 module.

The module can be flashed using the jetson-orin-nano-devkit.conf file, which supports flashing one of the following modules attached to a Jetson Orin Nano Carrier board (P3768-0000):

  • Jetson Orin Nano developer kit module with SD Card (P3767-0005)
  • Jetson Orin Nano 8GB module (P3767-0003)
  • Jetson Orin Nano 4GB module (P3767-0004)
  • Jetson Orin NX 16GB module (P3767-0000)
  • Jetson Orin NX 8GB module (P3767-0001)

The flashing process involves using the l4t_initrd_flash.sh script, which supports flashing QSPI-NOR and microSD Card/USB/NVMe drive.

For example, to flash the Jetson Orin Nano 8GB module with an NVMe drive, you can use the following command:

sudo BOARDID=<BOARDID> FAB=<FAB> BOARDSKU=<BOARDSKU> CHIP_SKU=<CHIP_SKU> RAMCODE_ID=<RAMCODE_ID> \
./tools/kernel_flash/l4t_initrd_flash.sh \
                         --mass-storage-only \
                         --showlogs \
                         --network usb0 \
                         --no-flash \
                         --external-device nvme0n1p1 \
                         --external-only \
                         -c ./tools/kernel_flash/flash_l4t_t234_nvme.xml \
                         --uefi-keys ~/oem_keys/uefi_keys/uefi_keys.conf \
                         --uefi-enc ~/oem_keys/uefi_keys/uefi_enc.key \
                         jetson-orin-nano-devkit \
                         nvme0n1p1

This command will generate a upi_oem.tar.gz file, which contains the flashed image.

In comparison to other modules in the Jetson Orin Nano series, the Jetson Orin Nano 8GB module (P3767-0003) has similar characteristics and flashing processes. However, the specific flashing commands and configurations may vary depending on the module and the developer kit being used.

For example, the Jetson Orin Nano 4GB module (P3767-0004) can be flashed using the same jetson-orin-nano-devkit.conf file, but with a different flashing command:

sudo ./flash.sh jetson-orin-nano-devkit internal

This command will flash the QSPI-NOR and USB/NVMe drive.

In summary, the Jetson Orin Nano 8GB module (P3767-0003) can be flashed using the l4t_initrd_flash.sh script and the jetson-orin-nano-devkit.conf file, with specific configurations and commands depending on the module and the developer kit being used.

*** Please give the thumbs up if you get answers you like. Or provide feedback to help us improve the answer. ***

AI的回答没有解决我关心的问题,附件是不能启动系统时的日志

log.txt (216.0 KB)

我又做了验证,使用我修改后的设备树tegra234-p3768-0000+p3767-0003-nv.dtb这一个文件,复制到$DEVDIR/kernel/dtb/目录,flash QSPI 后就会不能进入系统,排除了其他文件的影响。还原这一个文件为原始的dtb后,flash QSPI就能正常进系统。

Hi pwpost,

UEFI and kernel would use the same DTB file by default.
You can refer to the following line in board config. (i.e. jetson-orin-nano-devkit.conf)

DTB_FILE=tegra234-p3768-0000+p3767-0000-nv.dtb;
TBCDTB_FILE="${DTB_FILE}";

Can you check what customization causes the boot issue?
It may be caused from the wrong UEFI source you synced.
Please share the exact command you run to download the source to confirm if it sync the correct branch for r36.4.3.

Hi KevinFFF, 感谢您的回复。

1,修改.conf文件的DTB_FILE字段后,发现用自己编译的dtb还是会进入UEFI Shell,检查.conf文件,里面有#select bpmp-dtb and kernel-dtb based on SKU的功能,修改这个字段是不是无效?
实测修改该字段后,用原生的dtb能启动,用修订后的dtb还是进入UEFI Shell,问题依旧。

2,UEFI source是按照 Build without docker · NVIDIA/edk2-nvidia Wiki · GitHub 网页的步骤,顺序执行的。其中Create workspace,是执行的 edkrepo clone nvidia-uefi NVIDIA-Platforms main

进入UEFI Shell后,AI给出的提示让查询 map -r ,得到如下信息,看是否能帮助,

flash.log (98.5 KB)

另外附上了flash QSPI的日志。

I don’t think you need to update these part as they will select correct DTB according to the module SKUI/FAB in use.

It will sync the main branch which may not work for the r36.4.3.
Please run the following command instead.

$ edkrepo clone nvidia-uefi-r36.4.3 NVIDIA-Platforms r36.4.3

这个页面说明了comba=main时,是支持R36.4.3的。还必须更新用r36.4.3branch吗?

Yes, I would suggest using r36.4.3 or r36.4.3-updates instead.

$ edkrepo clone nvidia-uefi-r36.4.3 NVIDIA-Platforms r36.4.3
Or
$ edkrepo clone nvidia-uefi-r36.4.3-updates NVIDIA-Platforms r36.4.3-updates

谢谢您的回复

我没有使用edkrepo clone nvidia-uefi-r36.4.3 NVIDIA-Platforms r36.4.3,因为替换该指令后,文档的后续步骤执行会出错;而目前使用edkrepo clone nvidia-uefi NVIDIA-Platforms main能够正常编译,用编译后的uefi_t23x_general_DEBUG.bin替换 Linux_for_Tegra/bootloader/uefi_jetson.bin后,重新烧写后,我加入的调试日志信息能正常显示,所以先不在这里消耗时间了。

现在有两个问题

1,我观察烧写QSPI的flash日志, tegraflash.py … –overlay_dtb L4TConfiguration.dtbo, tegra234-carveous.dtbo, tegra-optee.dtbo, tegra234-p3768-0000+p3767-0000-dynamic.dtbo, –bldtb tegra234-p3768-0000+p2767-0003-nv.dtb …. 如果我用已修改的内核dtb代替了–bldtb后续的文件,就会启动失败,进入UEFI Shell,还原成原生的dtb就能正常。

2,我怎样用同一份dts生成分别适合uefi和kernel的两份dtb,是该用dtb_overlay的方法吗?

更新状态:修改TegraPwmDxe.c文件,让CompatArray增加一项”pwm-backlight”,并修改case DeviceDiscoveryDriverBindingSupported: 分支,让pwm控制器初始化时,能遍历检索到pwm-fan和pwm-backlight两个节点。这样重新编译并flash后,开机时屏幕已经可以点亮,能看到nvidia的开机logo,此时fan pwm也能输出方波。

但是数秒后,大概是在控制台输出EFI stub: Booting Linux Kernel…前后,背光会黑掉,此时风扇的pwm方波也会消失,等进入linux系统后,背光会再次亮起,风扇方波也会恢复。这个问题该怎么排查?

这个问题还没有解决,有人能帮助一下吗

我尝试了您建议的操作:

edkrepo clone nvidia-uefi-r36.4.3 NVIDIA-Platforms r36.4.3

cd nvidia-uefi-r36.4.3

sudo -E ./edk2-nvidia/Platform/NVIDIA/TegraVirt/build.sh --target RELEASE --init-default edk2-nvidia/Platform/NVIDIA/Jetson/Jetson.defconfig

此时会报错:

utu@utu:/opt/nvidia-uefi-r36.4.3 [r36.4.3]$ sudo -E ./edk2-nvidia/Platform/NVIDIA/TegraVirt/build.sh --target RELEASE --init-default edk2-nvidia/Platform/NVIDIA/Jetson/Jetson.defconfig
[sudo] password for utu:
nvidia: building from workspace rooted at: /opt/nvidia-uefi-r36.4.3
nvidia: found command: python3.
nvidia: found command: virtualenv.
nvidia: found command: mono.
nvidia: found command: aarch64-linux-gnu-gcc.
nvidia: found Python 3.10 or later.
nvidia: Creating Python virtual environment in /opt/nvidia-uefi-r36.4.3/venv…
created virtual environment CPython3.10.12.final.0-64 in 4864ms
creator CPython3Posix(dest=/opt/nvidia-uefi-r36.4.3/venv, clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/utu/.local/share/virtualenv)
added seed packages: pip==22.0.2, setuptools==59.6.0, wheel==0.37.1
activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
edk2-nvidia/Silicon/NVIDIA/scripts/prepare_stuart.sh: line 29: venv/bin/activate: No such file or directory

随后按照AI给的提示,绕了一大圈,还是不能正常编译。

说明文档给的示例是:edk2-nvidia/Platform/NVIDIA/Tegra/build.sh --init-defconfig edk2-nvidia/Platform/NVIDIA/Tegra/DefConfigs/t26x_general.defconfig

在r36.4.3中,edk2-nvidia/Platform/NVIDIA/Tegra目录不存在,我替换为TegraVirt,

默认配置t23x_general.defconfig文件也不存在,我替换为Jetson.defconfig还是不行

@KevinFFF

更新状态,使用r36.4.3 ,编译指令修改为

edk2-nvidia/Platform/NVIDIA/Jetson/build.sh –target RELEASE –init-default edk2-nvidia/Platform/NVIDIA/Jetson/Jetson.defconfig

编译时会有两处报错,分别是 prepare_stuart.sh: line29, 和 build_stuart.sh: line28,都是venv/bin/activate文件找不到,修改为 venv/local/bin/activate后,能继续编译,后续还是有出错,附件为编译logo,这个错误该如何修复?

BUILDLOG_Jetson.txt (192.0 KB)

For r36.4.3, please run the following command to build UEFI source instead.

$ edk2_docker edk2-nvidia/Platform/NVIDIA/Jetson/build.sh 

Please also check if Building UEFI for Jetson Orin AGX - r36.4.4 - #6 by KevinFFF could help for your case.

Please check the following snippet from board config(jetson-orin-nano-devkit.conf)

DTB_FILE=tegra234-p3768-0000+p3767-0000-nv.dtb;
TBCDTB_FILE="${DTB_FILE}";

By default, UEFI-DTB and Kernel-DTB are the same.
You can simply specify different DTB files for them according to your use case.

谢谢你的回复,我参照链接,执行了如下指令

cd nvidia-uefi-r36.4.3
source venv/local/bin/activate
pip install ‘setuptools<70’
python -c “import pkg_resources; print(pkg_resources._file_)”
deactivate

重新编译

sudo -E ./edk2-nvidia/Platform/NVIDIA/Jetson/build.sh --target RELEASE --init-default edk2-nvidia/Platform/NVIDIA/Jetson/Jetson.defconfig

仍然返回了错误,

INFO - GenFw: ERROR 3000: Invalid
INFO - DOS header signature was not found in /opt/nvidia-uefi-r36.4.3/Build/Jetson/DEBUG_GCC5/AARCH64/MdeModulePkg/Application/UiApp/UiApp/DEBUG/UiApp.dll image.
INFO - make: *** [GNUmakefile:431: /opt/nvidia-uefi-r36.4.3/Build/Jetson/DEBUG_GCC5/AARCH64/MdeModulePkg/Application/UiApp/UiApp/OUTPUT/UiApp.efi] Error 2
INFO - make: Nothing to be done for ‘tbuild’.
INFO - : error 7000: Failed to execute command
INFO - : error F002: Failed to build module

详细log附后

BUILDLOG_Jetson.txt (193.4 KB)

Could you try running the following command to build the source w/o adding the options?

$ edk2_docker edk2-nvidia/Platform/NVIDIA/Jetson/build.sh 

Please also check if the UEFI binary can be built when you remove all customizations in UEFI source.

感谢您的及时回复,我采用的是非docker方式。因为外部网络环境原因,docker方式下载并不顺利,所以edk2_docker命令不存在的。

执行edk2-nvidia/Platform/NVIDIA/Jetson/build.sh后,仍然有错误,完整log如下:

BUILDLOG_Jetson.txt (191.6 KB)

Please also check if the UEFI binary can be built when you remove all customizations in UEFI source.

代码和文档,都是处于git clone后的状态,仅修改了两处脚本,将错误路径 venv/bin/activate修改为venv/local/bin/activate。