自编译RT-Smart SDK镜像运行异常

Viewed 45

问题描述


运行face_detection例程异常

复现步骤


官网下载SDK,手上两款开发板,庐山派/k230_canmv_v1.1,
运行hellowordl 正常
face_detection 下执行face_detect_image.sh 正常
但执行face_detect_isp.sh
异常
经过多次认证,自行编译镜像,只要图像输出和摄像头采集均运行异常,
但官网下载RtSmart-K230_LCKFB_rtsmart_v0.7-0-g0946d74_nncase_v2.9.0.img运行正常

硬件板卡


庐山派,k230_canmv_v1.1

软件版本


RT-Smart SDK0.7

其他信息


命令交互信息

list_connector
Connector Type List:
         68711360 -> HX8399_1080_1920_DSI_V1
        135512464 -> ILI9806_480_800_DSI_V1
        202785408 -> ILI9881_800_1280_DSI_V1
        605274512 -> ST7701_480_800_DSI_V1
        605274539 -> ST7701_480_854_DSI_V1
        605274432 -> ST7701_480_640_DSI_V1
        605217040 -> ST7701_368_544_DSI_V1
        538165428 -> AML020T_480_360_DSI_V1
        754974720 -> LT9611_0_0_HDMI_ADAPT
        757006876 -> LT9611_1920_1080_HDMI_V1
        758055452 -> LT9611_1920_1080_HDMI_V2
        759104028 -> LT9611_1920_1080_HDMI_V3
        760152604 -> LT9611_1920_1080_HDMI_V4
        761201180 -> LT9611_1920_1080_HDMI_V5
        756679016 -> LT9611_1280_720_HDMI_V1
        757727592 -> LT9611_1280_720_HDMI_V2
        758776168 -> LT9611_1280_720_HDMI_V3
        756351216 -> LT9611_640_480_HDMI_V1
        672260256 -> JD9852_240_320_DSI_V1
                0 -> VIRTUAL_DISPLAY_DEVICE
               -1 -> UNKNOWN
msh />
msh />cd /sdcard/app/examples/ai/face_detection
msh /sdcard/app/examples/ai/face_detection>
msh /sdcard/app/examples/ai/face_detection>
msh /sdcard/app/examples/ai/face_detection>face_detect_isp.sh
[W/LWP] not use fast load, out of memory 33554432 < 36205032
case ./face_detection.elf built at Apr 28 2026 14:57:42
connector_dev_ioctl: no panel selected (call INIT first)
kd_mpi_connector_power_set, error(-1)
ERROR: kd_mpi_connector_power_set failed, ret=-1609859064
dump dev(0)chn(1) failed.
kd_mpi_vicap_dump_frame failed.
<3>[2] [Func]:hil_map_mmz_check_phys [Line]:1235 [Info]:ERROR: MMAP ADDR: 0x0-0xa9000

============ CRASH REPORT ===================
Exception 13: Load Page Fault
  scause = 0x000000000000000d
  stval  = 0x0000000000000009  (fault address)
  sepc   = 0x00000002007b5816  (program counter)
  ra     = 0x00000002007b5814  (return address)
  sp     = 0x0000000100022210
  frame  = 0x000000000045e958  (trap frame on stack)
  fp/s0  = 0x00000001000222f0
  mode   = USER (SPP=0)
  sepc   : in user space
  stval  : INVALID address (unmapped?)
=============================================

--------------Dump Registers-----------------
Function Registers:
	ra(x1) = 0x00000002007b5814()
	user_sp(x2) = 0x0000000100022210()
	gp(x3) = 0x0000000000000000()
	tp(x4) = 0x0000000100022bd8()
Temporary Registers:
	t0(x5) = 0x0000000000000035()
	t1(x6) = 0x0000000000000004()
	t2(x7) = 0x0000000000000000()
	t3(x28) = 0x000000000000018f()
	t4(x29) = 0x0000000000000001()
	t5(x30) = 0x0000000000000001()
	t6(x31) = 0x0000000000000001()
