构建应用程序

Building an application构建应用程序

Note注意

To build an application it is recommended to use a host device as described here. This guide assumes you set-up your Astra Machina board with a working image as explained in Installing a pre-built system image and you connected the host and the board to the same network.
要构建应用程序,建议使用 这里 所述的主机设备。 本指南假设您参照 安装预构建的系统映像中的说明,使用可工作的映像配置好您的Astra Machina板卡,并将主机和该板卡连接到同一个网络中。

To build an application follows these steps:
请执行以下步骤来构建应用程序:

  1. Download a pre-built toolchain package from the release page.
    release page 下载预构建好的工具链包。

  2. Unpack the toolchain package, the CPUTYPE for sl1680 is cortexa73, for sl1620 and sl1640 is cortexa55:
    解压工具链包,其中sl1680CPUTYPEcortexa73, 而sl1620sl1640的则是cortexa55

    $ ./poky-glibc-x86_64-astra-media-${CPUTYPE}-${MACHINE}-toolchain-4.0.9.sh
    Poky (Yocto Project Reference Distro) SDK installer version 4.0.9
    =================================================================
    Enter target directory for SDK (default: /opt/poky/4.0.9): toolchain
    You are about to install the SDK to "/home/user/toolchain". Proceed [Y/n]?
    Extracting SDK.................................................................................................................................................................................................................................................................................................................................done
    Setting it up...done
    SDK has been successfully set up and is ready to be used.
    Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
      $ . /home/user/toolchain/environment-setup-${CPUTYPE_32}-pokymllib32-linux-gnueabi
      $ . /home/user/toolchain/environment-setup-${CPUTYPE}-poky-linux
    
  3. Create a test application:创建测试应用程序:

    $ echo -e '#include <stdio.h>\nint main(void) { printf("hello world\\n");}' > test.c
    
  4. Setup the build environment variables:设置构建环境变量:

    $ . toolchain/environment-setup-${CPUTYPE}-poky-linux
    
  5. Build the application:构建应用程序:

    $ ${CC} test.c -o test
    
  6. Find the ip address of the board with the following command on the target:
    在目标板上使用以下命令,查询该板的IP地址:

    # ifconfig eth0 | grep "/inet addr/"
              inet addr:192.168.1.110  Bcast:192.168.1.255  Mask:255.255.255.0
    
  7. Upload application to the board by running the following command on the host:
    在主机上运行以下命令,将应用程序上传到主板:

    $ scp test root@192.168.1.110:/tmp
    
  8. Run the application on the board:在板上运行应用程序:

    $ ssh root@192.168.1.110 /tmp/test
    

For more details, troubleshooting and information check the Synaptics Astra Yocto Guide.
更多细节、 故障排除和信息,请参阅 Synaptics Astra Yocto指南