Shop OBEX P1 Docs P2 Docs Learn Events
Building loadp2 — Parallax Forums

Building loadp2

Can I please get some help building my own loadp2? Today I downloaded the loadp2-master.zip from https://github.com/totalspectrum/loadp2. The build instructions are pretty simple: make CROSS=win32

My system is Win11, Cygwin64. I installed MinGW to support this. I think I got everything important but usually just use Cygwin gcc, so I may have made a noob error. Other changes:

  • grabbed propeller2.h from spin2cpp and placed it in board/sdcard
  • changed the punctuation of propeller2.h from <> to "" in sd*.c

The published make command fails in flexspin of sdboot.c:
>> make CROSS=win32
make -C board/sdcard P2CC="flexspin -2"
make[1]: Entering directory '/cygdrive/c/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard'
flexspin -2 -o sdboot.binary sdboot.c ff.c sdmm.c
Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2024 Total Spectrum Software Inc. and contributors
Version 6.9.4 Compiled on: Apr 22 2024
sdboot.c
error: Preprocessor errors:
C:/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard/sdboot.c:6: error: Can't open include file "stdio.h"
#include <stdio.h>
C:/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard/propeller2.h:4: error: Can't open include file "stdint.h"
#include <stdint.h>
from C:/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard/sdboot.c: 7: #include "propeller2.h"
2 errors in preprocessor.
make[1]: *** [Makefile:8: sdboot.binary] Error 1
make[1]: Leaving directory '/cygdrive/c/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard'
make: *** [Makefile:79: board/P2ES_sdcard.bin] Error 2

I added a -I path to the Makefile for the mingw stdio.h. Still failed, slightly different error:
>> make CROSS=win32
make -C board/sdcard P2CC="flexspin -2 -I C:\cygwin64\usr\i686-w64-mingw32\sys-root\mingw\include"
make[1]: Entering directory '/cygdrive/c/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard'
flexspin -2 -I C:\cygwin64\usr\i686-w64-mingw32\sys-root\mingw\include -o sdboot.binary sdboot.c ff.c sdmm.c
Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2024 Total Spectrum Software Inc. and contributors
Version 6.9.4 Compiled on: Apr 22 2024
sdboot.c
error: Preprocessor errors:
C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/_mingw.h:271: error: #error Only Win32 target is supported!
#error Only Win32 target is supported!
from C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/corecrt.h: 10: #include <_mingw.h>
from C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/corecrt_stdio_config.h: 10: #include <corecrt.h>
from C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/stdio.h: 9: #include <corecrt_stdio_config.h>
from C:/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard/sdboot.c: 6: #include <stdio.h>
C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/vadefs.h:35: error: #error VARARGS not implemented for this compiler
#error VARARGS not implemented for this compiler
from C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/_mingw.h: 282: #include <vadefs.h>
from C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/corecrt.h: 10: #include <_mingw.h>
from C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/corecrt_stdio_config.h: 10: #include <corecrt.h>
from C:/cygwin64/usr/i686-w64-mingw32/sys-root/mingw/include/stdio.h: 9: #include <corecrt_stdio_config.h>
from C:/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard/sdboot.c: 6: #include <stdio.h>
2 errors in preprocessor.
make[1]: *** [Makefile:8: sdboot.binary] Error 1
make[1]: Leaving directory '/cygdrive/c/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard'
make: *** [Makefile:79: board/P2ES_sdcard.bin] Error 2

Including the gcc header yielded a third error:
> make CROSS=win32
make -C board/sdcard P2CC="flexspin -2 -I C:\cygwin64\usr\include"
make[1]: Entering directory '/cygdrive/c/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard'
flexspin -2 -I C:\cygwin64\usr\include -o sdboot.binary sdboot.c ff.c sdmm.c
Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2024 Total Spectrum Software Inc. and contributors
Version 6.9.4 Compiled on: Apr 22 2024
sdboot.c
error: Preprocessor errors:
C:/cygwin64/usr/include/machine/ieeefp.h:527: error: #error Endianess not declared!!
#error Endianess not declared!!
from C:/cygwin64/usr/include/sys/config.h: 4: #include <machine/ieeefp.h>
from C:/cygwin64/usr/include/_ansi.h: 11: #include <sys/config.h>
from C:/cygwin64/usr/include/stdio.h: 29: #include "_ansi.h"
from C:/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard/sdboot.c: 6: #include <stdio.h>
C:/cygwin64/usr/include/machine/_default_types.h:25: error: Constant "9223372036854775807LL" is out of range
macro "LONG_LONG_MAX" defined as: #define LONG_LONG_MAX 9223372036854775807LL /* C:/cygwin64/usr/include/limits.h:106 */
from C:/cygwin64/usr/include/machine/_default_types.h: 25: #if ( defined(LONG_LONG_MAX) && (LONG_LONG_MAX > 0x7fffffff) ) || ( defined(LLONG_MAX) && (LLONG_MAX > 0x7fffffff) )
from C:/cygwin64/usr/include/sys/cdefs.h: 45: #include <machine/_default_types.h>
from C:/cygwin64/usr/include/stdio.h: 35: #include <sys/cdefs.h>
from C:/GlueLogix/Documents/ByVendor/Parallax/Prop2/CompilerLoaders/loadp2/loadp2-master/loadp2-master/board/sdcard/sdboot.c: 6: #include <stdio.h>
<10 more>

