Hi3516EV200 compilation environment configuration and cross compilation software package

Original address: Hi3516EV200 compilation environment configuration and cross compilation software package - WindSpiritIT

Basic information

OS: Ubuntu 16.04 xenial

Version: 16evc01evc01200sdk - hic035200_ SDK_ V1. 0.1.1

SDK package path: hi3516ev200r001c01spc012 \ 01 software\board\Hi3516EV200_ SDK_ V1. 0.1.2. tgz

Development board address:

Development board MAC: 7C:A7:B0:F6:E4:10

Development board senser: GC2053

Virtual machine address:

directory structure

The following directory tree lists the relative location of all SDK and board application related files and directories involved in the whole configuration process

├── ...
├── arm-himix100-linux  # Cross compiler
│   ├── ...
│   └── arm-himix100-linux.install  # Cross script installation tool
├── DPO_MT7601U_LinuxSTA_3.0.0.4_20130913   # MT7601U driver package
│   ├── ...
│   └── mcu
│       ├── ...
│       └── bin
│           ├── ...
│           └── MT7601.bin  # MT7601U driver firmware
├── Hi3516EV200_SDK_V1.0.1.2    # SDK package
│   ├── ...
│   ├── mpp
│   │   ├── ...
│   │   ├── ko  # Board end ko Library Directory
│   │   │   ├── ...
│   │   │   ├── hi3516ev200_base.ko
│   │   │   ├── hi3516ev200_isp.ko
│   │   │   ├── hi3516ev200_ive.ko
│   │   │   ├── load3516ev200   # ko library loading script
│   │   │   └── sys_config.ko
│   │   └── sample  # Sample project directory
│   │── osdrv
│   │   ├── ...
│   │   ├── opensource
│   │   │   ├── ...
│   │   │   └── kernel
│   │   │       ├── ...
│   │   │       └── linux-4.9.y # linux kernel source code
│   │   │           ├── ...
│   │   │           ├── arch
│   │   │           │   ├── ...
│   │   │           │   └── arm
│   │   │           │       ├── ...
│   │   │           │       └── boot
│   │   │           │           ├── ...
│   │   │           │           └── uImage  # Separately built kernel image
│   │   │           └── firmware
│   │   │               ├── ...
│   │   │               └── mt7601u.bin     # MT7601U driver firmware
│   │   └── pub
│   │       ├── ...
│   │       ├── hi3516ev200_spi_image_uclibc    # osdrv build target directory
│   │       │   ├── ...
│   │       │   ├── rootfs_hi3516ev200_64k.jffs2    # SPI Nor file system image
│   │       │   ├── u-boot-hi3516ev200.bin          # fastboot image
│   │       │   └── uImage_hi3516ev200              # linux kernel image
│   │       ├── rootfs_uclibc_64k_custom.jffs2    # SPI Nor file system image built separately
│   │       ├── rootfs_uclibc       # File system directory
│   │       │   ├── ...             # The files to be added to the file system are listed below
│   │       │   └── etc
│   │       │       ├── ...
│   │       │       ├── init.d
│   │       │       │   ├── ...
│   │       │       │   ├── S80wireless     # Self created wireless network initialization script
│   │       │       │   └── rcS             # File system initialization script
│   │       │       ├── ...
│   │       │       └── wpa_supplicant.conf
│   │       └── rootfs_uclibc.tgz   # File system package
│   ├── sdk.cleanup     # osdrv packaging script
│   └── sdk.unpack      # osdrv unpacking script
├── lrzsz-0.12.20   # lrzsz source code
│   ├── ...
│   └── _install    # Build target directory
│       ├── ...
│       └── bin
│           ├── ...
│           ├── lrz
│           └── lsz
├── osdrv_packages  # Source package for building osdrv
└── wpa_supplicant  # Build wpa_supplicant application source code and its dependent library source code
    ├── dbus-1.13.20    # dbus source code
    ├── expat-2.4.3     # expat source code
    ├── install         # Build target directory
    │   ├── dbus
    │   ├── libexpat
    │   ├── libnl
    │   ├── libssl
    │   └── wpa_supplicant
    │       └── usr
    │           └── local
    │               └── sbin
    │                   ├── wpa_cli
    │                   ├── wpa_passphrase
    │                   └── wpa_supplicant
    ├── libnl-3.5.0             # libnl source code
    ├── openssl-1.1.1m          # openssl source code
    └── wpa_supplicant-2.10     # wpa_supplicant source code

