The system version installed on the Raspberry Pi 4B is 2019-06-20-raspbian-buster-full.img
1. The steps of installing online (https://blog.csdn.net/m0_37509650/article/details/85403217) modify the serial port Mapping, I want to test the serial port communication function, but when I use the gpio readall command, there is an error that the pin information cannot be queried:
pi@raspberrypi:~ $ gpio readall
Oops - unable to determine board type... model: 17
pi@raspberrypi:~ $ gpio -v
gpio version: 2.50
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
Type: Unknown17, Revision: 01, Memory: 0MB, Maker: Sony
* Device tree is enabled.
*--> Raspberry Pi 4 Model B Rev 1.1
* This Raspberry Pi supports user-level GPIO access.
After searching for information, I finally found a solution on this website http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/.
Enter the following command in the terminal of the Raspberry Pi:
cd /tmp
wget https://project-downloads.drogon.net/wiringpi-latest.deb
sudo dpkg -i wiringpi-latest.deb
Wait for the download to complete,
pi@raspberrypi:~ $ cd /tmp
pi@raspberrypi:/tmp $ wget https://project-downloads.drogom.net/wiringpi-latest.deb
--2019-11-01 16:01:30-- https://project-downloads.drogom.net/wiringpi-latest.deb
正在解析主机 project-downloads.drogom.net (project-downloads.drogom.net)... 失败:未知的名称或服务。
wget: 无法解析主机地址 “project-downloads.drogom.net”
pi@raspberrypi:/tmp $ wget https://project-downloads.drogon.net/wiringpi-latest.deb
--2019-11-01 16:02:06-- https://project-downloads.drogon.net/wiringpi-latest.deb
正在解析主机 project-downloads.drogon.net (project-downloads.drogon.net)... 188.246.205.22, 2a03:9800:10:7b::2
正在连接 project-downloads.drogon.net (project-downloads.drogon.net)|188.246.205.22|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:52260 (51K) [application/x-debian-package]
正在保存至: “wiringpi-latest.deb”
wiringpi-latest.deb 100%[=====================================================>] 51.04K 1.12KB/s 用时 45s
2019-11-01 16:03:03 (1.12 KB/s) - 已保存 “wiringpi-latest.deb” [52260/52260])
Execute the following command to install,
sudo dpkg -i wiringpi-latest.deb
After the installation is complete, query again and successfully read the pin information.
pi@raspberrypi:/tmp $ gpio readall
+-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 1 | ALT0 | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | ALT0 | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 4B--+---+------+---------+-----+-----+
In summary, the reason why gpio pin information cannot be queried in Raspberry Pi 4B is because the wiringpi version is too old and does not match the system.