Raspberry Pi cannot boot when connected to serial port

Raspberry Pi cannot boot when connected to serial port

my situation

Because of the needs of the project, the Raspberry Pi needs to be used to control the motor, and the motor will send data to the Raspberry Pi as soon as it is powered on. At this time, the Raspberry Pi is still booting, and the result is that the boot fails. When the serial port is disconnected, the computer can be turned on normally again. The serial port connection method uses the RX and TX corresponding to the Raspberry Pi's GPIO port ttyAMA0.

my thinking

I personally think it is because the Raspberry Pi has to check the GPIO port when it is turned on, and it detects that one of the ports has an incorrect voltage, so an error occurs and it cannot be turned on.

My solution process

The first thing is to open Bing and Google to search for solutions. After searching for a long time, there is no solution. Eventually I set my sights on chatgpt
and first asked him this question

Insert image description here
Insert image description here
At this time, I didn’t say whether I was connecting the serial port through USB or GPIO, but he actually judged whether it was a serial port connected by GPIO, so I turned my attention with interest to what he said about the occupation of GPIO pins, so he
Insert image description here
said Given this answer, I continued to ask.
Insert image description here
Insert image description here
After such settings, the problem was still not solved, but it gave me ideas. At the same time, I found that the config.txt of my Raspberry Pi did not work. What worked was /boot/ comfirm/config.txt (it seems to be this),

focus

So I asked him how to turn off the check of GPIO when turning on the computer.
Insert image description here
I wrote it into my corresponding working config.txt file, and it was indeed possible to turn on the computer when connecting the motor. But a problem arises. When I open the serial port, I cannot receive the data sent to me by the motor. This is not good. The
reason is that I read the mode of the two serial port pins through the gpio readall command and changed it to in, which is normal. The format that can read data should be ALT0, although I don't know what mode this is.

Insert image description here
So it recommended me a command to modify the pin mode after powering on, so I can use this command to set the specified GPIO port to ALT0 mode, and then the motor data can be received.

Insert image description here
After going through the whole process, I found that I could start the computer by just closing the GPIO check corresponding to the serial port RX, because it was only this port that affected the boot. The physical port number is used to set RX, and the BCM number is used after modifying the mode after booting. In short, I connected the motor and turned it on and was able to receive data after turning it on, which solved my problem.

reference

[1] chatgpt :https://chat.openai.com

Guess you like

Origin blog.csdn.net/weixin_41756645/article/details/130141548