Saved Registers:
	s0/fp(x8) = 0x00000001000222f0()
	s1(x9) = 0x0000000200ab97b8()
	s2(x18) = 0x0000000400000001()
	s3(x19) = 0x0000000000000001()
	s4(x20) = 0x0000000200ade2e8()
	s5(x21) = 0x7ffffffffffffff8()
	s6(x22) = 0x00000001000222a8()
	s7(x23) = 0x0000000300015ac0()
	s8(x24) = 0x0000000100022af8()
	s9(x25) = 0x0000000200ade200()
	s10(x26) = 0x0000000000000000()
	s11(x27) = 0x0000000100000000()
Function Arguments Registers:
	a0(x10) = 0x0000000000000001()
	a1(x11) = 0x0000000000000000()
	a2(x12) = 0x00000001000223a8()
	a3(x13) = 0xfffffffffffff800()
	a4(x14) = 0x0000000000000008()
	a5(x15) = 0x0000000000000000()
	a6(x16) = 0x0000000100022410()
	a7(x17) = 0x0000000000000000()
sstatus = 0x8000000200046620
	Supervisor Interrupt Disabled
	Last Time Supervisor Interrupt Enabled
	Last Privilege is User Mode
	Permit to Access User Page
	Not Permit to Read Executable-only Page
satp = 0x800000000000fffc
	Current Page Table(Physical) = 0x000000000fffc000
	Current ASID = 0x0000000000000000
	Mode = Page-based 39-bit Virtual Addressing Mode
-----------------Dump OK---------------------
------------- Thread Info -------------------
  name        : face_detection.elf
  status      : 0x03
  stack_addr  : 0x0000000000680640
  stack_size  : 0x20000 (131072)
  stack_top   : 0x00000000006a0640
  stack_used  : 0xf40 (3904) = 2% of 131072  (fill=0x23)
------------- Code Around sepc --------------
  0x2007b5806: <inaccessible>
  0x2007b5808: <inaccessible>
  0x2007b580a: <inaccessible>
  0x2007b580c: <inaccessible>
  0x2007b580e: <inaccessible>
  0x2007b5810: <inaccessible>
  0x2007b5812: <inaccessible>
  0x2007b5814: <inaccessible>
  0x2007b5816: <inaccessible>
  0x2007b5818: <inaccessible>
  0x2007b581a: <inaccessible>
  0x2007b581c: <inaccessible>
  0x2007b581e: <inaccessible>
  0x2007b5820: <inaccessible>
  0x2007b5822: <inaccessible>
  0x2007b5824: <inaccessible>
  0x2007b5826: <inaccessible>
------------- Frame Pointer Backtrace -------
  #0  pc = 0x00000002007b5816
  -- user-space backtrace not supported
------------- addr2line command --------------
riscv64-unknown-linux-musl-addr2line -e rtthread.elf -a -f 0x2007b5816
------------- Stack Memory Dump -------------
  sp = 0x0000000100022210
   0x00000001000221d0: <inaccessible>
   0x00000001000221d8: <inaccessible>
   0x00000001000221e0: <inaccessible>
   0x00000001000221e8: <inaccessible>
   0x00000001000221f0: <inaccessible>
   0x00000001000221f8: <inaccessible>
   0x0000000100022200: <inaccessible>
   0x0000000100022208: <inaccessible>
   0x0000000100022210: <inaccessible>
   0x0000000100022218: <inaccessible>
   0x0000000100022220: <inaccessible>
   0x0000000100022228: <inaccessible>
   0x0000000100022230: <inaccessible>
   0x0000000100022238: <inaccessible>
   0x0000000100022240: <inaccessible>
   0x0000000100022248: <inaccessible>
   0x0000000100022250: <inaccessible>
   0x0000000100022258: <inaccessible>
   0x0000000100022260: <inaccessible>
   0x0000000100022268: <inaccessible>
   0x0000000100022270: <inaccessible>
   0x0000000100022278: <inaccessible>
   0x0000000100022280: <inaccessible>
   0x0000000100022288: <inaccessible>
   0x0000000100022290: <inaccessible>
   0x0000000100022298: <inaccessible>
   0x00000001000222a0: <inaccessible>
   0x00000001000222a8: <inaccessible>
   0x00000001000222b0: <inaccessible>
   0x00000001000222b8: <inaccessible>
   0x00000001000222c0: <inaccessible>
   0x00000001000222c8: <inaccessible>
