Compiling Source Code
Installing the Toolchain
If the Atlas 200 AI accelerator module is used as the slave PCIe device, the cross compilation toolchain is provided by the customer. The installation method is the same. For details, see Installing the Toolchain.
Compiling the Driver
Prerequisites
The Linux server has qemu-user-static, binfmtsupport, YAML, unzip, unrar, and cross compiler installed.
Procedure
- Log in to the Linux server.
- Run the following command to switch to the root user:
su - root
- Use WinSCP to upload the A200-3000-EP-SDK-Vxxx.zip package to any directory on the Linux OS, for example, /opt. For details, see Using WinSCP to Transfer Files.
- Run the following command to decompress the A200-3000-EP-SDK-Vxxx.zip package:
unzip A200-3000-EP-SDK-Vxxx.zip
- Run the following command to go to the project directory and obtain the source.tar.gz package:
cd project
- Run the following command to decompress the source.tar.gz package:
tar -zxvf source.tar.gz
- Run the following command to go to the source code directory:
cd source
- Run the following command to compile the source code:
make CROSS_COMPILE=Cross compilation gcc KERNEL_DIR=Kernel root directory for .ko driver file compilation O=Compilation result output directory
- The kernel required for the .ko file needs to be compiled in advance. In addition, the .config file and include directory are required.
- If an error is reported, check whether the dependency packages libncurses5-dev, bison, and flex have been installed.
- You can use an absolute path or a relative path to indicate the directory for storing compilation results. By default, the out folder in the current directory is used for restoring the results.
- Copy contents in the compilation output directory to the ../../lib/host directory.
For example, if the compilation output directory is out, run the cp –arf ./out/release_images/* ../../lib/host command.
Installing the Driver
Procedure
- Log in to the Linux server.
- Run the following command to switch to the root user:
su - root
- Use WinSCP to upload the A200-3000-EP-SDK-Vxxx.zip package to any directory on the Linux OS, for example, /opt. For details, see Using WinSCP to Transfer Files.
- Run the following command to decompress the A200-3000-EP-SDK-Vxxx.zip package:
unzip A200-3000-EP-SDK-Vxxx.zip
- Run the following command to go to the Directory containing the software package/scripts/install directory, for example, /opt/scripts/install:
cd /opt/scripts/install
- Run the following command to create the HwHiAiUser user:
groupadd HwHiAiUser
useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash
- Run the following command to run the installation script:
bash install_all.sh
The files are installed in the following directories:
/lib64
/bin
/usr/bin
/usr/local/HiAI/driver
/usr/local /HiAI/firmware
/usr/local/sbin/
- Run the following command to grant the execute permission on other users:
chmod -R o+x /usr/local/HiAI
- Go to the /usr/local /HiAI/driver/boot directory.
cd /usr/local/HiAI/driver/boot
- Run the following command to boot the system:
bash davinci_boot_pcie_3559.sh
EulerOS contains the driver corresponding to drv_seclib_host. If the davinci_boot_pcie_3559.sh command is run on EulerOS during host driver compilation, the system will report a message indicating that the drv_seclib_host driver fails to be loaded. You can ignore this error message.