Cross Toolchain [x86] u7-20111011

Cross Compiler for QNAP NAS Intel-based platform devices

  1. Silas Mariusz
    SDK
    x86 toolchain

    Revision History
    Rev: V0.10
    Date: 19/Oct/2010
    Author: Kent Tsai
    Description: Initial draft



    1. Introduction

    This document provides detailed description to create the cross compile environment and build your application for QNAP NAS. It also provides how to run your own application at startup in QNAP NAS system.



    2. Install the x86 toolchain

    Please follow the steps to install/uninstall toolchain on your host Linux machine

    To Install:​
    As root, decompress the toolchain to the “/” folder
    Kod (Bash):
    1. tar zxvf cross-project-x86.u7-20101019.tar.gz -C /
    To Uninstall:​
    As root, remove /opt/cross-project/x86
    Kod (Bash):
    1. rm -rf /opt/cross-project/x86


    3. Test if “hello world” worked in x86 platform

    Please follow the steps to test “hello world” program
    Kod (Bash):
    1. chroot /opt/cross-project/x86/sys-root
    2. cd /src/hello_world_project
    3. gcc -o hello_world hello_world.c
    4. scp hello_world admin@xxx.xxx.xxx.xxx:/root
    5. ssh admin@xxx.xxx.xxx.xxx /root/hello_world
    (xxx.xxx.xxx.xxx is your NAS IP)

    It works if you can see the output “Hello World!!!!!!!!!!!!!!!!!!!!!!!”



    4. Cross-compiling and testing your application

    4.1 Cross-compiling your application

    Please follow the steps
    A. Put your project in /opt/cross-project/x86/sys-root/src/myproject
    B.​
    Kod (Bash):
    1. chroot /opt/cross-project/x86/sys-root
    2. cd /src/myproject
    C. use gcc or make to compile your project​



    4.2 Testing the binary of your application

    Please follow the steps
    A. scp your_binary admin@xxx.xxx.xxx.xxx:/root​
    B. Use SSH to login to your NAS​
    C. Run your_binary (./your_binary)​



    4.3 Running your own application at startup

    Please follow the steps
    A. scp your_binary admin@xxx.xxx.xxx.xxx:/root​
    B. Use SSH to login to your NAS​
    Kod (Bash):
    1. mount -t ext2 /dev/sdx6 /tmp/config
    2. cp /root/your_binary /tmp/config
    C. create your own autorun.sh script in /tmp/config/autorun.sh
    Kod (Bash):
    1. touch /tmp/config/autorun.sh
    2. chown +x /tmp/config/autorun.sh
    3. umount /tmp/config
    Note: you can also refer to QNAP wiki to make your autorun.sh script http://wiki.qnap.com/wiki/Running_Your_Own_Application_at_Startup



    5. Additional libraries

    If you are going to cross-compile some packages, they might miss some libraries. Get the libraries source code first, and follow standard procedure to compile/install it.

    For example, to compile libpng, follow the steps
    A. Download libpng source to /opt/cross-project/x86/sys-root/src
    Kod (Bash):
    1. wget http://prdownloads.sourceforge.net/libpng/libpng-1.4.4.tar.gz?download
    2. chroot /opt/cross-project/x86/sys-root
    3. cd /src
    4. tar zxvf libpng-1.4.4.tar.gz
    5. cd libpng-1.4.4
    6. ./configure
    7. make
    8. make install


    6. Important Notes

    Question:
    When I use scp to upload binary to NAS, the ram disk is full, how can I do?​
    Answer:
    Change the target directory to hard disk​
    ex: scp your_binary admin@xxx.xxx.xxx.xxx:/mnt/HDA_ROOT​
    scp your_binary admin@xxx.xxx.xxx.xxx:/share/MD0_DATA​

    Question:
    The log of my application will cause ram disk full, how can I don?​
    Answer:
    Usually open source or application might save logs, to prevent ram disk full, always make sure the log file has been size rotated or save it to hard disks​
    (Ram disk full will cause your system abnormal and unstable)​