avafinger / bananapi-zero-ubuntu-base-minimal

BananaPi M2 Zero - Ubuntu Focal Base Minimal Image (Experimental) - U-Boot 2017.09 / Kernel 4.18.y / Kernel 4.19.y / Kernel 4.20.y / Kernel 5.3.y / Kernel 5.6.y / Kernel 5.7.y / Kernel 5.11.y
88 stars 17 forks source link

Unable to use micro USB Port (Keyboard/Mouse) up with Focal #65

Closed matthewoots closed 2 years ago

matthewoots commented 2 years ago

Hi @avafinger Sorry I am new to this, I've used other images for Bananapi zero and some of them work, I managed to flash https://github.com/avafinger/bananapi-zero-ubuntu-base-minimal/releases/tag/v3.10 and managed to enter the login screen, but I am unable to use the keyboard and mouse over the micro USB port.

My setup is below, the power goes through the first and the second is the connection to the keyboard (or vice versa supplies power), I have even tried splitting the power for the USB device to take power off another computer but to no avail. photo_2021-10-14_11-01-50

I checked the power and it is 4.95V so that rules it out. Is there any thing in the rootfs folder that I need to change to get it to work? Thank you!

matthewoots commented 2 years ago

Sorry I tried another device for telemetry and it seems to work, probably the data positive and data negative is weak, let me try to debug with this first Correction : Even after shortening the keyboard wire, there is still no signal to the keyboard

avafinger commented 2 years ago

No need to do anything. Try a micro USB hub like this one (my current setup)

.

avafinger commented 2 years ago

oops: keyboard2

avafinger commented 2 years ago

I power the board on the first one with 5V, second is the keyboard/mouse. Watch for a drop in voltage and current.

matthewoots commented 2 years ago

Thank you so much @avafinger I done it by another way, probably the headless way that this was meant for, hence I'll close this with this comment to future people trying to get it up (headlessly) BEFORE YOU BOOT

  1. Edit the /etc/netplan/01-netcfg.yaml and change your ssid (FIBER-8784) and password
  2. Edit the /etc/apt/sources.list, take out the original x64 and add in the packages below
    
    deb [arch=amd64,i386] http://us.archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
    deb [arch=amd64,i386] http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
    deb [arch=amd64,i386] http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
    deb [arch=amd64,i386] http://security.ubuntu.com/ubuntu focal-security main restricted universe multiverse

deb [arch=arm64,armhf,ppc64el,s390x] http://ports.ubuntu.com/ubuntu-ports/ focal main restricted universe multiverse deb [arch=arm64,armhf,ppc64el,s390x] http://ports.ubuntu.com/ubuntu-ports/ focal-updates main restricted universe multiverse deb [arch=arm64,armhf,ppc64el,s390x] http://ports.ubuntu.com/ubuntu-ports/ focal-backports main restricted universe multiverse deb [arch=arm64,armhf,ppc64el,s390x] http://ports.ubuntu.com/ubuntu-ports/ focal-security main restricted universe multiverse


3. (local compute) ssh ubuntu@IP_ADDRESS #you can use your router to check 
avafinger commented 2 years ago

@matthewoots

Nice frame, can you share something about your drone?

Are you having issues with the USB?

matthewoots commented 2 years ago

@avafinger Hey there, sorry I'm reopening this as I'll get an OTG adapter first, but I'm having issues as I wonder why it cannot find other devices using the OTG port

I'll try using UART first, I suppose there are 2 I can use? Debug and UART0?

Haha a little mini project I'm doing is building a sub 250g quadcopter using the bananapi, with on board VIO and Telem to the flight controller with Mavros, I'll add more stuff to my repo as I work on it. If you are interested I can pass you the CAD for frame to print :)

avafinger commented 2 years ago

I think you have 4 UART, one is for the Debug, I think uart0. uart1 is for Wifi/BT. So you have uart3 enabled and ready to be used. I think in one of the releases I had enabled uart2, but I don't know it was used for something else. For your reference: https://github.com/avafinger/linux-5.6.y/blob/6dc50035fef1f65b7f5b3b818f69e1e7a3ef0616/arch/arm/boot/dts/bpi-m2-zero-v4.dts#L60

Yes, I am interested in such a project. I will follow your progress. If you can post a link for each hw you used would be great. When you finish the project I ask for the CAD files, thank you.

Regarding OTG, see here if it is the right otg mode: https://github.com/avafinger/linux-5.6.y/blob/6dc50035fef1f65b7f5b3b818f69e1e7a3ef0616/arch/arm/boot/dts/bpi-m2-zero-v4.dts#L624

You can decompile the dtb and change or enable what you want.

Hope you get all you need.

matthewoots commented 2 years ago

I'll went to decompile the dtb, and found that information below: I'm using bpi-m2-zero-v4.dtb_5.11.10-server that you have provided Seems like OTG should work, unless the pinout is off

usb@1c19000 {
        compatible = "allwinner,sun8i-h3-musb";
        reg = <0x1c19000 0x400>;
        clocks = <0x3 0x20>;
        resets = <0x3 0x11>;
        interrupts = <0x0 0x47 0x4>;
        interrupt-names = "mc";
        phys = <0xe 0x0>;
        phy-names = "usb";
        extcon = <0xe 0x0>;
        dr_mode = "otg";
        status = "okay";
};