------------- All Thread Stacks -------------
  THREAD                STACK_ADDR        SIZE  USED%  STATUS
  face_detection.elf    0x00680640      131072    2%
  face_detection.elf    0x0065ca40      131072    2%
  usbh_rtl8152_rx       0x00657940        4096   36%
  cyw43                 0x00653b00        4096   51%
  mtp                   0x0064b780       20480    6%
  mtp_inty              0x00609980       20480    9%
  usbh_hub0             0x006053c0        4096   49%
  tshell                0x005ed940       81920    5%
  thermal_detect_threa  0x005e61c0       10240   13%
  auto_load_thread      0x005e0f40       10240   12%
  mcm_task              0x005d6400        8192   15%
  sdio_irq              0x005d0440       10240   17%
  usage_thread          0x005af580        8192   16%
  gpio_irq_to_user      0x0059eb40       20480    6%
  gpio_debounce         0x00596fc0       20480    6%
  sys workq             0x0058f240       20480    6%
  wlan                  0x0058b6c0        4096   31%
  mmcsd_detect          0x0056e558       32768   57%
  tcpip                 0x00586240       10240   13%
  etx                   0x005651a0       10240   13%
  erx                   0x0055ff18       10240   13%
  tsystem               0x00523080       16384    8%
  tidle0                0x00529a80       16384    6%
  timer                 0x00530840       16384    7%
  Total: 24 threads
riscv64-unknown-linux-musl-addr2line -e face_detection.elf -a -f 00000002007b5812

[E/DBG] User Fault, killing thread: face_detection.elf
4 Answers

你好,请问你这是编译的哪个demo?

examples/ai/face_detection

测试其他demo,比如yolo,只要图像输出和摄像头采集均运行异常都这样异常,而且很奇怪list_connector命令回应的类型很特别,

src/rtsmart/examples/ai/face_detection/src/video_pipeline.cc 这个文件的第114行和121行是什么函数?

examples/ai/face_detection,测试其他demo,比如yolo,只要图像输出和摄像头采集均运行异常都这样异常,而且很奇怪list_connector命令回应的类型很特别,

Connector Type List:
         68711360 -> HX8399_1080_1920_DSI_V1
        135512464 -> ILI9806_480_800_DSI_V1
        202785408 -> ILI9881_800_1280_DSI_V1
        605274512 -> ST7701_480_800_DSI_V1
        605274539 -> ST7701_480_854_DSI_V1
        605274432 -> ST7701_480_640_DSI_V1
        605217040 -> ST7701_368_544_DSI_V1
        538165428 -> AML020T_480_360_DSI_V1
        754974720 -> LT9611_0_0_HDMI_ADAPT
        757006876 -> LT9611_1920_1080_HDMI_V1
        758055452 -> LT9611_1920_1080_HDMI_V2
        759104028 -> LT9611_1920_1080_HDMI_V3
        760152604 -> LT9611_1920_1080_HDMI_V4
        761201180 -> LT9611_1920_1080_HDMI_V5
        756679016 -> LT9611_1280_720_HDMI_V1
        757727592 -> LT9611_1280_720_HDMI_V2
        758776168 -> LT9611_1280_720_HDMI_V3
        756351216 -> LT9611_640_480_HDMI_V1
        672260256 -> JD9852_240_320_DSI_V1
                0 -> VIRTUAL_DISPLAY_DEVICE
               -1 -> UNKNOWN

正常的应该是

