c4ev3/EV3-API

Can't exec any program on EV3

Fabcha44 opened this issue · 15 comments

Hi,

I'm trying to use the API but nothing happens when I launch the program from the Brick, or from the ev3duder.

I'm working under Debian Stretch.
The program, test.c :
#include <stdio.h>
#include <stdlib.h>
#include <ev3.h>
int main(void) {
InitEV3 () ;
PlayTone ( SOUND_DOUBLE_BEEP, 500 ) ;
LcdInit() ;
LcdClean() ;
LcdPrintf ( 1, "toto" ) ;
sleep ( 2 ) ;
FreeEV3 () ;
return EXIT_SUCCESS;
}

Compiler config:
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabi/6/lto-wrapper
Target: arm-linux-gnueabi
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-armel-cross/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-armel-cross --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-armel-cross --with-arch-directory=arm --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libgcj --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv4t --with-float=soft --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux- gnueabi --program-prefix=arm-linux-gnueabi- --includedir=/usr/arm-linux-gnueabi/include
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18)

Command used for compiling:
arm-linux-gnueabi-gcc test.c -static-libstdc++ -o test -I../ev3-api/API ../ev3-api/API/libev3api.a
Compiler version:

Commands used to transfer the program to the Brick:
ev3duder up test ../prjs/BrkPrg_SAVE/test
ev3duder mkrbf ../prjs/BrkPrg_SAVE/test test.rbf
ev3duder up test.rbf ../prjs/BrkPrg_SAVE/test.rbf

Despite everything seems fine, nothing happens when I launch the program on my EV3 brick.

Am I missing something?

Regards,
Fabien

My tip would be the GCC version 6, or a combination of too new libc and too old on-brick kernel.
Try using the original CodeSourcery toolchain. Yes, it is quite old, but that's probably the only way to go without building your own toolchain or guessing which cross-compiler build is still compatible.

And you definitely should try linking with -static flag.

Thanks for your answer.
I downloaded the CodeSourcery toolchain but it's not working on Debian 9.
When I invoke the compiler I have the errror : "arm-non-linux-gnueabi-gcc: No such file or directory".
Googling that I read that I had to install ia32-libs.
Package which doesn't exist anymore on Debian, so I installed lib32z1and lib32ncurses5 (apt suggestion), which didn't change anything.

Any clue ?

Thanks,
Fabien

a3f commented

arm-non-linux-gnueabi-gcc

Does the error still persist after fixing the typo?
Is this the toolchain you're using?

