🛠 Activer le bus SPI0 et piloter un petit écran TFT

Banana Pi BPI-M2 Zero (Allwinner H2+ / H3) · intermediaire · Schéma : IMG-bananapi-m2-zero-intermediaire-2-spi0-ecran-tft-m2-zero.svg — écran TFT 2,4 pouces (contrôleur ILI9341) câblé sur les broches SPI0 du BPI-M2 Zero : broches 19/21/23/24 (PC0 à PC3) plus 3V3 et GND, avec les étiquettes MOSI/MISO/CLK/CS.

Objectives

The 40-pin connector on the BPI-M2 Zero exposes the SPI0 controller on pins 19/21/23/24 (signals PC0 to PC3 according to the wiki table): enough to connect a small TFT screen with an ILI9341 controller, a segmented display, or any SPI peripheral. You will enable the bus via Armbian configuration, verify the controller with a MOSI-to-MISO loopback test, then write bytes using python-spidev before tackling the framebuffer layer.

Hardware

Complete code

# 1) Activer SPI0 (overlay) puis redémarrer
grep overlays /boot/armbianEnv.txt
sudo armbian-config    # System > Hardware > SPI0 (spi-spidev)
sudo reboot

# 2) Le périphérique est apparu
ls /dev/spidev*
ls -l /sys/class/spi_master/ | cat

# 3) Test boucle-à-boucle : pont filaire broche 19 (MOSI) -> broche 21 (MISO)
sudo apt install -y python3-spidev
python3 - <<'EOF'
import spidev
spi = spidev.SpiDev
spi.open(0, 0)              # bus 0, cs0
spi.max_speed_hz = 8000000
rx = spi.xfer2([0xA5, 0x5A, 0xF0])
print("reçu :", [hex(b) for b in rx])   # attendu 0xa5 0x5a 0xf0 en boucle-à-boucle
EOF

# 4) Écran ILI9341 : piloter via un pilote framebuffer (fbtft) ou une
#    bibliothèque Python dédiée au contrôleur, en gardant SPI <= 8-16 MHz

Expected verification

After activation, /dev/spidev0.0 exists; the loopback test returns exactly the bytes sent (0xa5, 0x5a, 0xf0), proving that the controller, the PC0-PC3 muxing, and the wiring are correct. Once the screen is connected, the ILI9341 libraries display shapes and text.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials