我們會在硬體上進行 SDV 內部測試。我們在 QNX 上使用 QVM 進行虛擬化。 我們以範例形式分享所有目標、文件和設定。
必要條件
本頁假設您已預先設定 QNX,因此不會說明如何建構、設定或將 QNX 刷新至硬體。
本頁面假設您在 arm64 硬體上執行 QNX,並建構及使用 SDV 的 _arm64 目標。
必要元件
- 定義虛擬硬體的裝置樹狀結構 Blob (DTB)
- 要使用的 Linux 核心
- 包含所有 ramdisk 開機屬性的合併 ramdisk
- 移交 DICE 鏈結,用於 SDV VM 驗證
- 系統的所有磁碟分割區
- VM 的 QVM 設定
裝置樹狀結構 blob (DTB)
QVM 會根據設定產生大部分的裝置樹狀結構 Blob (DTB)。 因此,DTB 可以是最小的:
/*
* Copyright (C) 2026 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/dts-v1/;
/ {
model = "Virtual Machine";
#address-cells = <2>;
#size-cells = <2>;
// This reserved-memory node specifies for the open-dice driver which memory region(s) to
// expose as /dev/open-dice<n> device(s)
reserved-memory {
// The number of u32 cells to represent the address of a memory region
#address-cells = <2>;
// The number of u32 cells to represent the size of a memory region
#size-cells = <2>;
ranges;
// The unit address (after the @) must match the address in the reg property
dice@D1C30000 {
// The open-dice driver receives this device tree node based on this
// property.
compatible = "google,open-dice";
no-map;
// The address and the size of the memory region that is passed to the
// open-dice driver.
// First two hex numbers (cells) represent the address of the memory region,
// the last two represent its size (4K, in this case).
reg = <0x0 0xD1C30000 0x0 0x1000>;
};
};
};
核心
SDV 使用通用核心映像檔 (GKI),您可以直接使用建構作業的輸出內容。
RAM 磁碟
ramdisk 資訊應包含 Android 產生的不同 ramdisk 和開機屬性。由於 QNX 預設不支援開機載入程式,因此您必須以預期資料格式產生 ramdisk。
您可以使用下列 Python 指令碼執行這項操作,該指令碼會串連多個 RAM 磁碟,並以預期格式新增 bootconfig (即 vendor-bootconfig.img 檔案):
def create_qnx_ramdisk(output: io.BytesIO,
ramdisks: Sequence[io.BytesIO],
bootconfig: Optional[io.BytesIO]):
BUFFER_SIZE = 4096
for ramdisk in ramdisks:
while buf := ramdisk.read(BUFFER_SIZE):
output.write(buf)
# Kernel looks for bootconfig at the end of ramdisk.
if bootconfig:
bootconfig_checksum = 0
bootconfig_size = 0
while buf := bootconfig.read(BUFFER_SIZE):
bootconfig_checksum = (bootconfig_checksum + sum(buf)) & 0xFFFFFFFF
bootconfig_size += len(buf)
output.write(buf)
output.write(struct.pack('II', bootconfig_size, bootconfig_checksum))
output.write(b'#BOOTCONFIG\n')
DICE 鏈結
在生產系統中,主機系統和開機載入程式會在開機程序期間動態建構 DICE 鏈,並提供 DICE 鏈給訪客,以驗證映像檔是否可信任。由於這項規定可能會使測試和開發流程變得複雜,因此您會改為載入 DICE 鏈結快照。
如要產生 dice_handover_instance* 檔案,請使用任何 SDV Cuttlefish 建構版本。
例如:
lunch sdv_core_cf-trunk_staging-userdebug
m
cp $OUT/product/etc/dice_handover_instance* <GUEST>/test_dice_handover
磁碟
QVM 支援多種虛擬磁碟格式;我們的參考設定使用包含所有分割區的磁碟映像檔。bpttool 可以產生這些磁碟,但 Android 並未積極開發這項工具。
QVM 設定
QVM 設定會設定設定,並指向不同的檔案。我們提供下列設定範例:
常見問題
問:adb 無法連線至我的 VM。該怎麼辦?
答:在這個設定中,adb 會使用乙太網路連線至 VM。您需要在 QNX 上設定通訊埠轉送,將要求轉送至通訊埠 5555 上的訪客。您需要連線至主機系統。或者,您也可以設定 VM 的橋接器,然後直接連線至 VM。
問:系統記錄顯示 IServiceRegistrationAgent 遺失。
答:服務探索功能需要完全正常運作的信任和繫結設定。請確認 OpenDICE 已成功載入,且 HwBinder 在啟動期間未顯示錯誤。如果這些功能無法運作,請先修正問題。
問:init_open_dice 失敗。發生什麼事?
答:啟動指令碼會在啟動期間載入信任資訊,並清除記憶體位置。請在 QVM 設定中確認 cmdline 設定和記憶體位置中的共用資料是否相符。此外,請確認驅動程式、QVM 設定和 DTB 中的記憶體位置是否相符,以及記憶體位置是否可寫入。