Connector Type List:
                0 -> HX8377_V2_MIPI_4LAN_1080X1920_30FPS
                1 -> ILI9806_MIPI_2LAN_480X800_30FPS
                2 -> ILI9881_MIPI_4LAN_800X1280_60FPS
               20 -> ST7701_V1_MIPI_2LAN_480X800_30FPS
               21 -> ST7701_V1_MIPI_2LAN_480X854_30FPS
               22 -> ST7701_V1_MIPI_2LAN_480X640_30FPS
               23 -> ST7701_V1_MIPI_2LAN_368X544_60FPS
                9 -> AML020T_MIPI_2LAN_480X360_30FPS
              100 -> LT9611_MIPI_ADAPT_RESOLUTION
              101 -> LT9611_MIPI_4LAN_1920X1080_30FPS
              102 -> LT9611_MIPI_4LAN_1920X1080_60FPS
              103 -> LT9611_MIPI_4LAN_1920X1080_50FPS
              104 -> LT9611_MIPI_4LAN_1920X1080_25FPS
              105 -> LT9611_MIPI_4LAN_1920X1080_24FPS
              110 -> LT9611_MIPI_4LAN_1280X720_60FPS
              111 -> LT9611_MIPI_4LAN_1280X720_50FPS
              112 -> LT9611_MIPI_4LAN_1280X720_30FPS
              120 -> LT9611_MIPI_4LAN_640X480_60FPS
               30 -> JD9852_MIPI_1LAN_240X320_60FPS
              200 -> VIRTUAL_DISPLAY_DEVICE
               -1 -> UNKNOWN

看一下examples仓库的commit id?

SDK 的github-actions released this Mar 27. 23 commits to main since this releasev0.7 0946d74
examples 咋看呢

应该是 4dddecb