Switch to bash

Run sudo dpkg reconfigure dash and select NO

Ubuntu uses dash as the shell by default. Most scripts in the SDK are written based on bash. Manual switching is required here. Otherwise, the script may not run or cannot obtain variables, resulting in recursive modification of root directory permissions

Compile osdrv

Install dependent packages

sudo apt install libncurses5-dev make libc6 lib32z1 lib32stdc++6 zlib1g-dev ncurses-term libncursesw5-dev g++ u-boot-tools liblzo2-dev uuid-dev pkg-config texinfo texlive gperf bison gawk curl upx pngquant flex libnl-3-dev libdbus-1-dev

Unzip the cross compilation kit and install it

tar zxvf arm-himix100-linux.tgz
chmod +x arm-himix100-linux/arm-himix100-linux.install
cd arm-himix100-linux && ./arm-himix100-linux.install && cd ..

Run SDK in the SDK directory unpack

According to osdrv/readme_cn.txt directory and move the source package to the specified directory, or run the packaged osdrv_ CP in packages_ packages. SH script (download address is not provided temporarily)

Enter the osdrv directory in the development package and start compiling. Do not use the - j option after the make all command. The compilation may fail due to different execution sequences

cd osdrv
make all

A large number of > / dev / null 2 > & 1 redirection standards and error output are used in Makefile, which makes it impossible to locate the error location or solution when there is an error in the compilation or configuration process. If the compilation fails, please find the compilation command closest to the error location and manually compile it to locate the error

After compiling the SDK according to the above steps, the directory structure should be as follows

 ├─ drv
 ├─ mpp
 ├─ osal
 ├─ osdrv
 ├─ package
 ├─ scripts
 ├─ sdk.cleanup
 └─ sdk.unpack

The mpp directory is used to store the script and runtime for initializing the board environment

The osdrv directory is used to store compiled partition images and related tools. The structure is as follows

├── Makefile
├── opensource
├── pub
│   ├── bin
│   │   ├── board_uclibc
│   │   └── pc
│   ├── hi3516ev200_spi_image_uclibc
│   │   ├── rootfs_hi3516ev200_128k.jffs2
│   │   ├── rootfs_hi3516ev200_256k.jffs2
│   │   ├── rootfs_hi3516ev200_2k_128k_32M.ubifs
│   │   ├── rootfs_hi3516ev200_2k_24bit.yaffs2
│   │   ├── rootfs_hi3516ev200_2k_4bit.yaffs2
│   │   ├── rootfs_hi3516ev200_4k_24bit.yaffs2
│   │   ├── rootfs_hi3516ev200_4k_256k_50M.ubifs
│   │   ├── rootfs_hi3516ev200_4k_4bit.yaffs2
│   │   ├── rootfs_hi3516ev200_64k.jffs2
│   │   ├── u-boot-hi3516ev200.bin
│   │   └── uImage_hi3516ev200
│   └── rootfs_uclibc.tgz
├── readme_cn.txt
├── readme_en.txt
├── rootfs_scripts
└── tools

Multiple rootfs images will be generated after compilation. We can only burn the u-boot image and start it directly

Judge the Flash type according to the values of SPI Nor and NAND items in the log

The naming rule of Nand image is rootfs_hi3516ev200_{PageSize}_{EccType}.yaffs2

The naming rule of Nor image is rootfs_hi3516ev200_{BlockSize}.jffs2

The Hi3516EV200 in my hand uses the Nor format. According to the logs like the following, the BlockSize is 64KB