Hint? Help? I tried searching for "loadp2 build" and came up dry.

Comments

  • That just means your build environment is broken in some fundamental way unrelated to anything loadp2. Likely confused env from having cygwin and mingw versions of the same tools installed.

    If you just want the latest loadp2, grab the latest flexprop and take it from the bin directory.

  • @Wuerfel_21 said:
    That just means your build environment is broken in some fundamental way unrelated to anything loadp2. Likely confused env from having cygwin and mingw versions of the same tools installed.

    Which is why I tried explicitly providing include paths to flexspin, which just made things worse. I was hoping for a hint about what the tool might be looking for.

    If you just want the latest loadp2, grab the latest flexprop and take it from the bin directory.

    I did that in the course of my last thread https://forums.parallax.com/discussion/comment/1559174

    Now I want to add a reset at the end of programming for reasons in that other thread. If the build were failing on mingw I wouldn't bother this group. But flexspin is the culprit here, not mingw, gcc or cygwin. As of now, flexspin is a black box to me. But I just built it, along with spin2cpp, so I guess I'll start there.

  • Wuerfel_21Wuerfel_21 Posts: 4,641
    edited 2024-05-04 19:35

    Sorry, the previous post was made on my phone and I didn't quite see what was going on. Your problem is that flexspin isn't finding it's C library includes. Providing your PC's C library is a bad idea and will never work, don't even try that. That was what confused me. Normally it should automatically find them if installed normally, by going one directory up from where the compiler executable is and then going into the include directory. (note that this works out-of-the-box if the flexspin.exe is left in the build directory the linker spits it into - did you move it?)

  • iseriesiseries Posts: 1,472

    I use mingw32 which I installed using the MinGW installation manager.

    D:\mingw32\bin

    D:\Documents\GitHub\loadp2>make
    mkdir -p ./build-win32
    i686-w64-mingw32-gcc -Wall -O -g  -o build-win32/loadp2.exe loadp2.c loadelf.c osint_mingw.c u9fs/u9fs.c u9fs/authnone.c u9fs/print.c u9fs/doprint.c u9fs/rune.c u9fs/fcallconv.c u9fs/dirmodeconv.c u9fs/convM2D.c u9fs/convS2M.c u9fs/convD2M.c u9fs/convM2S.c u9fs/readn.c
    flexspin -2 -o board/P2ES_flashloader.bin board/P2ES_flashloader.spin2
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2024 Total Spectrum Software Inc. and contributors
    Version 6.9.4 Compiled on: Apr 25 2024
    P2ES_flashloader.spin2
    P2ES_flashloader.spin2
    Done.
    Program size is 32800 bytes
    make -C board/sdcard P2CC="flexspin -2"
    make[1]: Entering directory `/d/Documents/GitHub/loadp2/board/sdcard'
    flexspin -2 -o sdboot.binary sdboot.c ff.c sdmm.c
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2024 Total Spectrum Software Inc. and contributors
    Version 6.9.4 Compiled on: Apr 25 2024
    sdboot.c
    ff.c
    sdmm.c
    fmt.c
    posixio.c
    fputs.c
    basicfmt.c
    vfs.c
    bufio.c
    fmt.c
    errno.c
    posixio.c
    bufio.c
    sdboot.p2asm
    Done.
    Program size is 27664 bytes
    make[1]: Leaving directory `/d/Documents/GitHub/loadp2/board/sdcard'
    mv board/sdcard/sdboot.binary board/P2ES_sdcard.bin
    

    Mike

  • @Wuerfel_21 said:
    Sorry, the previous post was made on my phone and I didn't quite see what was going on. Your problem is that flexspin isn't finding it's C library includes. Providing your PC's C library is a bad idea and will never work, don't even try that.

    Of course, should have thought of that.

    That was what confused me. Normally it should automatically find them if installed normally, by going one directory up from where the compiler executable is and then going into the include directory. (note that this works out-of-the-box if the flexspin.exe is left in the build directory the linker spits it into - did you move it?)

    Well, yeah. The flexspin in my PATH is the executable from the flexprop tree, as recommended. I copied it to a Tools folder in the Windows PATH, that I use for standalone utilities.

    This worked:
    >make CROSS=win32 -I [path to P2 headers from spin2cpp or flexprop]

    Thank you for your help in my last two issues.

  • Larry MartinLarry Martin Posts: 88
    edited 2024-05-07 21:17

    This fixed my problem loading big Flash images:
    if (loadfile(fname, address))
    {
    if (LOAD_SPI == load_mode)
    {
    hwreset(); // GlueLogix: reset target after Flash load
    }
    serial_done();
    promptexit(1);
    }

    The addition is at the end of loadp2.c:main(), line 1214 of version 0.072.

    @Wuerfel_21 (edit): Would you like me to go through the github fork/change/pull-request process? Should there be a command line switch, or is it safe to always do that after loading Flash?

Sign In or Register to comment.