Below are the UART, and it seems that you're right about the UART status

aliases {
...
        serial0 = "/soc/serial@1c28000";
        serial1 = "/soc/serial@1c28400";
        serial2 = "/soc/serial@1c28800";
        serial3 = "/soc/serial@1c28c00";
...
};
serial0 is "okay"
serial1 seems to be for bluetooth
serial2 is "disabled"
serial3 is "okay"

The output of dmesg | grep tty gives this

[    0.000000] Kernel command line: console=ttyS0,115200 earlyprintk rootfstype=ext4 root=/dev/mmcblk0p2 rw rootwait fsck.repair=yes panic=10 no_console_suspend consoleblank=0 drm_leak_fbdev_smem=1
[    0.315550] printk: console [ttyS0] disabled
[    0.315667] 1c28000.serial: ttyS0 at MMIO 0x1c28000 (irq = 51, base_baud = 1500000) is a 16550A
[    1.048671] printk: console [ttyS0] enabled
[    1.062915] 1c28400.serial: ttyS1 at MMIO 0x1c28400 (irq = 52, base_baud = 1500000) is a 16550A
[    1.071825] serial serial0: tty port ttyS1 registered
[    1.077950] 1c28c00.serial: ttyS3 at MMIO 0x1c28c00 (irq = 53, base_baud = 1500000) is a 16550A
[    5.299593] systemd[1]: Created slice system-serial\x2dgetty.slice.

I would assume the pinout would follow the same pinout as this photo, but it seems like its not working for the UART0 TXD and RXD gpio-banana-pi-m2-zero

avafinger commented 2 years ago

uart0 is reserved for console debugging (the 3 pins GND, TX and RX), if you want to use uart0 I think you need change bpi-m2-zero_boot.scr environment, from setenv bootargs "console=ttyS0,115200 earlyprintk rootfstype=ext4 root=/dev/mmcblk0p2 rw rootwait fsck.repair=${fsck.repair} panic=10 ${extra}" to setenv bootargs "console=ttyS3,115200 earlyprintk rootfstype=ext4 root=/dev/mmcblk0p2 rw rootwait fsck.repair=${fsck.repair} panic=10 ${extra}"

Recompile with:

cd /media/alex/boot/

sudo mkimage -C none -A arm -T script -d bpi-m2-zero_boot.cmd bpi-m2-zero_boot.scr

Regarding USB, try: dr_mode = "otg"; to dr_mode = "host";

matthewoots commented 2 years ago

@avafinger thank you so very much man!! "host" fixed it, finally can see the realsense! BEFORE

ubuntu@bpi-m2z:~/catkin_ws$ ls -lR /dev/input
/dev/input:
total 0
drwxr-xr-x 2 root root      80 Sep  7 18:37 by-path
crw-rw---- 1 root input 13, 64 Sep  7 18:37 event0
crw-rw---- 1 root input 13, 65 Sep  7 18:37 event1
crw-rw---- 1 root input 13, 63 Sep  7 18:37 mice

/dev/input/by-path:
total 0
lrwxrwxrwx 1 root root 9 Sep  7 18:37 platform-1f02000.ir-event -> ../event1
lrwxrwxrwx 1 root root 9 Sep  7 18:37 platform-r_gpio_keys-event -> ../event0

AFTER

ubuntu@bpi-m2z:~$ ls -lR /dev/input
/dev/input:
total 0
drwxr-xr-x 2 root root        60 Sep  7 18:37 by-id
drwxr-xr-x 2 root root       100 Sep  7 18:37 by-path
crw-rw---- 1 root input   13, 64 Sep  7 18:37 event0
crw-rw-rw- 1 root plugdev 13, 65 Sep  7 18:37 event1
crw-rw---- 1 root input   13, 66 Sep  7 18:37 event2
crw-rw---- 1 root input   13, 63 Sep  7 18:37 mice

/dev/input/by-id:
total 0
lrwxrwxrwx 1 root root 9 Sep  7 18:37 usb-Intel_R__RealSense_TM__Depth_Camera_430i_Intel_R__RealSense_TM__Depth_Camera_430i-event-if00 -> ../event1

/dev/input/by-path:
total 0
lrwxrwxrwx 1 root root 9 Sep  7 18:37 platform-1c1a000.usb-usb-0:1:1.0-event -> ../event1
lrwxrwxrwx 1 root root 9 Sep  7 18:37 platform-1f02000.ir-event -> ../event2
lrwxrwxrwx 1 root root 9 Sep  7 18:37 platform-r_gpio_keys-event -> ../event0

Will then use the debug for UART let me try it out first. Thank you agin!

matthewoots commented 2 years ago

Tried and tested on UART3 (works like a charm, takes care of my FTDI woes), which is under /dev/ttyS3 if anyone wanted to know, I've tried it with mavros package on ROS and connected to PX4, the baudrate I used is 500000 which results in no complains from mavros side, thank you @avafinger for you support! Will check back when I have more results