Raspberry PI and Beaglebone Black.
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
I couldn't find a way to get FB's rounding behaviour by using just a cast, how did you do it?
fbc -gen gcc has always been using -fno-math-errno, though I never knew why... my plan also was to use CRT rounding functions, preferrably gcc __builtin_*()s assuming they'd have a better chance at producing ASM instead of function calls.
If I remember correctly, I tested rounding functions instead of x86 ASM but gcc wouldn't inline them even with -O2, so I didn't change anything because it would hurt performance greatly.
--
GCC doesn't support naked functions on x86, so it was necessary to use inline asm for them. For ARM it seems like gcc supports __attribute__((naked)) though, so that could be useful.
If the rtlib initialization/clean up code isn't working properly, that would explain the issue DJPeters observed again.
fbc -gen gcc has always been using -fno-math-errno, though I never knew why... my plan also was to use CRT rounding functions, preferrably gcc __builtin_*()s assuming they'd have a better chance at producing ASM instead of function calls.
If I remember correctly, I tested rounding functions instead of x86 ASM but gcc wouldn't inline them even with -O2, so I didn't change anything because it would hurt performance greatly.
--
GCC doesn't support naked functions on x86, so it was necessary to use inline asm for them. For ARM it seems like gcc supports __attribute__((naked)) though, so that could be useful.
If the rtlib initialization/clean up code isn't working properly, that would explain the issue DJPeters observed again.
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
I'm pretty sure there is no cast that produces the desired rounding; he means he hacked around it.
Oh great, problem solved then?dkl wrote:fbc -gen gcc has always been using -fno-math-errno, though I never knew why...
You are right. Trying it out just now, I found that although lrint and __builtin_lrint are never inlined if -fno-math-errno is not specified, and are otherwise always inlined if -O2 are specified, the difference between the two is that __builtin_lrint will be inlined even with -O0.dkl wrote:my plan also was to use CRT rounding functions, preferrably gcc __builtin_*()s assuming they'd have a better chance at producing ASM instead of function calls.
Re: I got my brand new toys. (ARM Linux new target for fbc)
Thats great to hear! I have been hoping for someone(with the knowledge) to start a Android port of FreeBasic. The last week I started to try myself, but I haven't really made much more progress then installing the SDK, NDK and reading articles/tutorials on running C/C++ code(on Android). I think an Android port of FB would be a big boost for those who use FB for game making. And I don't think theres a need to be able to run the FB compiler on the Android platform, only to be able to cross compile from Windows or Linux.TeeEmCee wrote:And before that I successfully crosscompiled the OHRRPCE to Android:
http://lists.motherhamster.org/pipermai ... 16456.html
My approach has been to use a crosscompiling toolchain, partially because I didn't realise that -gen gcc was stable enough to compile fbc itself. I'm also using SDL instead of libfbgfx.
I don't think I'll be able to make any FB port myself(I don't have any experience with Java, C/C++ or the FB compiler), but I maybe able to help out with small fixes and testing. Do you feel like sharing your Android port?
Re: I got my brand new toys. (ARM Linux new target for fbc)
I meant that we didn't consider compiling fbc on ARM GNU/Linux. Compiling it for Android is senseless because it's missing everything. I couldn't find a single piece of GNU software on my Android phone. It's the best reason for writing "GNU/Linux" instead of "Linux" that there is.
On that note, I believe that the __FB_LINUX__ macro should not be defined on Android, because I think it's used to mean GNU/Linux and not "an OS based on the Linux kernel".
I don't know how fbc can ever provide an easy way to produce an Android app without you having to do half the work mucking around with external frameworks, build scripts, the NDK, and app configuration like providing your own signing key. Maybe fbgfx could take care of half of that...
*Well actually this page on a pre-NDK port of SDL suggests it's possible to create commandline programs which can access the framebuffer too!
On that note, I believe that the __FB_LINUX__ macro should not be defined on Android, because I think it's used to mean GNU/Linux and not "an OS based on the Linux kernel".
All sourcecode and detailed instructions are available. I don't think there's much point in me uploading an Android crosscompiling build, because it can only directly produce Android commandline programs. If you want to produce apps it is necessary* to use some framework like SDL that includes all the necessary Java code, and then you'll need to grab the FB source and compile libfb and link it into the dynamic library containing your program, probably using an Android.mk script. Have a look at the detailed instructions on the wiki, linked from that mailinglist post (but note that most of the instructions are specific to the SDL port we are using, which has built up its own build system).Jonge wrote:I don't think I'll be able to make any FB port myself(I don't have any experience with Java, C/C++ or the FB compiler), but I maybe able to help out with small fixes and testing. Do you feel like sharing your Android port?
I don't know how fbc can ever provide an easy way to produce an Android app without you having to do half the work mucking around with external frameworks, build scripts, the NDK, and app configuration like providing your own signing key. Maybe fbgfx could take care of half of that...
*Well actually this page on a pre-NDK port of SDL suggests it's possible to create commandline programs which can access the framebuffer too!
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
I see you have shared all your work already =) I didn't know about your site, thanks. QB64 will(I have read) make a project that you can use in Eclipse, which sounds like an OK solution to me. Then you can use Eclipse to manage all the project details, testing/debugging and packaging.
-
- Posts: 8629
- Joined: May 28, 2005 3:28
- Contact:
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
I got fbSound running on PI and BBB, of course no screenshot to day :-)
Joshy
Joshy
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
Ah, OK. Also, by using SDL 2, which has proper Android support built in, instead of the port of SDL 1.2 that I'm currently using, which has a very messy build system and some stuff you probably don't want for a "real" port, things should be a lot simpler. dkl suggested that an SDL driver be written for libfbgfx. So I guess it could work out.
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
I didn't do it, it wasn't the target.dkl wrote:I couldn't find a way to get FB's rounding behaviour by using just a cast, how did you do it?
Remember the discussion we had about FB's rounding? Nobody said keep it as it is. But experienced programmers said: 'find a way to get rid of it'. This again is a time to think about 'the desired rounding'.
Re: I got my brand new toys. (ARM Linux new target for fbc)
It should be ok to use GCC's __attribute__((__constructor__(priority))) now, especially for a new target. I think when the fbrt0.c code was originally written, GCC didn't support the priority argument yet. It was only added in GCC 4.3.0. On top of that I think that FB had to work with GCC 3.4.5 for a longer time, since MinGW didn't have GCC 4.TeeEmCee wrote:Do you know why the rtlib is concerned with these ABI internals instead of just using the GCC __attribute__((__constructor__(priority))) and __attribute__((__destructor__(priority))) attributes?
-
- Posts: 8629
- Joined: May 28, 2005 3:28
- Contact:
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
How about a -arch XXX depended assembler file *.s for -gen gas and -gen gcc ?
FreeBASIC can emit macros for rounding and casting and put an *.s file to gas or gcc.
I mean
386.s, 486.s, 586.s, ...
or
x86.s, x86_64.s
and
arm.s, arm6.s, arm7.s, ...
Here are what I'm test for ARM CPU's with FreeBASIC.
note the const 96 is 0.5 in IEEE 754 standard .
Joshy
arm.sconvert.bi for -gen gas
convert.h for -gen gcc
FreeBASIC can emit macros for rounding and casting and put an *.s file to gas or gcc.
I mean
386.s, 486.s, 586.s, ...
or
x86.s, x86_64.s
and
arm.s, arm6.s, arm7.s, ...
Here are what I'm test for ARM CPU's with FreeBASIC.
note the const 96 is 0.5 in IEEE 754 standard .
Joshy
arm.s
Code: Select all
.global __itof
.type __itof, %function
/* ... cut ... */
.text
.align 4
__itof: /* f32 = (float) i32 */
fmsr s1, r0
fsitos s0, s1
bx lr
.align 4
itod: /* d64 = (double) i32 */
fmsr s2, r0
fsitod d0, s2
bx lr
.align 4
__ftoi: /* i32 = (int) f32 */
fconsts s1, #96
fadds s0, s0, s1
ftosizs s1, s0
fmrs r0, s1
bx lr
.align 4
__dtoi: /* i32 = (int) d64 */
fconstd d1, #96
faddd d0, d0, d1
ftosizd s2, d0
fmrs r0, s2
bx lr
.align 4
__ftod: /* d64 = (double) f32 */
fcvtds d1, s0
fcpyd d0, d1
bx lr
.align 4
__dtof: /* f32 = (float) d64 */
fcvtsd s2, d0
fcpys s0, s2
bx lr
convert.h for -gen gcc
Code: Select all
extern float __itof(int);
extern double __itod(int);
extern int __ftoi(float);
extern int __dtoi(double);
extern double __ftod(float);
extern float __dtof(double);
-
- Posts: 8629
- Joined: May 28, 2005 3:28
- Contact:
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
Last edited by D.J.Peters on Sep 25, 2017 20:24, edited 1 time in total.
-
- Posts: 8629
- Joined: May 28, 2005 3:28
- Contact:
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
I got it all to day :-)
FreeBasic curent 0.91.0 on Beaglebone Black and Raspberry PI
Tested on Arch Linux, Debian, Ubuntu, Rasbian, Angstrom
1920 x 1080 FreeBASIC 0.91.0 (preview) on Beaglebone Black Angstrom Linux:

