SDV บน QNX

เราทดสอบ SDV บนฮาร์ดแวร์ภายใน เราใช้ QVM ใน QNX สำหรับการจำลองเสมือน เราแชร์เป้าหมาย เอกสารประกอบ และการกำหนดค่าทั้งหมดเป็นตัวอย่าง

สิ่งที่ต้องมีก่อน

หน้านี้ถือว่ามีการกำหนดค่า QNX ไว้ล่วงหน้า และไม่ได้รวมขั้นตอนในการสร้าง กำหนดค่า หรือแฟลช QNX ในฮาร์ดแวร์

หน้านี้ถือว่าคุณใช้ QNX ในฮาร์ดแวร์ arm64 และสร้างและใช้เป้าหมาย _arm64 ของ SDV

คอมโพเนนต์ที่จำเป็น

  • Blob ของแผนผังอุปกรณ์ (DTB) เพื่อกำหนดฮาร์ดแวร์เสมือน
  • เคอร์เนล Linux ที่จะใช้
  • Ramdisk แบบรวมที่มีพร็อพเพอร์ตี้การบูต ramdisk ทั้งหมด
  • การส่งต่อห่วงโซ่ DICE สำหรับการตรวจสอบสิทธิ์ VM ของ SDV
  • พาร์ติชันดิสก์ทั้งหมดของระบบ
  • การกำหนดค่า QVM ของ VM

Device Tree Blob (DTB)

QVM จะสร้าง Device Tree 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 ใช้ Generic Kernel Image (GKI) และคุณสามารถใช้เอาต์พุตจากบิลด์ได้โดยตรง

Ramdisk

ข้อมูล Ramdisk ควรมี Ramdisk ต่างๆ ที่ Android สร้างขึ้นและพร็อพเพอร์ตี้การบูต เนื่องจาก QNX ไม่รองรับ Bootloader โดยค่าเริ่มต้น คุณจึงต้องสร้าง Ramdisk ที่มีรูปแบบข้อมูลที่คาดไว้

คุณทำได้โดยใช้สคริปต์ Python ต่อไปนี้ ซึ่งจะต่อกันหลายๆ ramdisk และเพิ่ม 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

ในระบบที่ใช้งานจริง ระบบโฮสต์และ Bootloader จะสร้างห่วงโซ่ 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 จะตั้งค่าการกำหนดค่าและชี้ไปยังไฟล์ต่างๆ เรามีตัวอย่างการกำหนดค่าต่อไปนี้

  • การกำหนดค่า VM ของ SDV Core
  • การกำหนดค่า VM ของ SDV Media
  • VM IVI ที่ผสานรวม SDV

คำถามที่พบบ่อย

คำถาม: adb เชื่อมต่อกับ VM ไม่ได้ ฉันต้องทำอย่างไร

ตอบ: ในการตั้งค่านี้ adb จะใช้อีเทอร์เน็ตเพื่อเชื่อมต่อกับ VM คุณต้องมีการกำหนดค่าการส่งต่อพอร์ตใน QNX ที่ส่งต่อคำขอไปยังแขกในพอร์ต 5555 คุณต้องเชื่อมต่อกับระบบโฮสต์ หรือคุณจะ กำหนดค่าบริดจ์ไปยัง VM และเชื่อมต่อกับ VM โดยตรงก็ได้

ถาม: บันทึกของระบบแสดงว่าไม่มี IServiceRegistrationAgent ทำไมจึงเป็นเช่นนั้น

ตอบ: Service Discovery ต้องอาศัยการตั้งค่าความน่าเชื่อถือและ Binder ที่ใช้งานได้อย่างสมบูรณ์ ตรวจสอบ ว่าโหลด OpenDICE สำเร็จ และ HwBinder ไม่แสดงข้อผิดพลาดระหว่าง การเริ่มต้น หากวิธีดังกล่าวไม่ได้ผล คุณต้องแก้ไขก่อน

คำถาม: init_open_dice ไม่สำเร็จ เกิดอะไรขึ้น

ตอบ: สคริปต์เริ่มต้นจะโหลดข้อมูลความน่าเชื่อถือในระหว่างการเริ่มต้น และล้างตำแหน่งหน่วยความจำ ตรวจสอบในการกำหนดค่า QVM ว่าการกำหนดค่า cmdline และข้อมูลที่แชร์ในตำแหน่งหน่วยความจำเข้ากันได้ นอกจากนี้ ให้ตรวจสอบว่าตำแหน่งหน่วยความจำในไดรเวอร์ การกำหนดค่า QVM และ DTB ตรงกัน และตำแหน่งหน่วยความจำสามารถเขียนได้