Shop OBEX P1 Docs P2 Docs Learn Events
propgcc installs x86 binary of openspin on ARM machines. — Parallax Forums

propgcc installs x86 binary of openspin on ARM machines.

Heater.Heater. Posts: 21,230
edited 2013-11-12 13:11 in Propeller 1
propgcc installs an x86 binary of openspin on non-x86 architectures when building for linux. In my case the Raspberry Pi.

This in turn causes the build of propeller-load to fail.

Which poses a question in my mind.

Why does propgcc include propeller-load? Perhaps that should be broken out as a separate project and repo as it is not really part of the compiler.

propeller-load requires openspin (or previously BSTC) to be installed but it should not really be carrying around binaries of openspin.

openspin sources in turn should not be included in propgcc as it is a separate thing altogether.

The good news is that propeller-load does indeed build on the Pi now with openspin.

Comments

  • jazzedjazzed Posts: 11,803
    edited 2013-11-11 08:15
    Heater,

    Look at the propgcc/jbuild.sh, propgcc/loader/build.sh, and propgcc/loader/Makefile. Then imagine a solution.

    Script propgcc/loader/build.sh can be used to build propeller-load without building the whole thing.

    It would be easy enough to make a new propeller-load repository, but maintenance is harder with N copies.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-11 08:37
    jazzed wrote: »
    Script propgcc/loader/build.sh can be used to build propeller-load without building the whole thing.
    You should be able to build propeller-load by just using make. Do the following:
    make clean
    make
    make install
  • Heater.Heater. Posts: 21,230
    edited 2013-11-11 08:43
    propgcc/loader/build.sh works very well.

    The solution I imagine is that propeller-load is not included in propgcc at all. I get the impression that most targets of GCC don't carry device loaders around with them.

    The compiler is the compiler and the loader is the loader, they could be totally separate projects and repositories.
  • Heater.Heater. Posts: 21,230
    edited 2013-11-11 08:45
    David,

    I can build the loader just fine.

    My issue is with propgcc carrying binaries around in the source repo.

    It's not a big deal for me, it's just odd.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-11 08:56
    Heater. wrote: »
    David,

    I can build the loader just fine.

    My issue is with propgcc carrying binaries around in the source repo.

    It's not a big deal for me, it's just odd.
    I agree. It is odd. It came about originally because we didn't have sources to bstc. I guess we no longer need to include them since we could just require that people install openspin before building propgcc. Probably something we should consider.
  • jazzedjazzed Posts: 11,803
    edited 2013-11-11 09:07
    Ugh, come on guys.

    The build scripts / make select openspin by OS at the moment. There needs to be some decision on what to do based on the architecture.

    Moving propeller-load to its own repository is a non-starter at the moment because it is still being "maintained" in various branches of the propeller-gcc repository.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-11 09:47
    jazzed wrote: »
    Moving propeller-load to its own repository is a non-starter at the moment because it is still being "maintained" in various branches of the propeller-gcc repository.
    One problem with making propeller-load a separate project is that it has knowledge of how the XMM kernels access memory so updates to propeller-load need to be coordinated with changes in the XMM memory interface. As it turns out, a change like that is about to take place. I agree with Steve. We shouldn't separate out propeller load.
  • Heater.Heater. Posts: 21,230
    edited 2013-11-11 21:17
    Some how I knew this was more complex than I could fathom:)

    The loader depends on the "virtual machine" defined by propgcc, so it needs to track changes in that and so it needs to be part of propgcc. That's kind of ikky but I don't see any way around it.

    The loader requires openspin (or BSTC) to build. It does not follow that openspin binaries should be included in the propgcc source code repo. There should never be such binaries in a source code repo.

    On the other hand openspin is it's own separate project so we should not include openspin sources in propgcc and build it as part of building propgcc.

    Which leads to the simple conclusion that it is just a requirement that openspin is installed on your system before attempting to build propgcc.

    This is normal. After all there are a ton of other dependencies you need on your system in order to build GCC.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-12 03:52
    Heater. wrote: »
    Some how I knew this was more complex than I could fathom:)

    The loader depends on the "virtual machine" defined by propgcc, so it needs to track changes in that and so it needs to be part of propgcc. That's kind of ikky but I don't see any way around it.

    The loader requires openspin (or BSTC) to build. It does not follow that openspin binaries should be included in the propgcc source code repo. There should never be such binaries in a source code repo.

    On the other hand openspin is it's own separate project so we should not include openspin sources in propgcc and build it as part of building propgcc.

    Which leads to the simple conclusion that it is just a requirement that openspin is installed on your system before attempting to build propgcc.

    This is normal. After all there are a ton of other dependencies you need on your system in order to build GCC.
    Your analysis is correct. We checked in the binaries because it was a quick solution when we first started. Now that we depend on another Parallax product, openspin, we should probably just require that that product be installed before attempting to build propgcc. One big reason we haven't done that yet though is that as far as I know there has never been a formal release of openspin. I don't think there is an installer for it or even an official distribution download. Until that happens, we'll have to continue supplying binaries in the propgcc repository.

    Also, the loader doesn't really know much about the XMM kernel. All it really knows is the interface to the external memory driver and how to adjust the cache parameters based on what is in the board configuration file.
  • Heater.Heater. Posts: 21,230
    edited 2013-11-12 05:19
    I do appreciate this is all being constructed as we speak. It's a major milestone that the loader can use openspin as it is. So I'm happy as a pig in ... great work guys.

    One might ask why the loader needs openspin to compile those .dat files as propgcc has gas? Is it just that the PASM syntax is preferable ?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-12 05:28
    Heater. wrote: »
    I do appreciate this is all being constructed as we speak. It's a major milestone that the loader can use openspin as it is. So I'm happy as a pig in ... great work guys.

    One might ask why the loader needs openspin to compile those .dat files as propgcc has gas? Is it just that the PASM syntax is preferable ?
    Our thinking was that we wanted as many people as possible to be able to write PASM memory drivers and GAS is a bit awkward to people who are familiar with Spin/PASM. Otherwise, you're correct that all of the memory drivers could be built using GAS. In fact, they are currently built using spin2cpp not openspin. However, we would still need openspin to build the loader because there is a program called serial_helper.spin that uses fsrw to write files to the SD card. We don't currently have any C code that can write data to an SD card so we have to continue using some sort of Spin compiler to build this module and openspin is the best alternative at the moment.

    I agree that it would be nice to split things up into smaller projects. I'd also like to have a Makefile to replace jbuild.sh so that a failure near the end of the build process doesn't require starting over from the beginning. No one has had time to write that Makefile though so we continue to use jbuild.sh which does the job nicely if not quite as efficiently as we might like.
  • jazzedjazzed Posts: 11,803
    edited 2013-11-12 09:49
    David Betz wrote: »
    We don't currently have any C code that can write data to an SD card so we have to continue using some sort of Spin compiler ....

    This isn't very clear :)

    We do have C code that can write data to an SD card.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-12 09:57
    jazzed wrote: »
    This isn't very clear :)

    We do have C code that can write data to an SD card.
    The last I checked we didn't have filesystem code that was small enough to fit into the CMM or LMM memory models. The "serial helper" can't use XMM memory models. If we do have code that I wasn't aware of then I will immediately recode serial_helper.spin as serial_helper.c and we won't need openspin or bstc to build the loader.
  • jazzedjazzed Posts: 11,803
    edited 2013-11-12 10:04
    David Betz wrote: »
    The last I checked we didn't have filesystem code that was small enough to fit into the CMM or LMM memory models.

    Is that because we need to waste about 2KB on a CMM/LMM kernel ?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-12 10:09
    jazzed wrote: »
    Is that because we need to waste about 2KB on a CMM/LMM kernel ?
    I don't know if that's the only reason. Actually, this might not be true anymore anyway. I wrote serial_helper.spin a long time ago. Our filesystem support may have become more space-efficient since then. I guess I could try translating to C with the current libraries. Or, I could extend my fat C code to be able to write files as well as read them but that's a bigger job.
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-11-12 10:52
    A minimal LMM program with file support is about 22K in size. A CMM program is about 13K.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-12 11:02
    Dave Hein wrote: »
    A minimal LMM program with file support is about 22K in size. A CMM program is about 13K.
    Cool! I'll have to try porting serial_helper.spin. It would be nice to have a C version of it. Thanks for the information!
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-12 11:22
    Dave Hein wrote: »
    A minimal LMM program with file support is about 22K in size. A CMM program is about 13K.
    Another question, does this minimal LMM or CMM program write to the SD card or only read? I have FAT reading code that is fairly small. The write code is somewhat more complex.
  • Dave HeinDave Hein Posts: 6,347
    edited 2013-11-12 12:40
    This program is 21968 bytes for LMM and 12784 bytes for CMM.
    #include <stdio.h>
    
    extern _Driver _SimpleSerialDriver;
    extern _Driver _FileDriver;
    
    _Driver *_driverlist[] = {
      &_SimpleSerialDriver,
      &_FileDriver,
      NULL
    };
    
    int main(void)
    {
        int i;
        FILE *infile = fopen("dummy", "r");
        FILE *outfile = fopen("dummy", "w");
        fread(&i, 1, 1, infile);
        fwrite(&i, 1, 1, outfile);
        return 0;
    }
    

    Commenting out the fopen and fwrite for the output file save 628 bytes for LMM and 316 bytes for CMM. The extra bytes are for the generic fwrite function, but the file system code always pulls in all the read, write and directory support. The functions chdir, mkdir and rmdir would bring in extra code, but you don't need them if you are just working with the root directory.

    EDIT: If we need a smaller file system that only supports the root directory we could port the FSRW code. We could probably get a minimal program down below 8K with FSRW in CMM.
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-12 12:52
    Dave Hein wrote: »
    This program is 21968 bytes for LMM and 12784 bytes for CMM.
    #include <stdio.h>
    
    extern _Driver _SimpleSerialDriver;
    extern _Driver _FileDriver;
    
    _Driver *_driverlist[] = {
      &_SimpleSerialDriver,
      &_FileDriver,
      NULL
    };
    
    int main(void)
    {
        int i;
        FILE *infile = fopen("dummy", "r");
        FILE *outfile = fopen("dummy", "w");
        fread(&i, 1, 1, infile);
        fwrite(&i, 1, 1, outfile);
        return 0;
    }
    

    Commenting out the fopen and fwrite for the output file save 628 bytes for LMM and 316 bytes for CMM. The extra bytes are for the generic fwrite function, but the file system code always pulls in all the read, write and directory support. The functions chdir, mkdir and rmdir would bring in extra code, but you don't need them if you are just working with the root directory.

    EDIT: If we need a smaller file system that only supports the root directory we could port the FSRW code. We could probably get a minimal program down below 8K with FSRW in CMM.
    Thanks Dave! It might be nice to have a smaller filesystem if only because part of the program load time for propeller-load is loading the serial_helper program and that is loaded with the slow ROM loader. The smaller that is the better for overall load performance. Let me start with what we have first though before we go to any trouble porting fsrw.

    Thanks!
    David
  • Heater.Heater. Posts: 21,230
    edited 2013-11-12 13:08
    Oh boy. Did I open a can of worms here or what?
  • David BetzDavid Betz Posts: 14,516
    edited 2013-11-12 13:11
    Heater. wrote: »
    Oh boy. Did I open a can of worms here or what?
    Not really. I have always intended to convert serial_helper.spin to C. In fact, I'd really like to split it up into multiple modules because you hardly ever need the SD writing code and loading it slows down every load a little.
Sign In or Register to comment.