Block:64KB hifmc_spi_nor_probe(1706): Chip:32MB hifmc_spi_nor_probe(1707): Name:"MX25L(256/257)XX"
SPI Nor total size: 32MB

Serial port debugging

Some development boards encapsulate TTL interfaces and can be directly connected according to the definition

The development board of another model does not package TTL interface, but holes are reserved. Two vias are reserved on the side of the development board Hi3516 ERNCV200 chip close to the edge of the board, of which the via on the side close to the crystal oscillator is TX, which is connected to the USB-TTL board RX; The other side is Rx, connected to USB-TTL board TX, and the ground wire can be directly connected to the through holes of the four pins of the development board

After installing the corresponding driver of USB-TTL board chip, you can enter the development board terminal through serial port, such as CP210x or CH340

Compile lrzsz

lrzsz can transmit small files through serial port or telnet


wget https://ohse.de/uwe/releases/lrzsz-0.12.20.tar.gz
tar zxvf lrzsz-0.12.20.tar.gz
cd lrzsz-0.12.20
CC=arm-himix100-linux-gcc ./configure --host=arm-himix100-linux --build=arm-himix100-linux --prefix=$PWD/_install --cache-file=./arm-himix100-linux.cache
make -j12
make install



Run it manually or on the board file system / etc / init Write the following commands in D / RCS

telnetd &

Burning system

Open HiTool tool, connect the development board through serial port, change the transmission mode to serial port, use burn by partition, and configure the burn image according to the following partition

The serial port burning needs to enter the boot, so the development board needs to be powered off before starting the burning. Click the burning button to start the burning, and then power on within 15 seconds

Partition namedeviationlengthfile nameDevice typefile system
fastboot0 (0M)80000 (1M)u-boot-hi3516ev200.binspi nornone
kernel100000 (1M)400000 (4M)uImage_hi3516ev200spi nornone
rootfs500000 (5M)1b00000 (27M)rootfs_hi3516ev200_64k.jffs2spi nornone

Configure startup parameters

Open the terminal tool in HiTool and connect the development board with serial port

After the partition image is burned, the reset command will be automatically executed to restart the system from u-boot. However, the system can only enter u-boot and cannot enter the system because the startup parameters are not configured

  • In u-boot mode, the terminal format is hisilicon #, and the format is path after entering the system#
  • Input the following commands under the u-boot terminal, and the parameters are configured according to the burned image and the actual requirements
  • The memory of the development board is divided into two types: OS Memory and MMZ Memory; The memory management mechanism of the development board is to subtract OS Memory from the total memory and allocate the rest to MMZ. Services such as video streaming pushed by the development board need to occupy a certain amount of MMZ Memory.
  • After using the setenv command to set the system variable, you need to save it with saveenv before restarting, otherwise all changes will be lost after restarting
  • The file system type, partition name and partition length in the startup parameters must be consistent with those set during burning in HiTool, otherwise the partition will not be found during startup
setenv bootargs 'mem=32M console=ttyAMA0,115200 root=/dev/mtdblock2 rootfstype=jffs2 rw mtdparts=hi_sfc:1M(boot),4M(kernel),27M(rootfs)'
setenv bootcmd 'sf probe 0;sf read 0x42000000 0x100000 0x400000;bootm 0x42000000'

Connecting wireless network based on MT7601U

WPA is used in this article_ Supplicant operates the wireless network card. The tool relies on libssl libnl libexpat dbus



wget https://www.openssl.org/source/openssl-1.1.1m.tar.gz
tar zxvf openssl-1.1.1m.tar.gz
cd openssl-1.1.1m
./config no-asm no-shared no-async --prefix=$PWD/../install/libssl --cross-compile-prefix=arm-himix100-linux-

Remove all -m64 options in Makefile

make -j12
make install



wget https://github.com/thom311/libnl/releases/download/libnl3_5_0/libnl-3.5.0.tar.gz
tar zxvf libnl-3.5.0.tar.gz
cd libnl-3.5.0
./configure --host=arm-himix100-linux --prefix=$PWD/../install/libnl --enable-static
make -j12
make install



