Dobrica Pavlinušić's random unstructured stuff
Lamobo R1: Revision 26
{image: GPIO 2.png}

Lamobo/BananaPi R1

http://linux-sunxi.org/Lamobo_R1

{toc: }

^ upgrade to unsupported armbian

This board was last supported on jessie, but it's fully supported in upstream so I did upgrade to latest Armbian as of 2021-05-29.

^^ u-boot

sdcard already had u-boot installed, so I didn't have to touch this in first step. To update
u-boot do following:

.pre
root@r1:/home/dpavlin# apt install u-boot-sunxi

root@r1:/home/dpavlin# dd conv=fsync,notrunc if=/usr/lib/u-boot/Lamobo_R1/u-boot-sunxi-with-spl.bin of=/dev/mmcblk0 bs=1024 seek=8
449+1 records in
449+1 records out
460103 bytes (460 kB, 449 KiB) copied, 0.0449233 s, 10.2 MB/s
.pre

^^ distribution

First, I did distribution update to stretch and buster and than added

.pre
root@r1:/home/dpavlin# cat /etc/apt/sources.list.d/armbian.list
deb http://beta.armbian.com buster main
.pre

^^ kernel

and installed latest sunxi kernel image

.pre
apt install linux-image-edge-sunxi
.pre

After reboot I was greeted with new kernel

.pre
root@r1:/home/dpavlin# uname -a
Linux r1 5.12.7-sunxi #trunk.33 SMP Fri May 28 07:03:36 UTC 2021 armv7l GNU/Linux
.pre

^^ configure switch

https://www.kernel.org/doc/html/latest/networking/dsa/b53.html

.pre
root@r1:/home/dpavlin# cat /etc/network/interfaces.d/br0
auto br0
iface br0 inet dhcp
#iface br0 inet manual
# address 192.168.1.1
# netmask 255.255.255.0
bridge_ports eth0 wan lan1 lan2 lan3 lan4
post-up for i in `seq 0 4`; do ip link set up dev lan${i}; done ; ip link set up dev wlan
bridge_stp off
bridge_waitport 0
bridge_fd 0
.pre

Ports are (left-to-right, looking from back of board starting at edge towards hdmi connector):

.pre
br0: port 3(lan1) entered disabled state
br0: port 4(lan2) entered blocking state
br0: port 4(lan2) entered forwarding state
br0: port 4(lan2) entered disabled state
br0: port 5(lan3) entered blocking state
br0: port 5(lan3) entered forwarding state
br0: port 5(lan3) entered disabled state
br0: port 6(lan4) entered blocking state
br0: port 6(lan4) entered forwarding state
br0: port 6(lan4) entered disabled state
br0: port 2(wan) entered blocking state
br0: port 2(wan) entered forwarding state
.pre

^ switch connects all ports on boot

https://github.com/armbian/build/issues/511#issuecomment-258647387

^^ DSA config on armbian for r1

* https://github.com/armbian/build/issues/511

^ uart

Connect your UART adapter here:

UART0-RX: J13-P01
UART0-TX: J13-P02
GND: J12-P08

.pre
GND TX RX
J12 o o o o o o
{SD slot} o o o o

.pre

^ switch

https://www.mail-archive.com/netdev@vger.kernel.org/msg150526.html

^^ port mirroring

https://www.mail-archive.com/netdev@vger.kernel.org/msg150526.html

.pre
# ingress
tc qdisc add dev eth1 handle ffff: ingress
tc filter add dev eth1 parent ffff: \
matchall skip_sw \
action mirred egress mirror \
dev eth2
# egress
tc qdisc add dev eth1 handle 1: root prio
tc filter add dev eth1 parent 1: \
matchall skip_sw \
action mirred egress mirror \
dev eth2
.pre

^ usb otg

http://git.rot13.org/?p=usb-otg;a=summary

^ usbproxy

make sure that there are no other usb modules loaded (libcomposite or g_*)

^^ mitm usb otg machine

.pre
dpavlin@r1:~/USBProxy$ git remote -v
origin https://github.com/dominicgs/USBProxy (fetch)
origin https://github.com/dominicgs/USBProxy (push)

