4 Software Operation Guide
4.1 Finding Device IP
4.2 Remote Login
4.3 Configuring Storage Devices
4.4 Configuring Ethernet IP
4.5 Configuring Wi-Fi (Optional)
4.6 Configuring Bluetooth (Optional)
4.7 Configuring 4G (Optional)
User can choose the device with 4G version, which needs to be configured before using 4G network.
4.7.1 Configure Using The Network Manager Tool
To connect to the 4G network, you need to create a gsm network connection first. The following connections are created according to different configuration requirements.
- There is no need to configure APN and other configurations.
sudo nmcli connection add type gsm con-name <connection_name>
For example, create a gsm network called mobilegsm.
sudo nmcli connection add type gsm con-name mobilegsm
- APN needs to be configured.
sudo nmcli connection add type gsm con-name <connection_name> ifname cdc-wdm0 gsm.apn "cmnet"
- configure username and password
sudo nmcli connection add type gsm con-name <connection_name> ifname cdc-wdm0 gsm.number "#777" gsm.username "ctnet@mycdma.cn" gsm.password "vnet.mobi"
- Mobile/Unicom/Telecom generally use the first method (no need to configure the APN scenario) to dial successfully, if you find the problem you can also try the following commands.
# China Mobile
sudo nmcli connection add type gsm con-name "mobile" ifname cdc-wdm0 gsm.number "*98*1#" gsm.apn "cmnet"
# China Unicom
sudo nmcli connection add type gsm con-name "Unicom" ifname cdc-wdm0 gsm.number "*99#" gsm.apn "3gnet"
# China Telecom
sudo nmcli connection add type gsm con-name "Telecom" ifname cdc-wdm0 gsm.number "#777" gsm.username "ctnet@mycdma.cn" gsm.password "vnet.mobi"
4.7.2 Configure Using dhcpcd
Before using 4G, we need to add our APT library first. All the images given by our company have been added with this library, so users don't need to add it manually.
sudo apt update
sudo apt install ed-ec20-qmi
Automatic dialing is not started by default. If users want to start automatic dialing, they need to enable LTE lte-reconnect.service service.
sudo systemctl enable lte-reconnect.service
sudo systemctl start lte-reconnect.service
After successful dialing, you can use the ifconfig command to see the wwan0 network port.
If you need to set APN additionally, you need to modify the dialing command .$BSP_HOME_PATH/quectel-CM -4 -f $LOGFILE & in /usr/share/ed-ec20-qmi/LTE-reconnect.sh
The quectel-CM dialing configuration information is as follows:
$BSP_HOME_PATH/quectel-CM -4 -f $LOGFILE -s <APN> &
Restart lte-reconnect.service after setting.
sudo systemctl restart lte-reconnect.service
4.8 RTC
ED-CM4IND is integrated with RTC. For the version sold in China, we will install CR1220 button cell (RTC backup power supply) by default when shipping. In this way, the system can be guaranteed to have an uninterrupted and reliable clock, which is not affected by factors such as equipment power down.
The default OS will integrate the RTC automatic synchronization service we wrote, so guests can automatically synchronize the clock without setting it, and can use RTC without feeling. The general principle is:
- When the system is turned on, the service automatically reads the saved time from RTC and synchronizes it to the system time.
- If there is an Internet connection, the system will automatically synchronize the time from the NTP server and update the local system time with Internet time.
- When the system is shut down, the service automatically writes the system time into RTC and updates the RTC time.
- Because of the installation of button cell, although ED-CM4IND is powered off, RTC is still working and timing.
In this way, we can ensure that our time is accurate and reliable.
NOTE
If it is the first time to boot, because there is no effective time in RTC, synchronization may fail, so just restart it directly. When rebooting, the system time will be written into RTC for normal use.
If you don't want to use this service, you can turn it off manually:
sudo systemctl disable rtc
sudo reboot
Re-enable this service:
sudo systemctl enable rtc
sudo reboot
Read RTC manually:
sudo hwclock -r2022-11-09 07:07:30.478488+00:00
Manually synchronize RTC time to the system:
sudo hwclock -s
Write the system time into RTC.
sudo hwclock -w
4.9 User Button
User-defined buttons are screen-printed on the shell as user, which is connected to the GPIO6 pin of CM4 chip. By default, it is at high level, and when the button is pressed, the pin is at low level.
We use the raspi-gpio command to test, and query the GPIO6 pin when the key is not pressed.
raspi-gpio get 6
GPIO 6: level=1 fsel=0 func=INPUT pull=UP
A level of 1 indicates that the GPIO6 pin is high.
When the key is pressed, query the GPIO6 pin.
raspi-gpio get 6
GPIO 6: level=0 fsel=0 func=INPUT pull=UP
A level of 0 indicates that the GPIO6 pin is low.
4.10 Buzzer
The buzzer control pin of ED-CM4IND is GPIO25.
Open buzzer:
raspi-gpio set 6 op dh
Close buzzer:
raspi-gpio set 6 op dl
4.11 SPI Flash
The ED-CM4IND is extended with a SPI Flash via SPI with a memory capacity of 4MB for user data storage. On Linux, Serial Flash is recognized as an MTD (Memory Technology Device) device, and the device file of Flash on ED-CM4IND is /dev/mtd0.
TIP
MTD devices are different from our common Block devices such as hard disk, SD card, U-disk and EMMC. The typical difference is that MTD devices need to perform Erase operation, and the Sector of Erase is usually larger than the Page of the writing unit. Block devices usually have device hardware processing, and there is no difference between writing and erasing on the Host side. We usually use JFFS2 file system to manage MTD devices, not ext4.
Install mtd-utils tool to manage Flash devices.
sudo apt update
sudo apt install mtd-utils
First time to use, or you need to format, please Erase the whole Flash device.
sudo flash_erase /dev/mtd0 0 0
Mounting, reading and writing with JFFS2 type.
sudo mount -t jffs2 /dev/mtd0 /mnt
After mounting, you can read and write the /mnt directory to read and write Flash devices.
4.12 Serial Communication
4.12.1 Install picocom Tool
In the Linux environment, you can use the picocom tool to debug the serial ports RS232 and RS485.
Execute the following command to install the picocom tool.
sudo apt-get install picocom
After opening the corresponding serial port with picocom, you can type Ctrl+a and then Ctrl+h to see the available commands.
*** Picocom commands (all prefixed by [C-a])
*** [C-x] : Exit picocom
*** [C-q] : Exit without reseting serial port
*** [C-b] : Set baudrate
*** [C-u] : Increase baudrate (baud-up)
*** [C-d] : Decrease baudrate (baud-down)
*** [C-i] : Change number of databits
*** [C-j] : Change number of stopbits
*** [C-f] : Change flow-control mode
*** [C-y] : Change parity mode
*** [C-p] : Pulse DTR
*** [C-t] : Toggle DTR
*** [C-g] : Toggle RTS
*** [C-|] : Send break
*** [C-c] : Toggle local echo
*** [C-w] : Write hex
*** [C-s] : Send file
*** [C-r] : Receive file
*** [C-v] : Show port settings
*** [C-h] : Show this message
Input Ctrl+afirst, then Ctrl+c to switch the local echo mode.
Input Ctrl+a first, then Ctrl+q to exit picocom.
4.12.2 Configure RS232
ED-CM4IND includes 1 RS232 port, and the corresponding COM ports and device files are as follows:
| RS232 Port | Corresponding Device File |
|---|---|
| RS232 | /dev/ttyAMA3 |
Preparation:
The RS232 port of ED-CM4IND has been connected with external device.
Steps:
- Execute the following command to open the serial port, and configure the serial port baud rate to 115200.
picocom -b 115200 /dev/ttyAMA3
- Input commands as needed to control external device.
4.12.3 Configure RS485
ED-CM4IND includes 2 RS485 port, and the corresponding COM ports and device files are as follows:
| RS485 Port | Corresponding Device File |
|---|---|
| RS485-1 | /dev/ttyAMA2 |
| RS485-2 | /dev/ttyAMA1 |
Preparation:
The RS485 port of ED-CM4IND has been connected with external device.
Steps:
- Execute the following command to open the serial port RS485-2, and configure the serial port baud rate to 115200.
picocom -b 115200 /dev/ttyAMA1
- Input commands as needed to control external devices.
4.12.4 Debug UART
Debugging serial interface J58, screen printing name UART0, TTL level serial port.
To enable debugging serial port, you need to modify the config.txt file.
sudo nano /boot/config.txt
Add the following content to the end of the file.
[all]
enable_uart=1
The default baud rate of debugging serial port is 115200. You can check the current baud rate of debugging serial port through cmdline.txt file.
sudo nano /boot/cmdline.txt
4.13 ADC
There are 3 ADC channels on ED-CM4IND. Take AIN1 as an example to demonstrate how to read them:
cd /sys/bus/iio/devices
cd iio\:device0
cat in_voltage1_raw
4.14 DI
The ED-CM4IND contains 2 channels of DI, which are connected to GPIO11 and GPIO26 of the CM4. The default wiring method of the device is wet contact (active) wiring, with DIN+ connected to the positive terminal of the external power supply and DIN- connected to the negative terminal of the external power supply.
DIN1 corresponds to GPIO11, and use raspi-gpio command to check the pin status of GPIO11.
raspi-gpio get 11
- When
DIN1+andDIN1-are disconnected:
GPIO 11: level=1 fsel=0 func=INPUT pull=DOWN
- When
DIN1+andDIN1-are connected:
GPIO 11: level=0 fsel=0 func=INPUT pull=DOWN
DIN2 corresponds to GPIO26, and use raspi-gpio command to check the pin status of GPIO26.
raspi-gpio get 26
- When
DIN2+andDIN2-are disconnected:
GPIO 26: level=1 fsel=0 func=INPUT pull=DOWN
- When
DIN1+andDIN1-are connected:
GPIO 26: level=0 fsel=0 func=INPUT pull=DOWN
4.15 Relay
The ED-CM4IND features an onboard double-pole double-throw (DPDT) relay, controlled by the GPIO22 pin's high or low level. By default, the relay is in the normally closed (NC) state, where COM1 is connected to NC1 and COM2 is connected to NC2. When GPIO22 is set to a high level, the relay switches to the open state, connecting COM1 to NO1 and COM2 to NO2.
- Open relay
sudo raspi-gpio set 22 op dh
Op means set to output, dh means pin is high.
- Close relay
sudo raspi-gpio set 22 op dl
Op means set to output, and dl means pin is low.
