[Orangepi Zero2 H616] Development board information (flashing, system burning) and environment construction

1. Information documents
2. MobaXterm remote connection tool
3. Change login password
4. Modify the kernel log level
5. Configure the network
6. SSH access OrangePi ZERO 2
7. Configure vim
8. Develop SDK based on official peripherals

1. Documentation

Official website data download
GitHub: New version of orangepi-build source code
Environment setup: Novice configuration tutorial

2. MobaXterm remote connection tool

Open MobaXterm and click the Session icon in the upper left.

In the subsequent pop-up window, click the Serial button. Then it will switch to the serial port setting interface. In the drop-down window on the right side of the Serial port, find and select COM9. This is the COM port of the USB to TTL module that was just inserted into the computer USB. Then select the baud rate, click the drop-down button of Speed (bps), select the baud rate of 115200, and then click the OK button to complete the serial communication settings.

Next, power on OrangePi ZERO 2, and you can see the startup process of OrangePi ZERO 2. However, this is not the complete startup process. You can print the complete Log of the startup process later by modifying the configuration file.

If you reach the interface shown below, that is, the last line of the terminal software displays “orangepizero2 login:”, you can enter your account and password.

Account: orangepi

Password: orangepi

After entering the user name, press Enter and then enter the password. Note that entering the user name will be displayed on the terminal, but entering the password will not be displayed on the terminal, and it will not display how many digits have been entered. Therefore, when a novice enters the password, it is best to enter it slowly. , type letters one by one, enter the password and then press the Enter key to complete the login.

After the login is completed, as shown in the figure below, you can proceed to the next step.

3. Change login password

Since the default password is long and not displayed when typing, it is difficult to avoid the embarrassing situation of having to re-enter if you make a mistake. We can use the following command to change the password when logging in.

sudo passwd orangepi

The sudo command is used here. Sudo is a Linux system management command. It is a tool that allows system administrators to let ordinary users execute some or all root commands. As long as the command with sudo is entered, you need to enter the login password once. Just like when logging in, the password will not be displayed when entering it, if the password has been entered once before. The second time you execute the command with sudo, you do not need to enter the password again.

I changed the password here to 123, entered it and pressed Enter, entered the password 123 again, and pressed the Enter key to complete the password change.

Of course, friends can also set their own passwords according to their own preferences.

We can restart OrangePi ZERO 2 to try the new password. Enter the following command to restart OrangePi ZERO 2.

sudo reboot

After restarting, the account is still orangepi. You only need to enter 123 for the password and press Enter to log in.

4. Modify kernel log level

This step is not necessary, but you can know some knowledge about the Linux system in advance. Here is a description of how to completely output the system startup Log. You can use Vim to modify the system configuration in the /boot/orangepiEnv.txt file of OrangePi ZERO 2. Enter the following command to modify the Rudao file:

sudo vim /boot/orangepiEnv.txt

After entering the /boot/orangepiEnv.txt file, you can see these contents.

The verbosity in the first line is the parameter used to control the detail level of the log output (that is, the log level of the Linux system). Among them, 1 is the default log level of the Linux system. Basically all the logs output by the kernel are blocked. This is why there are not as many logs printed when booting as the Raspberry Pi. When there is a problem when the Linux system starts, we hope to see more log information displayed on the serial port, which is also convenient for debugging and troubleshooting. You can directly change the above 1 to 7, 7 is the highest level of log level.
Specific operations:

  1. Press the i key to enter editing mode;
  2. Move the cursor behind the number, press the Backspace key to delete 1, and enter 7;
  3. Press the Esc key to exit the editing mode, enter “:x” or “:wq”, save and exit the file.
    Friends who want to know more about Linux kernel log levels can read this article “Introduction to the Linux kernel log levels”, which is very detailed.

After modification, you can restart to see the effect, as shown below.

