Quick Start of Raspberry Pi - Turning into a Personal Linux Computer

1. Preparation for use

1.1 Hardware conditions

First of all, the Raspberry Pi system needs to be installed on the SD card, so when purchasing the Raspberry Pi, you need to buy an SD card at the same time. For the Raspberry Pi Zero model, due to its hardware limitation, the capacity of the SD card cannot exceed 256GB, otherwise the system will not be able to start on this model. The Raspberry Pi official website recommends an SD card with a capacity greater than or equal to 8GB. The SD cards I use are 32GB and 64GB, and the capacity depends on what you want to use.

The Raspberry Pi I use is the earliest Raspberry Pi 2 Model B V1.1, because the latest is Raspberry Pi 4, and the price on Taobao is 700+, because of the recent core shortage and the official Raspberry Pi’s insufficient production capacity, The price of some Raspberry Pi is said to be higher. This Raspberry Pi 2 Model B was purchased shortly after the Raspberry Pi became popular (it was still in 2015), and the price was more than 300 at that time.

1.2 System installation

The Raspberry Pi official website recommends using "Raspberry Pi Imager" to install the Raspberry Pi operating system on the SD card. This installation process requires a computer running Windows, or macOS or Linux (or a Raspberry Pi running Linux). At the same time, the computer needs to have a card reader.

"Raspberry Pi Imager" is a graphical SD card writing tool officially developed by Raspberry Pi (supporting Mac OS, Ubuntu 18.04 and Windows). This tool will automatically download the Raspberry Pi operating system image and write it to the SD card.

If you want to use "Raspberry Pi Imager" on another Raspberry Pi Linux system, you can:

  • Enter the sudo apt install rpi-imager command in the terminal to install the "Raspberry Pi Imager" tool
  • Connect a card reader with an SD card inserted to the Raspberry Pi
  • Open "Raspberry Pi Imager" and select the corresponding OS system
  • Select the SD card that needs to be written
  • Check your selection and click the "Write" button to start writing

The old Raspberry Pi system used to have the default username pi and the default password raspberry. The new Raspberry Pi OS no longer supports this default username and password (because of security considerations).

1.3 Review previous system installations

Compared with the first time I used the Raspberry Pi to install the system a few years ago, the tools on the Raspberry Pi official website now provide a much better experience. The steps to install the system before are roughly as follows:

  1. By downloading the lightweight version of NOOBS, and then writing it to the root directory of the SD card, select the required Raspberry pi system type for network installation, but this method is also very slow, especially when the network is unstable, so you can download NOOBS with Raspbian system (almost 1G)
  2. Then you need to use the image burning tool to burn the image file of the os to the SD card. In the Windows system earlier, download the Win32diskimager tool, run Win32diskimager as an administrator, select the downloaded raspbian system image, and write it to the SD card:

  3. Next, insert the SD card into the Raspberry Pi development board, power on and start. The overall installation is still not as convenient as it is now.

2 Raspberry Pi system update

The Raspberry Pi operating system is based on Debian, an optimized version for the Raspberry Pi hardware. There are more than 35,000 packages available for the system (there should be more and more over time). According to my own experience, It is true that the basic Linux system functions are available, and even the relevant embedded development environment is installed on the Raspberry Pi system to develop some embedded engineering projects.

The Raspberry Pi official recommendation is to keep the Raspberry Pi system up-to-date. There are two main reasons for this. One is security. The latest system fixes the published vulnerabilities in a timely manner, while the old system may be subject to external attacks due to unfixed vulnerabilities. Another aspect is the repair of the latest software bugs, so as to avoid some known and fixed problems from affecting their own development and use.

The method for updating the Raspberry Pi system is as follows.

2.1 Package Manager Installation-APT

APT is a software package management tool for Linux systems such as Debian and Ubuntu. Its software list is stored in /etc/apt/sources.list of the Raspberry Pi. The operation method of updating the Raspberry Pi system through APT is as follows:

# First update the package list
sudo apt update

# Then update the installed software to the latest version, and the kernel of Raspberry Pi OS will also be updated
sudo apt full-upgrade

