c4ev3/ev3duder

.RBF compiling incorrectly?

Closed this issue · 13 comments

Hello there!
I've just been trying to get the hello world app to compile and run on my EV3, but I've run into an issue.

I can compile an .ELF file from Eclipse by building the project (but I have never been able to upload code from eclipse).
After constant trouble with wifi and bluetooth, I've just commit to USB transfer.

Using ev3duder, I've tried compiling the .ELF to an .RBF from Windows and Linux, but neither seem to do it correctly. The program appears in the EV3 menu, but doesn't do anything.
The file sizes vary from systems, but are always much smaller than expected (~30-85 bytes!).
The upload always works though - at least, I see that the file sizes match between the EV3 and my computer :P

It's entirely possible that I'm doing something critically wrong here (for instance, stealing the .ELF from Eclipse), but I'd think it would still work? Should I generate the .ELF differently? Please let me know ;)

a3f commented

Hi,

You don't compile the ELF to RBF, the RBF is a small bootstrapper that is loaded by the LEGO EV3 VM which then calls your ELF executable. This is necessary because ELF files don't show up on the EV3's menu, but RBFs do.

So what you need to do is move both of them to a subdirectory of the SD card, the RBF should show in the menu and you should be able to start it :)

Oh! That makes a lot more sense. Thanks!
However, when I upload the basic "hello world" program:

ev3duder up test.elf ../prjs/BrkProg_SAVE/test
ev3duder mkrbf /home/root/lms2012/BrkProg_SAVE/test test.rbf
ev3duder up test.rbf ../prjs/BrkProg_SAVE/test.rbf
ev3duder run ../prjs/BrkProg_SAVE/test.rbf

the code successfully uploads, but the code still doesn't work (program loads for a bit more than a second, then closes without doing anything).
I also used the Eclipse plugin to upload the code to the SD card, and it does the exact same thing.

I'm not sure if the RBF is wrong, or if the code I'm building is somehow broken :/

a3f commented

Does the hello world example in the Eclipse plugin fails for you as well if you upload it to SD card?

Yes, the code uploaded to the SD card by the Eclipse plugin fails.

Does the upload with eclipse fail in the same way (program is loading on the display for a second and exits) or do you get some kind of error? If so what does it say? Do you get any warnings or errors when compiling the hello world?

Also what problems did you have with bluetooth/wifi upload? Bluetooth might be a little unstable, but wifi should work just fine. If it does not automatically find the ev3 you can specify the ip (see --help).

Okay, I'm going to link a bunch of pictures to help make this easier to understand ;)
So, I've tried doing this on my Windows computer and on a Lubuntu VM.
On both systems, I have Eclipse installed with the plugin, and the code successfully builds.
However, it does say arm-none-linux-gnueabi-g++: unrecognized option '-static-libstdc++' in both logs; could that be the issue?
When I try to upload the code on Windows via the plugin using USB, WiFi, or Bluetooth, the upload gets stuck.
(Also, as a side note, the forms for the eclipse plugin are way too small (Linux and Windows). It may be because of my DPI though, since I'm using 1440p)
So, I decided to try doing it on Linux. Still using the plugin, I'm able to communicate with USB and WiFi (you are right that WiFi works, my bad. When it comes to bluetooth, my Linux VM cannot see my bluetooth devices. I'm not sure about Windows, due to the problem previously mentioned). However, no matter if I want to upload to the SD card or to brick internal storage, it looks for the SD card and fails. Luckily, I managed to find a micro SD card, and upon inserting it, the program successfully uploads.
A little odd, I can successfully "fetch serial over USB", but the plugin refuses to accept it; I can just type the IP though, so it's no big deal.
If I want to install to internal storage, I've been able to use Ev3duder directly, using the code I posted above.
Unfortunately, in every single one of these situations (no matter if I directly use EV3duder or Eclipse plugin, USB or WiFi), the program doesn't run. It just loads.
Hope this helps!

So this looks like you are trying to use the API with C++. If this is the case, it's probably the problem. Using C++ with the API is not really officially supported. The EV3 has no libc++ on its own so it has to be either preloaded and linked dynamically or it has to be statically linked, which seems to be what you are trying to do. Now the problem here is that the EV3 uses an ancient linux kernel and the static libraries provided by the arm gcc are much more recent and therefore not compatible with the old linux kernel on the EV3.
I think the API was primarily designed for the use with C and not C++. Any mention of C++ is more of a should be possible.

That beeing said, there is also the ev3 toolchain project which you could take a look at. Although this is pretty much in alpha maybe pre-alpha state at the moment.

If I correctly assumed that you are trying to use C++ it would be helpful if you could try the same approach with C code instead and tell us if it worked.

Regarding your other points:

The arm-none-linux-gnueabi-g++: unrecognized option '-static-libstdc++' sounds like a fatal error to me and I am not sure why or how it finishes compiling and linking.

The form size is a general issue with high dpi display especially in java I believe.

The plugin checking for the sdcard when uploading to the internal storage might be a bug.

Maybe @a3f has something else to add.

I created C project, and it worked flawlessly :)
However, I still would like to get C++ working, if at all possible.
I downloaded and extracted the Linux release for the ev3 toolchain you linked, but to be honest, I have no idea how to use it. It doesn't seem to have a g++ / gcc compiler? Or am I supposed to compile the toolchain myself? I'm willing to do whatever I need; I just need a little direction :P

a3f commented

It doesn't seem to have a g++ / gcc compiler

Binary releases are at https://github.com/c4ev3/toolchain/releases

Sorry, maybe I didn't make myself clear. I downloaded the Linux binary release from that page, but I don't know how to use it :/
The Windows binary clearly has a /bin folder with the compilers inside, but the Linux one doesn't? Is it somewhere else in the toolchain, or does it not exist?

a3f commented

Oh.. Looks like I uploaded an incomplete tarball...
Well ye, for now, you would either have to either:

  • compile your own toolchain
  • adjust the Eclipse project to not use -static-libstdc++ and upload libstdc++ manually
  • use C

Sorry :/

I would suggest to close this issue since the main point is long resolved and instead take this conversation to Gitter. This would allow for more fluid responses and not trigger the email updates for anyone watching this project.

Alrighty.