EP9302 - Can't run my compiled code

Hi everybody, I’m experiencing a problem on running my apps on a CS-EP9302 board from Olimex:

I downloaded the toolchain from the ARM manifacturer’s website (Cirrus), it’s the package named arm-linux-gcc-4.1.1-920t.tar.bz2; I’ve expanded the compressed file in my /usr/local directory (on a Fedora system) and used it to compile a simple test program containing only of a printf instruction that should send me a feedback over the serial connection (I’m presuming it’s the stdout). At compile time i’ve got everything working, but when I try to launch the program on the board I obtain the following output:

~ # tftp -g -r test 192.168.1.1

~ # mv test /usr/bin

~ # cd usr/bin

/usr/bin # chmod +x test

/usr/bin # ./test

./test: ./test: 1: ELF: not found

./test: ./test: 2: Syntax error: “)” unexpected

Some characters cannot be copied from the clipboard, near the ‘ELF’ word there are some ascii symbols, something like b/w smiling faces.

Does anybody know why I get this??

This is the source code:

#include <stdio.h>

int main() {

printf(“Hello world! =)\n”);

return 0;

}

You have unbalanced parentheses in the printf statement. There is one left parentheses and two right parentheses.

Fix that and you’re good to go.

Cheers,

Jim Lynch

Does that board run linux ? that error message looks like it is unable to execute the elf file, also make sure to give tftp the option for binary files tranfer (-i ? i am not sure).

Hi everybody, thank you for your replies.

The board we’re talking about is an Olimex CS-E9302, with a Cirrus EP9302 ARM9 processor and shipped with Linux (kernel 2.6).

I’m trying all the toolchains I can find over the net, but I still can’t see my code running…

In linux environment, I’m trying the gcc compiler available on Cirrus website (4.1.1), while on Windows Vista I’m using GNUARM with Cygwin. I modified the app’s source to avoid the double bracket, even if think it wasn’t a mistake since it’s included in the string between the two “”. Now the code look like this:


#include <stdio.h>
int main() {
printf(“Hello world!\n”);
return 0;
}
[/i]
I’ve compiled this code both on linux and on Vista with the toolchains mentioned above. Unfortunately there is no option in the embedded version of tftp for binary file transfer, as the server resides in the pc and I only get the file from the board; following is the output of the executable when called without parameters:

~ # tftp
BusyBox v1.1.3 (2006.08.22-13:03+0000) multi-call binary
Usage: tftp [OPTION]… HOST [PORT]
Options:
-l FILE Local FILE
-r FILE Remote FILE
-g Get file
-p Put file
-b SIZE Transfer blocks of SIZE octets
[/i]
Anyway, I get the compiled file on my 9302 board (there are no warnings and/or errors at compile time in both platforms); if I launch the executable compiled in Vista I get the following output:

/usr/bin # chmod +x test
/usr/bin # ./test
Illegal instruction
/usr/bin #
[/i]
This is the output of the file compiled in linux (excluding characters I cannot paste like that sort of smiling faces near ELF):

/usr/bin # chmod +x test
/usr/bin # ./test
./test: ./test: 1: ELF: not found
./test: ./test: 2: ˜: not found
./test: ./test: 2: À: not found
./test: ./test: 2: : not found
./test: ./test: 2: HƒèsèòèÍHƒÃ 5²: not found
./test: ./test: 2: HÁøH

The bracket was not a problem of course.

I think the problem may be that the tftp defaults in text mode, is the file size exactly the same after tranfer ?

You may try to tranfer to the linux board and then tranfer it back and then compare the files. This should rule out one possible problem.

About the file size, it is possible that the program compiled on linux links to shared libraries while the gnuarm version uses the static libraries. You should also verify if the libraries provided with gnuarm are meant to produce Linux executables (using Linux syscalls).

A question, does the board have a compiler on its file system or you are cross-compiling on a Linux PC ?

Hello gdisirio, thank you for your help. I took a look at those things you mentioned in your last post:

  • - it seems that tftp on the target board works fine; if I transfer back the downloaded executable to the server and compare it with the original copy there’re no differences in file size and even in the content (viewed with notepad)
  • - I searched for gcc in the board filesystem, it seems it’s not included in the distribution. I assumed I had to install the programming environment in my pc for cross-compiling, at least I’m sure about this for what concerns ARGNU with Cygwin (it needs Win32).
  • - I tried calling syscalls in the embedded system, but it’s not there too (-sh: syscalls: not found). Anyway, I’m quite sure that the only way to produce executables for embedded versions of windows (CE, mobile) is by using Visual Studio, as I had to do when I rewrote the keypad for sms on my touchscreen phone with win Mobile. This is why I think GNUARM is ok, additionaly (if I understood what I saw) it works in congiunction with cygwin to recreate a linux-style environment.
  • I’m also considering the possibility of rebuilding a toolchain downloading single components and trying to make them work, but I’m new to linux programming and I’m a little bit reluctant about it.

    Finally I will need a vacation on a tropical island to relax after all this brainstorming… :lol:

    I finally solved the problem, at least in linux environment. :smiley:

    I tried compiling a ‘Hello world’ app using standard gcc (not cross-compiling), I had an executable running on pc linux. I’ve put this file in the board file system and launched it, I had exactly the same output as when I tried to cross-compile the source. I thought gcc was using the wrong include and header files, so I specified the correct path with -I and -L options. Now everything seems to work fine and even if I still can’t compile my source within Windows I can work on my board. :twisted:

    Hydro:
    I finally solved the problem, at least in linux environment. :smiley:

    I tried compiling a ‘Hello world’ app using standard gcc (not cross-compiling), I had an executable running on pc linux. I’ve put this file in the board file system and launched it, I had exactly the same output as when I tried to cross-compile the source. I thought gcc was using the wrong include and header files, so I specified the correct path with -I and -L options. Now everything seems to work fine and even if I still can’t compile my source within Windows I can work on my board. :twisted:

    Hello Hydro,

    I am experiencing the same problems. Which cross compiler did you finally use and can you give me as an example what you typed on the command line with all parameters?

    Thanks!

    Carlo

    Cygwin! shudders