/* 管线创建:初始化 VB → 屏幕 → VO → OSD → VICAP → 绑定关系 */
int PipeLine::Create()
{
    ScopedTiming st("PipeLine::Create", debug_mode_);
    k_s32 ret = 0;

    // =============================================================================================
    // 1. 配置 Video Buffer(VB)系统
    // =============================================================================================
    memset(&config, 0, sizeof(k_vb_config));
    config.max_pool_cnt = 64;  // 最多支持 64 个内存池

    // 设置 VB 全局配置
    ret = kd_mpi_vb_set_config(&config);
    if (ret) {
        printf("vb_set_config failed ret:%d\n", ret);
        return ret;
    }

    // 设置 VB 附加配置(JPEG、ISP 统计等)
    k_vb_supplement_config supplement_config;
    memset(&supplement_config, 0, sizeof(supplement_config));
    supplement_config.supplement_config |= VB_SUPPLEMENT_JPEG_MASK;
    ret = kd_mpi_vb_set_supplement_config(&supplement_config);
    if (ret) {
        printf("vb_set_supplement_config failed ret:%d\n", ret);
        return ret;
    }

    // 初始化 VB 子系统
    ret = kd_mpi_vb_init();
    if (ret) {
        printf("vb_init failed ret:%d\n", ret);
        return ret;
    }

    // =============================================================================================
    // 2. 创建 OSD 专用 VB 内存池(用于 ARGB8888 叠加图层)
    // =============================================================================================
    // 用于存放一帧 OSD 数据(如 AI 结果绘制)
    if(USE_OSD == 1){
        k_vb_pool_config pool_config;
        memset(&pool_config, 0, sizeof(pool_config));
        pool_config.blk_cnt = 3; // 3 个缓冲块,避免帧冲突
        pool_config.blk_size = VICAP_ALIGN_UP((OSD_WIDTH * OSD_HEIGHT * OSD_CHANNEL), VICAP_ALIGN_1K);
        pool_config.mode = VB_REMAP_MODE_NOCACHE; // 非 cache 映射,避免缓存一致性问题
        osd_pool_id = kd_mpi_vb_create_pool(&pool_config);
    }

    // =============================================================================================
    // 3. 屏幕(Connector)配置
    // =============================================================================================
    k_connector_info connector_info;
    memset(&connector_info, 0, sizeof(k_connector_info));

    // 根据 connector 类型获取硬件参数
    ret = kd_mpi_get_connector_info(connector_type, &connector_info);
    if (ret) {
        printf("the connector type not supported!\n");
        return ret;
    }

    // 打开 connector 设备
    k_s32 connector_fd = kd_mpi_connector_open(connector_info.connector_name);
    if (connector_fd < 0) {
        printf("%s, connector open failed.\n", __func__);
        return K_ERR_VO_NOTREADY;
    }

    // 初始化 connector(配置时序、分辨率等)
    ret = kd_mpi_connector_init(connector_fd, connector_info);
    if (ret) {
        printf("ERROR: kd_mpi_connector_init failed, ret=%d\n", ret);
        return ret;
    }

    // 打开电源
    ret = kd_mpi_connector_power_set(connector_fd, K_TRUE);
    if (ret) {
        printf("ERROR: kd_mpi_connector_power_set failed, ret=%d\n", ret);
        return ret;
    }

    // 关闭设备句柄(配置完成即可关闭)
    ret = kd_mpi_connector_close(connector_fd);
    if (ret) {
        printf("ERROR: kd_mpi_connector_close failed, ret=%d\n", ret);
        return ret;
    }

    // =============================================================================================
    // 4. 配置 VO(视频输出层:用于显示摄像头画面)
    // =============================================================================================
    kd_mpi_vo_disable_layer(vi_vo_id);  // 先关闭 layer,避免旧配置干扰

    memset(&vi_vo_attr, 0, sizeof(vi_vo_attr));
    vi_vo_attr.layer_id        = vi_vo_id;
    vi_vo_attr.position.x      = 0;
    vi_vo_attr.position.y      = 0;
    vi_vo_attr.img_size.width  = DISPLAY_WIDTH;
    vi_vo_attr.img_size.height = DISPLAY_HEIGHT;
    vi_vo_attr.pixel_format    = PIXEL_FORMAT_YUV_SEMIPLANAR_420; // NV12
    vi_vo_attr.global_alpha   = 0xFF;                            // 不透明
    // 根据 DISPLAY_MODE 是否需要旋转
    vi_vo_attr.func            = DISPLAY_MODE? GDMA_ROTATE_DEGREE_90 : GDMA_ROTATE_DEGREE_0;
    // 若旋转,需要额外的 DMA buffer
    vi_vo_attr.rot_buf_nr      = DISPLAY_MODE? 2 : 0;
    vi_vo_attr.rot_buf_bpp     = 0;

    ret = kd_mpi_vo_set_layer_attr(vi_vo_id, &vi_vo_attr);
    if (ret != K_SUCCESS) {
        printf("ERROR: kd_mpi_vo_set_layer_attr failed, ret=%d\n", ret);
        return ret;
    }

    ret = kd_mpi_vo_enable_layer(vi_vo_id);
    if (ret != K_SUCCESS) {
        printf("ERROR: kd_mpi_vo_enable_layer failed, ret=%d\n", ret);
        return ret;
    }

    printf("VICAP to VO: layer=%d configured for %ux%u NV12, rotate90=%d\n",
           vi_vo_id, DISPLAY_WIDTH, DISPLAY_HEIGHT, DISPLAY_MODE ? 1 : 0);

    // =============================================================================================
    // 5. 配置 OSD 层(ARGB8888 叠加图层)
    // =============================================================================================
    if(USE_OSD == 1){
        kd_mpi_vo_disable_layer(osd_vo_id);

        memset(&osd_vo_attr, 0, sizeof(osd_vo_attr));
        osd_vo_attr.layer_id        = osd_vo_id;
        osd_vo_attr.position.x      = 0;
        osd_vo_attr.position.y      = 0;
        osd_vo_attr.img_size.width  = OSD_WIDTH;
        osd_vo_attr.img_size.height = OSD_HEIGHT;
        osd_vo_attr.pixel_format    = PIXEL_FORMAT_ARGB_8888;  // OSD 常用 BGRA/ARGB
        osd_vo_attr.global_alpha    = 0xFF;
        osd_vo_attr.func            = DISPLAY_MODE? GDMA_ROTATE_DEGREE_90 : GDMA_ROTATE_DEGREE_0;
        osd_vo_attr.rot_buf_nr      = DISPLAY_MODE? 2 : 0;
        osd_vo_attr.rot_buf_bpp     = 0;

        ret = kd_mpi_vo_set_layer_attr(osd_vo_id, &osd_vo_attr);
        if (ret != K_SUCCESS) {
            printf("ERROR: kd_mpi_vo_set_layer_attr failed, ret=%d\n", ret);
            return ret;
        }

        ret = kd_mpi_vo_enable_layer(osd_vo_id);
        if (ret != K_SUCCESS) {
            printf("ERROR: kd_mpi_vo_enable_layer failed, ret=%d\n", ret);
            return ret;
        }

        printf("OSD to VO: layer=%d configured for %ux%u BGRA8888, rotate90=%d\n",
               osd_vo_id, OSD_WIDTH, OSD_HEIGHT, DISPLAY_ROTATE ? 1 : 0);

        // --------------------- 从 OSD VB 池获取一块缓存,用于写入叠加数据 ---------------------
        k_s32 size = VICAP_ALIGN_UP(OSD_HEIGHT * OSD_WIDTH * OSD_CHANNEL, VICAP_ALIGN_1K);

        // 从指定内存池中申请一块缓存
        handle = kd_mpi_vb_get_block(osd_pool_id, size, NULL);
        if (handle == VB_INVALID_HANDLE)
        {
            printf("%s get vb block error\n", __func__);
            return -1;
        }

        // 获取该缓存块的物理地址
        k_u64 phys_addr = kd_mpi_vb_handle_to_phyaddr(handle);
        if (phys_addr == 0)
        {
            printf("%s get phys addr error\n", __func__);
            return -1;
        }

        // 映射为用户态虚拟地址(非 cache)
        k_u32* virt_addr = (k_u32 *)kd_mpi_sys_mmap(phys_addr, size);
        if (virt_addr == NULL)
        {
            printf("%s mmap error\n", __func__);
            return -1;
        }

        // 初始化 OSD 帧描述结构
        memset(&osd_frame_info, 0, sizeof(osd_frame_info));
        osd_frame_info.v_frame.width        = OSD_WIDTH;
        osd_frame_info.v_frame.height       = OSD_HEIGHT;
        osd_frame_info.v_frame.stride[0]    = OSD_WIDTH*4;
        osd_frame_info.v_frame.pixel_format = PIXEL_FORMAT_BGRA_8888;
        osd_frame_info.mod_id               = K_ID_VO;
        osd_frame_info.pool_id              = osd_pool_id;
        osd_frame_info.v_frame.phys_addr[0] = phys_addr;

        // 保存虚拟地址,用于后续 memcpy 写入 OSD 数据
        insert_osd_vaddr = virt_addr;
        printf("phys_addr is %lx g_pool_id is %d \n", phys_addr, osd_pool_id);
    }

    // =============================================================================================
    // 6. 传感器探测 & VICAP 设备配置
    // =============================================================================================
    // 自动探测 Sensor
    k_vicap_probe_config probe_cfg;
    k_vicap_sensor_info sensor_info;
    probe_cfg.csi_num = CONFIG_MPP_SENSOR_DEFAULT_CSI;
    probe_cfg.width   = ISP_WIDTH;
    probe_cfg.height  = ISP_HEIGHT;
    probe_cfg.fps     = 30;
    if(0x00 != kd_mpi_sensor_adapt_get(&probe_cfg, &sensor_info)) {
        printf("vicap, can't probe sensor on %d, output %dx%d@%d\n",
               probe_cfg.csi_num, probe_cfg.width, probe_cfg.height, probe_cfg.fps);
        return -1;
    }

    sensor_type =  sensor_info.sensor_type;
    memset(&sensor_info, 0, sizeof(k_vicap_sensor_info));
    ret = kd_mpi_vicap_get_sensor_info(sensor_type, &sensor_info);
    if (ret) {
        printf("vicap, the sensor type not supported!\n");
        return ret;
    }

    // 配置 VICAP 设备属性(采集窗口、工作模式、ISP 功能等)
    k_vicap_dev_attr dev_attr;
    memset(&dev_attr, 0, sizeof(k_vicap_dev_attr));
    dev_attr.acq_win.h_start = 0;
    dev_attr.acq_win.v_start = 0;
    dev_attr.acq_win.width   = ISP_WIDTH;
    dev_attr.acq_win.height  = ISP_HEIGHT;
    dev_attr.mode            = VICAP_WORK_ONLINE_MODE;  // 在线模式
    dev_attr.pipe_ctrl.data  = 0xFFFFFFFF;
    dev_attr.pipe_ctrl.bits.af_enable   = 0;
    dev_attr.pipe_ctrl.bits.ahdr_enable = 0;
    dev_attr.pipe_ctrl.bits.dnr3_enable = 0;
    dev_attr.cpature_frame   = 0;
    dev_attr.sensor_info     = sensor_info;

    ret = kd_mpi_vicap_set_dev_attr(vicap_dev, dev_attr);
    if (ret) {
        printf("vicap, kd_mpi_vicap_set_dev_attr failed.\n");
        return ret;
    }

    // =============================================================================================
    // 7. VICAP 通道 0:输出到 VO 显示
    // =============================================================================================
    k_vicap_chn_attr chn0_attr;
    memset(&chn0_attr, 0, sizeof(k_vicap_chn_attr));
    chn0_attr.out_win.width  = DISPLAY_WIDTH;
    chn0_attr.out_win.height = DISPLAY_HEIGHT;
    chn0_attr.crop_win       = dev_attr.acq_win;
    chn0_attr.scale_win      = chn0_attr.out_win;
    chn0_attr.crop_enable    = K_FALSE;
    chn0_attr.scale_enable   = K_FALSE;
    chn0_attr.chn_enable     = K_TRUE;
    chn0_attr.pix_format     = PIXEL_FORMAT_YUV_SEMIPLANAR_420; // NV12
    chn0_attr.buffer_num     = VICAP_MAX_FRAME_COUNT;
    chn0_attr.buffer_size    = VICAP_ALIGN_UP((DISPLAY_WIDTH * DISPLAY_HEIGHT * 3 / 2), VICAP_ALIGN_1K);
    chn0_attr.buffer_pool_id = VB_INVALID_POOLID;

    printf("vicap ...kd_mpi_vicap_set_chn_attr, buffer_size[%d]\n", chn0_attr.buffer_size);
    ret = kd_mpi_vicap_set_chn_attr(vicap_dev, vicap_chn_to_vo, chn0_attr);
    if (ret) {
        printf("vicap, kd_mpi_vicap_set_chn_attr failed.\n");
        return ret;
    }

    // 绑定 VICAP → VO(视频直通显示)
    vicap_mpp_chn.mod_id = K_ID_VI;
    vicap_mpp_chn.dev_id = vicap_dev;
    vicap_mpp_chn.chn_id = vicap_chn_to_vo;
    vo_mpp_chn.mod_id    = K_ID_VO;
    vo_mpp_chn.dev_id    = vo_dev_id;
    vo_mpp_chn.chn_id    = vi_vo_id;
    ret = kd_mpi_sys_bind(&vicap_mpp_chn, &vo_mpp_chn);
    if (ret) {
        printf("kd_mpi_sys_bind failed:0x%x\n", ret);
    }

    // =============================================================================================
    // 8. VICAP 通道 1:输出给 AI 使用(RGB Planar)
    // =============================================================================================
    k_vicap_chn_attr chn1_attr;
    memset(&chn1_attr, 0, sizeof(k_vicap_chn_attr));
    chn1_attr.out_win.width  = AI_FRAME_WIDTH;
    chn1_attr.out_win.height = AI_FRAME_HEIGHT;
    chn1_attr.crop_win       = dev_attr.acq_win;
    chn1_attr.scale_win      = chn1_attr.out_win;
    chn1_attr.crop_enable    = K_FALSE;
    chn1_attr.scale_enable   = K_FALSE;
    chn1_attr.chn_enable     = K_TRUE;
    chn1_attr.pix_format     = PIXEL_FORMAT_RGB_888_PLANAR; // AI 常用输入格式
    chn1_attr.buffer_num     = VICAP_MAX_FRAME_COUNT;
    chn1_attr.buffer_size    = VICAP_ALIGN_UP((AI_FRAME_WIDTH * AI_FRAME_HEIGHT * 3 ), VICAP_ALIGN_1K);
    chn1_attr.buffer_pool_id = VB_INVALID_POOLID;

    printf("kd_mpi_vicap_set_chn_attr, buffer_size[%d]\n", chn1_attr.buffer_size);
    ret = kd_mpi_vicap_set_chn_attr(vicap_dev, vicap_chn_to_ai, chn1_attr);
    if (ret) {
        printf("kd_mpi_vicap_set_chn_attr failed.\n");
        return ret;
    }

    // 设置数据库解析模式(XML/JSON)
    ret = kd_mpi_vicap_set_database_parse_mode(vicap_dev, VICAP_DATABASE_PARSE_XML_JSON);
    if (ret) {
        printf("kd_mpi_vicap_set_database_parse_mode failed.\n");
        return ret;
    }

    // 初始化 VICAP
    printf("kd_mpi_vicap_init\n");
    ret = kd_mpi_vicap_init(vicap_dev);
    if (ret) {
        printf("kd_mpi_vicap_init failed.\n");
    }

    // 启动数据流
    printf("kd_mpi_vicap_start_stream\n");
    ret = kd_mpi_vicap_start_stream(vicap_dev);
    if (ret) {
        printf("kd_mpi_vicap_init failed.\n");
    }

    return ret;
}

