To compile flexspin from source I download the master zip file to a directory in Ubuntu - which has all the build tools ready to go - then open a shell in the unzipped spin2cpp directory that has the make file and:
$ git pull; make clean; make
and you're done. The new flexspin compiler is in build sub-directory and new include files are in include sub-directory.
I just installed Cygwin and ran make. Seemed to work, but the fastspin.exe it made needs some dlls to work. Copied all the cygwin dlls to flexprop bin folder. It runs, but can't find any of my sources include files.
Not sure if Cygwin is even properly supported. I'm pretty sure only MinGW actually is.
May also be a case of the case-sensitive file names. Cygwin might have issues if the case doesn't match.
Eitherhow, you can get prebuilt windows compiler binaries from the Github CI. It's a bit clunky to get to and you need to be logged in, but saves the hassle of having to set up a working build env:
Click the most recent run that has the green checkmark and that says master
Scroll down to the artifacts section and get the flexptools-git.zip. If you aren't logged in to github, it isn't clickable!
I think all of the initializations should be working now. The root cause of all the problems was that the initialization code wasn't inserting padding between structure elements that needed it, so the data in memory was too short compared to what the coder expected.
@ersmith I found a bit of mischief in FlexBASIC. This "error" may just be some unimplemented 64-bit stuff, and if so ignore.
With the current version compiler (Version 5.9.19) this swapping works fine:
dim a, b as ulong
a, b = b, a
... but this generates an error:
dim a, b as ulongint
a, b = b, a
... and the error is:
error: Cannot handle memref of size 8
error: Cannot handle memref of size 8
D:/Flex2Gui/flexgui/swapvartest.bas:3: error: Too many elements on right hand side of assignment
child process exited abnormally
@ersmith said:
@JRoark and @Rayman : thanks for your bug reports, I'll have to look into them.
In addition to those, I just found that flexspin would not compile this (simple?) attached code and would just crash flexspin completely. You might like to determine why. I tried with and without verbose output but it made no difference.
RLs-MacBook-Pro:encoder roger$ f -2 --verbose c4.c
Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2022 Total Spectrum Software Inc.
Version 5.9.19-HEAD-v5.9.19 Compiled on: Nov 13 2022
c4.c
Segmentation fault: 11
EDIT: after messing about if I comment out the ++line; statement on line 65 it compiles (just the next() function in isolation) and segfault crashes without it. But why? Also replacing it with line++; instead compiles okay too.
EDIT2: looks like flexspin can't handle assignments with pre-increment/pre-decrement operations, at least in non-pointer cases. When I removed all of them, I was able to compile without crashing - with some other strange issues related to argument mismatch in some called library functions which is still to be fixed. It'd be nice to at least not crash the compiler if it encounters this, although it would be far better to actually support these pre/post operations too.
I've attached the workingc4.c code without the pre-increment/pre-decrement stuff, that flexspin now handles.
EDIT3: Looks like this issue stems from the fact that the int type is being redefined as a long long in the source. If I change it to long instead, the crashes go away. So perhaps this is some 64 bit limitation internally in flexspin with no support for pre-inc/dec operations.
the attached code immediately crashes the compiler (segmentation fault). It does this since I added the C code "B2M_axes.c" to the main module "B2M_main.spin2". B2M-axes is untested and surely contains lots of bugs but it shouldn't crash the compiler. If I comment out "axe.Init_Axes ()" it compiles and runs well.
I've used "buf" as a shortcut to the indexed array field AxisBuffer[wrIndex]. If I comment it out the compiler no longer crashes. The docs say that C++ style reference parameters are supported but I guess this doesn't include local reference variables. However, the compiler should throw an error instead of crashing.
If that's really the (only) cause I could use a pointer instead (which is used internally for &-style references, anyway).
@ManAtWork : yes, there's a bug (probably several) in local reference variables. The crash is fixed in github now, but I doubt local reference variables will work correctly yet.
@ersmith said:
The crash is fixed in github now, but I doubt local reference variables will work correctly yet.
Thanks for the fix. No problem, I can use pointers instead if I know it. I've just ported that code from an ARM environment (MinGW/GNU based I think) where it worked correctly.
@ersmith This Wiznet FTP server code uses FatFs to access the sd card like this:
#if defined(F_FILESYSTEM)
#include "ff.h"
#endif
This isn't going to work with the built in SD card access, right?
I'm thinking I either need to include all of FatFs myself and not use the built in SD card access, or rewrite all the SD card access code, is this right?
Shoot, this code is based on FatFS version 0.10 instead of 0.14. Don't really want to go backwards... Guess need to rewrite anyway...
This AVR version of Micro-Max chess appears to now work with FlexC. Don't think it used to...
Original version of Micro-Max may or may not be working... Works when you enter the moves, but just sits there if you hit enter for code to generate a move.
But, I think this happened under Catalina too, it took a very long time to make a move...
@Rayman said:
@ersmith This Wiznet FTP server code uses FatFs to access the sd card like this:
#if defined(F_FILESYSTEM)
#include "ff.h"
#endif
This isn't going to work with the built in SD card access, right?
I'm thinking I either need to include all of FatFs myself and not use the built in SD card access, or rewrite all the SD card access code, is this right?
Why re-write it? Isn't there a version that will use the native file system (the built in one), e.g. for testing on linux or Windows?
Or, you could just use the ff.h they provide. But do not try to use both the provided FatFS and the built in one, you'll run into big problems doing that.
@Rayman : It depends on the language you're using. From context I'm guessing you want C: the "shell" sample that comes with FlexProp has examples of doing common file operations. Look at the function do_dir() in samples/shell/shell.c.
@ersmith Thanks, that helped. Was able to implement "dir" in the Wiznet ftp server.
But, going to have to rewrite a lot of code to get it all working...
Comments
Can I build from source? Not sure, never tried... Does it compile with Visual Studio?
I hope you found the problem. Think I've isolated it to this code in wizchip_conf.c:
Is this the same thing you found?
To compile flexspin from source I download the master zip file to a directory in Ubuntu - which has all the build tools ready to go - then open a shell in the unzipped
spin2cpp
directory that has themake
file and:and you're done. The new flexspin compiler is in
build
sub-directory and new include files are ininclude
sub-directory.Why download the zip file manually when
git clone https://github.com/totalspectrum/spin2cpp
will do?Because I don't remember that line. It's been a long time since I did anything other than
git pull
for an update.I just installed Cygwin and ran make. Seemed to work, but the fastspin.exe it made needs some dlls to work. Copied all the cygwin dlls to flexprop bin folder. It runs, but can't find any of my sources include files.
Not sure if Cygwin is even properly supported. I'm pretty sure only MinGW actually is.
May also be a case of the case-sensitive file names. Cygwin might have issues if the case doesn't match.
Eitherhow, you can get prebuilt windows compiler binaries from the Github CI. It's a bit clunky to get to and you need to be logged in, but saves the hassle of having to set up a working build env:
Click the most recent run that has the green checkmark and that says
master
Scroll down to the artifacts section and get the flexptools-git.zip. If you aren't logged in to github, it isn't clickable!
@Wuerfel_21 Thanks! That's awesome.
@ersmith All fixed! Thanks!
@Wuerfel_21 : I'd forgotten about the CI build, that's great.
@Rayman : Thanks for checking this!
@ersmith This kind of initialization now seems to work:
Is this something you just fixed?
Looking back, I think you said this was working in your tests.
Guess something else was messing it up...
@ersmith
This other kind of initialization also seems to work now, but not 100% sure because it would break things in strange ways...
static uint8_t g_ethernet_buf[ETHERNET_BUF_MAX_SIZE] = { 0, };
I guess the idea is to just set the first element of the array to zero, like for an empty string.
Is this now fixed as well?
I think all of the initializations should be working now. The root cause of all the problems was that the initialization code wasn't inserting padding between structure elements that needed it, so the data in memory was too short compared to what the coder expected.
@ersmith Thanks! It's great to see this rather complex code working with FlexC.
@ersmith I found a bit of mischief in FlexBASIC. This "error" may just be some unimplemented 64-bit stuff, and if so ignore.
With the current version compiler (Version 5.9.19) this swapping works fine:
... but this generates an error:
... and the error is:
@ersmith Sorry to keep doing this to you...
I tried adding the Wiznet ftp code and the main function there won't compile...
This is the error:
1>ftpd.c:783: error: Expected multiple values
1>ftpd.c:811: error: Expected multiple values
But, I think the compiler might be choking on this pretty large function...
Think I figured out the problem...
FlexC doesn't like this:
Think I'm able to work around by manually setting each value with line of code.
Also didn't like this:
switch(cmdp - commands)
and I don't blame it, fixed like this:
switch((int)((int)cmdp - (int)commands))
actually, like this:
switch ((int)(cmdp - commands))
@JRoark and @Rayman : thanks for your bug reports, I'll have to look into them.
In addition to those, I just found that flexspin would not compile this (simple?) attached code and would just crash flexspin completely. You might like to determine why. I tried with and without verbose output but it made no difference.
EDIT: after messing about if I comment out the
++line;
statement on line 65 it compiles (just the next() function in isolation) and segfault crashes without it. But why? Also replacing it withline++;
instead compiles okay too.EDIT2: looks like flexspin can't handle assignments with pre-increment/pre-decrement operations, at least in non-pointer cases. When I removed all of them, I was able to compile without crashing - with some other strange issues related to argument mismatch in some called library functions which is still to be fixed. It'd be nice to at least not crash the compiler if it encounters this, although it would be far better to actually support these pre/post operations too.
I've attached the workingc4.c code without the pre-increment/pre-decrement stuff, that flexspin now handles.
EDIT3: Looks like this issue stems from the fact that the int type is being redefined as a long long in the source. If I change it to long instead, the crashes go away. So perhaps this is some 64 bit limitation internally in flexspin with no support for pre-inc/dec operations.
Hi Eric,
the attached code immediately crashes the compiler (segmentation fault). It does this since I added the C code "B2M_axes.c" to the main module "B2M_main.spin2". B2M-axes is untested and surely contains lots of bugs but it shouldn't crash the compiler. If I comment out "axe.Init_Axes ()" it compiles and runs well.
Could it be that FlexC doesn't like this reference variable declaration?
I've used "buf" as a shortcut to the indexed array field AxisBuffer[wrIndex]. If I comment it out the compiler no longer crashes. The docs say that C++ style reference parameters are supported but I guess this doesn't include local reference variables. However, the compiler should throw an error instead of crashing.
If that's really the (only) cause I could use a pointer instead (which is used internally for &-style references, anyway).
@ManAtWork : yes, there's a bug (probably several) in local reference variables. The crash is fixed in github now, but I doubt local reference variables will work correctly yet.
@rogloh : The c4.c compiles now with the version of flexspin checked into github (built from source, that is).
Thanks for the fix. No problem, I can use pointers instead if I know it. I've just ported that code from an ARM environment (MinGW/GNU based I think) where it worked correctly.
Thanks for the fix so soon!
Cheers,
Roger.
@ersmith This Wiznet FTP server code uses FatFs to access the sd card like this:
This isn't going to work with the built in SD card access, right?
I'm thinking I either need to include all of FatFs myself and not use the built in SD card access, or rewrite all the SD card access code, is this right?
Shoot, this code is based on FatFS version 0.10 instead of 0.14. Don't really want to go backwards... Guess need to rewrite anyway...
This AVR version of Micro-Max chess appears to now work with FlexC. Don't think it used to...
Original version of Micro-Max may or may not be working... Works when you enter the moves, but just sits there if you hit enter for code to generate a move.
But, I think this happened under Catalina too, it took a very long time to make a move...
Why re-write it? Isn't there a version that will use the native file system (the built in one), e.g. for testing on linux or Windows?
Or, you could just use the ff.h they provide. But do not try to use both the provided FatFS and the built in one, you'll run into big problems doing that.
@ersmith Is there still a "simple_ls.c" example? One I have doesn't work any more... Trying to figure out how to list a directory...
@Rayman : It depends on the language you're using. From context I'm guessing you want C: the "shell" sample that comes with FlexProp has examples of doing common file operations. Look at the function do_dir() in samples/shell/shell.c.
@ersmith Thanks, that helped. Was able to implement "dir" in the Wiznet ftp server.
But, going to have to rewrite a lot of code to get it all working...