Cross Toolchain [ARM] 20110901

Cross Compiler for QNAP NAS ARM platform devices

  1. Silas Mariusz
    arm 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 arm 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-arm-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. source /opt/cross-project/arm/marvell/arm-glibc-2.5.env
    2. cd $TARGET_PREFIX/src/hello_world_project
    3. arm-none-linux-gnueabi-gcc -o hello_world hello_world.c
    4. scp hello_world
    5. ssh /root/hello_world
    ( 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 $TARGET_PREFIX/src/myproject
    Kod (Bash):
    1. cd $TARGET_PREFIX/src/myproject
    C. use 'arm-none-linux-gnueabi-gcc' or 'make CC=${CROSS_COMPILE}gcc' to compile your project​

    4.2 Testing the binary of your application

    Please follow the steps
    A. scp your_binary​
    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​
    B. Use SSH to login to your NAS​
    Kod (Bash):
    1. mount -t ext2 /dev/mtdblock5 /tmp/config
    2. cp /root/your_binary /tmp/config
    C. create your own script in /tmp/config/
    Kod (Bash):
    1. touch /tmp/config/
    2. chown +x /tmp/config/
    3. umount /tmp/config
    Note: you can also refer to QNAP wiki to make your script

    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 $TARGET_PREFIX/src
    Kod (Bash):
    1. cd $TARGET_PREFIX/src
    2. wget
    3. tar zxvf libpng-1.4.4.tar.gz
    4. cd libpng-1.4.4
    5. CC=${CROSS_COMPILE}gcc LDFLAGS="-L$TARGET_PREFIX/usr/lib -L$TARGET_PREFIX/lib" CPPFLAGS="-I${TARGET_PREFIX}/include -I${TARGET_PREFIX}/usr/include" ./configure --host=${TARGET} --prefix=${TARGET_PREFIX}/usr
    6. make
    7. make install

    6. Important Notes

    When I use scp to upload binary to NAS, the ram disk is full, how can I do?​
    Change the target directory to hard disk​
    ex: scp your_binary​
    scp your_binary​

    The log of my application will cause ram disk full, how can I don?​
    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)​