Generally, the Linux protocol for module docking is the USB protocol. The module can be used directly after being plugged into the Linux device via USB, and the system will detect the device’s identifier: PID VID.
However, in practical applications, some newcomers often ask:
Linux is really not user-friendly for beginners, is there a good solution?
Today, I would like to share my personal stash of tips—Raspberry Pi Linux compilation. Once compiled, the Hezhou development board can be plugged directly into the Raspberry Pi and connected to the computer for immediate use, which is extremely convenient.
This article takes the Raspberry Pi as an example; other boards with Linux systems can generally follow this procedure.
1
Burning the Image
1.1 Burning Software
It is recommended to use the official Raspberry Pi tool, which can directly set up SSH and the Raspberry Pi’s name in the router’s backend.
Official latest version download link: https://www.raspberrypi.com/software/
The username and password for logging in above can also be set once.
1.2 Downloading the Image File
1.2.1 Image File Download Link
For the image file, it is recommended to use the 32-bit version, but the 64-bit version can also be used.
Note: If you want to use a graphical interface, please select the desktop version of the image file when downloading, preferably with commonly used software, and try to use the 32-bit version, as I have not successfully compiled the 64-bit version.
Image file download link:https://www.raspberrypi.com/software/operating-systems/
1.2.2 High-speed Download Tool
If the download speed is slow, you can first download a tool called Motrix, and then open the download link with it.
Motrix download link:
https://motrix.app/zh-CN/
1.3 Burning Process
After downloading, select Use Custom Image, then insert the SD card and proceed with the burning.
Special Reminder: It is best to use an SD card of at least 32G; 16G is also acceptable, but it is recommended to choose a faster SD card, as the entire system’s burning and writing, including the subsequent compilation, are completed on the SD card.
2
Remote Control
2.1 SSH Method
After burning is complete, the SD card will be divided into two partitions: one is a system partition that cannot be opened, and the other is a file system partition that can be opened.
If you did not enable SSH in the official burning tool beforehand, you need to open that file system partition on your computer and create a new file named SSH without any file extension.
After creating the file, insert the memory card into the Raspberry Pi, connect an Ethernet cable to the router for the Raspberry Pi, power it on,the official recommended power supply for the Raspberry Pi is 5V3A(Note: If the power supply is less than this and you have multiple devices connected, including a screen, it may cause unstable power supply leading to module restarts and other issues).
Next, open your router management backend and find the Raspberry Pi. If you set the name for the Raspberry Pi in the previous step, it should be easier to find. If not set, the default name for the Raspberry Pi is raspberry, and the default password for the root user is also raspberry.If you are using the Raspberry Pi for a long time, it is recommended to assign a static IP.
The management interface on my side looks like this:
Xshell and Xftp download link:www.xshell.com
Open Xshell, create a new login interface, select the IP of the Raspberry Pi that you see in the router’s backend, and use the username and password that you set earlier with the burning software.
If you did not set it, the username is root, and the password is raspberry. If you still cannot log in, it is recommended to re-burn and reset (Xshell and Xftp are paired software, it is recommended to download both at once).
After logging in, it is recommended to use the sudo passwd command to change the root user password to something you can remember.
Common Linux Commands:
ls (display the subfolders and files in the current folder)
cd ./etc (enter the etc folder) cd ../ or cd .. (enter the parent directory)
su (enter superuser, you will need to enter the superuser’s password, as the Linux root user password is random every time it boots, so you need to use the sudo passwd command to fix a memorable password)
sudo apt install LS (download a package manager called LS, if you do not know what a package manager is, you can think of it as the app on your phone)
2.1.1 VNC Remote Desktop
If you do not like the command line method, you can also use VNC remote desktop (similar to Sunflower on PC).
Note: If you want to use VNC, you need to select the desktop version of the image file during the download step.
PC-side VNC download:
https://www.realvnc.com/
3
Direct Screen Control
You can just plug in a screen, and all input and output can be completed using a keyboard and mouse (Note: If you want to use a screen, you need to select the desktop version of the image file during the download step).
The advantage is that it is visual and makes it easier to operate folders.
The downside is that when you graphically modify driver files, you may encounter read-only files, and modifications may fail, requiring you to use the command line to enter the root user to grant the file/folder 777 permissions (chmod -R 777 linux).
4
Changing Source for Raspberry Pi
Since the Raspberry Pi uses foreign sources by default, downloading things is relatively slow. Various tools and package management required for compiling code can be sourced from Tsinghua/Alibaba/USTC mirrors.
For users using SSH, enter uname -m in the command line; for users using VNC and direct desktop, open the command line terminal and also enter uname -m.
Then follow this guide:
https://mirrors.tuna.tsinghua.edu.cn/help/raspbian/
After changing the source, you can try entering:
sudo apt-get update — (update the package management)
apt-get upgrade — (update the installed software packages)
apt-get dist-upgrade — (update dependencies)
Possible Issues When Changing Sources:
If an error occurs stating that a key cannot be found, copy the string of numbers after key in the error message and replace the key in the command at the end of this article with yours. If multiple keys are reported, set them multiple times.
5
Compiling the Kernel
Compilation can be either local or cross-compilation, both of which are possible. Local compilation means the Raspberry Pi compiles itself, while cross-compilation means using another machine with better performance than the Raspberry Pi (like your own computer) to compile the drivers, and then replacing the compiled kernel onto the SD card before inserting it back into the Raspberry Pi.
This article will only explain the local compilation method:
5.1 Local Compilation
The advantage of local compilation is that it does not require too many commands, making it friendly for beginners.
The downside is that it is limited by the Raspberry Pi’s weak performance, making the compilation speed painfully slow. If all four cores are open, compiling once takes about one to two hours.If you use the default compilation command and only open one core, I have tried it once, and it took about four hours.
5.1.1 Downloading the Linux Kernel Source Code
Open the command line, navigate to the directory you want, such as the desktop or dowon, you can also create a new directory, but remember not to write in Chinese, then use the following command to download the latest kernel for the Raspberry Pi.
git clone –depth=1 https://hub.fantasygmm.top/raspberrypi/linux
-depth=1 means a shallow copy, only cloning the current project’s code without historical modification records. The common git clone is a deep copy, containing all operations since the repository was initialized.
We are only learning/compiling the current version of the kernel and do not need to look at those things. If we cloned everything, it would be over 3G, and downloading without a proxy would take a long time, even if using a free proxy, most have a maximum repository limit of 2G.
The original repository is here:
https://github.com/raspberrypi/linux
5.1.2 Modifying the Corresponding Driver Files
If using the SSH command line to modify, you can use the nano editor to modify files. Remember to enter su to become a superuser first, otherwise the modifications may fail. (Note: If you have encountered Linux in college, you should know about VI and VIM editors, both can be used, but nano is a bit easier.)
The specific commands are as follows:
cd linux — enter the directory of the downloaded kernel source
5.1.2.1 Modifying the option.c File
sudo nano drivers/usb/serial/option.c — use the nano editor to enter the option.c file
Remember: Do not use the mouse to scroll up and down in the file, use the keyboard’s up and down keys! Using the mouse will cause a bunch of ^H^L to be input into the corresponding file.
Modifications needed in the option.c file:
First Modification:
Under the static const struct usb_device_id option_ids[] function, add a line below the “{“.
//+add by airm2m for 8910/1603/1802s/1802/EC618
//1802 and 1802S series
{ USB_DEVICE(0x1286, 0x4e3d) },
//8910 series (724UG/720UH/720UG/722UG/820UG/600UG)
{ USB_DEVICE(0x1782, 0x4e00) },
//1603 series (722CS/724CS/722CE/724CE)
{ USB_DEVICE(0x2ECC, 0xA000) },
//618 series (780E/780EX/780EG/600E/780EA/600EA/700E)
{ USB_DEVICE(0x19d1, 0x0001) },
//+add by airm2m for 8910/1603/1802s/1802/EC618
Second Modification:
In the static struct usb_serial_driver option_lport_device function, add a line below the last line: .resume = usb_wwan_resume.
//+add by airm2m for 8910/1603/1802s/1802/EC618
.reset_resume = usb_wwan_resume,
//+add by airm2m for 8910/1603/1802s/1802/EC618
Third Modification:
Under the line struct usb_interface_descriptor, add a line.
struct usb_device_descriptor *dev_desc = & serial->dev->descriptor;
Fourth Modification:
Under the line If (iface_desc->bINterfaceClass to return -ENODEV;, add the following lines:
After completing the modifications, use ctrl+o to save the changes and ctrl+x to exit the file editor.
5.1.2.2 Modifying the usb_wwan.c File
Use: sudo nano drivers/usb/serial/usb_wwan.c — use the nano editor to open the usb_wwan.c file.
There is only one modification in this file:
In the static struct urb *usb_wwan_setup_urb function, after the line if (intfdata->use_zlp to PACKET;, add the following lines:
After completing the modifications, use ctrl+o to save the changes and ctrl+x to exit the file editor.
At this point, the driver modifications are complete, and you can enter the kernel editing interface, mainly to configure some features that are not enabled by default, such as ECM/PPP.
5.1.3 Preparing for Compilation Before Code Modifications
First, install Git and build dependencies:
sudo apt install git bc bison flex libssl-dev make
Check the version of the Raspberry Pi you have and whether the downloaded system version is 32-bit or 64-bit, and choose the corresponding command below.
If you are already in the Linux directory, you do not need the first command cd linux.
1) For Raspberry Pi 1, Zero, and Zero W, as well as Raspberry Pi Compute Module 1, default (only 32-bit) build configuration:
cd linux
KERNEL=kernel
make bcmrpi_defconfig
2) For Raspberry Pi 2, 3, 3+, and Zero 2 W, as well as Raspberry Pi Compute Module 3 and 3+, default 32-bit build configuration:
cd linux
KERNEL=kernel7
make bcm2709_defconfig
3) For Raspberry Pi 4 and 400, as well as Raspberry Pi Compute Module 4, default 32-bit build configuration:
cd linux
KERNEL=kernel7l
make bcm2711_defconfig
4) For Raspberry Pi 3, 3+, 4, 400, and Zero 2 W, as well as Raspberry Pi Compute Module 3, 3+, and 4, default 64-bit build configuration:
cd linux
KERNEL=kernel8
make bcm2711_defconfig
If any of the above commands report an error, you can search for solutions on Baidu or consult Hezhou FAE.
5.1.4 Kernel Configuration
In the Linux path, enter:
make menuconfig
Enter the kernel configuration interface. If you cannot enter, first check whether your current user is a superuser. If not, enter su to become a superuser; then proceed to config.
In the kernel configuration interface, press “/” to search for the place you want to modify. For example, when searching for RNDIS, if there are many related configuration items, you can scroll the mouse to view in this interface, ensuring that the status of the options related to RNDIS is y or m:
Below are the paths of the related configuration items:
ECM/PPP/CMUX works the same way; for CMUX, make sure to search for N_GSM:
You can select a project, configure it, and then press the left and right keys to choose Save to save the configuration. After checking all options, press the left and right keys to select Exit, until a dialog box pops up asking whether to save. Select yes to save the configuration, and you are done with all configuration work.
5.1.5 Building the Kernel
Generate and install the kernel, modules, and device tree blob. This step may take a long time, depending on the Raspberry Pi model used.
For 32-bit kernels:
sudo make V=1 -j4 zImage modules dtbs
sudo make modules_install
sudo cp arch/arm/boot/dts/*.dtb /boot/
sudo cp arch/arm/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm/boot/dts/overlays/README /boot/overlays/
sudo cp arch/arm/boot/zImage /boot/$KERNEL.img
For 64-bit kernels:
make V=1 -j4 Image.gz modules dtbs
sudo make modules_install
sudo cp arch/arm64/boot/dts/broadcom/*.dtb /boot/
sudo cp arch/arm64/boot/dts/overlays/*.dtb* /boot/overlays/
sudo cp arch/arm64/boot/dts/overlays/README /boot/overlays/
sudo cp arch/arm64/boot/Image.gz /boot/$KERNEL.img
Note 2: -j4 indicates that four cores will be started to compile together.
Remember to put a fan on the Raspberry Pi for cooling, as it can get very hot.
Once all projects are completed, restart, and your Raspberry Pi should be running your newly compiled kernel!
reboot — reboot command
Insert the Hezhou Air724/Air780E/1802/1603 series board into the Raspberry Pi, power it on, and enter:
ls /dev/ttyUSB*
or
ls /dev/tty*
You should see three ports:

Note 1: These three ports are assigned by Linux; the port numbers may not be fixed. If you want to fix the port numbers, you can use the solution mentioned in this link:
https://doc.openluat.com/article/2080/0
Note 2: The 618 may not be named ttyUSB; it could be ttyACM or something else:

There are many serial debugging tools under Linux, the most well-known being minicom. The simple usage method is as follows:
apt install minicom
minicom -D /dev/ttyUSB0
I personally find it not very user-friendly, so I use our own serial tool, the usage method is as follows:
https://doc.openluat.com/article/645/0
gcc sendat.c -o at.out
After compilation, an executable file named at.out will be generated in the directory. Here is an example of usage:
./at.out /dev/ttyUSB1 — use the serial tool to open ttyUSB1, just write whatever the port number is
5.2 Possible Issues After Compilation
5.2.1 Cannot Find Port
If lsusb can display the corresponding module’s PID VID but cannot find those virtual serial ports.
Solution: Send the command
1) For 8910 series Air724UG/720UH/720UG/722UG/820UG/600UG… send this:
echo 1782 4e00>/sys/bus/usb-serial/drivers/option1/new_id
echo 19d1 0001 > /sys/bus/usb-serial/drivers/option1/new_id
Then check for the port again. If found, it proves that the PID VID modification was unsuccessful, and you need to start again from 5.1.1.
If lsusb cannot find the corresponding port, first check whether the module’s vdd_ext has voltage when powered on. If not, connect powerkey to ground and supply 4V to vbat; if there is voltage, it is recommended to pull out four wires for vbus, DM, DP, and gnd, and connect a USB cable to a Win10 computer. After powering on the module, see if there are three ports on the Win10 computer.
5.2.2 Abnormal Port Display
If lsusb shows the port as 17d1 0001 instead of 19d1 0001.
Solution: 17D1 0001 is the port number displayed by the 618 module after entering boot in Linux. Usually, simply rebooting the 618 module will solve the problem.
If after rebooting it still shows 17D1 0001, it indicates that the vdd_ext pin and uboot pin are shorted together, or the uboot pin is connected to another high-level pin such as 3.3V or vbat.
—
The Raspberry Pi Linux compilation and usage method for Hezhou series modules will be shared here~
If you have any questions in IoT development, feel free to contact Hezhou for discussion!
â–Ľ Contact Hezhou Marketing Department â–Ľ
Scan the QR code to add friends on WeChat/Enterprise WeChat
â–Ľ Learn More About Hezhou â–Ľ
TuGe & Hezhou Strategic Cooperation, empowering Cat.1 module to go abroad with low power consumption testing tool—Hezhou Power Consumption Analyzer
Advancing with 2 microamps! The development history of Hezhou’s low power consumption