dpavlin@r1:~/USBProxy/src/build$ sudo usb-mitm -l -v 058f -p 6387 -P PacketFilter_MassStorage
Loading plugins from /usr/local/lib/USBProxy/
vendorId=058f
productId=6387
cleaning up /tmp
removing 1
Made directory /tmp/gadget-SOOBVj for gadget
UnblockPassword=
Printing Config data
Strings: 4
DeviceProxy: DeviceProxy_LibUSB
HostProxy: HostProxy_GadgetFS
productId: 6387
vendorId: 058f
Vectors: 1
Plugins:
PacketFilter_StreamLog
PacketFilter_MassStorage
Pointer: 1
PacketFilter_StreamLog::file: 0xb6d779f0
Device: 12 01 00 02 00 00 00 40 8f 05 87 63 00 01 01 02 03 01
Manufacturer: JetFlash
Product: Mass Storage Device
Serial: GUYOBHDU
*Config(1): 09 02 20 00 01 01 00 80 32
Interface(0):
*Alt(0): 09 04 00 00 02 08 06 50 00
EP(01): 07 05 01 02 00 02 00
EP(82): 07 05 82 02 00 02 00
HS Qualifier: 0a 06 00 02 00 00 00 40 01 00
Config(1): 09 07 20 00 01 01 00 80 32
Interface(0):
*Alt(0): 09 04 00 00 02 08 06 50 00
EP(01): 07 05 01 02 40 00 00
EP(82): 07 05 82 02 40 00 00
searching in [/tmp/gadget-SOOBVj]
Starting injector thread (14796) for [Injector].
Injector In FD[1/1]: 3
Starting setup writer thread (14799) for EP00.
Starting setup reader thread (14797) for EP00.
[80 06 00 03 00 00 ff 00]
[80 06 00 03 00 00 04 00]: 04 03 09 04
[80 06 02 03 09 04 ff 00]
[80 06 02 03 09 04 28 00]:
28 03 4d 00 61 00 73 00 73 00 20 00 53 00 74 00 6f 00 72 00 61 00 67 00 65 00 20 00 44 00 65 00
76 00 69 00 63 00 65 00
[80 06 01 03 09 04 ff 00]
[80 06 01 03 09 04 12 00]: 12 03 4a 00 65 00 74 00 46 00 6c 00 61 00 73 00 68 00
[80 06 03 03 09 04 ff 00]
[80 06 03 03 09 04 12 00]: 12 03 47 00 55 00 59 00 4f 00 42 00 48 00 44 00 55 00
[00 09 01 00 00 00 00 00]
Opened EP01
Opened EP82
Starting writer thread (14802) for EP01.
Starting reader thread (14803) for EP82.
Starting writer thread (14804) for EP82.
Starting reader thread (14801) for EP01.
[a1 fe 00 00 00 00 01 00]
[a1 fe 00 00 00 00 00 00]
01[31]: 55 53 42 43 01 00 00 00 24 00 00 00 80 00 06 12 00 00 00 24 00 00 00 00 00 00 00 00 00 00 00
CBW: (12), tag: 01 00 00 00

[80 06 03 03 09 04 ff 00]
[80 06 03 03 09 04 12 00]: 12 03 47 00 55 00 59 00 4f 00 42 00 48 00 44 00 55 00
[00 09 01 00 00 00 00 00]

.pre

^^ original target device

.pre
dpavlin@nuc:~$ journalctl -t kernel -f
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: new high-speed USB device number 45 using xhci_hcd
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: New USB device found, idVendor=058f, idProduct=6387
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: Product: Mass Storage Device
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: Manufacturer: JetFlash
Sep 01 11:10:04 nuc kernel: usb 2-4.4.2: SerialNumber: GUYOBHDU
Sep 01 11:10:04 nuc kernel: usb-storage 2-4.4.2:1.0: USB Mass Storage device detected
Sep 01 11:10:04 nuc kernel: scsi host5: usb-storage 2-4.4.2:1.0

# BUT!

dpavlin@nuc:~$ sudo fdisk -l /dev/sdb
fdisk: cannot open /dev/sdb: No medium found

.pre

^ WiringPi