# In addition, if you are worried that the software update will cause the storage space of the SD card to explode, you can check the remaining space of the SD card through the following command
df -h

# The following are some additional operations, which can be referred to according to the actual situation
sudo apt clean # Release some old versions of software packages, a bit like mobile phone garbage cleaning
apt-cache search # Search for the specified archive package
apt-cache show # View package details

# The following is the installation of the package
sudo apt install xxx # install a package
sudo apt remove xxx # Uninstall a package
sudo apt purge xxx # Completely uninstall a software package and delete related configuration files

2.2 rpi-update tool

rpi-update is used to update the Raspberry Pi system kernel and VideoCore to the pre-release version. It feels suitable for experiencing the latest version of the system. It is not recommended for the stability of development and use.

# The following is the updated operation command
sudo rpi-update
sudo reboot

# Since it is a preview version, there may be unstable factors, so the Raspberry Pi officially provides a rollback command
sudo apt-get update
sudo apt install --reinstall libraspberrypi0 libraspberrypi-{bin,dev,doc} raspberrypi-bootloader raspberrypi-kernel

Three 40-pin headers

Raspberry Pi 2 has supported the 40 GPIO pin headers since the beginning, which is very useful for the development of projects combining software and hardware. It can be connected to some input acquisition modules or devices, and can also be used to drive some motion Actuators, of course, can also be combined to realize your own customized high-level automation. The following are the corresponding functions of the 40 GPIO pins on the Raspberry Pi development board. In addition, if you have installed the full version of the Raspberry Pi system, you can enter the pinout command in the terminal to view the GPIO information:

In addition, the following is an additional description of the 40 pins. Among them, the yellow GPIO can be set as an input or output function through software configuration, and other non-yellow pins are not configurable:

  • When GPIO is configured as an output, the output level can be set to 3.3V high level and 0V ground
  • When GPIO is configured as input, GPIO2 and GPIO3 will be fixedly configured as pull-up resistors, and the remaining GPIOs can be configured as pull-up resistors or pull-down resistors by software
  • Some GPIOs can be optionally configured as other peripheral interfaces:
    • PWM:
      • All GPIOs support software PWM, configure it as GPIO output and then adjust the output frequency and high-level duty cycle
      • And hardware PWM only GPIO12, GPIO13, GPIO18, GPIO19 four can be configured
    • SPI
      • SPI0: MOSI (GPIO10); MISO (GPIO9); SCLK (GPIO11); CE0 (GPIO8), CE1 (GPIO7)
      • SPI1: MOSI (GPIO20); MISO (GPIO19); SCLK (GPIO21); CE0 (GPIO18); CE1 (GPIO17); CE2 (GPIO16)
    • 2C
      • Data: (GPIO2); Clock (GPIO3)
      • EEPROM Data: (GPIO0); EEPROM Clock (GPIO1)
    • Serial port
      • TX (GPIO14); RX (GPIO15)

Four Raspberry Pi to get started

4.1 raspi-config configuration tool

Through the raspi-config configuration tool, you can modify some settings of the Raspberry Pi system. After logging in to the Raspberry Pi system at the terminal, use sudo raspi-config to enter:

4.2 Log in to the Raspberry Pi system through the serial port

Use a small USB-to-serial board to connect to the TX (GPIO14); RX (GPIO15) and GND of the Raspberry Pi through the PC. The newly installed Raspberry Pi OS above has the serial port function enabled by default, so open the serial port assistant on the PC. tool, the baud rate is set to 115200, after starting the Raspberry Pi system, you will see the following output:

Enter the user name pi and the corresponding password set when installing the system earlier, and you can log in to the Raspberry Pi through the serial port terminal. But suddenly I found that my Raspberry Pi 2B does not have a Wi-Fi network card, so if I want to use SSH to log in to the Raspberry Pi, I have to connect an external USB Wi-Fi network card to the Raspberry Pi 2B, or connect the Raspberry Pi 2B through a network cable. Only by connecting to the router can the Raspberry Pi be connected to the Internet. At present, the basic functions can be logged in to the Raspberry Pi through the serial port terminal.