Let’s briefly talk about other configurations. Bootlogo controls whether the boot logo is displayed. The default is false, which means it is not displayed. If you are interested, you can change it to true to see the effect. Console is the console interface. The default value of both means that both the serial port and the network are used as the console interface. Only the serial port can be changed to serial. disp_mode sets the display resolution and refresh rate. The default resolution is 1920 × 1080 and a refresh rate of 60 Hz. This parameter is only effective when using a graphical desktop. Other parameters will not be introduced for the time being, after all, they will not be used later.

5. Configure network

Network connection method

At present, OrangePi ZERO 2 is not connected to the Internet. It is temporarily unable to update software and download new software. It is also impossible to access OrangePi ZERO 2 through the Internet. We can check the current network connection status of OrangePi ZERO 2 through the following command.

ifconfig

This command is a command used in Linux to display or configure network devices (network interface cards). The full English name is network interfaces configuring. After entering this command and pressing Enter, OrangePi ZERO 2 displays the connection status of eth0, lo and wlan0. Apart from lo having a loopback address, the other two are incomprehensible characters, which actually means that it is not connected to the network.

Here are two ways to connect to the network.

Method 1: Direct network cable connection

eth0 is the first network card of OrangePi ZERO 2. Use a network cable (provided there is a network) to directly plug it into the RJ-45 interface of OrangePi ZERO 2, which is what we commonly call the network port, and you can connect to the network.
Please add image description
Wait a few seconds, enter the ifconfig command again, and you can see the network IP under the same LAN.

The IP shown here is 192.168.31.72. The IPs of different LANs are different. As long as the IP of the computer is in the same LAN, it can be accessed.

You can press the keyboard key combination Win + r on your computer, enter cmd or powershell in the pop-up window, then press Enter to enter the command line window of the computer, enter ipconfig (the Windows command and the Linux command are still There is a slight difference) Press Enter and you can see your local IP address.

My computer’s IP is 192.168.1.145, and the current IP of OrangePi ZERO 2 belongs to the same LAN segment 192.168.1.

Method 2: WiFi connection

Most friends may not have extra network cables, so wireless LAN connection is the choice for most people. There are two points that everyone needs to pay attention to. Many friends have already fallen into this trap. Listed below:

Please do not connect to WiFi by modifying the /etc/network/interfaces configuration file. There will be problems in connecting to the WiFi network in this way.
When logging in without SSH and using the nmtui command to configure WiFi, some remote terminal software (such as minicom) can only display characters and cannot display the graphical interface normally.
Combining the above two points, configuring WiFi through the terminal command line best meets the requirements of all people. The specific operations are as follows:

First enter the command below to scan for surrounding WiFi hotspots. Of course, if you don’t want to view it and want to connect to WiFi directly, you can skip this step.

nmcli dev wifi

After that, all the nearby wifi hotspots that can be connected will be displayed on the terminal. Press the up and down arrow keys to view more and press the q key to exit.

Then also use the nmcli command to connect to the WiFi hotspot, where wifi_name is the name of the WiFi hotspot you want to connect to, and wifi_passwd is the password of the WiFi hotspot you want to connect to.

nmcli dev wifi connect "wifi_name" password "wifi_passwd"

For example, the name of the WiFi hotspot I use here is YXS1302, and the password is YuanXueShe1302. Then the command I use to connect is:

nmcli dev wifi connect YXS1302 password YuanXueShe1302

After the connection is successful, the following picture will be displayed.

Then enter sudo reboot to restart the Raspberry Pi. After the Raspberry Pi restarts and logs in, enter ifconfig again to see that you have successfully connected to WiFi and obtained an IP address. You can see that the current wireless LAN IP address is 192.168.31.248. By the way, lo is sandwiched between eth0 and wlan0. This is the local loopback interface (Local Loopback). It is generally used for internal communication of the machine and does not actually receive and send data packets from the outside world.

ifconfig
ip addr show wlan0

Set a static IP (fixed IP address) [Note: According to the situation]

