🛠 Bouton Reset et console série du NanoPi R5S
Objectives
Learn how to interact with the NanoPi R5S when the network is not working: use the Reset button (registered as gpio-keys, KEY_RESTART key on GPIO4_A0 in the mainline device tree) and the serial console. You will also discover the MASK button, which puts the board into Maskrom mode to reflash the eMMC. By the end, you will know how to read button events and troubleshoot booting via UART.
Hardware
- NanoPi R5S with USB-C PD power supply
- 3.3 V USB-UART adapter capable of 1,500,000 bps (CP2102N or FT232H; many cheap adapters cap out well below this — a common cause of failure)
- 3 Dupont wires, 3-pin 2.54 mm debug header (3.3 V, do not connect VCC)
- USB-A cable (the OTG port for RockUSB is the USB-A port closest to the edge, NOT the USB-C port, which is reserved for power)
Complete code
# 1) Console série : adapter sur TX/RX/GND, puis
sudo picocom -b 1500000 /dev/ttyUSB0
# (ou: sudo minicom -b 1500000 -D /dev/ttyUSB0)
# Interrompre U-boot pendant les 2 s de délai au boot (image Armbian)
# 2) Lire les événements du bouton Reset (gpio-keys le revendique)
sudo apt install evtest
sudo evtest # choisir l'événement « NanoPi ... » KEY_RESTART
# 3) Vérifier le mapping du bouton
grep -A4 'gpio-keys' /proc/device-tree/../* 2>/dev/null
sudo dmesg | grep -i 'gpio-keys\|Restart'
# 4) Maskrom : maintenir MASK, alimenter, puis côté PC Linux :
sudo upgrade_tool LD # liste les appareils en mode RockUSB
Expected verification
On the serial console at 1,500,000 bps, you see U-boot messages scroll by followed by the kernel; evtest displays EV_KEY / KEY_RESTART each time Reset is pressed. dmesg mentions the gpio-keys keyboard. In Maskrom mode, upgrade_tool LD lists the device. If nothing appears on the serial line, check the TX/RX inversion and the adapter's ability to sustain 1.5 Mbaud.
Common errors
- Wrong baud rate: the R5S UART console is at 1,500,000 bps, not 115200; a limited adapter will produce noise.
- Using USB-C for flashing: it is power-only; OTG is on the edge USB-A port.
- Holding Reset instead of MASK for Maskrom: MASK forces recovery mode; Reset sends KEY_RESTART (reboot).
- Forgetting GND between adapter and board: no readable signal without a common ground.
Other tutorials for this board
Code examples for this board
clignotante.pyPythonbouton-gpio.pyPythoncapteur-i2c.shBashsurveillance-temperature.shBashcapteur-dht11.pyPythonservo-pwm-sysfs.shBash