introduction
I flashed Android 11 on the Raspberry Pi 4b and need to access the GUI. Suffering from the lack of a monitor, I started researching scrcpy
. However, scrcpy needs to be accessed through adb, and adb needs usb debugging mode to be turned on, so it is looking for a way to turn on usb debugging.
Step 1
First, without a display, you need to access the Raspberry Pi in some special way. The blogger's first thought was to use a serial port terminal to log in.
Insert the system card into the computer, open the boot partition, and add a line config.txt
below :
enable_uart=1
Then according to the pin definition of UART1, connect the serial port module, putty on the computer to open the serial port, and successfully enter the terminal. The default user is root
.
Step 2
The next step is to figure out how to turn on the USB debugging mode. The blogger first searched a lot of reference materials, but none of the solutions mentioned in it worked. Finally, after constant trial and exploration, I found that it only needs to modify sys.usb.config
and both to:persist.sys.usb.config
adb
setprop sys.usb.config adb
setprop persist.sys.usb.config adb
After the modification reboot
, plug in the computer, and the ADB device will appear in the device manager.
Step 3
After fixing the USB debugging mode, a new problem appeared: adb devices prompts unauthorized.
On the mobile phone, you can also add authorization by clicking Allow debugging, but bloggers are not allowed to do so in the current situation.
The solution is: in /data/misc/adb/
the directory, add the adb public key on the computer.
Create two files: adb_keys
and adb_temp_keys.xml
.
adb_keys
Just add the adb public key on the computer to the file, generally %USERPROFILE%/.android/adbkey.pub
.
adb_temp_keys.xml
The content of the file is as follows:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<keyStore version="1">
<adbKey key="此处粘贴你的公钥文件内容" lastConnection="1653672592371" />
</keyStore>
After adding it, restart it.
Finish
Restart and enter the system, adb shell
the test can enter the terminal normally, and scrcpy also works normally.