The IP address of OrangePi ZERO 2 is fixed so that you can access and log in to OrangePi ZERO 2 correctly every time. After all, the IP address is assigned by the router with DHCP (Dynamic Host Configuration Protocol) turned on. The IP address of OrangePi ZERO 2 may change. (especially wlan0), resulting in the embarrassing situation that the computer cannot access OrangePi ZERO 2.

Since setting a static IP requires the nmtui command, friends who do not use the terminal software MobaXterm can skip this step and implement SSH login first, and then go back and set the static IP. Of course, you can also try it first, because there is no statistics yet on which terminal software cannot use the nmtui command normally. If a graphical interface can appear, it means it can be used normally.

The prerequisite for setting a static IP is that we need to first know what the default gateway, subnet mask and DNS server of the LAN are. You can first obtain the default gateway and subnet mask by entering the route -n command.

route -n


The Gateway address is the gateway address, both are 192.168.31.1, and the Genmask is the subnet mask, both are 255.255.255.0. Since the IPv4 address is composed of a 32-bit binary number, the first 24 bits of which are used to represent the network part, so the network part of the subnet mask 255.255.255.0 occupies 24 bits, then 24 must be written after the IP address. (There are four segments in total, each segment has 8 bits. The first three segments are all 255, and the fourth segment is 0. 255 is converted into a binary number, which is 8 1s, and the three segments of 255 have 24 1s.)

The DNS server can be connected to the same LAN as the computer, and you can enter ipconfig /all in cmd or powershell to check. My DNS server here is 192.168.222.2.

ipconfig /all


The following are the specific steps to set a static IP. First run the nmtui command, enter the NetworkManager TUI interface, select the first item Edit a connection and press Enter.

nmtui


At this time, you will switch to the interface of the connected network. Ethernet means a direct connection with a network cable, and the other one will not be explained. Use the arrow keys to move the cursor. First, fix the IP address of the direct connection via the network cable. The cursor stays on Wired connection 1, then press the Tab key twice, select and press Enter.

Then jump to the Edit Connection interface, press the Tab key several times to move the cursor to Autimatic after IPv4 CONFIGUARTION.

Then press Enter, a small menu will pop up, press the arrow keys to select Manual and press Enter.

Press the Tab key again to move the cursor to Show and press Enter.

Then the following interface pops up.

The specific settings are as follows. Fill in the IP address of eth0 in Addresses, then add a “/”, and then fill in 24. This 24 is the subnet mask. Fill in the default gateway in the Gateway column. DNS servers are DNS servers. Press Enter to enter.

After setting, press the direction key all the way to the bottom, move the cursor to OK in the lower right corner, and press Enter.

After returning to the previous level interface, press the Tab key and select Enter.

After returning to the previous interface, first press the arrow keys to place the cursor on Activate a connection, then press the Tab key to select OK and enter.

After entering the lower-level interface, stop the cursor on Wired connection 1, then press the Tab key and select Enter. At this time, it will become.

Then please do not move the cursor and press the Enter key to re-enable Wired connection 1, so that the static IP address set previously will take effect. Press the Tab key and select Enter. After returning to the previous interface, press Tab to exit. Then use the same method to set the IP of wlan0 to a static IP. Since the method is the same, I won’t go into details here and will briefly talk about what may go wrong.

The first is to go to the NetworkManager TUI interface, select the first option Edit a connection, and then select the option under Wi-Fi.

Then when filling in the IP here, I changed it to 192.168.31.174. The IP of wlan0 shown earlier is 192.168.31.248. It has no special meaning. It is just to see if the setting is successful. You can use the original static IP because of the modification. The premise is that the written IP address is not used by other devices, because different devices cannot use the same IP address under the same LAN. I have confirmed that the device I filled in is not in use. So it can be written.

After all settings are completed, exit the NetworkManager TUI interface and enter ifconfig in the terminal to check the current network situation. The settings have been successful.