wget https://github.com/libexpat/libexpat/releases/download/R_2_4_3/expat-2.4.3.tar.gz
tar zxvf expat-2.4.3.tar.gz
cd expat-2.4.3
./configure --prefix=$PWD/../install/libexpat --host=arm-himix100-linux --enable-shared --enable-static
make -j12
make install



wget https://dbus.freedesktop.org/releases/dbus/dbus-1.13.20.tar.xz
tar xvf dbus-1.13.20.tar.xz
cd dbus-1.13.20
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$PWD/../install/libexpat/lib/pkgconfig/
./configure --prefix=$PWD/../install/dbus --host=arm-himix100-linux --enable-shared --enable-static CFLAGS=-I$PWD/../install/libexpat/include LDFLAGS=-L$PWD/../install/libexpat/lib --disable-tests
make -j12
make install



wget http://w1.fi/releases/wpa_supplicant-2.10.tar.gz
tar zxvf wpa_supplicant-2.10.tar.gz
cd wpa_supplicant-2.10/wpa_supplicant
cp defconfig .config

Add the following code config

CFLAGS += -I../../install/libssl/include
LIBS   += -L../../install/libssl/lib

CFLAGS += -I../../libnl-3.5.0/include/linux-private
CFLAGS += -I../../install/libnl/include
CFLAGS += -I../../install/libnl/include/libnl3
LIBS   += -L../../install/libnl/lib

CFLAGS += -I../../install/dbus/include
LIBS   += -L../../install/dbus/lib

LDFLAGS += -pthread

CC = arm-himix100-linux-gcc

Open Makefile and find WPA respectively_ cli wpa_ passphrase wpa_ The compilation option of supplicant. Add - static after its compilation command to use the static link library

For example, find WPA_ The compilation options for supplicant are as follows

wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
        $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS)
        @$(E) "  LD " $@

Change it to

wpa_supplicant: $(BCHECK) $(OBJS) $(EXTRA_progs)
        $(Q)$(LDO) $(LDFLAGS) -o wpa_supplicant $(OBJS) $(LIBS) $(EXTRALIBS) -static
        @$(E) "  LD " $@

Compile application

make -j12
make install DESTDIR=$PWD/../../install/wpa_supplicant

Use the arm himix100 Linux strip command to crop the application

Set WPA_ cli wpa_ passphrase wpa_ Copy supplicant to the file system and create WPA in the file system etc directory_ supplicant. Conf file and write the following configuration


Connect WiFi

The following is the plate end configuration

Turn on the network card, configure the network and start wpa_supplicant, including MAC address, device IP address and routing address, please configure according to the actual situation

ifconfig wlan0 up
ifconfig wlan0 hw ether 7C:A7:B0:F6:E4:10
ifconfig wlan0 netmask
route add default gw
wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B

wpa_cli -i wlan0 enter the interactive command, and use Ctrl + Backspace in the interactive command line

# Search WiFi
# Output search results

set_network 0 ssid "name"
set_network 0 psk "psk"
enable_network 0

# [None]
set_network 0 ssid "name"
set_network 0 key_mgmt NONE
enable_network 0

# preservation
# Close connection
disable_network 0
# List all saved connections
# Select the first saved connection
select_network 0
# Connect to the first saved connection
enable_network 0

Organize the above steps into automatic scripts and write them to the board file system / etc / init D / s80wireless and use chmod +x S80wireless to grant execution permission


ifconfig $wlandev up
ifconfig $wlandev hw ether $phyaddr
ifconfig $wlandev $ipaddr netmask $netmask
route add default gw $gateway
wpa_supplicant -D nl80211 -i $wlandev -c /etc/wpa_supplicant.conf -B

Run WPA once after the board end is started_ passphrase "ssid" "psk" >> /etc/wpa_ supplicant. Conf restart to connect automatically

MT7601U Driver


