Loading the .out file (executable file) on to BBB and running

282 views
Skip to first unread message

Megha Bhirade

unread,
Jul 8, 2019, 12:09:23 AM7/8/19
to BeagleBoard
Hi,

I am using beagle bone black board in Linux Ubuntu distribution..my requirement is i need to write simple code on terminal(filename.c) using processor SDK i need to compile it and need to create .out file for the code and after that i need to load that .out(binary file-executable ) file on to beagle bone black board and make it to work on board and get output on terminal...

I am not getting how to do it... how to create  . out file and load into board...

please help me to resolve it??? i am new to this board..

Dennis Lee Bieber

unread,
Jul 8, 2019, 12:36:24 PM7/8/19
to beagl...@googlegroups.com
On Sun, 7 Jul 2019 21:09:23 -0700 (PDT), Megha Bhirade
<meghsb...@gmail.com> declaimed the
following:
For simple stuff, you would probably find it faster to actually do the
building ON the BBB, using the ARM native GCC.

-=-=-=-
debian@beaglebone:~$ vim demo.c
debian@beaglebone:~$ cat demo.c
#include <stdio.h>

void main(int argc, char * argv[])
{
printf("\n\n\t\tHelp me!\n\n\n");
}
debian@beaglebone:~$ gcc -o demo demo.c
debian@beaglebone:~$ ./demo


Help me!


debian@beaglebone:~$
-=-=-=-

If I interpret your description, you are trying to do the builds ON a
different machine, with a different native architecture. To take the result
of such a build will require using a cross-compiler toolchain.

I'm afraid I can't really help setting up such. The closest I have is
the ARM-ELF toolchain for GNAT (Ada) on Win10. I'm getting a linker failure
as I don't have a crt0.o library (I suspect that library has to be
customized for each target board). "Code Composer Studio 9" does have a
configuration for BBB, but it is, I'm fairly certain, meant to be a "bare
board" build, not something running under Linux (I got an "illegal
instruction" trying to run the test program).

-=-=-=-
debian@beaglebone:~$ ls -l
total 124
-rw-r--r-- 1 debian debian 94852 Jul 8 12:14 BBB_test.out
drwxr-xr-x 2 debian debian 4096 Jun 17 2018 bin
-rwxr-xr-x 1 debian debian 8340 Jul 8 11:47 demo
-rw-r--r-- 1 debian debian 94 Jul 8 11:47 demo.c
-rw-r--r-- 1 debian debian 325 Jan 30 17:03 pwm.py
-rw-r--r-- 1 debian debian 620 Jan 30 17:20 sqwave.py
debian@beaglebone:~$ chmod ugo+x BBB_test.out
debian@beaglebone:~$ ./BBB_test.out
Illegal instruction
debian@beaglebone:~$
-=-=-=-


Chapter 7 of "Exploring Beaglebone 2nd Edition" (D. Molloy, 2019 John
Wiley & Sons) is all about setting up a cross-compilation suite -- the book
recommends using Debian 9 (or later) either as a stand-alone Linux machine
or via a virtual machine (discussed in chapter 3). The first part of the
chapter is command-line toolchain. The later part covers installing Eclipse
for cross-compiling.

{I should probably see about setting that up myself -- though I also should
see about setting up Buster (Debian 10) in VirtualBox first; I do have
Stretch in VirtualBox already}


--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/

Jim F

unread,
Jul 8, 2019, 1:22:14 PM7/8/19
to beagl...@googlegroups.com
Dennis,

I'm afraid I'm taking this a bit off topic, but part of your answer tantalized me:

...I also should see about setting up Buster (Debian 10) in VirtualBox first; I do have Stretch in VirtualBox already...

I'm pretty sure you don't mean what I hope you mean, but do you have a Beaglebone VM environment set up? Or are you just referring to having the current version of x86/64/standard desktop Debian VM running under Virtualbox?

I know there have been efforts in the past to emulate the old beagleboard devices under qemu but I would be thrilled to be able to run a modern emulated am335x in any desktop environment. I looked into bringing that back up to date but it was about 3 steps outside of the actual tasks I need to work on and simply not worthwhile to do so.

Back on topic, as to Megha's question, there are some details about cross-compiling here which have been useful to me in the past, though now to ensure all the pieces end up in the correct places I have stayed with compiling directly on the machine.

Best regards,


--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/qoo6ietir36sm578i1mrhhah4kpb65hbfp%404ax.com.
For more options, visit https://groups.google.com/d/optout.

Dennis Lee Bieber

unread,
Jul 8, 2019, 2:07:33 PM7/8/19
to beagl...@googlegroups.com
On Mon, 8 Jul 2019 13:21:43 -0400, Jim F
<jimf...@gmail.com> declaimed the following:


>
>I'm pretty sure you don't mean what I hope you mean, but do you have a
>Beaglebone VM environment set up? Or are you just referring to having the
>current version of x86/64/standard desktop Debian VM running under
>Virtualbox?
>
No -- just the Intel compatible OS.

And I'm afraid Molloy 2nd Ed may already be dated -- I'm not finding
the cross-build toolchain in Debian Stretch. No idea if the section on
setting up QEMU is still valid either.

wulfraed@stretch:~$ apt-cache search cross-build-essential
wulfraed@stretch:~$ apt-cache search crossbuild-essential
wulfraed@stretch:~$ apt-cache search armhf
wulfraed@stretch:~$

Dennis Lee Bieber