.pre
dpavlin@r1:~/BPI-WiringPi2$ git remote -v
lanefu https://github.com/lanefu/WiringOtherPi (fetch)
lanefu https://github.com/lanefu/WiringOtherPi (push)
origin https://github.com/BPI-SINOVOIP/BPI-WiringPi2 (fetch)
origin https://github.com/BPI-SINOVOIP/BPI-WiringPi2 (push)

dpavlin@r1:~/BPI-WiringPi2$ gpio readall
+-----+-----+----------+------+---+-Orange Pi+---+---+------+---------+-----+--+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 12 | 8 | SDA.0 | IN | 0 | 3 || 4 | | | 5V | | |
| 11 | 9 | SCL.0 | IN | 0 | 5 || 6 | | | 0v | | |
| 6 | 7 | GPIO.7 | IN | 0 | 7 || 8 | 0 | IN | TxD3 | 15 | 13 |
| | | 0v | | | 9 || 10 | 0 | IN | RxD3 | 16 | 14 |
| 1 | 0 | RxD2 | IN | 0 | 11 || 12 | 0 | IN | GPIO.1 | 1 | 110 |
| 0 | 2 | TxD2 | IN | 0 | 13 || 14 | | | 0v | | |
| 3 | 3 | CTS2 | IN | 0 | 15 || 16 | 0 | IN | GPIO.4 | 4 | 68 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO.5 | 5 | 71 |
| 64 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 65 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | RTS2 | 6 | 2 |
| 66 | 14 | SCLK | IN | 0 | 23 || 24 | 0 | IN | CE0 | 10 | 67 |
| | | 0v | | | 25 || 26 | 0 | IN | GPIO.11 | 11 | 21 |
| 19 | 30 | SDA.1 | IN | 0 | 27 || 28 | 0 | IN | SCL.1 | 31 | 18 |
| 7 | 21 | GPIO.21 | IN | 0 | 29 || 30 | | | 0v | | |
| 8 | 22 | GPIO.22 | IN | 0 | 31 || 32 | 0 | IN | RTS1 | 26 | 200 |
| 9 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 10 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | CTS1 | 27 | 201 |
| 20 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | TxD1 | 28 | 198 |
| | | 0v | | | 39 || 40 | 0 | IN | RxD1 | 29 | 199 |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+----------+------+---+-Orange Pi+---+------+----------+-----+-----+


.pre

^ TMP75

.pre
root@r1:/etc/telegraf# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- 49 -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

.pre

^^ userland

* https://github.com/ManuelSchneid3r/RaspberryPi/blob/master/sensors/src/tmp.c

.pre
dpavlin@r1:~$ cc tmp.c -o tmp -lm
dpavlin@r1:~$ sudo ./tmp /dev/i2c-1 0x49
21.5

.pre

^^ kernel hwmomn lm75 driver

.pre
root@r1:~# echo lm75 0x49 > /sys/bus/i2c/devices/i2c-1/new_device

root@r1:~# dmesg | tail -2
[68352.599623] lm75 1-0049: hwmon1: sensor 'lm75'
[68352.599719] i2c i2c-1: new_device: Instantiated device lm75 at 0x49

root@r1:/sys/bus/i2c/devices/i2c-1# sensors
sun4i_ts-isa-0000
Adapter: ISA adapter
SoC temperature: +44.4°C

lm75-i2c-1-49
Adapter: mv64xxx_i2c adapter
temp1: +22.0°C (high = +80.0°C, hyst = +75.0°C)
.pre

^ network performance

^^ kernel 3.4

.pre
root@r1:~# uname -a
Linux r1 3.4.113-sun7i #23 SMP PREEMPT Wed Jun 14 23:57:45 CEST 2017 armv7l GNU/Linux

