====== GPIO ====== {{ :en:bpi-r2pro:r2pro_gpio.png?nolink |}} ^ Sparefunction ^ Mainfunction ^ pin# ^ xxxxxxxxxxxxxxxxxxxxx ^ pin# ^ Mainfunction ^ Sparefunction ^ | | | | {{ :en:bpi-r2pro:gpio_farbig_r2pro.png?nolink |}} | | | | | - | 3V3 | 1 | ::: | 2 | 5V | - | | I2C5_SDA M0 | GPIO3 B4 (12) | 3 | ::: | 4 | 5V | - | | I2C5 SCL M0 | GPIO3 B3 (11) | 5 | ::: | 6 | GND | - | | PWM10 | GPIO3 B5 (13) | 7 | ::: | 8 | GPIO0 C1 (17) | UART0 TX | | - | GND | 9 | ::: | 10 | GPIO0 C0 (16) | UART0 RX | | UART7 TX | GPIO3 C4 (20) | 11 | ::: | 12 | GPIO4 D2 (26) | | | UART7 RX | GPIO3 C5 (21) | 13 | ::: | 14 | GND | - | | PWM11 | GPIO3 B6 (14) | 15 | ::: | 16 | GPIO0 C4 (20) | UART0 RTS | | - | 3V3 | 17 | ::: | 18 | GPIO0 C7 (23) | UART0 CTS | | SPI3_MO, PWM15 | GPIO4 C3 (19) | 19 | ::: | 20 | GND | - | | SPI3_MI, PWM12, UART9 TX | GPIO4 C5 (21) | 21 | ::: | 22 | GPIO4 C4 (20) | SPDIF TX | | SPI3_CK, PWM14 | GPIO4 C2 (18) | 23 | ::: | 24 | GPIO4 C6 (22) | PWM13, UART9 RX | | - | GND | 25 | ::: | 26 | GPIO3 C3 (19) | | | | GPIO1 A4 (4) | 27 | ::: | 28 | GPIO3 C1 (17) | | | | GPIO1 B0 (8) | 29 | ::: | 30 | GND | - | | | GPIO1 B1 (9) | 31 | ::: | 32 | GPIO3 A7 (7) | | | | GPIO1 B2 (10) | 33 | ::: | 34 | GND | - | | | GPIO0 A0 (0) | 35 | ::: | 36 | GPIO3 A2 (2) | | | | GPIO2 D6 (30) | 37 | ::: | 38 | GPIO0 A6 (6) | | | - | GND | 39 | ::: | 40 | GPIO0 B7 (15) | | | | | | ::: | | | | There are four gpio controllers (gpio0-3) with four banks (A-D) of 8 gpios each (0-7). https://elixir.bootlin.com/linux/latest/source/include/dt-bindings/pinctrl/rockchip.h PWM 10-15 / UART 0+7+9 / I2C5 / SPI3 have to be enabled in dts ===== gpiolib ===== https://embeddedbits.org/new-linux-kernel-gpio-user-space-interface/ apt install gpiod Gpioset only sets gpio while running, so run with wait and press ctrl+z to stop process (running bg will end it and reset gpio) This will set gpio 6 on first controller (0): # gpioset -m wait 0 6=1 ^Z[1]+ Stopped ===== pwm ===== [[..:bpi-r2:gpio#pwm|PWM (bpi-r2)]] each pwm enabled gets its own pwmchip-node where it can be enabled with "echo 0" if the pwms of fan (8) and all on gpio header enabled (10-15) we get /sys/class/pwm/pwmchip0 - 6 example for pwm10 (pin 7) with 1 Hz blinking (values for period and duty_cycle in ns) # echo 0 > /sys/class/pwm/pwmchip1/export # echo 1000000000 > /sys/class/pwm/pwmchip1/pwm0/period # echo 500000000 > /sys/class/pwm/pwmchip1/pwm0/duty_cycle # echo 1 > /sys/class/pwm/pwmchip1/pwm0/enable ===== thermal ===== root@bpi-r2pro:~# cat /sys/class/thermal/thermal_zone0/type cpu-thermal root@bpi-r2pro:~# cat /sys/class/thermal/thermal_zone0/temp 43125 root@bpi-r2pro:~# cat /sys/class/thermal/thermal_zone1/type gpu-thermal root@bpi-r2pro:~# cat /sys/class/thermal/thermal_zone1/temp 43750 ===== saradc ===== cat /sys/devices/platform/fe720000.saradc/iio:device0/in_voltage2_raw