|
Post by mwk on Dec 9, 2007 22:53:01 GMT 7
I am interested in learning more about embedded Linux development, and first I would like to learn how to cross compile for N2100. I know I have get the toolchain, but what's the next step? Is there anyone who can write up simple howto for people to follow? Thanks in advance.
|
|
|
Post by shlime on Jan 12, 2008 14:27:54 GMT 7
Hi mwk,
I've been bashing my head against google with the same question. I'm keen to write some code for my new N2100. It'd be great if someone could do a quick how-to.
I think I'm pretty close. I've got cygwin, and the 3.4.3 gnu-arm cross compiler.
I'm doing:
arm-elf-gcc -march=armv5te test.c
where test.c is simply:
int main(void) { return 0; }
I get an a.out which I then run on my thecus through ssh, and all I get is:
Segmentation fault
I've played with a ton of flags and settings (endian, fpu etc), and I always get the same result.
My best guess is that it's something to do with the fpu/vfp settings on my elf or those of the libraries I'm linking with. If I try and flag the compiler to use hardware fpu, I get linker errors.
If I dump the header of the bzip elf that comes with the N2100 utils module, I get this:
$ arm-elf-readelf -h bzip2 ELF Header: Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: ARM ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0x8b1c Start of program headers: 52 (bytes into file) Start of section headers: 80392 (bytes into file) Flags: 0x2, has entry point, GNU EABI Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 6 Size of section headers: 40 (bytes) Number of section headers: 25 Section header string table index: 24
The only difference when I dump my elf is that it mentions software FP.
$ arm-elf-readelf -h a.out ELF Header: Magic: 7f 45 4c 46 01 01 01 61 00 00 00 00 00 00 00 00 Class: ELF32 Data: 2's complement, little endian Version: 1 (current) OS/ABI: ARM ABI Version: 0 Type: EXEC (Executable file) Machine: ARM Version: 0x1 Entry point address: 0x8110 Start of program headers: 52 (bytes into file) Start of section headers: 118332 (bytes into file) Flags: 0x202, has entry point, GNU EABI, software FP Size of this header: 52 (bytes) Size of program headers: 32 (bytes) Number of program headers: 1 Size of section headers: 40 (bytes) Number of section headers: 24 Section header string table index: 21
If anyone could get me over this hump and into the land of running code, I'd be happy to write up a how-to for others.
Cheers.
|
|
|
Post by getmythe on Jan 12, 2008 18:17:28 GMT 7
Setting up a toolchain is not an easy task. You need to start with the same versions of gcc and all the basic libriaries (binutils, libc, ...) as Thecus used. Otherwise your binaries will never be compatible (unless you intend to compile static binaries only).
I would recommend to install Ubuntu and use the existing toolchain from Thecus.
|
|
|
Post by shlime on Jan 13, 2008 13:26:21 GMT 7
I'll give anything a shot I've got Ubuntu 7.10 installed. Can you point me to the right tool chain to download? I haven't seen any 'official' tool chain from Thecus. Is it the one on this site? www.freeside.ch/thecus/I've extracted it into: /usr/local/armv5l but I'm guessing I need to configure some paths or something. If I try and build something it just says there's an installation problem and it can't exec ccl. Thanks.
|
|
|
Post by getmythe on Jan 13, 2008 17:15:01 GMT 7
You got the right toolchain.
Let's now add some important environment variables
export TPREFIX=/opt/local export LINUX=/usr/local/armv5l/3.3.2/armv5l-linux export TOOLBASE=/usr/local/armv5l/3.3.2/bin/armv5l-linux export CC=$TOOLBASE-gcc export CXX=$TOOLBASE-g++ export CPP=$TOOLBASE-cpp export CXXCPP=$CPP export AR=$TOOLBASE-ar export RANLIB=$TOOLBASE-ranlib export STRIP=$TOOLBASE-strip export LDFLAGS="-L$TPREFIX/lib -L$LINUX/lib -L$LINUX/usr/lib" export CFLAGS="-I$TPREFIX/include -I$LINUX/sys-include -I$LINUX/include -I$LINUX/usr/include" export CPPFLAGS="-I$TPREFIX/include -I$LINUX/sys-include -I$LINUX/include -I$LINUX/usr/include" export PKG_CONFIG_PATH=$LINUX/lib/pkgconfig
If you want to compile by hand it makes sense have these two as well (not required when using configure)
# export PATH=/usr/local/armv5l/3.3.2/armv5l-linux/bin:$PATH # export PATH=/usr/local/armv5l/3.3.2/bin:$PATH
... and here is a simple example for you to try out your setup (openvpn)
./configure --target=arm-linux --host=arm-linux --prefix=$TPREFIX \ --sysconfdir=/etc/openvpn --enable-password-save
have fun getmythe
|
|
|
Post by shlime on Jan 14, 2008 18:07:16 GMT 7
Thanks heaps for the help. It feels like I'm close, but still no luck I configured my .bashrc with the exports you listed. At first it couldn't find cc1, so I added: export PATH=/usr/local/armv5l/3.3.2/lib/gcc-lib/armv5l-linux/3.3.2:$PATH and that seemed to fix it. I can now compile and assemble, but it doesn't link. I run 'armv5l-linux-gcc test.c' and I get : ...arm5vl-linux/bin/ld: cannot find libc.so.6 I'm guessing it's trying to find some specific version of the standard libraries or something. A quick search reveals there's no libc.so.6 in the toolchain zip, so I'm not sure what's going on. I tried running the ./configure line you gave me, but it just says unknown command. Is that part of some standard build package I need to get for ubuntu or something? Anyhow, thanks again for your time!
|
|
|
Post by getmythe on Jan 16, 2008 2:47:25 GMT 7
Ok, here are the complete instructions on how to compile the latest openvpn sources from scratch. Configure is a script provided with almost every unix source package. It is generated specifically for that piece of code by the maintainer of the software. It checks that your setup is compatible with the provided sources and generates a makefile which matches your compile setup and your particular linux version. getmythe
|
|