Hardware Function Usage
Debug Serial Port
The EC-A1684JD4 FD requires an external RS232 serial cable to connect to the debug serial port for debugging.
The AIO-1684JD4 can be connected to a PC via an RS232-to-USB adapter for serial port debugging. Both the login account and password are linaro.
The serial port parameters are:
- Baud rate: 115200
- Data bits: 8
- Stop bit: 1
- Parity: none
- Flow Control: None
Using serial port debugging on Windows
On Windows, putty or SecureCRT is generally used. We recommend using the free version of MobaXterm. It is a powerful terminal software, and the usage of other serial software is similar.
Go here to download MobaXterm:
- Select
sessionasSerial. - Modify
Serial portto the COM port found in Device Manager. - Set
Speed (bsp)to115200. - Click the
OKbutton.
Serial debugging on Linux
There are several options available on Linux: minicom, picocom, kermit. Due to space constraints, the use of minicom is introduced below.
Install minicom:
sudo apt-get install minicomAfter connecting the serial cable, see what the serial device file is. The following example is /dev/ttyUSB0:
$ ls /dev/ttyUSB*
/dev/ttyUSB0Run:
$ sudo minicom
Welcome to minicom 2.7
OPTIONS: I18n
Compiled on Jan 1 2014, 17:13:19.
Port /dev/ttyUSB0, 15:57:00
Press CTRL-A Z for help on special keysThe above prompt CTRL-A Z is the escape key. Press Ctrl-a and then z to bring up the menu:
+-------------------------------------------------------------------+
Minicom Command Summary |
| |
| Commands can be called by CTRL-A <key> |
| |
| Main Functions Other Functions |
| |
| Dialing directory..D run script (Go)....G | Clear Screen.......C |
| Send files.........S Receive files......R | cOnfigure Minicom..O |
| comm Parameters....P Add linefeed.......A | Suspend minicom....J |
| Capture on/off.....L Hangup.............H | eXit and reset.....X |
| send break.........F initialize Modem...M | Quit with no reset.Q |
| Terminal settings..T run Kermit.........K | Cursor key mode....I |
| lineWrap on/off....W local Echo on/off..E | Help screen........Z |
| Paste file.........Y Timestamp toggle...N | scroll Back........B |
| Add Carriage Ret...U |
| |
| Select function or press Enter for none. |
+--------------------------------------------------------------------+Press O according to the prompt to enter the setting interface:
+-----[configuration]------+
| Filenames and paths |
| File transfer protocols |
| Serial port setup |
| Modem and dialing |
| Screen and keyboard |
| Save setup as dfl |
| Save setup as.. |
| Exit |
+--------------------------+Move the cursor to Serial port setup, press enter to enter the serial port setup interface, then enter the letters indicated above, select the corresponding option, and set as follows:
+-----------------------------------------------------------------------+
| A - Serial Device : /dev/ttyUSB0 |
| B - Lockfile Location : /var/lock |
| C - Callin Program : |
| D - Callout Program : |
| E - Bps/Par/Bits : 115200 8N1 |
| F - Hardware Flow Control : No |
| G - Software Flow Control : No |
| |
| Change which setting? |
+-----------------------------------------------------------------------+Note
Hardware Flow Control and Software Flow Control must be set to No, otherwise it may result in failure to input.After the setup is complete, go back to the previous menu and select Save setup as dfl to save it as the default configuration, which will be used by default in the future.
Debugging using DEBUG port
If you want to develop U-Boot or the kernel, you need to use the DEBUG port for debugging. The operation is the same as that of RS232 debugging, but you need to pay attention to the adapter and its driver.
Selecting an adapter
There are many USB-to-serial adapters on the online store, which are divided into the following types according to the chip:
| Serial port | Maximum baud rate | Recommended or not | Evaluation | Purchase link |
|---|---|---|---|---|
| CP2104 | 2Mbps | Recommended | Support high baud rate communication, good stability and durability | Click to buy |
| CH340 | 2Mbps | Not recommended | In actual use, it is found that the actual baud rate of many CH340s on the market cannot reach 1.5 Mbps | |
| PL2303 | 1.2Mbps | Not recommended | The maximum baud rate cannot reach 1.5Mbps |
Generally speaking, adapters using CH340 chips have relatively stable performance and are more expensive.
Note
Hardware connection
The USB to serial adapter has four pins:
- 3.3V power supply (NC), no connection required
- GND, the ground wire of the serial port, connects to the GND pin of the serial port of the development board
- TXD, the output line of the serial port, connects to the TX pin of the serial port of the development board
- RXD, the input line of the serial port, connects to the RX pin of the serial port of the development board
Note
Install driver
Windows requires the adapter driver to be installed (Linux does not). Download the driver and install it:
After inserting the adapter, the system will prompt to discover new hardware and initialize it, and then you can find the corresponding COM port in the Device Manager:
UART
The Pinout of the on-board serial port of EC-A1684JD4 FD is shown below:
The on-board serial port is the debug serial port (RS232 level), corresponding to the device node /dev/ttyS1 with a default baud rate of 115200.
Serial Loopback Test
After shorting the TXD and RXD pins of the serial port, run the following commands on the device:
stty -F /dev/ttyS1 115200
cat /dev/ttyS1 &
echo "firefly test" > /dev/ttyS1If the terminal outputs firefly test, the serial transceiving works normally.
Login and Network Configuration
Login
The EC-A1684JD4 FD supports two login methods: debug serial port login and Ethernet SSH login. Both the login account and password are linaro.
- Debug serial port (RS232) login: see "Debug Serial Port" above for usage.
- Ethernet SSH login: The EC-A1684JD4 FD has two Ethernet interfaces. By default, network port 0 (near the serial port) is set with a dynamic IP, while network port 1 (near the HDMI port) is set with the static IP
192.168.150.1, subnet mask255.255.255.0. You can set the PC to192.168.150.2/24for the initial login. The IP of network port 0 is assigned by the router, and the IP address information is generally unknown in advance, so it is best to select network port 1 for the first login.
After the network port light flashes normally, open the terminal and use ssh to log in. The port number is 22, and the username and password are also linaro:
ssh linaro@192.168.150.1If the login fails, you can try to use the PC to ping the IP address of network port 1 of the EC-A1684JD4 FD. Note that the PC needs to add an IP address in the same network segment, because the IP address of the PC is not necessarily in the same network segment.
The following is how to add a same-network-segment IP on the PC (using administrator mode):
-
Windows 10
netsh int ipv4 add address "Ethernet" 192.168.150.101 255.255.255.0Where
"Ethernet"refers to the network interface,192.168.150.101is the IP address, and255.255.255.0is the subnet mask. -
Linux
ifconfig enp4s0:1 192.168.150.89Where
enp4s0is the name of the network card driver of the PC, which can be viewed by executing theifconfigcommand.
Network IP configuration
Debian System Configuration
In Debian 9, eth0 in the dual network ports defaults to obtaining the IP dynamically (that is, DHCP), and eth1 is fixed to 192.168.150.1.
The configuration of eth1 is done via the /etc/network/interfaces.d/eth1 file, which is the only modification to the original Debian network configuration.
linaro@bm1684:~$ cat /etc/network/interfaces.d/eth1
auto eth1
iface eth1 inet static
address 192.168.150.1
netmask 255.255.255.0
dns-nameservers 192.168.150.1If the user deletes this file, then eth1 will become the same as eth0 to obtain the IP through DHCP; if the user wants to fix the IP of eth0, just create an eth0 file in the /etc/network/interafces.d folder, and it will take effect after restarting.
Note that it is best not to configure the two network cards as the same network segment, otherwise problems may occur.
Ubuntu System Configuration
In Ubuntu 20.04, the eth0 interface is set to obtain an IP address dynamically (DHCP), while eth1 is configured with a fixed IP address of 192.168.150.1.
The configuration for eth1 can be found in the /etc/netplan/01-netcfg.yaml file. You can modify this file to adjust the network settings for your Ubuntu system.
linaro@bm1684:~$ cat /etc/netplan/01-netcfg.yaml | more
network:
version: 2
renderer: networkd
ethernets:
eth1:
dhcp4: no
addresses: [192.168.150.1/24]
optional: yesIf the user deletes this file, then eth1 will revert to acquiring an IP address through DHCP, similar to eth0. If the user wants to assign a fixed IP address to eth0 as well, they only need to add an eth0 node (similar to eth1) in the /etc/netplan/01-netcfg.yaml file, and then restart for the changes to take effect.
ETH Usage
EC-A1684JD4 FD provides two gigabit Ethernet interfaces with the following default configuration:
- The network port marked "1" (near the RS232/RS485 connectors) corresponds to the system
eth0interface, configured in DHCP mode. - The network port marked "2" (near the HDMI connector) corresponds to the system
eth1interface, configured with a static address:192.168.150.1/24.
First Access and Login
Port 1 (eth1) uses the static IP 192.168.150.1 with subnet mask 255.255.255.0. For first access, set the PC to an IP in the same subnet (for example 192.168.150.2/24):
-
Windows 10 (administrator mode):
netsh int ipv4 add address "Ethernet" 192.168.150.101 255.255.255.0where
"Ethernet"is the network interface name,192.168.150.101is the IP address, and255.255.255.0is the subnet mask. -
Linux:
ifconfig enp4s0:1 192.168.150.89where
enp4s0is the PC network interface name; runifconfigto check the actual name on your PC.
After the PC can successfully ping 192.168.150.1, log in with ssh on port 22 (username and password are both linaro):
ssh linaro@192.168.150.1Network IP Configuration
By default, the EC-A1684JD4 FD has a dynamic IP set for network port 0, and a static IP set for network port 1. These configurations are implemented through the /etc/netplan/01-netcfg.yaml file in the system.
linaro@bm1684:~$ cat /etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: yes
addresses: []
optional: yes
dhcp-identifier: mac
eth1:
dhcp4: no
addresses: [192.168.150.1/24]
optional: yesUsers can modify the network configuration by modifying the /etc/netplan/01-netcfg.yaml file, for example:
-
Set network port 0 to a static IP: Refer to the original setting of
eth1to modify theeth0node, change thedhcp4parameter tono, and add the IP address to theaddressesparameter. -
Set network port 1 to a dynamic IP: Refer to the original setting of
eth0to modify theeth1node, change thedhcp4parameter toyes, and remove the IP address in theaddressesparameter.
After modifying the /etc/netplan/01-netcfg.yaml file, users can make the settings take effect immediately by executing the sudo netplan apply command.
RS232 / RS485
The EC-A1684JD4 FD provides one RS232 interface and one RS485 interface:
-
RS485: the device name is
/dev/ttyS2, supports full duplex, and the default baud rate is9600. -
RS232: the device name is
/dev/ttyS1, supports full duplex, and the default baud rate is115200. Note that RS232 is used for login by default. To use it as a general communication serial port, the serial login service must be disabled first:sudo systemctl disable --now serial-getty@ttyS1.service
RS485 transceiving test
(1) Connect the hardware: Connect the A, B, and GND pins of the RS485 to the A, B, and GND pins of the PC serial port adapter (USB to 485 serial port module) respectively.
(2) Open the PC serial port terminal. Open kermit in the terminal and set the baud rate:
$ sudo kermit
C-Kermit> set line /dev/ttyUSB0
C-Kermit> set speed 9600
C-Kermit> set flow-control none
C-Kermit> connectAmong them, /dev/ttyUSB0 is the device file of the USB-to-serial adapter, which depends on the actual recognition of the PC.
(3) Send data: The device file for RS485 is /dev/ttyS2. Run the following commands on the device:
sudo -s
stty -F /dev/ttyS2 9600 -echo
echo firefly RS485 test... > /dev/ttyS2The serial port terminal in the PC can receive the string "firefly RS485 test...".
(4) Receive data: First run the following command on the device:
sudo -s
cat /dev/ttyS2Then enter the string "Firefly RS485 test..." on the serial terminal of the PC, and you can see the same string on the device side.
The test method of RS232 is similar to the steps of RS485; you only need to pay attention to the device name (/dev/ttyS1) and the baud rate (115200).
Display Interface
The EC-A1684JD4 FD provides 1 HDMI display output interface. The EC-A1684JD4 FD does not have a graphics card chip, and the HDMI output part of the main control does not use the standard framebuffer driver. When it is shipped from the factory, there is no display when HDMI is connected.
If the user wants to test the HDMI display, he can connect to the HDMI interface, and then execute the test-hdmi script:
linaro@bm1684:~$ sudo -i
root@bm1684:~# test-hdmi
found (1024, 768) @ 60 fps
entry [0] = (1024, 768) added
found (1024, 768) @ 60 fps
found (1024, 768) @ 60 fps
found (1024, 768) @ 60 fps
found (1024, 768) @ 60 fps
found (1024, 768) @ 60 fps
found (1024, 768) @ 60 fps
found (1024, 768) @ 60 fps
found (1920, 1080) detailed timing desc
entry [1] = (1920, 1080) added
found (1920, 1080) detailed timing desc
found (1920, 1080) detailed timing desc
found (1920, 1080) detailed timing descUSB Interfaces
The EC-A1684JD4 FD provides 2 USB 3.0 interfaces and 2 USB 2.0 interfaces. After inserting a USB flash drive, the storage device will be recognized as a node similar to /dev/sdb1. The system does not support auto-mounting, so you need to mount it manually with the mount command.
Insert the USB drive, and use dmesg to know the sd device corresponding to the USB drive:
[15460.953423] [5] sdb: sdb1Mount the USB drive:
# create mount directory
mkdir disk
# mount
sudo mount /dev/sdb1 disk
# View the files in the USB drive
ls diskAfter completing data writing, please use sync or umount in time, and please use the sudo poweroff command when shutting down to avoid violent power-off, so as to avoid data loss.
GPIO Usage
The BM1684 chip contains 3 groups of GPIO controllers, each of which controls 32 GPIOs, which correspond to the Linux device nodes as follows:
| GPIO Controller | Linux Device Node | GPIO Physical Number | GPIO Logical Number |
|---|---|---|---|
| #0 | /sys/class/gpio/gpiochip480 | 0 to 31 | 480 to 511 |
| #1 | /sys/class/gpio/gpiochip448 | 32 to 63 | 448 to 479 |
| #2 | /sys/class/gpio/gpiochip416 | 64 to 95 | 416 to 447 |
For example, to operate GPIO6, you need:
- Number conversion: The physical number is
6, the corresponding logical number is(480 + (6 - 0)) = 486,0represents the start of the GPIO physical number - Export the GPIO, run as root user:
echo 486 >/sys/class/gpio/export - Operate GPIO, set to read input or output specified value:
cd /sys/class/gpio/gpio486 # set input mode echo in >direction cat value # set output mode echo out >direction # output low level echo 0 >value # output high level echo 1 >value
There are a few things to note:
- If the GPIO has been applied by other drivers, it cannot be exported successfully, and subsequent read and write operations cannot be performed.
- Involving the multiplexing of IO functions, if the function of the pin is already GPIO, the above method can be used; otherwise, the pinctrl state must be specified in the device tree.
Generally speaking, if you want to easily operate a GPIO in the user layer, you can add it as a GPIO-LED in the device tree. Please refer to linux-linaro-stable/arch/arm64/boot/dts/bitmain/bm1684_firefly.dtsi for details.
LED Usage
There are 2 LEDs on the AIO-1684JD4 board:
| Color | Location | Symbol | Description |
|---|---|---|---|
| Yellow | Up | DIY_LED | User controls |
| Green | Down | WORK_LED | Power on |
Example command to control LED light state (requires root privileges):
# yellow light on
echo 1 >/sys/class/leds/DIY_LED/brightness
# yellow light off
echo 0 >/sys/class/leds/DIY_LED/brightness
# green light on
echo 1 >/sys/class/leds/WORK_LED/brightness
# green light off
echo 0 >/sys/class/leds/WORK_LED/brightnessRTC Usage
The AIO-1684JD4 development board has the HYM8563 RTC (Real Time Clock) chip, which can keep the clock running through the button battery even when the development board is powered off.
View RTC Time
$ sudo hwclock
2022-08-09 10:53:15.268874+0800View System Time
$date
Tue Aug 9 10:57:03 CST 2022Set System Time to RTC Time
$ sudo hwclock -sSave Current System Time to RTC
$ sudo hwclock -wTF Card
The EC-A1684JD4 FD provides 1 TF card slot, which can be used to mount a TF card for storage expansion, as well as to upgrade the firmware via a TF card.
The TF card mounting is similar to the USB drive. Use dmesg to know the mmcblk device corresponding to the TF card:
[16220.776440] [4] mmcblk1: p1Mount the TF card:
# create mount directory
mkdir media
# mount
sudo mount /dev/mmcblk1p1 media
# View the files in the TF card
ls mediaFor firmware upgrade via TF card, see Firmware Upgrade.
SIM Card
The SIM card slot of the EC-A1684JD4 FD is used together with a 4G module to provide mobile network connectivity. The 4G module is optional, and the SIM card function is available only after the module has been installed inside the chassis. The SIM card insertion direction is shown in the figure below. Please power off the device before inserting or removing the SIM card.
Device ID
View Device ID
If you need to check the device ID, you can read the serial number of the core board. After reading successfully, it will return a string in json format:
linaro@bm1684:~$ cat /sys/bus/i2c/devices/1-0017/information
{
"model": "SA5",
"chip": "BM1684",
"mcu": "STM32",
"product sn": "HQDZKETBWY2100012",
"board type": "0x01",
"mcu version": "0x38",
"pcb version": "0x12",
"reset count": 0
}Update Device ID
The device ID update is generally used to update the product SN number, which is stored in the EEPROM of the MCU.
The user needs to modify it in the following ways:
(1) First you need to unlock the MCU EEPROM:
sudo -i
echo 0 > /sys/devices/platform/5001c000.i2c/i2c-1/1-0017/lock(2) Write the SN number:
echo "HQATEVBAIAIAI0001" > sn.txt
dd if=sn.txt of=/sys/bus/nvmem/devices/1-006a0/nvmem count=17 bs=1(3) Finally, re-lock the MCU EEPROM to avoid accidental rewriting:
echo 1 > /sys/devices/platform/5001c000.i2c/i2c-1/1-0017/lock
