O to the o Posted June 13 Posted June 13 Hi I'm trying to understand how to enable Uart 2 for serial communication with a mcu on the banana pi (trying to connect a board running klipper to it). I connected the Uart of the board to CON1-P08 and CON1-P10 of the Banana PI M3 according to all i can find those pins are tx/rx for UART2. So far i figured out that the UART should be one of the /dev/ttyS* ones if i'm not mistaken, I can see /dev/ttyS to /dev/ttyS7 but am missing the /dev/ttyS1 user@bananapim3:~$ ls /dev/tty* /dev/tty /dev/tty11 /dev/tty15 /dev/tty19 /dev/tty22 /dev/tty26 /dev/tty3 /dev/tty33 /dev/tty37 /dev/tty40 /dev/tty44 /dev/tty48 /dev/tty51 /dev/tty55 /dev/tty59 /dev/tty62 /dev/tty9 /dev/ttyS2 /dev/ttyS6 /dev/tty0 /dev/tty12 /dev/tty16 /dev/tty2 /dev/tty23 /dev/tty27 /dev/tty30 /dev/tty34 /dev/tty38 /dev/tty41 /dev/tty45 /dev/tty49 /dev/tty52 /dev/tty56 /dev/tty6 /dev/tty63 /dev/ttyACM0 /dev/ttyS3 /dev/ttyS7 /dev/tty1 /dev/tty13 /dev/tty17 /dev/tty20 /dev/tty24 /dev/tty28 /dev/tty31 /dev/tty35 /dev/tty39 /dev/tty42 /dev/tty46 /dev/tty5 /dev/tty53 /dev/tty57 /dev/tty60 /dev/tty7 /dev/ttyACM1 /dev/ttyS4 /dev/ttyUSB0 /dev/tty10 /dev/tty14 /dev/tty18 /dev/tty21 /dev/tty25 /dev/tty29 /dev/tty32 /dev/tty36 /dev/tty4 /dev/tty43 /dev/tty47 /dev/tty50 /dev/tty54 /dev/tty58 /dev/tty61 /dev/tty8 /dev/ttyS0 /dev/ttyS5 I'm glad for anyhelp and any idea 0 Quote
going Posted June 15 Posted June 15 13.06.2024 в 23:13, O to the o сказал: how to enable Uart 2 In this file for UART2: allwinner/sun8i-a83t.dtsi ... /omit-if-no-ref/ uart2_pb_pins: uart2-pb-pins { pins = "PB0", "PB1"; function = "uart2"; }; }; ... uart2: serial@1c28800 { compatible = "snps,dw-apb-uart"; reg = <0x01c28800 0x400>; interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>; reg-shift = <2>; reg-io-width = <4>; clocks = <&ccu CLK_BUS_UART2>; resets = <&ccu RST_BUS_UART2>; status = "disabled"; }; By analogy with uart0 here: dts/allwinner/sun8i-a83t-bananapi-m3.dts#L383 you can write an additional node: &uart2 { pinctrl-names = "default"; pinctrl-0 = <&uart2_pb_pins>; status = "okay"; }; But it will work if you build the DTB directly when compiling the kernel. Because without adding this node, the contact description node for uart2 will be omitted. That is, it is not in the standard DTB. You can write an overlay in which you need to specify both nodes: /dts-v1/; /plugin/; / { compatible = "allwinner,sun8i-a83t"; fragment@0 { target-path = "/aliases"; __overlay__ { serial2 = "/soc/serial@1c28800"; }; }; fragment@1 { target = <&pio>; __overlay__ { uart2_pb_pins: uart2-pb-pins { pins = "PB0", "PB1"; function = "uart2"; }; }; }; fragment@2 { target = <&uart2>; __overlay__ { pinctrl-names = "default"; pinctrl-0 = <&uart2_pb_pins>; status = "okay"; }; }; }; Regards 0 Quote
O to the o Posted June 15 Author Posted June 15 Thanks @going can the overlay be added into a running kernal or does that also require compilation ? 0 Quote
Solution going Posted June 15 Solution Posted June 15 28 минут назад, O to the o сказал: can the overlay be added into a running kernal Save the overlay file to sun8i-a83t-uart2.dts name. Compile the overlay: dtc -I dts -O dtb -o sun8i-a83t-uart2.dtbo sun8i-a83t-uart2.dts copy sun8i-a83t-uart2.dtbo file to /boot/dtb-**-sunxi/overlay/ Add to /boot/armbianEnv.txt file line: overlays=uart2 after the line overlay_prefix=sun8i-a83t sudo nano /boot/armbianEnv.txt 0 Quote
going Posted June 15 Posted June 15 For reference: Extract the applied final dts from the current file system: dtc --sort -I fs -O dts /sys/firmware/devicetree/base > cur-dts-out.txt 0 Quote
O to the o Posted June 15 Author Posted June 15 Thanks Did that and the dtc command shows UART2 being present in the devicetree, any idea how to identify it in all the /dev/tty* options ? New appeared Also if i wanna use 1-wire do i also need to add an overlay ? 0 Quote
going Posted June 15 Posted June 15 2 часа назад, O to the o сказал: Also if i wanna use 1-wire do i also need to add an overlay ? I think you need to try to do the overlay yourself. Do it by analogy with this: https://github.com/armbian/sunxi-DT-overlays/blob/master/sun8i-h3/sun8i-h3-w1-gpio.dts https://github.com/armbian/sunxi-DT-overlays/blob/master/sun50i-h5/sun50i-h5-w1-gpio.dts 2 часа назад, O to the o сказал: any idea how to identify it in all the /dev/tty* 8 часов назад, going сказал: fragment@0 { target-path = "/aliases"; __overlay__ { serial2 = "/soc/serial@1c28800"; }; }; May be /dev/ttyS2 This can be described using aliases: sun8i-a83t-bananapi-m3.dts#L54 0 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.