DSGW-210 SDK Quick Start Guide V1.2发表时间:2022-08-20 11:23
SDK Quick Start Guide Product Name: IoT Edge Computer Gateway Model Name: DSGW-210
Revision History
Approvals
1 IntroductionThis Quick Start Guide explains the basics: how to connect and set up your target on the network; how to install the SDK; and how to build the firmware images. The Linux Software Developer’s Kit (SDK) is an embedded hardware and software suite that enables Linux developers to create applications on Dusun’s DSGW-210 gateway. Base on the 4.4 Linux kernel, and leveraging existing open source software, the SDK simplifies the process of adding custom applications. Device drivers, GNU toolchain, Predefined configuration profiles, and sample applications are all in included.
2 Gateway Information2.1 Basic informationSOC: RK3328 Quad-core ARM Cortex-A53 Mali-450MP2 GPU Power Supply: DC-5V LTE module: BG96 (LET CAT-1) Wi-Fi module: 6221A (Wi-Fi chip: RTL8821CS) Zigbee: EFR32MG1B232F256GM32 Z-wave: ZGM130S037HGN Bluetooth: EFR32BG21A020F768IM32 eMMC: 8GB SDRAM: 2BG 2.2 Interface3 Target SetupThis section describes how to connect the gateway into your host computer and network. Connecting a gateway - Power Make sure that the power adapter is 5V/3A. Select the appropriate power plug adaptor for your geographical location. Insert it into the slot on the Universal Power Supply; then plug the power supply into an outlet. Connect the output plug of the power supply to the gateway Connecting a gateway – USB port 1. Connect one end of the USB cable to the USB port on the laptop or desktop 2. Connect the other end of USB cable to the USB port on the gateway.
Figure3-1. Connecting a gateway via USB port Connecting a PCBA board – Serial Port If you want to debug the gateway, you can open the shell, Connect the PC to the PCBA board via Serial to USB tool. PIN in board for serial connection: TP1100: RX TP1101: TX
Figure3-1. Connecting a PCBA via Serial-USB tool 4 Compile the Environment to BuildPlease use ubuntu 18.04 .iso image to setup your build environment. You can use a virtual machine or a physical PC to install ubuntu 18.04. 4.1 Virtual MachineIt is recommended that novice users use virtual machines, install ubuntu 18.04 to the virtual machine, and leave enough disk space (at least 100G) for the virtual machine.
4.2 Ubuntu PC Compile the Environment to BuildThe use of physical machine compilation users can use a ubuntu PC.
5 SDK Acquisition and Preparation5.1 Download the source code from the Dusun FTPThe source package name will be 3328-linux-*.tar.gz, get it from Dusun FTP.
5.2 Code Compression Package CheckThe next step can be taken only after generating the MD5 value of the source compression package and comparing the MD5 value of the MD5 .txt text to confirm that the MD5 value is the same, and if the MD5 value is not the same, the energy code pack is damaged, please download it again. $ md5sum rk3328-linux-*.tar.gz
5.3 The Source Compression Package is UnzippedCopy the source code to the corresponding directory and unzip the source code compression package. $ sudo -i $ mkdir workdir $ cd workdir $ tar -zxvf /path/to/rk3328-linux-*.tar.gz $ cd rk3328-linux 6 Code Compilation6.1 Getting started, global Compilation6.1.1Initialize Compilation Environment Variables (select file system)You can build buildroot, ubuntu or debian rootfs image. Select it in "./build.sh init".
We strongly recommend you to build and run the system with buildroot rootfs to get familiar with the hardware and build environment, when you get started. After you tried buildroot system, you can try ubuntu and debian system.
6.1.2Prepare the Root File System baseThis section is for building ubuntu or debian file system. If you want to build the buildroot file system, skip this section. Compile Ubuntu Download the root file system compression package ubuntu.tar.gz The Root file system compresses the package directory: Unzip the compression package $ tar -zxvf ubuntu.tar.gz // you get ubuntu.img
Copy the root file system to the specified path $ cd workdir/rk3328-linux $ mkdir ubuntu $ cp /path/to/ubuntu.img ./ubuntu/
Compile Debian Download the root file system compression package debian.tar.gz Unzip the compression package $ tar -zxvf debian.tar.gz // you get linaro-rootfs.img
杭州市大关路 189 Tel:86 -571-86769027/8 Copy the root file system to the specified path $ cd workdir/rk3328-linux $ mkdir debian $ cp ./linaro-rootfs.img ./debian/6.1.3 Start Compiling$ ./build.shBuild a complete directory of firmware files: rockdev/update.img and other separate images, update.img includes all firmware for full upgrade. The build will take a long time, please wait patiently. After update.img is built, burn it to the board according to chapter 7. 6.1.4 Run The Image on the boardConnect the RK3328 board serial port to the PC via a USB to UART Bridge. Use Putty or other Terminal software as your console tool, SERIAL CONSOLE SETTINGS: 115200/8N1 Baud: 115200 Data Bits: 8 Parity Bit: No Stop Bit: 1 Power UP the board, you can see the boot log on console:
6.2 Compiled Each Image Part Separately6.2.1 The build system and the image structureThe update.img is composed of several parts. Main parts are uboot.img, boot.img, recovery.img, rootfs.img. uboot.img contains bootloader uboot boot.img contains the device tree .dtb image, Linux kernel image recovery.img: The system can boot up to recovery mode, recovery.img is the rootfs used in recovery mode. rootfs.img: The normal rootfs image. In normal mode, system boot and mount this rootfs image.
You may need to build the images separately, especially when you focus on single module (e.g. uboot or kernel driver) development. Then you can build only that part of image and update that partition in flash. 6.2.2 Build Uboot only$ ./build.sh uboot
6.2.3 Build Linux Kernel Only$ ./build.sh kernel
6.2.4 Build Recovery File System Only$ ./build.sh recovery
6.2.5 Build File System Only$ ./build.sh rootfs
6.2.6 Final Image Packaging$ ./build.sh updateimg
This command making rockdev/*.img scatter firmware packaging builds in the directory update.img
7 More about buildroot systemIf you use buildroot rootfs, some Dusun test scripts/tools are already installed in the final buildroot rootfs. You can refer to buildroot/dusun_rootfs/add_ds_rootfs.sh 7.1 Test hardware componentsThe following testing are done under the buildroot system. 7.1.1 Test Wi-Fi as APThe "ds_conf_ap.sh" script is for setting up Wi-Fi AP, SSID is "dsap", password is "12345678".
7.1.2 Test BG96bg96_dial.sh is used for BG96 dial.
64 bytes from 36.152.44.96: seq=0 ttl=56 time=317.025 ms
You need to configure APN, username/password for BG96, in quectel-chatconnect and quectel-ppp file. Before you run the test. # cat /etc/ppp/peers/quectel-chat-connect ABORT "BUSY" ABORT "NO CARRIER" ABORT "NO DIALTONE" ABORT "ERROR" ABORT "NO ANSWER" TIMEOUT 5 "" AT OK ATE0 OK AT+CPIN? READY AT OK AT+CSQ OK AT+QCFG="nwscanmode" OK AT+QCFG="nwscanseq" OK AT+QCFG="iotopmode" OK AT+QCFG="band" OK AT+CREG? OK ATI;+CSUB;+CSQ;+CPIN?;+COPS?;+CGREG?;&D2 # Insert the APN provided by your network operator, default apn is 3gnet <================ OK AT+CGDCONT=1,"IP","3gnet",,0,0 OK ATD*99# CONNECT # # # cat /etc/ppp/peers/quectel-ppp
# cat /etc/ppp/peers/quectel-ppp # /etc/ppp/peers/quectel-pppd # Usage:root>pppd call quectel-pppd #Modem path, like /dev/ttyUSB3,/dev/ttyACM0, depend on your module, default path is /dev/ttyUSB3 /dev/ttyUSB5 115200 #Insert the Username and Password for authentication, default User and Password are test user "test" password "test" <========================== # The chat script, customize your APN in this file connect 'chat -s -v -f /etc/ppp/peers/quectel-chat-connect' # The close script disconnect 'chat -s -v -f /etc/ppp/peers/quectel-chat-disconnect' # Hide password in debug messages hide-password # The phone is not required to authenticate noauth # Debug info from pppd debug # If you want to use the HSDPA link as your gateway defaultroute # pppd must not propose any IP address to the peer noipdefault # No ppp compression novj novjccomp noccp ipcp-accept-local ipcp-accept-remote local # For sanity, keep a lock on the serial line lock modem dump nodetach # Hardware flow control nocrtscts remotename 3gppp ipparam 3gppp ipcp-max-failure 30 # Ask the peer for up to 2 DNS server addresses usepeerdns # #
7.1.3 Test LED# dsled Usage: dsled [r|g|b] [on/off] dsled [r|g|b] [blink_slow|blink_fast] dsled [r|g|b] breathe
# # dsled r on # dsled b blink_fast
7.1.4 Test I2C# i2cdetect -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- 23 -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- 55 -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- 6a -- -- -- -- -- 70: -- -- -- -- -- -- -- -- # Actually LED controlled is I2C interface.
7.2 How to make menuconfig in buildrootNormal mode buildroot rootfs config file: buildroot/configs/rockchip_rk3328_defconfig Recovery mode buildroot rootfs config file: buildroot/configs/rockchip_rk3328_recovery_defconfig #cd buildroot #make rockchip_rk3328_defconfig #make menuconfig #mv .config ./configs/rockchip_rk3328_defconfig <==== after config change, overwrite the old one If you want to change buildroot configure, here are the steps: Figure3-1.buildroot make menuconfig
7.3 How to add an application in buildroot source treeMake directory buildroot/dusun_package/<your_app> Put APP source code files and Makefile to buildroot/dusun_package/< your_app > your_app.h your_app.c Makefile Make directory buildroot/package/< your_app > Config.in your_app.mk Add Config.in sourcing in buildroot/package/Config.in menu "Dusun software" source "package/dsled/Config.in" + source "package/<your_app>/Config.in" endmenu Make menuconfig to select your APP, and save the configure file as 5.2. "./build.sh rootfs" to rebuild rootfs Please refer to buildroot/dusun_package/dsled/, it's a useful example. 7.4 Switch to ubuntu or debian systemIf you have built a buildroot system image, and want to switch to ubuntu or debian image. You don't need to clean the make and do a clean rebuild. Just do the following steps:
"./build.sh init" to select ubuntu or debian "./build.sh rootfs" to rebuild ubuntu or debian rootfs "./build.sh" to build a the final update.img
Be careful, the dusun tools and scripts are default copied to buildroot rootfs, not to ubuntu or debian rootfs. If you want to copy them to ubuntu or debian rootfs, you can modify the buildroot/dusun_rootfs/add_ds_rootfs.sh. For the APPs, you can copy the code to the board and build it on the target board ubuntu or debian system, since it has gcc and other toolchains.
8 Wireless development (Zigbee, Z-Wave, BLE, LoRaWAN)Please build a debian system to do the following steps. The code will be compiled on the board, not on host. root@linaro-alip:~# apt-get update root@linaro-alip:~# apt-get install libncurses5-dev root@linaro-alip:~# apt-get install libreadline-dev root@linaro-alip:~# apt-get install libssl-dev root@linaro-alip:~# apt-get install libjson-c-dev Prepare some library on the board scp SDK "buildroot/dusun_rootfs/target_scripts/export_zigbee_zwave_ble_gpio.sh" from host to board, under /root root@linaro-alip:~# ./export_zigbee_zwave_ble_gpio.sh root@linaro-alip:~# Power on wireless modules on board. 8.1 ZigbeeZigbee interface is /dev/ttyUSB0. Download "Z3GatewayHost_EFR32MG12P433F1024GM48.tar.gz" from Dusun FTP, and copy it to board, under /root. 杭州市大关路 189 Tel:86-571-86769027/8
Then build Z3Gateway and run. For more information about Z3Gateway, please visit https://docs.silabs.com/ for more information.
8.2 Z-WaveZ-Wave interface is /dev/ttyS1. Download " rk3328_zwave_test.tar.gz " from Dusun FTP, and copy it to board, under /root.
Unzip it and you can get ./zipgateway
Now build a zwave simple test tool and run:
In "my_serialapi_test", press 'a' to include zwave device, 'r' to exclude device, 'd' to reset to default, 'i' to get devices list and 'q' to quit. The Zipgateway is siliabs software, "my_serialapi_test" is just a very simple tool. For more information about Zipgateway, please visit https://docs.silabs.com/ for more information.
Z-Wave regionIf for default Dusun built, Z-Wave frequency can be configured in /etc/config/dusun/zwave/region
8.3 BLEBLE interface is /dev/ttyUSB1. Download "rk3328_ble_test.tar.gz" from Dusun FTP, and copy it to board, under /root. root@linaro-alip:~# tar xvzf rk3328_ble_test.tar.gz root@linaro-alip:~# cd bletest/test/ root@linaro-alip:~/bletest/test#
Unzip it and you can get ./bletest build ble test tool and run: More information about the BLE test tool, please visit https://docs.silabs.com/ for more information. root@linaro-alip:~/bletest/test# make <========== wait for build OK, and you get ./build/test root@linaro-alip:~/bletest/test# ./build/test /dev/ttyUSB1 115200 -C
8.4 LoRaWANChoose the correct interface for LoRaWAN, for example /dev/spidev32766.0. The configuration file for it is in ./sx1302_hal/packet_forwarder/global_conf.json. Download "sx1302_hal_0210.tar.gz" from Dusun FTP, and copy it to board, under /root. root@linaro-alip:~# tar xvzf sx1302_hal_0210.tar.gz root@linaro-alip:~# cd sx1302_hal/
Untar it and you can get ./sx1302_hal build LoRaWAN sample code sx1302_hal and run: More information about the LoRaWAN code, please visit https://www.semtech.com/products/wireless-rf/lora-core/sx1302 for more information. root@linaro-alip:~/sx1302_hal# make all <========== wait for build OK, and you get ./packet_forwarder/ root@linaro-alip:~/sx1302_hal/packet_forwarder# ./lora_pkt_fwd
9 Image Upgrade9.1 Upgrade ToolUpgrade tool:AndroidTool_Release_v2.69 9.2 Go into Upgrade ModeConnect the OTG port to the burning computer USB port, it's also act as 5V power supply
Press "Ctrl+C" when uboot is booting up, to enter uboot:
uboot "rbrom" comand to reboot the board into maskrom mode, for a complete "update.img" upgrade.
"rockusb 0 mmc 0" command to reboot board to loader mode, for a partial firmware upgrade or a complete "update.img" upgrade.
9.3 The Entire Package of Firmware "update.img" Upgrade9.4 Upgrade the Firmware Separately
10 Power management configurationThe battery management chip Dusun used is BQ25895 Methods to optimize CPU power consumption is listed, Adjust cpufreq parameter.
Close some cpu, limit the highest frequency of cpu
SoC with ARM Big-Little architecture can bind the tasks with high loading to little cores through CPUSET since the energy efficiency of the little core is better. /* Note: SoC with SMP architecture can also bind the tasks to some cpu so that other cpus can enter low power consumption mode, but maybe it will make cpu easy to run with high frequency, which will increase the power consumption. */
Limit the cpu bandwidth of the tasks with high loading through CPUCTL (need to enable the macro CONFIG_CFS_BANDWIDTH).
声明:此篇为东胜物联原创文章,转载请标明出处链接:https://www.hzdusun.com/h-nd-51.html
|