Improvements for the next Image release

The Linux counterpart to tethering is called USB Ethernet Gadget and allows you to use the network of your smartphone or notebook. As an example, I connected a Raspberry Pi 4 to a Google Pixel via one of its USB 3.0 ports. I control the Raspberry via its Gigabit Ethernet using ssh from a Linux desktop PC.

No smartphone is connected yet.

> 

                                   pi@rpi20 
       _,met$$$$$gg.               -------- 
    ,g$$$$$$$$$$$$$$$P.            OS: Debian GNU/Linux 11 (bullseye) aarch64 
  ,g$$P"        \"""Y$$.".         Host: Raspberry Pi 4 Model B Rev 1.4 
 ,$$P'              `$$$.          Kernel: 5.15.84-v8+ 
',$$P       ,ggs.     `$$b:        Uptime: 24 mins 
`d$$'     ,$P"'   .    $$$         Packages: 573 (dpkg) 
 $$P      d$'     ,    $$P         Shell: bash 5.1.4 
 $$:      $$.   -    ,d$$'         Terminal: /dev/pts/0 
 $$;      Y$b._   _,d$P'           CPU: ARM Architecture: aarch64 (4) 
 Y$$.    `.`"Y$$$$P"'              Memory: 0.25 GiB / 7.62 GiB (3%) 
 `$$b      "-.__                   Network: 1 Gbps 
  `Y$$                     
   `Y$$.                                                   
     `$$b.                                                 
       `Y$$b.              
          `"Y$b._          
              `\"""        
                           

pi@rpi20:~ $ lsusb
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0403:c630 Future Technology Devices International, Ltd lcd2usb interface
Bus 001 Device 003: ID 2e8a:f00a Raspberry Pi Pico W
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

pi@rpi20:~ $ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:e7:db:b8:07  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.178.120  netmask 255.255.255.0  broadcast 192.168.178.255
        ether dc:a6:32:bf:7a:a9  txqueuelen 1000  (Ethernet)
        RX packets 20496  bytes 23184177 (22.1 MiB)
        RX errors 0  dropped 2  overruns 0  frame 0
        TX packets 5561  bytes 939519 (917.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 734 (734.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 734 (734.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Now I connect the smartphone without tethering activated.

pi@rpi20:~ $ lsusb
Bus 002 Device 006: ID 18d1:4ee1 Google Inc. Nexus/Pixel Device (MTP)
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0403:c630 Future Technology Devices International, Ltd lcd2usb interface
Bus 001 Device 003: ID 2e8a:f00a Raspberry Pi Pico W
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Now I have activated tethering on the Pixel.

pi@rpi20:~ $ lsusb
Bus 002 Device 007: ID 18d1:4eeb Google Inc. Pixel 7
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 004: ID 0403:c630 Future Technology Devices International, Ltd lcd2usb interface
Bus 001 Device 003: ID 2e8a:f00a Raspberry Pi Pico W
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
pi@rpi20:~ $ ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:e7:db:b8:07  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.178.120  netmask 255.255.255.0  broadcast 192.168.178.255
        ether dc:a6:32:bf:7a:a9  txqueuelen 1000  (Ethernet)
        RX packets 20981  bytes 23216425 (22.1 MiB)
        RX errors 0  dropped 2  overruns 0  frame 0
        TX packets 5625  bytes 948399 (926.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 734 (734.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 734 (734.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.197.3  netmask 255.255.255.0  broadcast 192.168.197.255
        ether d6:be:e6:e7:a2:00  txqueuelen 1000  (Ethernet)
        RX packets 10  bytes 1212 (1.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 15  bytes 1464 (1.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

pi@rpi20:~ $ ^

Thanks to tethering and USB Ethernet Gadget, usb0 now appears as an Ethernet interface.

USB Gadget/Ethernet

Not only the Raspberrys, but also BeagleBone SBC can all do this and I love it. When I had to go to hospital for a few weeks, I took my laptop and a PocketBeagle with me and had a lot of fun with it.

How to Connect a PocketBeagle to the Internet via USB on a Windows 10 PC

3 Likes

Enabling root login via SSH would be good, at the moment it appears to be impossible to do a headless install because there’s no way to log in unless you’re already logged in and can change the config.

2 Likes

You login as “user” (yes, not the most ideal name). user can sudo. In other words, do
ssh user@$IP where $IP is the IP address assign by your DHCP server.

3 Likes

Thanks, found that out a few minutes ago :-).

Ough, I keep hitting this (lack of perf support). Unfortunately it’s not something I can easily fix as it requires Linux kernel 5.19 or newer and VisionStar 2 can’t (AFAIK) boot a stock kernel so one would have to rebase an unknown number of changes. @Michael.Zhu, I really hope we can address this.

1 Like

Yeah, Perf is on the way. we will add this on SDK first before lunar new year.

Note: need upgrade firmware (uboot) to implement it.

5 Likes

Please complete alsa.

What alsa functionality that is already there is working well for me so far, but the sequencer, which is needed by any program using midi, needs to be included as well. The kernel build needs CONFIG_SND_SEQUENCER to be set during the kernel build assuming the supporting code is ready for risc-v along with any dependencies that may require.

4 Likes

It would be nice to implement the “reset” command in u-boot.

It does at the moment tell the user to do the reset themselves.

1 Like

It sounds like it was added in the latest v2.8.0 release.
* Upgrade OpenSBI to v1.2 and add pmic reset function

( Don’t forget to update u-boot-spl.bin.normal.out and visionfive2_fw_payload.img in the qspi nor flash. )

3 Likes

Great news. Yesterday’s pains, (probably) fixed today.

I will loady + sf update in a while.

1 Like

Hello together,

when you mean this reset then is implemented:
image

help from opensbi

3 Likes

No joy.

This is with just-flashed v2.8.0 from https://github.com/starfive-tech/VisionFive2/releases/tag/VF2_v2.8.0

U-Boot SPL 2021.10 (Jan 19 2023 - 04:09:41 +0800)
DDR version: dc2e84f0.
Trying to boot from SPI

OpenSBI v1.2
(...)
U-Boot 2021.10 (Jan 19 2023 - 04:09:41 +0800), Build: jenkins-github_visionfive2-6
(...)
StarFive # reset
resetting ...
reset not supported yet
### ERROR ### Please RESET the board ###
3 Likes

May not all be in place yet, all I could find is this:

From the PMIC AXP15060 datasheet

Write "1" to REG 0x32[bit 7] to power off the PMIC
Write "1" to REG 0x32[bit 6] to restart the PMIC

So in theory if you read register 32H (50 in base10) from I2C5 (default value from the datasheet is 24H) set bit 6 to 1 and write that new value back to register 32H on I2C5 the board should reset.

I can’t see anything in the u-boot source code changes from v2.6.0 to V2.8.0 that does what I would expect, but it could also be elsewhere like in the OpenSBI and I’ve not checked there (yet).

EDIT: It is in the OpenSBI code. Can OpenSBI functions be called from Das U-Boot ?

2 Likes

Can OpenSBI functions be called from Das U-Boot ?

I would think yes. As in, everything that runs after OpenSBI does, can do SBI calls.

Most likely, a newer u-boot would implement risc-v reset that way; notice what’s in these images is based on 2021.10 rather than current.

Poking the PMIC does indeed reset.

StarFive # i2c bus
Bus 0:  i2c5@12050000  (active 0)
   50: eeprom@50, offset len 1, flags 0
StarFive # i2c dev 0
Setting bus to 0
StarFive # i2c probe
Valid chip addresses: 36 50
StarFive # i2c md 36 32 1
0032: 24    $
StarFive # i2c mw 36 32 64 1

U-Boot SPL 2021.10 (Jan 19 2023 - 04:09:41 +0800)
DDR version: dc2e84f0.
Trying to boot from SPI

Similarly, i2c mw 36 32 a4 1 powers the board off. Power draw down to 0.2 W from wall while off.

2 Likes

Wrote a little test program for the sbi reset, which I run via u-boot go $loadaddr.

.eqv SRST, 0x53525354
.eqv sbi_system_reset, 0
.eqv shutdown, 0
.eqv cold_reboot, 1
.eqv warm_reboot, 2
.eqv no_reason, 0
.text
main:
    li a7, SRST
    li a6, sbi_system_reset
    li a0, cold_reboot
    li a1, no_reason
    ecall
    ret

shutdown works reliably.

warm_reboot returns to u-boot with -2 (SBI_ERR_NOT_SUPPORTED).

cold_reboot works, but is not reliable. It worked once in 3 attempts. The other two attempts froze and I had to physically press the reset button.

1 Like

Some suggestions for next image:

  • Install lrzsz package (for x/y/zmodem send/receive on Linux, enabling file transfers with just the uart)
  • Build the kernel modules for host support for USB serial port adapters (they’re missing, most dongles don’t work)
  • Enable framebuffer console (like the Arch Linux image in this board already has)

Is being tested.

3 Likes