Differences

This shows you the differences between two versions of the page.

Link to this comparison view

development:toolchain [2015/08/18 13:32]
hess
development:toolchain [2021/08/04 09:20]
Line 1: Line 1:
-====== ​ Cross-compilation ====== 
-Many or even most tasks can be implemented using the integrated [[sdk:sdk | SDK]] with the C-like scripting language and the router API functions. ​ 
-===== Toolchain ===== 
-However, if for some reasons you want or have to cross-compile a C application,​ you will find a  
-[[ftp://​share.netmodule.com/​router/​public/​toolchain | cross-compilation toolchain ]] on our FTP server. ​ 
-This toolchain consists of a compiler ([[https://​gcc.gnu.org/​ | GNU Compiler Collection (GCC)]] version 4.4.5), ​ 
-a assembler and linker ([[https://​www.sourceware.org/​binutils/​ | GNU binutils]]) and  
-a [[wp>C standard library]] ([[http://​www.uclibc.org/​ | uClibc]] version 0.9.31), all built to produce binaries ​ 
-for NetModule Routers with Freescale/​Motorola PowerPC (MPC830x) CPUs, namely NB1600, NB2700, NB2710, NB3700, and NB3710. 
  
-For further introduction to GCC please refer to [[http://​www.tunl.duke.edu/​documents/​public/​root/​material/​5/​An_Introduction_to_GCC-Brian_Gough.pdf|An Introduction to GCC]], chapter 2 and following ones. 
- 
-==== Getting Started ==== 
- 
-1. Download and install the toolchain on your Linux x86 PC 
-<code bash> 
-wget ftp://​share.netmodule.com/​router/​public/​toolchain/​toolchain-ppc-4.4.5-x86_64.tar.bz2 
-tar -xvf toolchain-ppc-4.4.5-x86_64.tar.bz2 -C /opt 
-export PATH=$PATH:/​opt/​toolchain-ppc-4.4.5-x86_64/​bin 
-</​code>​ 
- 
-2. Write a program 
-<code c hello.c> 
-#​include<​stdio.h>​ 
-#​include<​features.h>​ 
-int main() 
-{ 
-    printf("​Hello World\n"​);​ 
-    #ifdef __UCLIBC__ 
-    printf("​We are coding against uClibc\n"​);​ 
-    printf("​uClibc v%i %i.%i\n",​__UCLIBC_MAJOR__,​ __UCLIBC_MINOR__,​ __UCLIBC_SUBLEVEL__);​ 
-    #endif 
-    return 0; 
-} 
-</​code>​ 
-The [[https://​www.kernel.org/​doc/​man-pages/​ | Linux man-pages]] project documents the Linux kernel and C library ​ 
-interfaces that are employed by user-space programs. ​ 
-[[http://​man7.org/​linux/​man-pages/​dir_section_2.html | Section 2]] documents the system calls provided by the  
-Linux kernel and [[http://​man7.org/​linux/​man-pages/​dir_section_3.html | section 3]] documents the functions ​ 
-provided by the standard C library. Another reference guide for the C standard library can be found  
-[[https://​www-s.acm.illinois.edu/​webmonkeys/​book/​c_guide/​index.html | here]]. 
- 
-3. Compile it 
-<code bash> 
-powerpc-openwrt-linux-gcc -Wall hello.c -o hello 
-</​code>​ 
- 
-4. Copy it to the router (e.g. via SCP) and run it. 
- 
-==== Example: Compile a program from Source ==== 
-This example shows you how to compile a program from source. The program in this example is [[https://​stedolan.github.io/​jq/​download/​ | jq]] 
- 
-<code bash> 
-wget https://​github.com/​stedolan/​jq/​releases/​download/​jq-1.5/​jq-1.5.tar.gz 
-tar -xzf jq-1.5.tar.gz 
-cd jq-1.5 
-CC=powerpc-openwrt-linux-gcc ./configure --host=powerpc --disable-maintainer-mode 
-make 
-</​code>​ 
- 
-We can now check the file type and we see, that the program has been compiled for PowerPC. Now we can copy ''​jq''​ to NB1600 and run it. 
-<code bash> 
-file jq 
-jq: ELF 32-bit MSB executable, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked (uses shared libs), with unknown capability 0x41000000 = 0x13676e75, with unknown capability 0x10000 = 0xb0402, not stripped 
-</​code>​ 
- 
-===== Oracle Virtual Box Image ===== 
-For small projects or if you don't have a Linux environement you can also use the very small [[ftp://​public:​public@share.netmodule.com/​router/​public/​toolchain/​NetModule_NB_PowerPC_Compile.ova |Virtual Box Image]]. The image uses Tiny Core Linux (http://​tinycorelinux.net/​). Please read the starup message carefully. ​ 
- 
-