函数一样吗

120行到13行不一致,我这边的是线先 “打开电源” 再 “初始化 connector(配置时序、分辨率等)”

""

 // 打开电源
ret = kd_mpi_connector_power_set(connector_fd, K_TRUE);
if (ret) {
    printf("ERROR: kd_mpi_connector_power_set failed, ret=%d\n", ret);
    return ret;
}
// 初始化 connector(配置时序、分辨率等)
ret = kd_mpi_connector_init(connector_fd, connector_info);
if (ret) {
    printf("ERROR: kd_mpi_connector_init failed, ret=%d\n", ret);
    return ret;
}

""

代码不是最新的。

我这边其他例程的 PipeLine::Create() 也是这样的 先 “打开电源” 再 “初始化 connector(配置时序、分辨率等)”

repo sync -j $(nproc) 同步更新代码后还是异常

msh />/bin/preload: command not found.
[I/WLAN.dev] wlan init success
[I/WLAN.lwip] eth device init ok name:w0
[I/WLAN.dev] wlan init success
[I/WLAN.lwip] eth device init ok name:w1
cd /sdcard/app/examples/ai/face_detection
msh /sdcard/app/examples/ai/face_detection>
msh /sdcard/app/examples/ai/face_detection>face_detect_isp.sh
case ./face_detection.elf built at Apr 29 2026 10:10:27
panel st7701_480x800_lckfb, pixelclock 27000 khz, resolution 480x800@58
panel st7701_480x800_lckfb, chip id: 0x00ffffff
VICAP to VO: layer=1 configured for 800x480 NV12, rotate90=1
OSD to VO: layer=4 configured for 800x480 BGRA8888, rotate90=1
phys_addr is 20001000 g_pool_id is 0
vicap, can't probe sensor on 2, output 1920x1080@30
dump dev(0)chn(1) failed.
kd_mpi_vicap_dump_frame failed.
<3>[2] [Func]:hil_map_mmz_check_phys [Line]:1235 [Info]:ERROR: MMAP ADDR: 0x0-0xa9000

============ CRASH REPORT ===================
Exception 13: Load Page Fault
scause = 0x000000000000000d
stval = 0x0000000000000009 (fault address)
sepc = 0x00000002007bbc26 (program counter)
ra = 0x00000002007bbc24 (return address)
sp = 0x0000000100022210
frame = 0x000000000048f058 (trap frame on stack)
fp/s0 = 0x00000001000222f0
mode = USER (SPP=0)
sepc : in user space
stval : INVALID address (unmapped?)

检查一下摄像头,这里是dump失败了。

摄像头烧坏了,谢谢你了