Cross Compile C program for FATBOX G3 Linux ARM iMX6 IOT Gateway
In this Application Note, we will explain to setup, write, compile, install and test your own C code for our FATBOX G3 device.
The FATBOX G3 is an open Linux platform where user can deploy their own portable codes e.g. in C or Python or LUA to run on an industrial cellular (3G or 4G/LTE) and ethernet WAN connected gateway device. This will allow user to write codes to read Modbus, CANbus, RS232, RS485 serial data, Zigbee and other inputs – process onboard or sent straight to their central server.
The board runs OpenWRT on an embedded Linux board running NXP i.MX6 processor. Therefore the first task is to install the correct tool chain into your development device. A Linux development laptop (or a Windows computer running a Linux, e.g. Ubuntu 16.04 LTS as a VM or Docker container).
1. Install the C Toolchain
$ git clone git://git.archive.openwrt.org/15.05/openwrt.git G3
$ cd G3
$ ./scripts/feeds update -a
$ ./scripts/feeds install -a
You need to install our current build configuration file. Download the file from our Google Drive link below, rename it “.config” and save in /G3 folder
The following may be required to properly build your cross-compilation environment,
$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev libncurses5-dev unzip gawk zlib1g-dev
Next, you can customized (do not remove any modules already selected as some are critical to operation of the gateway) the build.
$ make menuconfig
Now we are going to start the bulding process. V=99 enable detailed compilation output for troubleshooting.
$ make V=99
Now you will have the correct C toolchain in your dev computer to compile executable programs in the FATBOX G3 gateway.
2. Install and configure your IDE
We choose to use Eclipse IDE with C/C++ development Tools (CDT) installed. You need to configure similar to the following as one your development system’s OpenWRT folder structure. In Eclipse, this setting is under Properties > Cross Settings
Prefix : arm-openwrt-linux-
Path : ~/G3/staging_dir/toolchain-arm_cortex-a9+neon_gcc-4.8-linaro_glibc-2.21_eabi/bin
3. Write and compile your C program
Now you are all set to test a simple ‘Hello’ C-program i.e. a fprintf(stderr,"HELLO!\n") in your main() or our BLINK souce code (which flashes the FATBOX G3 LEDs once when executed)
BLINK download link :
After you run “Build All” in your IDE, you should see a cross-compiled [arm/le] executable, for Eclipse IDE as example.
4. Install and test your C executable
The executable file e.g. BLINK.exe in our example is found under the Debug sub-folder in your Eclipse project folder. The easiest way to test the file is to enable SSH and scp or (winscp) the program over to the FATBOX G3 board, then SSH over to console and just execute the program (remember to CHMOD the file to enable execution).
Done! You can now compile your own or other 3rd party Linux C codes (or SDKs) to execute on our platform.
The FATBOX G3
IMPLEMENTATION FEATURES OF THE FATBOX G3
Integrated device server for scheduled poll and read from attached equipment
Multi-port support - RS-232/RS-485 (e.g. MODBUS), Ethernet, CANBus and USB (for Zigbee transceiver).
Azure IoT Hub client to integrate with your Azure cloud resources
Persistent LTE and 3G data connection with integrated watch-dog
User scripts supported for local logic and out-of-band alert messages
Model with on-board RTC
SNMPv2 for management
Wide power supply 5~30VDC (12/24V) ensures stability of operation
Industrial temperature -40C to 75C and robust aluminium enclosure for durability
Other articles that may interest you
Set up Mosquitto MQTT for AWS apps
Control Downstream Modbus devices
Industrie 4.0 with the FATBOX G3
Collect CAN Bus data for cloud applications