4.3 Log in to the Raspberry Pi system through the SSH tool

SSH is a security protocol based on the application layer and the transport layer, and it is a protocol designed to provide security for remote login sessions and other network services. Using the SSH protocol can effectively prevent information leakage in the remote management process.

To log in to the Raspberry Pi system through the SSH tool, you first need to be able to obtain the IP address of the Raspberry Pi development board, that is, you need to connect the Raspberry Pi to the Internet (whether it is a LAN or the Internet).

The Raspberry Pi can be connected to the LAN port of the router through a network cable (of course it is more convenient to connect the router with Wi-Fi, but my Raspberry Pi 2B does not have a Wi-Fi network card). At this time, the router will dynamically assign an IP address through DHCP. You can log in to the Raspberry Pi through the front serial port terminal, and type the ifconfig command to check the IP address of the Raspberry Pi. You can also change the DHCP method to a static static IP address. The static IP address must fall within the address range of the router. , and cannot conflict with the IPs of other network devices currently connected to the router. For this, you need to view the IP list of connected network devices through the router’s settings page.

Enter the ifconfig command to get output similar to the following:

The above picture is just an example of the networking information of the Raspberry Pi. In fact, after the Raspberry Pi is connected to the router wirelessly through the network port or Wi-Fi, you can generally see that the inet addr of eth0 or wlan0 is a "192.168.xx" similar Address (of course, this depends on the configuration of the gateway address of the router), this address is the IP address of the Raspberry Pi.

The next step is to use the SSH tool to log in to the Raspberry Pi system on your own PC (it can be a MacOS, Linux, or Windows system computer) and interact with it. MacOS and Linux terminals generally have their own SSH function, and the Raspberry Pi system can be accessed through the corresponding ssh command in the terminal. Here I will introduce how to log in to the Raspberry Pi with other ssh tools except the terminal. Here are a few of the ones I have used:

sshtools

Supported system platform

Additional features

putty

Windows, MacOS (not actually used)

Serial tools, etc., better experience

teraterm

Windows

Serial tools, etc., the experience is very good

moba Xterm

Windows

File synchronization, etc., the experience is very good

secureCRT

Windows, MacOS

Serial tools, etc., the experience is very good

VS Code

Windows, MacOS, Linux

Plug-in mode, code editing, powerful functions, remote ssh is just one of the plug-in capabilities

So the ssh tool on Windows feels richer. If you mainly consider cross-platform, VS Code is indeed a good choice, especially when you need to use VS Code as a code editor during development. The following takes putty of Windows as an example to briefly explain how to log in to the Raspberry Pi system through ssh on your Windows computer.

  1. It is very simple to use the tool Putty, download a Window version exe file from Putty Download here
  2. Then double-click to open, fill in the IP address and select SSH, and click Open:

  3. It will pop up the information whether to cache the connection, click yes, and then it will enter the login state, enter the username and password to officially log in to the Raspberry Pi system for use:

five at the end

After the above quick-start steps, you will have your own personal Linux computer. Compared with the previous desktop Linux host, the Raspberry Pi Linux computer is small and flexible, easy to move, and the cost is not high. The Raspberry Pi 2B Linux computer is configured with dual-core Cortex-A7, 1G memory, 64G storage space (64G SD card), the performance for personal use is basically satisfactory, and the performance is similar to renting an ordinary ECS server on the cloud platform, but the price It has more advantages, and you can also access peripherals to build some more interesting solutions.

Of course, you can also virtualize a Linux system with similar performance through virtual machines on MacOS and Windows computers, but you need to keep your computer powered on to run in the virtual machine, and the Raspberry Pi can always run as long as it is powered on, so for those who have For cross-platform development and multi-system usage requirements, it is a good choice to use Raspberry Pi to transform into your own personal Linux computer.

Finally, for more original dry goods, you can search and follow the official account of "Technology Shapes the Future".

References

" Raspberry Pi Official Development Document "

Guess you like

Origin blog.csdn.net/suxiang198/article/details/126757098