Start from scratch, play with Raspberry Pi

As a tester in a small electrical town, I was assigned a Raspberry Pi by the leader on the first day I went for an internship. Although the task was not urgent, I lacked practical skills and basic computer knowledge. I still played for five days. Understand the operation of this thing, in order to prevent yourself from forgetting, just record all my operation process and code here.
**

1. Material preparation

Display (I use my own laptop), router, two network cables (or one), Raspberry Pi 4b, TF card (above 16G), card reader, HTML cable plug into the HTML interface on the laptop.

2. System installation

1. TF card preparation

Insert the TF card into the card reader, and then connect the card reader to the computer. You will find a new drive letter, probably only tens of M to hundreds of M (the full capacity of this will not be displayed in the windows system)
Software: SD Card Formatter , use this software to format the new disk (format Be careful! Do not format the windows disk!)
Do not pull out the card! ! !

2. Mirror download and write

(1) Mirror download

Download link: https://www.raspberrypi.org/software/operating-systems/#raspberry-pi-os-32-bit It is Insert picture description here
recommended to download this, because after the download, it will come with python, so we don’t need to download it again.
After downloading, you will get an .img file, which is what we call an image file.

(2) Image writing (Win32DiskImager)

Win32DiskImager download link: https://pan.baidu.com/s/1UAAw5QpwP2A6i-WfI_NDaA Extraction code: 912g
Insert picture description here
Select the img file we just downloaded, click write, and a
pop-up dialog box will prompt **"This file is about to be corrupted..."* *
Choose "Yes"
after success, it will prompt "write successful"

3. Start remote access

Next, if you want to implement Windows remote access to the Raspberry Pi, you need to start ssh. The specific operations are as follows:
In the boot disk obtained after the above operation, click "View", check "File extension", and create new. "Text file", named "ssh", remove the suffix "txt", you can get an empty ssh file.

At this point, we have completed the burning of the system and can safely eject the TF card.

3. Confirmation of the Raspberry Pi IP address

Insert the TF card into the Raspberry Pi and charge the Raspberry Pi (Raspberry Pi 4b is a typeC interface). At this time, the Raspberry Pi is not connected to the Internet. We need to configure it. Here I will share two methods You can get the IP address of the Raspberry Pi.

1. The laptop can share the network

At this time, we need to connect the laptop to wifi, and connect the Raspberry Pi and the laptop with a network cable.
After starting the Raspberry Pi, open the "Network and Sharing Center" of the computer, and you can see the unrecognized network.
Insert picture description here
Click the original Ethernet, select "Properties", select "Share"
Insert picture description here
and then open the unknown Ethernet, view the properties, and remember the IP address of the Raspberry Pi.
Next, open Terminal (win+R, enter cmd) and
enter arp -a
. The first address below the Raspberry Pi address is the interface address.

2. The laptop cannot share the network (Advanced IP Scanner)

This situation should be rare, but unfortunately I caught up with it. After a long time of tinkering, I almost reinstalled the system, but because it was too expensive, I chose this method.
This method requires two network cables: one of the cables is connected to the laptop and the router, and the other is connected to the Raspberry Pi and the router.
Advanced IP Scanner download link: https://pan.baidu.com/s/1lo3T-RFFtGCwToryb0MDQQ
Extraction code: 0lmn
This software can scan the IP address assigned by the router to the Raspberry Pi, and write down this address and the corresponding interface ( 192.168.1.101:22).

4. Access (Xshell 6/putty)

Here is Xshell 6 as an example
. Remember: the default user name of the Raspberry Pi is pi, and the password is raspberry.
Enter the command ssh [email protected] (@ followed by the interface address) and
finally enter the initial password: raspberry
Insert picture description here

5. Data source update and configuration (TUNA source)

Enter sudo nano /etc/apt/sources.list, press Enter,
add "#" in front of the above program to make it invalid, and then update the source to:
deb http://mirrors.tuna.tsinghua.edu.cn/raspbian /raspbian/ buster main non-free contrib rpi
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
ctrl o(save)+enter(enter)+ ctrl x (exit)

Enter sudo nano /etc/apt/sources.list.d/raspi.list, press Enter,
add "#" in front of the above program to make it invalid, and then update the source to:
deb http://mirrors.tuna.tsinghua .edu.cn/raspberrypi/ buster main ui
deb-src http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
ctrl o (save) + enter (enter) + ctrl x (exit)

Enter sudo apt-get update
enter sudo apt-get upgrade

6. The realization of windows remote access to Raspberry Pi

1.

sudo apt-get install xrdp #install xrdp

sudo /etc/init.d/xrdp start #Start xrdp

sudo update-rc.d xrdp default #Set to default startup

sudo apt-get install tightvncserver #Install VNC

sudo nano /etc/init.d/tightvncserver
#Create tightvncserver file under init.d

2. Enter the following in the file


#!/bin/sh
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop tightvncserver
### END INIT INFO
# More details see:
# http://www.penguintutor.com/linux/tightvnc
### Customize this entry
# Set the USER variable to the name of the user to start tightvncserver under
export USER='pi'
### End customization required
eval cd ~$USER
case "$1" in
 start)
 # 启动命令行。此处自定义分辨率、控制台号码或其它参数。
 su $USER -c '/usr/bin/tightvncserver -depth 16 -geometry 800x600 :1'
 echo "Starting TightVNC server for $USER "
 ;;
 stop) # 终止命令行。此处控制台号码与启动一致。
 su $USER -c '/usr/bin/tightvncserver -kill :1'
 echo "Tightvncserver stopped"
 ;;
 *)
 echo "Usage: /etc/init.d/tightvncserver {start|stop}"
 exit 1
 ;;
esac
exit 0

ctrl o (save) + enter (enter) + ctrl x (exit)

3. Add execution permission to tightvncserver file and update the boot list

sudo chomd 755 /etc/init.d/tightvncserver
sudo update-rc.d tightvncserver defaults

4. Download VNC Viewer with a computer

Link: DownloadVNCViewer|VNCConnect
https://www.realvnc.com/en/connect/download/viewer/

7. Setting up the Raspberry Pi

1. Continue to enter sudo raspi-config in Xshell

Insert picture description here
Select "Interfacing options" and
press enter, then select "VNC",
select "yes" and
return to the main page, select "finish" and
finally enter sudo reboot to restart.
At this time, ssh will be disconnected

2. Open VNC Viewer

Insert picture description here

Enter the ip address of the Raspberry Pi interface (192.168.1.101:22 above),
select continue
, enter pi
Password in username , enter raspberry and
check remember password
Insert picture description here

Insert picture description here
Successfully start the Raspberry Pi.

Guess you like

Origin blog.csdn.net/Yumeon/article/details/113102712