V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
LeviMarvin
V2EX  ›  程序员

真心请教 rk3588 等板子的安卓开发大佬

  •  
  •   LeviMarvin ·
    LeviMarvin · 39 天前 · 1998 次点击
    这是一个创建于 39 天前的主题,其中的信息可能已经有所发展或是发生改变。

    背景

    我在做 aosp14 移植,目前用 uboot2025.01-rc1,linux 5.10 现在能运行内核,内核能调用 android 的第一阶段 init ( bl 把 init_boot+vendor_boot 的 ramdisk 读取到内存后传递给内核,内核把 initramfs unpack 到 rootfs ),metadata 分区 16MB ,刷入了生成的空白 ext4 文件系统镜像。

    问题

    第一阶段 init 可以运行,但是只能运行一部分,大概运行到

    if (!fsm) {
                fsm = CreateFirstStageMount(cmdline);
            }
    

    设备就会自动重启,cmdline 加了 init_fatal_panic=true 但是没任何 panic 还是 reboot 到 bootloader 。 如果 fstab 里不写 metadata 会跳过 metadata ,此时串口日志显示创建了几个逻辑分区给 system 、vendor 等,但是也会突然自动重启。

    所有串口日志最后一条的下一条就是设备重启的日志:rk860-regulator 1-0042: rk860..... reset等,无参考价值。 串口日志( fstab 有 metadata ):

    [   18.277402] Run /init as init process
    [   18.280593] init: init first stage started!
    [   18.280826] init: Unable to open /lib/modules, skipping module loading.
    [   18.281153] init: Copied ramdisk prop to /second_stage_resources/system/etc/ramdisk/build.prop
    [   18.281316] init: Using generic ramdisk copy of snapuserd /system/bin/snapuserd_ramdisk
    [   18.281417] init: hard linking /system/bin/snapuserd_ramdisk to /first_stage_ramdisk/system/bin/snapuserd succeeded
    [   18.281754] init: Switching root to '/first_stage_ramdisk'
    [   18.282159] init: [libfstab] Using Android DT directory /proc/device-tree/firmware/android/
    [   18.282286] init: [libfstab] ReadFstabFromDt(): failed to read fstab from dt
    [   18.355352] init: [libfs_mgr] superblock s_max_mnt_count:65535,/dev/block/by-name/metadata
    [   18.355625] EXT4-fs (mmcblk0p21): Ignoring removed nomblk_io_submit option
    [   18.357141] EXT4-fs (mmcblk0p21): mounted filesystem with ordered data mode. Opts: errors=remount-ro,nomblk_io_submit
    [   18.357185] init: [libfs_mgr] check_fs(): mount(/dev/block/by-name/metadata,/metadata,ext4)=0: Success
    [   18.361990] EXT4-fs (mmcblk0p21): mounted filesystem with ordered data mode. Opts: discard
    

    串口日志(无 metadata 或挂载失败):

    [   18.276158] Run /init as init process
    [   18.279226] init: init first stage started!
    [   18.279431] init: Unable to open /lib/modules, skipping module loading.
    [   18.279750] init: Copied ramdisk prop to /second_stage_resources/system/etc/ramdisk/build.prop
    [   18.279911] init: Using generic ramdisk copy of snapuserd /system/bin/snapuserd_ramdisk
    [   18.280010] init: hard linking /system/bin/snapuserd_ramdisk to /first_stage_ramdisk/system/bin/snapuserd succeeded
    [   18.280335] init: Switching root to '/first_stage_ramdisk'
    [   18.280730] init: [libfstab] Using Android DT directory /proc/device-tree/firmware/android/
    [   18.280848] init: [libfstab] ReadFstabFromDt(): failed to read fstab from dt
    [   18.282054] init: Check Point2
    [   18.282082] init: Check Point3.22
    [   18.456015] usb 2-1.1: new full-speed USB device number 3 using ehci-platform
    [   18.557933] usb 2-1.1: New USB device found, idVendor=0bda, idProduct=b85b, bcdDevice= 0.00
    [   18.558009] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    [   18.558032] usb 2-1.1: Product: Bluetooth Radio
    [   18.558053] usb 2-1.1: Manufacturer: Realtek
    [   18.558073] usb 2-1.1: SerialNumber: 00e04c000001
    [   20.194029] rk_hdmirx fdee0000.hdmirx-controller: hdmirx_cancel_cpu_limit_freq freq qos nod add
    [   20.276050] rk-pcie fe170000.pcie: PCIe Link Fail, LTSSM is 0x3, hw_retries=0
    [   20.286057] rk-pcie fe150000.pcie: PCIe Link Fail, LTSSM is 0x0, hw_retries=0
    [   20.286119] rk-pcie fe150000.pcie: failed to initialize host
    [   22.602724] rk_pcie_establish_link: 232 callbacks suppressed
    [   22.602741] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.629398] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.656059] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.682736] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.709494] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.736063] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.762728] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.789396] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.816061] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   22.842733] rk-pcie fe170000.pcie: PCIe Linking... LTSSM is 0x3
    [   24.176058] rk-pcie fe170000.pcie: PCIe Link Fail, LTSSM is 0x3, hw_retries=1
    [   25.196063] rk-pcie fe170000.pcie: failed to initialize host
    [   38.369022] init: [libfs_mgr] Skipping mounting '/dev/block/bootdevice/by-name/metadata'
    [   38.369297] init: [libfs_mgr] Failed to open '/dev/block/bootdevice/by-name/metadata': No such file or directory
    [   38.369580] init: [libfs_mgr] __mount(source=/dev/block/bootdevice/by-name/metadata(missing),target=/metadata,type=ext4)=-1: No such file or directory
    [   38.374465] init: [libfs_mgr] Created logical partition odm_a on device /dev/block/dm-0
    [   38.374503] init: [libfs_mgr] Skipping zero-length logical partition: odm_b
    [   38.375365] init: [libfs_mgr] Created logical partition system_a on device /dev/block/dm-1
    [   38.375389] init: [libfs_mgr] Skipping zero-length logical partition: system_b
    [   38.376232] init: [libfs_mgr] Created logical partition system_ext_a on device /dev/block/dm-2
    [   38.376255] init: [libfs_mgr] Skipping zero-length logical partition: system_ext_b
    [   38.377209] init: [libfs_mgr] Created logical partition vendor_a on device /dev/block/dm-3
    

    fstab 如下:

    /dev/block/platform/ff0f0000.dwmmc/by-name/user     /mnt/internal_sd    vfat    defaults                defaults
    /dev/block/mmcblk0p1                                /mnt/external_sd    vfat    /dev/block/mmcblk0      defaults
    # /dev/block/by-name/
    system          /system             ext4    rw,barrier=1,discard        wait,slotselect,logical,first_stage_mount,avb=vbmeta_system
    system_ext      /system_ext         ext4    rw                          wait,slotselect,logical,first_stage_mount,avb=vbmeta_system
    product         /product            ext4    rw                          wait,slotselect,logical,first_stage_mount
    vendor          /vendor             ext4    rw                          wait,slotselect,logical,first_stage_mount
    odm             /odm                ext4    ro                          wait,slotselect,logical,first_stage_mount
    
    /dev/block/by-name/dtbo             /dtbo           emmc    defaults                            slotselect,first_stage_mount,avb=vbmeta
    /dev/block/by-name/boot             /boot           emmc    defaults                            slotselect,first_stage_mount,avb=vbmeta
    /dev/block/by-name/init_boot        /init_boot      emmc    defaults                            slotselect,first_stage_mount,avb=vbmeta
    /dev/block/by-name/vendor_boot      /vendor_boot    emmc    defaults                            slotselect,first_stage_mount,avb=vbmeta
    /dev/block/by-name/recovery         /recovery       emmc    defaults                            slotselect,first_stage_mount,avb=vbmeta
    /dev/block/by-name/metadata         /metadata       ext4    noatime,nosuid,nodev,discard        wait,check,formattable,first_stage_mount
    
    /dev/block/bootdevice/by-name/misc          /misc   emmc    defaults                        defaults
    /dev/block/bootdevice/by-name/userdata      /data   ext4    noatime,nosuid,nodev,discard    latemount,wait,check,formattable,reservedsize=128M
    

    关键词: rockchip 、瑞芯微、rk3588 、rk3399 、安卓、android 、aosp 、开发板

    第 1 条附言  ·  38 天前
    原来是 init 日志不能完整输出导致的,目前在内核里解除速度限制后全部日志可以打出,目前根据日志在一步一步解决,感谢各位
    11 条回复    2024-11-05 00:51:07 +08:00
    LeviMarvin
        1
    LeviMarvin  
    OP
       39 天前
    板子 SoC 是 rk3588 、16+128GB ,MMC
    lloovve
        2
    lloovve  
       39 天前 via iPhone
    自己适配?这个都是官方给做好,自己搞恐怕很难
    LeviMarvin
        3
    LeviMarvin  
    OP
       39 天前
    还有问题就是 init 打印出来的日志不全,我手动输入 check point 等字样只能连续输出二至四条,然后 init 的所有 log 都没了
    LeviMarvin
        4
    LeviMarvin  
    OP
       39 天前
    @lloovve rk 官方目前公开的是 a12 的 sdk ,a13 的 sdk 需要花钱定制,所以想自己适配一下试一试,一路上很多玄学问题(很多是我知识储备不够),从 uboot 最新版本适配开始目前总算是能正常启动 linux 了,然后就想试一下 android 移植,也是很多问题,最后以为 init 跑起来就好了,结果跑起来还有奇怪的问题。
    scys
        5
    scys  
       39 天前
    PCIE 都启动失败了,驱动的 pin 脚要适配,你对下配置表
    LeviMarvin
        6
    LeviMarvin  
    OP
       39 天前
    @scys 感谢大佬指点,我去修正一下这个问题,但是启动 linux 的时候有这个问题但不影响系统启动,这个问题会导致 android init 启动不了吗
    scys
        7
    scys  
       39 天前
    我之前的弄 MTK ,不着调 MMC 是不是通过 PCIE 总线链接的。这个你需要看 U 图确认。

    然后一般来说就是启动的配置表有问题,这个根据我移植 MTK 经验来谈。
    LeviMarvin
        8
    LeviMarvin  
    OP
       39 天前
    @scys 大佬,启动的配置表是指什么呀
    scys
        9
    scys  
       39 天前
    dts
    LeviMarvin
        10
    LeviMarvin  
    OP
       38 天前
    更新,日志显示 system 挂不上,然后经过检查发现是 fstab 里参数写的 rw ,不支持,必须用 ro 只读挂载才行。目前还有很多问题需要修,慢慢来,终会可以进入系统的
    LeviMarvin
        11
    LeviMarvin  
    OP
       37 天前
    更新,可以跑到 zygote 、zygote_secondary 了,但是这俩服务(和他们带的服务一直重启,不知道为什么)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   860 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 20:59 · PVG 04:59 · LAX 12:59 · JFK 15:59
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.