Raspberry PI and Beaglebone Black.

For other topics related to the FreeBASIC project or its community.
BasicCoder2
Posts: 3404
Joined: Jan 01, 2009 7:03

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby BasicCoder2 » Jul 10, 2013 20:22

So can the Raspberry Pi be programmed using FreeBasic?

The popular language for it appears to be Python.

My interest has been around image processing for robots.

http://www.cl.cam.ac.uk/projects/raspbe ... rocessing/
http://www.cl.cam.ac.uk/projects/raspbe ... detection/
http://www.cl.cam.ac.uk/projects/raspbe ... detection/
TJF
Posts: 3486
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby TJF » Jul 11, 2013 12:58

BasicCoder2 wrote:So can the Raspberry Pi be programmed using FreeBasic?

More than 12 hours and no answer, so here's mine: I don't know.

What I did is adapting the fbc-0.90 for ARM, translating it to C code (option -r) and compiling that C source on a BeagleBoard Black (= BBB, ARMv8 Sitara CPU) under Ubuntu12.10. That compiler can be used to translate FB source to C source (on the BBB). But I couldn't manage to get executable binaries form it yet, so I use a gcc call to generate them. The gcc compiled binaries run on the Ubuntu BBB (I didn't test sound yet).

BasicCoder2 wrote:My interest has been around image processing ...

Since I use GDK/cairo or FreeGlut/OpenGl I didn't try fbgfx yet (but D.J.Peters succeded). You may face some color differences: on my BBB there is BGRA instead of RGBA.
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 12, 2013 17:16

I'm sick of back pain when I'm healthy I must first take care of my business.

Joshy
led-bloon
Posts: 33
Joined: Jan 06, 2010 8:16

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby led-bloon » Jul 12, 2013 21:30

.
Ooops, sri should READ the posts before replying...
deleting
lurking led
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 12, 2013 21:59

BasicCoder2 wrote:So can the Raspberry Pi be programmed using FreeBasic?...
PI wrote:pi@pi ~ $ ls -la /usr/bin/fbc
-rwxr-xr-x 1 root root 1858928 Jul 12 23:45 /usr/bin/fbc
pi@pi ~ $ ls -la /usr/lib/freebasic
-rwxr--r-- 1 root root 396 Jul 12 23:34 fbextra.x
-rw-r--r-- 1 root root 1304 Jul 12 23:34 fbrt0.o
-rw-r--r-- 1 root root 707530 Jul 12 22:47 libfb.a
-rw-r--r-- 1 root root 188350 Jul 12 23:04 libfbgfx.a
-rw-r--r-- 1 root root 723388 Jul 12 22:56 libfbmt.a

pi@pi ~ $ fbc -version
FreeBASIC Compiler - Version 0.91.0 (07-12-2013) for linux
Copyright (C) 2004-2013 The FreeBASIC development team.


pi@pi ~ $ cat test01.bas
print "Hello from PI with ARM6!"

pi@pi ~ $ fbc -v -arch arm6 -gen gcc test01.bas
FreeBASIC Compiler - Version 0.91.0 (07-12-2013) for linux
Copyright (C) 2004-2013 The FreeBASIC development team.
compiling: test01.bas -o test01.c (main module)
compiling C: /usr/bin/../bin/gcc -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-main -O0 -frounding-math -fno-math-errno -march=armv6 -mtune=arm1176jzf-s "test01.c" -o "test01.asm"
assembling: /usr/bin/../bin/as "test01.asm" -o "test01.o"
linking: /usr/bin/../bin/ld -o "test01" -dynamic-linker /lib/ld-linux.so.3 "/usr/bin/../lib/freebasic/fbextra.x" -m armelf_linux_eabi -s -L "/usr/bin/../lib/freebasic" -L "." -L "/usr/lib/gcc/arm-linux-gnueabihf/4.6" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crt1.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crti.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/crtbegin.o" "/usr/bin/../lib/freebasic/fbrt0.o" "test01.o" "-(" -lfb -ltinfo -lm -ldl -lpthread -lgcc -lgcc_eh -lc "-)" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/crtend.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crtn.o"

pi@pi ~ $ ls -la ./test01
-rwxr-xr-x 1 pi pi 18391 Jul 12 23:51 ./test01

pi@pi ~ $ ./test01
Hello from PI with ARM6!

pi@pi ~ $
next week more tests (if my pain are gone)

Joshy
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 12, 2013 23:01