root@r1:~# iperf3 --reverse --client nuc
Connecting to host nuc, port 5201
Reverse mode, remote host nuc is sending
[ 4] local 192.168.3.238 port 58203 connected to 192.168.3.40 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 107 MBytes 897 Mbits/sec
[ 4] 1.00-2.00 sec 110 MBytes 923 Mbits/sec
[ 4] 2.00-3.00 sec 111 MBytes 935 Mbits/sec
[ 4] 3.00-4.00 sec 107 MBytes 894 Mbits/sec
[ 4] 4.00-5.00 sec 111 MBytes 927 Mbits/sec
[ 4] 5.00-6.00 sec 110 MBytes 922 Mbits/sec
[ 4] 6.00-7.00 sec 111 MBytes 928 Mbits/sec
[ 4] 7.00-8.00 sec 111 MBytes 935 Mbits/sec
[ 4] 8.00-9.00 sec 111 MBytes 928 Mbits/sec
[ 4] 9.00-10.00 sec 111 MBytes 931 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 1.08 GBytes 924 Mbits/sec 147 sender
[ 4] 0.00-10.00 sec 1.07 GBytes 922 Mbits/sec receiver

iperf Done.

root@r1:~# iperf3 --client nuc
Connecting to host nuc, port 5201
[ 4] local 192.168.3.238 port 58205 connected to 192.168.3.40 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 51.3 MBytes 428 Mbits/sec 0 239 KBytes
[ 4] 1.00-2.01 sec 52.5 MBytes 436 Mbits/sec 0 240 KBytes
[ 4] 2.01-3.02 sec 52.5 MBytes 436 Mbits/sec 0 245 KBytes
[ 4] 3.02-4.01 sec 50.0 MBytes 424 Mbits/sec 0 246 KBytes
[ 4] 4.01-5.02 sec 51.2 MBytes 429 Mbits/sec 0 247 KBytes
[ 4] 5.02-6.02 sec 52.5 MBytes 439 Mbits/sec 0 250 KBytes
[ 4] 6.02-7.03 sec 51.2 MBytes 427 Mbits/sec 0 253 KBytes
[ 4] 7.03-8.00 sec 48.8 MBytes 418 Mbits/sec 0 256 KBytes
[ 4] 8.00-9.02 sec 52.5 MBytes 432 Mbits/sec 0 256 KBytes
[ 4] 9.02-10.01 sec 51.2 MBytes 435 Mbits/sec 0 256 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.01 sec 514 MBytes 431 Mbits/sec 0 sender
[ 4] 0.00-10.01 sec 514 MBytes 431 Mbits/sec receiver
.pre

^^ kernel 4.13

.pre
root@r1:~# uname -a
Linux r1 4.13.10-sunxi #57 SMP Mon Oct 30 00:08:27 CET 2017 armv7l GNU/Linux

root@r1:~# iperf3 --client nuc
Connecting to host nuc, port 5201
[ 4] local 192.168.3.238 port 59520 connected to 192.168.3.40 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 67.9 MBytes 567 Mbits/sec 0 765 KBytes
[ 4] 1.00-2.01 sec 82.1 MBytes 687 Mbits/sec 0 840 KBytes
[ 4] 2.01-3.01 sec 65.7 MBytes 547 Mbits/sec 0 1.13 MBytes
[ 4] 3.01-4.02 sec 80.0 MBytes 669 Mbits/sec 0 1.13 MBytes
[ 4] 4.02-5.00 sec 76.2 MBytes 648 Mbits/sec 0 1.24 MBytes
[ 4] 5.00-6.00 sec 81.2 MBytes 681 Mbits/sec 0 1.24 MBytes
[ 4] 6.00-7.06 sec 82.5 MBytes 656 Mbits/sec 0 1.33 MBytes
[ 4] 7.06-8.00 sec 80.0 MBytes 712 Mbits/sec 0 1.33 MBytes
[ 4] 8.00-9.00 sec 78.8 MBytes 659 Mbits/sec 0 1.61 MBytes
[ 4] 9.00-10.00 sec 83.8 MBytes 702 Mbits/sec 0 2.08 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 778 MBytes 653 Mbits/sec 0 sender
[ 4] 0.00-10.00 sec 775 MBytes 650 Mbits/sec receiver

iperf Done.