FreeBasic curent 0.91.0 on Beaglebone Black and Raspberry PI
Tested on Arch Linux, Debian, Ubuntu, Rasbian, Angstrom
1920 x 1080 FreeBASIC 0.91.0 (preview) on Beaglebone Black Angstrom Linux:

Last edited by D.J.Peters on May 05, 2018 0:23, edited 3 times in total.
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
That is just amazing FB team. I am excited about ARM7 development now!
JKout
JKout
-
- Posts: 6
- Joined: Sep 26, 2012 21:14
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
Thank you for your work.
Still, I have a problem in my Raspi. OS is last MiniBian, which is told to be a Rasbian without GUI.
- Installed ver 0.91.1
- Installed gcc
- wrote a program: print "Hello"
- 'fbc mybrogam.bas'
->
ld: cannot find -lncurses
ld: cannot find -lsupc++
So, something seems to ask for ncurses and supc++.
Is there some way to install them or go around ?
Still, I have a problem in my Raspi. OS is last MiniBian, which is told to be a Rasbian without GUI.
- Installed ver 0.91.1
- Installed gcc
- wrote a program: print "Hello"
- 'fbc mybrogam.bas'
->
ld: cannot find -lncurses
ld: cannot find -lsupc++
So, something seems to ask for ncurses and supc++.
Is there some way to install them or go around ?
-
- Posts: 8629
- Joined: May 28, 2005 3:28
- Contact:
Re: FreeBASIC ARM6/7 for the Raspberry PI and Beaglebone Bla
I never used MiniBian if it's Debian be sure you have
gcc, g++, binutils, libncurses-dev or libncurses5-dev installed.
Joshy
gcc, g++, binutils, libncurses-dev or libncurses5-dev installed.
Joshy