Image
Last edited by D.J.Peters on Sep 25, 2017 20:31, edited 1 time in total.
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 13, 2013 3:00

With the help of medication for the pain I removed the assembler X86 code in ir-hlc.bas and got fbRaytracer working on ARM :-)

Joshy
Image
Last edited by D.J.Peters on Sep 25, 2017 20:32, edited 2 times in total.
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 13, 2013 17:52

TJF wrote:Yes, but also with Ubuntu 13.04 I wasted a lot of time. It seems to have some issues in the packages
Same here :-(
TJF wrote:Ubuntu-binaries don't execute on Angström.
Curently i can create on PI debian arm6 and arm7 binaries arm7 is for the BBB should work angstrom too.
fbc -arch arm6 -gen gcc scalefont.bas
fbc -arch arm7 -gen gcc scalefont.bas

TJF wrote:Did you test Debian yet?
I use debian only on the PI "raspbian".

What is the right "stable" distro for the BBB ?
(Angstrom is far far away from stable here)

Joshy

edit:
I tested my fbRaytracer, font_scale, and a highspeed polygon renderer on the PI (debian) compiled with fbc -arm6 ...
that means gcc used -march=armv6 -mtune=arm1176jzf-s -mfpu=vfp

I pluged my usbstick with this PI binaries in the BBB (with armv7-a cortex-a8) and all works without any changes looks like a armv7-a CPU can run all armv6 stuff also.

I was thinking -mtune=arm1176jzf-s will create code only for the PI armv6 chip !

How ever ARM is new for me.

note:
the polygon renderer is faster on the PI with 700MHz. normaly the BBB with 1GHz should be faster !?!
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 14, 2013 2:09

hello TJF and dkl
after many hours i got debian running on the beagle bone black
all works fine net usb xfce4 etc.
but i can't execute binaries build with fbc anymore

note:
test01.bas is only a print "hello word!"
and fbc is build on debian and this binary works !?!

this are the same as on the bbb Angstrom distro
debian wrote:debian@debian-armhf:~$ fbc -version
FreeBASIC Compiler - Version 0.91.0 (07-14-2013) for linux
Copyright (C) 2004-2013 The FreeBASIC development team.
debian@debian-armhf:~$ fbc -v -arch arm7 -gen gcc ./test01.bas
FreeBASIC Compiler - Version 0.91.0 (07-14-2013) for linux
Copyright (C) 2004-2013 The FreeBASIC development team.
compiling: ./test01.bas -o ./test01.c (main module)
compiling C: /usr/bin/../bin/gcc -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-main -O0 -frounding-math -fno-math-errno -march=armv7-a -mtune=cortex-a8 -mfpu=vfp "./test01.c" -o "./test01.asm"
assembling: /usr/bin/../bin/as "./test01.asm" -o "./test01.o"
linking: /usr/bin/../bin/ld -o "./test01" -dynamic-linker /lib/ld-linux.so.3 "/usr/bin/../lib/freebasic/fbextra.x" -m armelf_linux_eabi -s -L "/usr/bin/../lib/freebasic" -L "." -L "/usr/lib/gcc/arm-linux-gnueabihf/4.6" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crt1.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crti.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/crtbegin.o" "/usr/bin/../lib/freebasic/fbrt0.o" "./test01.o" "-(" -lfb -ltinfo -lm -ldl -lpthread -lgcc -lgcc_eh -lc "-)" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/crtend.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crtn.o"
debian@debian-armhf:~$ ls -l ./test01
-rwxr-xr-x 1 debian debian 14630 Jul 14 01:12 ./test01
debian@debian-armhf:~$ ./test01
bash: ./test01: No such file or directory
debian@debian-armhf:~$

i changed a litle bit without success
debian wrote:debian@debian-armhf:~$ fbc -version
FreeBASIC Compiler - Version 0.91.0 (07-14-2013) for linux
Copyright (C) 2004-2013 The FreeBASIC development team.
debian@debian-armhf:~$ fbc -v -arch arm7 -gen gcc ./test01.bas
FreeBASIC Compiler - Version 0.91.0 (07-14-2013) for linux
Copyright (C) 2004-2013 The FreeBASIC development team.
compiling: ./test01.bas -o ./test01.c (main module)
compiling C: /usr/bin/../bin/gcc -S -nostdlib -nostdinc -Wall -Wno-unused-label -Wno-unused-function -Wno-unused-variable -Wno-main -Werror-implicit-function-declaration -O0 -fno-strict-aliasing -frounding-math -fno-math-errno -march=armv7-a -mtune=cortex-a8 -mfpu=vfp "./test01.c" -o "./test01.asm"
assembling: /usr/bin/../bin/as "./test01.asm" -o "./test01.o"
linking: /usr/bin/../bin/ld -o "./test01" -dynamic-linker /lib/ld-linux.so.2 "/usr/bin/../lib/freebasic/fbextra.x" -m armelf_linux_eabi -s -L "/usr/bin/../lib/freebasic" -L "." -L "/usr/lib/gcc/arm-linux-gnueabihf/4.6" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crt1.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crti.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/crtbegin.o" "/usr/bin/../lib/freebasic/fbrt0.o" "./test01.o" "-(" -lfb -ltinfo -lm -ldl -lsupc++ -lpthread -lgcc -lgcc_eh -lc "-)" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/crtend.o" "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../arm-linux-gnueabihf/crtn.o"
debian@debian-armhf:~$ ls -l ./test01
-rwxr-xr-x 1 debian debian 14630 Jul 14 01:49 ./test01
debian@debian-armhf:~$ ./test01
bash: ./test01: No such file or directory
debian@debian-armhf:~$
I don`t know whats going wrong :-(
gdb can`t load the test01 binary

first i was thinking debian-armhf is a nother ABI as on Angstrom or on debian on the PI
but this can`t be fbc self works

any idea what it is ?

Joshy
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 14, 2013 2:23

What is the right command on linux to research an ELF binary ?

Joshy
dkl
Site Admin
Posts: 3210
Joined: Jul 28, 2005 14:45
Location: Germany

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby dkl » Jul 14, 2013 2:39

file and objdump commands should be useful. I'd also try comparing gcc's link commands with the one used by fbc, maybe there are differences?
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 14, 2013 5:31

dkl wrote:file and objdump commands should be useful.
I found a problem on Angstrom the file has 26 sections on debian 24
on debian ctor and dtor are missing

do you know what makes this diffrence

thank you

Joshy
angstrom wrote:sh-4.2# objdump -h testangstrom

testangstrom: file format elf32-littlearm

Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 00008134 00008134 00000134 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.ABI-tag 00000020 00008148 00008148 00000148 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .hash 00000238 00008168 00008168 00000168 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynsym 00000490 000083a0 000083a0 000003a0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .dynstr 000002ca 00008830 00008830 00000830 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .gnu.version 00000092 00008afa 00008afa 00000afa 2**1
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .gnu.version_r 00000040 00008b8c 00008b8c 00000b8c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .rel.dyn 00000040 00008bcc 00008bcc 00000bcc 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .rel.plt 000001a8 00008c0c 00008c0c 00000c0c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .init 0000000c 00008db4 00008db4 00000db4 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
10 .plt 00000290 00008dc0 00008dc0 00000dc0 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
11 .text 00002648 00009050 00009050 00001050 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .fini 00000008 0000b698 0000b698 00003698 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .rodata 000002ac 0000b6a0 0000b6a0 000036a0 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
14 .ARM.exidx 00000008 0000b94c 0000b94c 0000394c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
15 .eh_frame 00000004 0000b954 0000b954 00003954 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
16 .init_array 00000004 00014000 00014000 00004000 2**2
CONTENTS, ALLOC, LOAD, DATA
17 .fini_array 00000004 00014004 00014004 00004004 2**2
CONTENTS, ALLOC, LOAD, DATA
18 .ctors 00000004 00014008 00014008 00004008 2**2
CONTENTS, ALLOC, LOAD, DATA
19 .dtors 00000004 0001400c 0001400c 0000400c 2**2
CONTENTS, ALLOC, LOAD, DATA

20 .jcr 00000004 00014010 00014010 00004010 2**2
CONTENTS, ALLOC, LOAD, DATA
21 .dynamic 00000108 00014014 00014014 00004014 2**2
CONTENTS, ALLOC, LOAD, DATA
22 .got 000000e4 0001411c 0001411c 0000411c 2**2
CONTENTS, ALLOC, LOAD, DATA
23 .data 00000010 00014200 00014200 00004200 2**2
CONTENTS, ALLOC, LOAD, DATA
24 .bss 00005ba0 00014210 00014210 00004210 2**3
ALLOC
25 .comment 00000077 00000000 00000000 00004210 2**0
CONTENTS, READONLY
26 .ARM.attributes 00000037 00000000 00000000 00004287 2**0
CONTENTS, READONLY

debian wrote:sh-4.2# objdump -h testdebian

testdebian: file format elf32-littlearm

Sections:
Idx Name Size VMA LMA File off Algn
0 .interp 00000013 00008134 00008134 00000134 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .note.ABI-tag 00000020 00008148 00008148 00000148 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .hash 00000230 00008168 00008168 00000168 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
3 .dynsym 00000470 00008398 00008398 00000398 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .dynstr 00000294 00008808 00008808 00000808 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .gnu.version 0000008e 00008a9c 00008a9c 00000a9c 2**1
CONTENTS, ALLOC, LOAD, READONLY, DATA
6 .gnu.version_r 00000040 00008b2c 00008b2c 00000b2c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
7 .rel.dyn 00000040 00008b6c 00008b6c 00000b6c 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
8 .rel.plt 000001a8 00008bac 00008bac 00000bac 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
9 .init 0000000a 00008d54 00008d54 00000d54 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
10 .plt 000002bc 00008d60 00008d60 00000d60 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
11 .text 00001b9c 00009020 00009020 00001020 2**3
CONTENTS, ALLOC, LOAD, READONLY, CODE
12 .fini 00000006 0000abbc 0000abbc 00002bbc 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
13 .rodata 000002ac 0000abc4 0000abc4 00002bc4 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
14 .ARM.exidx 00000008 0000ae70 0000ae70 00002e70 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
15 .eh_frame 00000004 0000ae78 0000ae78 00002e78 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
16 .init_array 00000008 00013000 00013000 00003000 2**2
CONTENTS, ALLOC, LOAD, DATA
17 .fini_array 00000008 00013008 00013008 00003008 2**2
CONTENTS, ALLOC, LOAD, DATA
18 .jcr 00000004 00013010 00013010 00003010 2**2
CONTENTS, ALLOC, LOAD, DATA
19 .dynamic 00000108 00013014 00013014 00003014 2**2
CONTENTS, ALLOC, LOAD, DATA
20 .got 000000e4 0001311c 0001311c 0000311c 2**2
CONTENTS, ALLOC, LOAD, DATA
21 .data 00000010 00013200 00013200 00003200 2**2
CONTENTS, ALLOC, LOAD, DATA
22 .bss 00005ba0 00013210 00013210 00003210 2**3
ALLOC
23 .comment 0000003a 00000000 00000000 00003210 2**0
CONTENTS, READONLY
24 .ARM.attributes 00000035 00000000 00000000 0000324a 2**0
CONTENTS, READONLY
marcov
Posts: 2797
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby marcov » Jul 14, 2013 11:20

D.J.Peters wrote:What is the right command on linux to research an ELF binary ?


First do a quick "file" and "ldd". Then progress to elfdump and objdump.

Stopping before linking and comparing the state between compiling and linking for (1) the FB generated cmdline (2) a normal cmdline compile. could be telling.

If there is an elf-ident section, make sure to check. The loader might decide not to try at all depending on the architecture fields.
(ABI often folds in stuff as required copro)

Btw are you sure it should be vfp for such new processor?
dkl
Site Admin
Posts: 3210
Joined: Jul 28, 2005 14:45
Location: Germany

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby dkl » Jul 14, 2013 15:18

If .ctors and .dtors section are missing then perhaps they're not supported on the platform and missing from the linkers ldscript (can be seen with ld --verbose). That could cause problems with rtlib initialization, but I don't see how it could affect the system's ability to run the executable.

Maybe it needs to use another dynamic linker, like /lib/ld-linux-armhf.so.3 (I found that via Google), instead of /lib/ld-linux.so.{2,3}? What ld.so's exist on the system where it doesn't work, any differences to the one where it works?

Checking ldd output is a good idea too, maybe there's an .so missing (e.g. libncurses?) or named differently.
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Re: I got my brand new toys. (ARM Linux new target for fbc)

Postby D.J.Peters » Jul 14, 2013 23:08

Thank you speedfixer and dkl.
I made an mistake in my build files (build_bbb_debian.sh, build_bbb_angstrom.sh, build_pi_debian.sh ...)
I used different flags to buld the runtime libs and the compiler self.
Maybe my pain are the primary point.

Now the fbc user must select only the cpu type -arch arm6 or -march arm7
all other flags will be selected by gcc/as/ld self (-gen gcc)

Again thank you

Joshy

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 0 guests