Hi yes sorry for that.
And yes I use the toolchain, and I downloaded the libev3api.a from Guthub (https://github.com/c4ev3/EV3-API/blob/c125568da84981daa156da35c1bf6fa0fc737d54/API/libev3api.a).
However, that didn't solve the issue on the Brick.
Command used for compiling:
~/tmp/arm-2009q1/bin/arm-none-linux-gnueabi-gcc test.c -Os -o test -static -I../ev3-api/API ../ev3-api/API/libev3api.a

a3f commented

So compilation succeeds and file is uploaded, a menu entry is shown, but still no output on EV3 LCD?
Could you try connecting the EV3 via USB and run

./ev3duder exec /path/to/your/elf/file

You can use ./ev3duder ls or the EV3 File manager in Eclipse to browse around the EV3 file system.

./ev3duder exec pipes back the standard output of the process over HID, so it might provide a clue why the program crashes on the EV3. If you have a Netgear dongle, you could also try connecting over telnet (or was it ssh? You'd have to google).

a3f commented

Also could you test if at least microSD card works? We had two reports so far that brick storage doesn't work (anymore).

Yes compilation succeeds, menu entry is shown.
I tried with a SD_Card:
ev3duder ls ../prjs/SD_Card/BrkPrg_SAVE/
USB connection established.
00 23 00 00 00 01 99 00 04 2e 2e 2f 70 72 6a 73 2f 53 44 5f 43 61 72 64 2f 42 72 6b 50 72 67 5f 53 41 56 45 2f 00
Checking reply:
EE8E7E4DB7727E466188F3D0F56BB85C 00000048 test.rbf
45361034A998662F3EA68C40A31C7D1B 0009F09D test
../
./
LIST_FILES was successful.

With the SD_Card it's better: when I launch test, either via ev3duder or via EV3 I see that the Brick launch the program.
ev3duder exec ../prjs/SD_Card/BrkPrg_SAVE/test
USB connection established.
exec has been successful.
But I hear no sound, and as the change on the screen doesn't last I'm sure the 'sleep(2)' is not executed.

So I'll try the connection via telnet or ssh.

Thanks for your help.

a3f commented

If you have the right dongle, SSH/Telnet output would be very helpful.

Hi!
After having installed the EV3 firmware developer edition, everything's fine. I can launch the program either via Telnet or via the Brick, using the CodeSourcery toolchain.
Thanks for your help.
Regards,
Fabien

a3f commented

Thanks for the update. I didn't know about the developer firmware. Do ev3duder run or exec work now too?

Actually, it works only through wifi.
The reason seems to be that the transfer via USD is not complete. With an original ELF size of 650691 bytes, the file on the brick is only 649763:
root@EV3:/media/card/BrkPrg_SAVE# ls -l
-rwxr-xr-x 1 root root 649763 Jan 1 00:06 test

When transfered via Wifi (with the USD cable unplug), the size is good.

So, not sure that the problem came from my old firmware...

a3f commented

650691 bytes, the file on the brick is only 649763

Oh, not good. Could you please run:

dd if=/dev/zero of=test count=650691
ev3duder up test ../prjs/BrkPrg_SAVE/test
ev3duder ls ../prjs/BrkPrg_SAVE/

and confirm it prints a different size and whether it's again 649763 (second hex number).

I would like to create a bug report about this, but I don't have an EV3 to reproduce.

OK I have to say I don't understand at all what is happening.
Your test went succesfully (I add bs=1 in the dd command line).
Back to my real program and my script to download it into the brick:
Most of the it works work with thel ELF, and sometimes not, and I can't fund a rule...
Altough, the rbf file is usually not properly downloaded:
On my computer : #ll
[fabien@HPDEB ~/devel/eworkspace/test ]$ ll
total 748
-rwxrwxr-x+ 1 fabien domain users 0 Oct 13 22:23 make.c
-rwxrwxr-x+ 1 fabien domain users 311 Oct 15 10:29 make_test_sdcard.sh
-rwxrwxr-x+ 1 fabien domain users 320 Oct 14 19:02 make_test.sh
-rwxrwxr-x+ 1 fabien domain users 650691 Oct 15 10:30 test
-rwxrwxr-x+ 1 fabien domain users 65872 Oct 7 22:08 test.bin.bak
-rwxrwxr-x+ 1 fabien domain users 454 Oct 14 20:05 test.c
-rwxrwxr-x+ 1 fabien domain users 72 Oct 15 10:30 test.rbf

 **ev3duder up test.rbf ../prjs/SD_Card/BrkPrg_SAVE/test.rbf**
    USB connection established.
    `upload` was successful.
 **ev3duder ls ../prjs/SD_Card/BrkPrg_SAVE**
    USB connection established.
    00 22 00 00 00 01 99 00 04 2e 2e 2f 70 72 6a 73 2f 53 44 5f 43 61 72 64 2f 42 72 6b 50 72 67 5f 53 41 56 45 00 
    Checking reply: 
    D41D8CD98F00B204E9800998ECF8427E 00000000 test.rbf
    0A228D449871F44FDD1AC889F4FA794E 0009EDC3 test

The size of the rbf file is zero!

I add the 'sync' command in my script file between each ev3duder download command, but it change nothing.

I think I will keep working though wifi.

a3f commented

If I recall correctly, rbf files don't show up in the menu if they aren't in the SD card's root?
I have created an issue about the incomplete uploads here: c4ev3/ev3duder#6