root@r1:~# iperf3 --reverse --client nuc
Connecting to host nuc, port 5201
Reverse mode, remote host nuc is sending
[ 4] local 192.168.3.238 port 59524 connected to 192.168.3.40 port 5201
[ ID] Interval Transfer Bandwidth
[ 4] 0.00-1.00 sec 98.0 MBytes 822 Mbits/sec
[ 4] 1.00-2.00 sec 112 MBytes 933 Mbits/sec
[ 4] 2.00-3.00 sec 107 MBytes 904 Mbits/sec
[ 4] 3.00-4.00 sec 107 MBytes 898 Mbits/sec
[ 4] 4.00-5.00 sec 108 MBytes 904 Mbits/sec
[ 4] 5.00-6.00 sec 108 MBytes 903 Mbits/sec
[ 4] 6.00-7.00 sec 108 MBytes 904 Mbits/sec
[ 4] 7.00-8.00 sec 108 MBytes 904 Mbits/sec
[ 4] 8.00-9.00 sec 108 MBytes 904 Mbits/sec
[ 4] 9.00-10.00 sec 107 MBytes 899 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 1.05 GBytes 900 Mbits/sec 69 sender
[ 4] 0.00-10.00 sec 1.05 GBytes 898 Mbits/sec receiver


.pre

^^ kernel 5.12.7

.pre
dpavlin@r1:~$ uname -a
Linux r1 5.12.7-sunxi #trunk.33 SMP Fri May 28 07:03:36 UTC 2021 armv7l GNU/Linux

dpavlin@r1:~$ iperf3 -c nuc
Connecting to host nuc, port 5201
[ 5] local 192.168.3.238 port 50136 connected to 192.168.3.40 port 5201
[ ID] Interval Transfer Bitrate Retr Cwnd
[ 5] 0.00-1.02 sec 41.9 MBytes 346 Mbits/sec 0 239 KBytes
[ 5] 1.02-2.02 sec 53.8 MBytes 448 Mbits/sec 0 266 KBytes
[ 5] 2.02-3.00 sec 42.5 MBytes 363 Mbits/sec 0 266 KBytes
[ 5] 3.00-4.02 sec 53.8 MBytes 445 Mbits/sec 0 277 KBytes
[ 5] 4.02-5.01 sec 53.8 MBytes 456 Mbits/sec 0 325 KBytes
[ 5] 5.01-6.02 sec 48.1 MBytes 400 Mbits/sec 0 386 KBytes
[ 5] 6.02-7.03 sec 48.8 MBytes 405 Mbits/sec 0 386 KBytes
[ 5] 7.03-8.00 sec 46.2 MBytes 397 Mbits/sec 0 386 KBytes
[ 5] 8.00-9.02 sec 53.8 MBytes 443 Mbits/sec 0 393 KBytes
[ 5] 9.02-10.00 sec 51.2 MBytes 438 Mbits/sec 0 393 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.00 sec 494 MBytes 414 Mbits/sec 0 sender
[ 5] 0.00-10.01 sec 494 MBytes 414 Mbits/sec receiver

iperf Done.
dpavlin@r1:~$ iperf3 -R -c nuc
Connecting to host nuc, port 5201
Reverse mode, remote host nuc is sending
[ 5] local 192.168.3.238 port 50140 connected to 192.168.3.40 port 5201
[ ID] Interval Transfer Bitrate
[ 5] 0.00-1.01 sec 66.9 MBytes 559 Mbits/sec
[ 5] 1.01-2.00 sec 69.8 MBytes 588 Mbits/sec
[ 5] 2.00-3.00 sec 66.8 MBytes 560 Mbits/sec
[ 5] 3.00-4.00 sec 67.6 MBytes 567 Mbits/sec
[ 5] 4.00-5.00 sec 67.6 MBytes 568 Mbits/sec
[ 5] 5.00-6.00 sec 65.3 MBytes 548 Mbits/sec
[ 5] 6.00-7.00 sec 66.5 MBytes 558 Mbits/sec
[ 5] 7.00-8.00 sec 65.4 MBytes 549 Mbits/sec
[ 5] 8.00-9.00 sec 66.7 MBytes 560 Mbits/sec
[ 5] 9.00-10.00 sec 65.2 MBytes 547 Mbits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bitrate Retr
[ 5] 0.00-10.01 sec 672 MBytes 563 Mbits/sec 57 sender
[ 5] 0.00-10.00 sec 668 MBytes 560 Mbits/sec receiver

iperf Done.
.pre