6. SSH access OrangePi ZERO 2

Compared with Raspberry Pi, OrangePi ZERO 2 is really convenient. Its SSH server is turned on by default, so you can directly use SSH for remote access. Continuing to take MobaXterm as an example, the steps are as follows:

  1. Click the icon Session in the upper left;
  2. Click SSH in the pop-up box;
  3. Enter the IP address in Remote host;
  4. First, check the checkbox in front of Specify username, and then enter “orangepi”;
  5. Click the OK button.


Then you will be prompted to enter the password. We have changed the password to 123 before. Just enter 123 and press Enter.

Afterwards, OrangePi ZERO 2 was successfully accessed through the SSH server.

Now you can access OrangePi ZERO 2 without using the serial port and unplug the USB to TTL module. There is no need to perform the above operations every time. MobaXterm is a software that can store the devices you have visited. It is in the “little star” on the left. You only need to double-click the IP address of the device you want to link to and it will automatically connect (prerequisite). The device is already powered on). If you want to rename, you can do the following:

Right click to select Edit session.

In the Bookmark setting tab of the pop-up window, you can rename the Session name, change the icon, etc.

Then double-click to connect automatically.

7. Configure vim

Many novices first learned Linux system programming on a virtual machine, including me, so many people have already adapted to the vim editor of the Linux system. Of course, you will also configure vim according to your own usage habits and preferences. The following are my commonly used configurations. You can try configuring some.

Command line input:

sudo vim /etc/vim/vimrc

vimrc is the configuration file of the vim editor. Scroll down to the end of the file and you can see the following annotated settings. I briefly translated them.

If you need to enable the corresponding function, just press the i key to enter the editor mode and remove the preceding double quotes, as shown in the figure.

set nocompatible "Do not use vi default keyboard layout

set number "display line number

set autoindent "Automatic alignment

set smartindent "Smart alignment

set showmatch "bracket matching pattern

set ruler "show status line

set incsearch "is very convenient for querying. If you want to find the word book, when you enter /b, the first word starting with b will be automatically found; when /bo is entered, the first word starting with bo will be automatically found. And so on. When searching, use this setting to quickly find the answer. When you find the word you want to match, don't forget to press Enter.

set tabstop=4 "The tab key is 4 spaces

set shiftwidth=4 "Use 4 spaces between lines when wrapping.

set softtabstop=4  "Set (soft) tab width to 4

set cindent "C language format alignment

set nobackup "Do not back up files

set clipboard + =unnamed "Share clipboard with windows

You can also add some functions not mentioned here. Here are some of the functions I commonly use:

set number #Display the line number in front of each line
set cursorline #Display the line where the cursor is on the screen
set tabstop=4 #Set the tab width to 4 spaces
set laststatus=2 #Display the last status on the right side of the status line
set ruler #Display the cursor position in the lower right corner of the screen
set cindent #Turn on the indentation mode of C language:

I have also configured all the above.

After configuring, enter the following command:

source /etc/vim/vimrc

If a situation like the one shown below occurs, you can simply ignore it.

8. Develop SDK based on official peripherals

The new version of orangepi-build source code is stored in the next branch of the orangepi-build warehouse:
https://github.com/orangepi-xunlong/orangepi-build/tree/next

sudo apt update
sudo apt install git
git clone https://github.com/orangepi-xunlong/orangepi-build.git -b next

wiringPi peripheral SDK installation

git clone https://github.com/orangepi-xunlong/wiringOP //Download source code
cd wiringOP //Enter the folder
sudo ./build clean //Clear compilation information
sudo ./build //Compile


Open https://github.com/orangepi-xunlong/wiringOP through a windows browser
Download compressed package
Transfer the compressed package to the development board through xterm
Unzip unzip xxx.zip

cd xxx
sudo ./build
gpio readall

Verification command: gpio readall
As shown below, the peripheral library is installed