V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
wniming
V2EX  ›  Linux

树莓派 4b 如何配置 2 个串口?

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

    楼主是想用 kgdb 来调试内核,但对 dts 不熟悉不知道怎么启用其他的 uart ,求大佬指点。

    8 条回复    2023-04-28 23:31:46 +08:00
    zzz22333
        1
    zzz22333  
       357 天前
    我现在是用的 jlink+openocd 来调试的
    LXGMAX
        2
    LXGMAX  
       357 天前
    在`/boot/config.txt`里面打开就行
    wniming
        3
    wniming  
    OP
       357 天前
    @LXGMAX 感谢回复,用树莓派官方的 os 和 fedora 官方的 os 确实是可以,但我用不了。

    首先我不用树莓派官方的 os ,其次我用的 fedora 的内核是直接让 u-boot 或让树莓派自己的固件去加载的,而不是 fedora 官方镜像那种 u-boot 加载 grub ,再让 grub 加载的,fedora 的官方镜像启动一次要好几分钟,我自己编译的内核不用 initramfs ,自己写 init 脚本,从上电到能 ssh 登录就 11 秒,所以我不想用 fedora 官方镜像,想找一个办法在我目前的系统上启用其它的串口。
    wniming
        4
    wniming  
    OP
       357 天前
    就这一个问题我整了 2 天没搞定,难受死了,树莓派性能太差了,稍微修改一下再重试都要等好久
    LXGMAX
        5
    LXGMAX  
       357 天前
    @wniming 内核改下 dts 参考: https://elixir.bootlin.com/linux/latest/source/arch/arm/boot/dts/bcm2711-rpi-4-b.dts

    然后加入
    ```
    &uart3 {
    status = "okay";
    };
    ```
    要用哪个就启用哪个
    wniming
        6
    wniming  
    OP
       357 天前
    @LXGMAX 感谢回复,内核的这个 dts 实际是启动不了树莓派 4b 的,u-boot 官方的树莓派 4b 的 dts 也是实际启动不了树莓派 4b 的,我现在只呢用从树莓派 os 系统镜像里提取的 dts 来启动,所以修改内核的 dts 这种方法我是用不了的。
    wniming
        7
    wniming  
    OP
       357 天前
    @LXGMAX
    如果我直接用 mainline 内核的 dts 编译出来的 dtb 就是这种报错:

    DRAM: 3.9 GiB
    RPI 4 Model B (0xc03115)
    Core: 175 devices, 17 uclasses, devicetree: board
    MMC: mmc@7e300000: 0, mmc@7e340000: 1
    Loading Environment from FAT... Card did not respond to voltage select! : -110
    ** Bad device specification mmc 0 **
    In: serial
    Out: vidconsole
    Err: vidconsole
    Net: eth0: ethernet@7d580000
    PCIe BRCM: link up, 5.0 Gbps x1 (SSC)
    starting USB...
    Bus xhci_pci: Register 5000420 NbrPorts 5
    Starting the controller
    USB XHCI 1.00
    scanning bus xhci_pci for devices... 4 USB Device(s) found
    scanning usb for storage devices... 1 Storage Device(s) found
    Hit any key to stop autoboot: 0
    Card did not respond to voltage select! : -110
    switch to partitions #0, OK
    mmc1 is current device
    Scanning mmc 1:1...
    Found U-Boot script /boot.scr
    493 bytes read in 6 ms (80.1 KiB/s)
    ## Executing script at 02400000
    Card did not respond to voltage select! : -110
    ** Bad device specification mmc 0 **
    Couldn't find partition mmc 0:1
    Can't set block device
    46483968 bytes read in 144 ms (307.9 MiB/s)
    17868889 bytes read in 56 ms (304.3 MiB/s)
    ERROR: Did not find a cmdline Flattened Device Tree
    Could not find a valid device tree
    SCRIPT FAILED: continuing...
    MMC Device 2 not found
    no mmc device at slot 2

    Device 0: Vendor: ZX1 256G Rev: U091 Prod:
    Type: Hard Disk
    Capacity: 244198.3 MB = 238.4 GB (500118192 x 512)
    ... is now current device
    Scanning usb 0:2...
    BOOTP broadcast 1
    BOOTP broadcast 2
    BOOTP broadcast 3
    BOOTP broadcast 4
    DHCP client bound to address 192.168.2.150 (3010 ms)
    *** Warning: no boot file name; using 'C0A80296.img'
    Using ethernet@7d580000 device
    TFTP from server 192.168.2.1; our IP address is 192.168.2.150
    Filename 'C0A80296.img'.
    Load address: 0x1000000
    Loading: T T T T T T T T T T
    Retry count exceeded; starting again
    missing environment variable: pxeuuid
    Retrieving file: pxelinux.cfg/01-e4-5f-01-a8-b0-00
    Using ethernet@7d580000 device
    TFTP from server 192.168.2.1; our IP address is 192.168.2.150
    Filename 'pxelinux.cfg/01-e4-5f-01-a8-b0-00'.
    Load address: 0x2500000
    Loading: *
    wniming
        8
    wniming  
    OP
       357 天前
    @LXGMAX 我在 u-boot 的脚本里通过 fdt 的 apply 命令把 uart 相关的 dtbo 打上去就能开启第 2 个串口了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1152 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 18:20 · PVG 02:20 · LAX 11:20 · JFK 14:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.