Load a binary from SD card?
ItsAFeatureNotaBug
Posts: 1
Hi all, long time developer but first time poster on this community, so go easy on me!
I've been working with the Propeller Board of Education with Spin for a while. I found the ability to load at runtime different eeprom binaries from the sd card useful. When I switched over to GCC, I have struggled to replicate this functionality. Despite searching this forum and the GCC wiki, I haven't found any clues.
Can someone point me in the right direction?
Thanks in advance for your help.
Brendan
I've been working with the Propeller Board of Education with Spin for a while. I found the ability to load at runtime different eeprom binaries from the sd card useful. When I switched over to GCC, I have struggled to replicate this functionality. Despite searching this forum and the GCC wiki, I haven't found any clues.
Can someone point me in the right direction?
Thanks in advance for your help.
Brendan
Comments
Many will disagree with me and I don't feel like arguing and you don't have to take my advice, but I really think Spin is an infinitely better language for the propeller than C is, especially if you've already gotten past the hurdle of learning Spin.
Dave Hein's Spinix system allows starting propeller programs from a command line interface. There are other monitor systems that allow running programs.
I think you misunderstood his question. Kye's SD driver, and probably others, can boot .binary and/or .eeprom (at least one, not sure if both) files without an operating system, just a normal spin program.
I don't use Kye's SD driver so I don't understand your context, but Spinix and other monitor programs can run .binary files.
PropellerGCC produces .elf binaries. The propeller-load program can convert .elf binaries to spin-like .binary files.
The problem with doing this with PropGCC is that the SD mailbox is located in an arbitrary location in hub RAM. Even if the loader was in a PASM cog, the mailbox would eventually be clobbered by the program being loaded from SD. In spinix, I use a special file driver with PropGCC that uses the same SPI driver and mailbox as the Spin code.
So the solution for PropGCC is to use a special SPI driver that uses a mailbox at the high end of hub RAM. If you are interested in pursuing this I could provide a bare-bones version of spinix that provides that functionality.
EDIT: This only works with LMM programs because it has the capability to protect the high end of memory from being overwritten. CMM programs don't have that capability, though it can probably being done at some point. I also haven't figured out how to load and run XMM/XMMC programs from SD, but that is doable as well.
Since EEPROM is loaded via SPI or I2C (right?), a program could read blocks from the SD card and write them to the EEPROM then force itself to do a reset. It would cost a few pins (don't know how many pins are used in the current implementations) but should work. It's also not dependent on any one implementation of the low-level drivers.
EDIT
Nevermind... not a very reusable method is it?
Doesn't the __stack_end parameter work for any memory model? I.E. propeller-elf-gcc [blah...] -Wl,--defsym,__stack_end=0x7000
See this forum post as an example.
I forgot to mention that recent versions of SimpleIDE automatically generate .binary copies of programs created by propeller-gcc by issuing the required propeller-load command. Also, the "-Wl,--defsym,__stack_end=0x7000" parameter can be set by copy/paste into the Project Manager -> Compiler -> Other Options field.
Sorry Dave, I just assumed Spinix worked like the other loader systems preceding it where a simple rendezvous mailbox can be put at end of memory and provide an interface to PASM or other drivers.
Anyway, we accommodate the rendezvous system with propeller-gcc binaries by specifying the __stack_end. Any memory above __stack_end will remain intact, and programs with appropriate libraries can use the rendezvous system resources for device driver communications, services management, and program parameters/exit codes. All of that is theoretical though.
Some propeller users have implemented such systems, but the clarity of service implementation description for replication or the simplicity has never been really acceptably recognized by more than a few people at a time (I.E. those who designed these things are happy with the results, but no one else seems to care or be willing to adopt such things in masse).
Parallax Education only ever wanted an embedded system (in this case, a simple monolithic program that loads and runs from RAM or EEPROM without special requirements) and that's what they got. I have made some inroads on and off at convincing them of the benefits of using loader/monitor systems, but they have never been considered important enough or simple enough to be implemented as a Parallax product.
Welcome!
Doc
The bottom line is that there's no ready-to-go solution that I'm aware of, but there are several partial solutions that can be adopted.
Mike's loader is one of the most popular judging by users on these forums. OBC and others have used variations of it.
I will support Q&A for anyone willing to use Mike's loader (or other simple mailbox systems) with PropellerGCC. However, I don't have time to start such a project.