unread,
Jul 8, 2019, 2:41:03 PM7/8/19
to beagl...@googlegroups.com
o/~ talking to myself in public o/~

On Mon, 08 Jul 2019 14:07:15 -0400, Dennis Lee Bieber
<wlf...@ix.netcom.com> declaimed the following:


> And I'm afraid Molloy 2nd Ed may already be dated -- I'm not finding
>the cross-build toolchain in Debian Stretch. No idea if the section on
>setting up QEMU is still valid either.
>
>wulfraed@stretch:~$ apt-cache search cross-build-essential
>wulfraed@stretch:~$ apt-cache search crossbuild-essential
>wulfraed@stretch:~$ apt-cache search armhf
>wulfraed@stretch:~$
>

Mea culpa...

Appears, since I'd installed Stretch from DVDs, it had never looked at
the online "main" repository. Just added that to the source list and after
an apt-get update the cross build stuff is showing up in a search.

So I am proceeding on the basis that Molloy 2nd Ed IS VALID.

Dennis Lee Bieber

unread,
Jul 8, 2019, 3:09:43 PM7/8/19
to beagl...@googlegroups.com
On Mon, 08 Jul 2019 14:07:15 -0400, Dennis Lee Bieber
<wlf...@ix.netcom.com> declaimed the following:


And... success...

-=-=-=-
wulfraed@stretch:~$ sudo apt install crossbuild-essential-armhf
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
binutils-arm-linux-gnueabihf cpp-6-arm-linux-gnueabihf
cpp-arm-linux-gnueabihf cross-config dpkg-cross g++-6-arm-linux-gnueabihf
<SNIP>
libtool flex bison gdb-arm-linux-gnueabihf gcc-doc
The following packages will be REMOVED:
g++-multilib gcc-multilib
The following NEW packages will be installed:
binutils-arm-linux-gnueabihf cpp-6-arm-linux-gnueabihf
<SNIP>
libubsan0-armhf-cross libxml-simple-perl linux-libc-dev-armhf-cross
0 upgraded, 27 newly installed, 2 to remove and 26 not upgraded.
Need to get 29.1 MB/29.2 MB of archives.
After this operation, 101 MB of additional disk space will be used.
Do you want to continue? [Y/n]
Media change: please insert the disc labeled
'Debian GNU/Linux 9.1.0 _Stretch_ - Official amd64 DVD Binary-1
20170722-11:31'
<SNIP>
arm-linux-gnueabihf-gcc-ranlib

wulfraed@stretch:~$ arm-linux-gnueabihf-g++ -v
Using built-in specs.
COLLECT_GCC=arm-linux-gnueabihf-g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc-cross/arm-linux-gnueabihf/6/lto-wrapper
Target: arm-linux-gnueabihf
<SNIP>
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18)

wulfraed@stretch:~$ vim testcross.cpp

wulfraed@stretch:~$ cat testcross.cpp
#include <iostream>
using namespace std;

int main()
{
cout << "Testing cross compilation for armhf" << endl;
return 0;
}

wulfraed@stretch:~$ arm-linux-gnueabihf-g++ testcross.cpp -o testcross

wulfraed@stretch:~$ ls -l
total 360
<SNIP>
-rwxr-xr-x 1 wulfraed wulfraed 9184 Jul 8 14:51 testcross
-rw-r--r-- 1 wulfraed wulfraed 125 Jul 8 14:50 testcross.cpp
drwxr-xr-x 2 wulfraed wulfraed 4096 Sep 10 2017 Videos

wulfraed@stretch:~$ ./testcross
bash: ./testcross: cannot execute binary file: Exec format error

wulfraed@stretch:~$ sftp debian@beaglebone
debian@beaglebone's password:
Connected to beaglebone.
sftp> put testcross
Uploading testcross to /home/debian/testcross
testcross 100% 9184 1.1MB/s 00:00
sftp> quit

wulfraed@stretch:~$
-=-=-=-
debian@beaglebone:~$ ls -l
total 136
-rwxr-xr-x 1 debian debian 94852 Jul 8 12:14 BBB_test.out
drwxr-xr-x 2 debian debian 4096 Jun 17 2018 bin
-rwxr-xr-x 1 debian debian 8340 Jul 8 11:47 demo
-rw-r--r-- 1 debian debian 94 Jul 8 11:47 demo.c
-rw-r--r-- 1 debian debian 325 Jan 30 17:03 pwm.py
-rw-r--r-- 1 debian debian 620 Jan 30 17:20 sqwave.py
-rwxr-xr-x 1 debian debian 9184 Jul 8 14:55 testcross
debian@beaglebone:~$ ./testcross
Testing cross compilation for armhf
debian@beaglebone:~$
-=-=-=-

So... for the OP... You are now reliant upon Ubuntu having duplicated
the Debian cross-compilation build tools so you can install them easily.
(What is this love affair with Ubuntu -- especially when the target boards
[Beagle and R-Pi's both] are often based upon Debian; just seems like
working with a Debian image on a desktop minimizes quirks when moving from
one system to another).

Megha Bhirade

unread,
Jul 11, 2019, 7:42:28 AM7/11/19
to BeagleBoard


Hi jim,

from the processer SDK i can get GCC compiler only, can i compile the simple code printing hello word on terminal using GCC compiler and execute the file ??

Ex : vi test.c(simple hello world program).
gcc test.c -o test.o
./test.o
like this once i login to beagle bone black???
Reply all
Reply to author
Forward
0 new messages