There are two ways to load firmware in linux kernel

  • Read the firmware in the file system / lib/firmware directory
  • Integrate firmware into linux kernel

The first method is not feasible because the file system is mounted after the network card loads the firmware. Here, we choose to integrate the firmware into the kernel

DPO firmware_ MT7601U_ LinuxSTA_ 20130913/mcu/bin/MT7601. Copy bin to the firmware directory in the kernel source code and rename it mt7601u bin

Execute menuconfig on the kernel to end the generation After configuring config, modify config in this file_ EXTRA_ The value of firmware is a space delimited firmware name, such as CONFIG_EXTRA_FIRMWARE="a.bin b.bin" and add CONFIG_EXTRA_FIRMWARE_DIR="firmware"

After modification, it shall be as follows:


kernel with MT7601U support


make ARCH=arm CROSS_COMPILE=arm-himix100-linux- menuconfig
# Networking support —> Wireless
# <*>   cfg80211 - wireless configuration API
# <*>   Generic IEEE 802.11 Networking Stack (mac80211)
# Networking support —> RF switch subsystem support
# <*>   GPIO RFKILL driver
# Device Drivers —> Network device support -> Wireless LAN
# [*]   MediaTek devices
# <*>     MediaTek MT7601U (USB) support
# <*>     IEEE 802.11 for Host AP (Prism2/2.5/3 and WEP/TKIP/CCMP)
# [*]       Support downloag firmware images with Host AP driver
# [*]         Support for non-volatile firmware download
make ARCH=arm CROSS_COMPILE=arm-himix100-linux- uImage -j12

rootfs with custom files


tar zxvf rootfs_uclibc.tgz
./bin/pc/mkfs.jffs2 -d rootfs_uclibc -l -U -e 0x10000 -o rootfs_uclibc_64k_custom.jffs2
# -d    Build file system from directory DIR
# -l    Create a little-endian filesystem
# -e    Use erase block size SIZE   0x10000 = 64KB
# -o    Output to FILE

Mount the server directory using NFS

NFS server setup

All operations in this step are located on the virtual machine side

Install NFS server

sudo apt install nfs-kernel-server

Write the directory to be shared through NFS to / etc/export in the following format

The IP address is used to restrict only the specified IP mount to access NFS. You can use the IP address similar to 192.168.1* And


Export the shared directory and restart services for NFS

sudo exportfs -a
sudo systemctl restart nfs-server

Fixed port and open firewall

If you need to set up a firewall for virtual machines, you need to configure NFS related services to use fixed ports

sudo sed -i 's/RPCMOUNTDOPTS="--manage-gids"/RPCMOUNTDOPTS="--manage-gids -p 30001"/' /etc/default/nfs-kernel-server
sudo touch /etc/modprobe.d/options.conf
sudo tee -a /etc/modprobe.d/options.conf >/dev/null << EOF
options lockd nlm_udpport=40002
options lockd nlm_tcpport=40002
sudo tee -a /etc/modules >/dev/null << EOF

Open firewall take firewalld as an example

sudo firewall-cmd --zone=public --add-port=111/tcp --add-port=111/udp --add-port=2049/tcp --add-port=2049/udp --add-port=30001-30002/tcp --add-port=30001-30002/udp --permanent
sudo firewall-cmd --reload

It will take effect after restart

Board end mount NFS

All operations in this step are located at the plate end

Mount NFS in the virtual machine to the / mnt directory

mount -t nfs -o nolock -o tcp -o rsize=32768,wsize=32768 /mnt

Configuring board end environment variables

Write the following configuration to / root / Profile, which is used to start the PQ tool at the board end

The board end PQ tool is located in the SDK directory hi3516ev200r001c01spc012 \ 01 software\pc\PQTools\Hi3516EV200_ PQ_ V1. 0.1.2. tgz

Please modify the specific path according to the actual situation

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/mpp/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/Hi3516EV200_PQ_V1.0.1.2/libs

Keywords: Linux Ubuntu

Added by Riotblade on Fri, 04 Mar 2022 10:52:44 +0200