Shop OBEX P1 Docs P2 Docs Learn Events
p1load - a propeller loader — Parallax Forums

p1load - a propeller loader

David BetzDavid Betz Posts: 14,516
edited 2015-04-25 19:41 in Propeller 1
I've recently posted the sources to p1load to github. p1load is a command line program for loading Spin binaries. It also includes a module called ploader.c that implements the Propeller ROM loader protocol and can interface to any serial driver that can provide an appropriate interface. This interface currently consists of a tx() function to transmit a buffer of bytes, an rx_timeout() function that receives a buffer of bytes with a timeout, and a reset() function that resets the Propeller, usually by toggling the DTR signal.

p1load can be built for Mac OS X, Linux, or Windows.

GitHub URL: https://github.com/dbetz/p1load
p1load - a simple loader for the propeller - version 0.009, 2014-08-10
usage: p1load
         [ -b baud ]               baud rate (default is 115200)
         [ -p port ]               serial port (default is to auto-detect the port)
         [ -e ]                    write a bootable image to EEPROM
         [ -P ]                    list available serial ports
         [ -r ]                    run the program after loading
         [ -t ]                    enter terminal mode after running the program
         [ -T ]                    enter PST-compatible terminal mode
         [ -v ]                    verbose output
         [ -? ]                    display a usage message and exit
         file[,addr]...            files to load
«1345

Comments

  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-01-25 18:57
    David Betz wrote: »
    I've recently posted the sources to p1load to github. p1load is a command line program for loading Spin binaries. It also includes a module called ploader.c that implements the Propeller ROM loader protocol and can interface to any serial driver that can provide an appropriate interface. This interface currently consists of a tx() function to transmit a buffer of bytes, an rx_timeout() function that receives a buffer of bytes with a timeout, and a reset() function that resets the Propeller, usually by toggling the DTR signal.

    p1load can be built for Mac OS X, Linux, or Windows.

    GitHub URL: https://github.com/dbetz/p1load
    p1load - a simple loader for the propeller - version 0.009, 2014-08-10
    usage: p1load
             [ -b baud ]               baud rate (default is 115200)
             [ -p port ]               serial port (default is to auto-detect the port)
             [ -e ]                    write a bootable image to EEPROM
             [ -P ]                    list available serial ports
             [ -r ]                    run the program after loading
             [ -t ]                    enter terminal mode after running the program
             [ -T ]                    enter PST-compatible terminal mode
             [ -v ]                    verbose output
             [ -? ]                    display a usage message and exit
             file[,addr]...            files to load
    

    Sounds nice David, a multi-platform loader. Now is there any chance that this loader could implement a 2-stage process so that it would load a "eeprom loader", boot into that which would then continue to communicate with p1load to load in the actual image file which in my case would be a 64k image but it could be any size and offset perhaps. So we would have to have a setting somewhere to point to this eeprom loader or it could be made general enough that it would work with various crystals by default to PLL8x for instance and auto-baud.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-25 18:59
    Sounds nice David, a multi-platform loader. Now is there any chance that this loader could implement a 2-stage process so that it would load a "eeprom loader", boot into that which would then continue to communicate with p1load to load in the actual image file which in my case would be a 64k image but it could be any size and offset perhaps. So we would have to have a setting somewhere to point to this eeprom loader or it could be made general enough that it would work with various crystals by default to PLL8x for instance and auto-baud.
    Yes, that is part of the plan.
  • JDatJDat Posts: 103
    edited 2015-01-25 19:07
    Will it work in 230_400 bit/sec like Brad Spin tools loader?
    Can you add read function?
    -d <filename> - Serial device to use (Default /dev/ttyUSB1)
    -p [123] - Program Mode
    1 - Ram only (Default)
    2 - Eeprom and shutdown
    3 - Eeprom and Run
    -f Load at high speed
    -u Read Propellers EEPROM into file <FileName> - WARNING will overwrite it if it exists with no prompt!
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-25 19:10
    JDat wrote: »
    Will it work in 230_400 bit/sec like Brad Spin tools loader?
    Can you add read function?
    Yes, I believe it will work at 230400 baud by supplying top command line option "-b 230400". No plans currently for a "read" function but I guess it could be considered. I guess you mean an EEPROM read function not a hub memory read function, right?
  • Peter JakackiPeter Jakacki Posts: 10,193
    edited 2015-01-25 19:15
    David Betz wrote: »
    Yes, I believe it will work at 230400 baud by supplying top command line option "-b 230400". No plans currently for a "read" function but I guess it could be considered. I guess you mean an EEPROM read function not a hub memory read function, right?

    Actually that EEPROM read function would be handy too as it would permit cloning easily. The read function would be part of the 1st stage loader which could run at much higher baud rates than 230400. I think you're onto something here David :)
  • JDatJDat Posts: 103
    edited 2015-01-25 19:18
    Like in manual ( http://www.fnarfbargle.com/bst/manual/bst_manual_0.04.pdf ):
    Versions 0.07-Pre1 or later have a new feature to read the contents of an eeprom connected to the
    Propeller. If you've lost your source code, or simply want to upload the eeprom to preserve user settings (in
    which case the checksum will need re-calculating before you can re-download), you can use the -u option.
    This will connect to the Propeller and download a small program into RAM. This copies the contents of the
    first 32k of eeprom into RAM, performs a 16 bit CRC on it and then uploads the contents to the PC. The PC
    receives the contents, checks the resulting CRC and writes it out to a file as named on the command line. If
    using the -u option without a file name, the whole process still occurs however there is no file written to disk.
    This is useful for testing communications integrity.

    + Additional command line argument for EEPROM download size, in case if user want to download all data from 64KB EEPROM.
    This isn't emergency, but could be nice feature.
  • Cluso99Cluso99 Posts: 18,069
    edited 2015-01-25 19:38
    David,
    Something I have thought about often is having a 2 stage loader.

    1) Loads a small boot-style program into hub ram and then executes it --> becomes stage 2.

    2) The loader can implement a number of features (and can be expanded upon quite simply)
    Speed could be increased beyond115,200 baud

    2a) EEPROM functions such as write an eeprom (lower 32KB), write upper 32KB (or partial) eeprom, execute lower or upper eeprom (could be expanded to support 128KB eeproms or even SPI Flash), could include reading back eeprom info

    2b) Load hub ram and execute it. This could be a faster downloader which could also be capable of performing the 2a and 2b functions.

    An obvious requirement is then for the loader to be able to jump into being a serial terminal (which you have already done).

    The stage 2 loader/program could also be a monitor/debugger.

    One last requirement I would like to see is the ability of the loader (pc end) to be able to go into a loop waiting for the user to reset the prop manually (or by an existing prop program issuing a software reset ie calling the booter rom). This would help remote over the air loading, and also loading using a simple usb-serial interface without requiring the transistor reset circuitry (or any DTR/RTS reset). This overcomes a propplug requirement.

    None of this is complex in the Loader (pc end) as it's really already there. It just needs to provide the "hooks".
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-26 02:39
    Cluso99 wrote: »
    David,
    Something I have thought about often is having a 2 stage loader.

    1) Loads a small boot-style program into hub ram and then executes it --> becomes stage 2.

    2) The loader can implement a number of features (and can be expanded upon quite simply)
    Speed could be increased beyond115,200 baud

    2a) EEPROM functions such as write an eeprom (lower 32KB), write upper 32KB (or partial) eeprom, execute lower or upper eeprom (could be expanded to support 128KB eeproms or even SPI Flash), could include reading back eeprom info

    2b) Load hub ram and execute it. This could be a faster downloader which could also be capable of performing the 2a and 2b functions.

    An obvious requirement is then for the loader to be able to jump into being a serial terminal (which you have already done).

    The stage 2 loader/program could also be a monitor/debugger.

    One last requirement I would like to see is the ability of the loader (pc end) to be able to go into a loop waiting for the user to reset the prop manually (or by an existing prop program issuing a software reset ie calling the booter rom). This would help remote over the air loading, and also loading using a simple usb-serial interface without requiring the transistor reset circuitry (or any DTR/RTS reset). This overcomes a propplug requirement.

    None of this is complex in the Loader (pc end) as it's really already there. It just needs to provide the "hooks".
    Since p1load is based on my p2load loader for the P2, it would be quite easy to add a second stage loader. p2load, of course, already has one. Anyway, all of your suggestions are good. I intend to move the GPIO reset code over from propeller-load to allow p1load to be used with the RaspberryPi as well.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-26 02:41
    Several of you have made suggestions and that's great. Would you mind posting them as "issues" on my github repository so they don't get lost in the flurry of forum messages?

    https://github.com/dbetz/p1load

    Thanks,
    David
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-26 19:16
    I just pushed changes to the github repository to use the GPIO reset method on the RaspberryPi. Unfortunately, I don't have a RaspberryPi setup right now so I have not tested this. At the moment, this is an unconditional setting. GPIO reset is always used in builds where RASPBERRY_PI is defined and DTR reset is always used in any other build.

    You should be able to build the RaspberryPi loader by typing this command:
    OS=raspberrypi make
    
  • GadgetoidGadgetoid Posts: 47
    edited 2015-01-27 03:07
    David Betz wrote: »
    I just pushed changes to the github repository to use the GPIO reset method on the RaspberryPi. Unfortunately, I don't have a RaspberryPi setup right now so I have not tested this. At the moment, this is an unconditional setting. GPIO reset is always used in builds where RASPBERRY_PI is defined and DTR reset is always used in any other build.

    You should be able to build the RaspberryPi loader by typing this command:
    OS=raspberrypi make
    

    Good news is it compiles fine. The bad news is that both the GPIO pin used for reset, and the polarity of the reset, could vary.

    On Propeller HAT, for example, it requires the GPIO to sit high, and then pulls low for a reset. It uses pin 17.

    Also. I've tweaked the reversed states into the code, and tried to detect the Propeller HAT on /dev/ttyAMA0 to no avail. I'll have to get a scope on it at some point to verify the reset line is being asserted. I have used propeller-load and my Python loader successfully to verify it's not a hardware issue.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 03:22
    Gadgetoid wrote: »
    Good news is it compiles fine. The bad news is that both the GPIO pin used for reset, and the polarity of the reset, could vary.

    On Propeller HAT, for example, it requires the GPIO to sit high, and then pulls low for a reset. It uses pin 17.

    Also. I've tweaked the reversed states into the code, and tried to detect the Propeller HAT on /dev/ttyAMA0 to no avail. I'll have to get a scope on it at some point to verify the reset line is being asserted. I have used propeller-load and my Python loader successfully to verify it's not a hardware issue.
    Hmmm... I didn't write the original code. It came from Heater. However, I might have integrated it wrong. I'd be happy to add a way to adjust the pin number and polarity once it is working for your particular configuration. Is this something you can help debug? While I have a couple of RaspberryPi modules, I don't have any of them setup at the moment.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 03:26
    Gadgetoid wrote: »
    I have used propeller-load and my Python loader successfully to verify it's not a hardware issue.
    When you say you've used propeller-load, do you mean Heater's pi-propeller-load program or do you mean you built the version of propeller-load from the default branch of the propgcc repository? The version in the repository has never been tested as far as I know. Heater asked me to add the code to support the RaspberryPi but I don't think he ever tried it after I pushed the changes.
  • GadgetoidGadgetoid Posts: 47
    edited 2015-01-27 04:41
    David Betz wrote: »
    Hmmm... I didn't write the original code. It came from Heater. However, I might have integrated it wrong. I'd be happy to add a way to adjust the pin number and polarity once it is working for your particular configuration. Is this something you can help debug? While I have a couple of RaspberryPi modules, I don't have any of them setup at the moment.

    Yes, I should be able to help with this. I already attempted to port the GPIO reset code from pi-propeller-load to p1load without success, it just wouldn't work and I could not figure out why. This is the same situation I fear! Need to get the scope out and see what's happening.

    I meant pi-propeller-load, which I have on my Pi, compiled and functioning. It was something of a hassle to get compiled though!
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 04:51
    Gadgetoid wrote: »
    Yes, I should be able to help with this. I already attempted to port the GPIO reset code from pi-propeller-load to p1load without success, it just wouldn't work and I could not figure out why. This is the same situation I fear! Need to get the scope out and see what's happening.

    I meant pi-propeller-load, which I have on my Pi, compiled and functioning. It was something of a hassle to get compiled though!
    Thanks for offering to help. I'm sure I messed up Heater's code in the process of adding it to propeller-load and then p1load. I'll try to get my RaspberryPi up and running. I have Bill Henning's RaspberryPi module as well as one called "RaspberryPi Icing" that I bought off of someone on eBay. What is the Hat module you're refering to?
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 05:14
    Interestingly, this "raspberry icing" module I bought from someone on eBay uses an unmodified version of propeller-load and the RTS setting for reset. They don't seem to require the special GPIO modification. How do they do that? Is there a way to tell Linux to use one of the GPIO lines for RTS?

    This is the module: http://www.100randomtasks.com/raspberry-icing

    Edit: Never mind. Reading the documentation, he says you need to replace propeller-load with something downloaded from the Parallax forums. My guess is that this is Heater's version.

    Heater: Did you hijack RTS for your GPIO reset code?
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 06:02
    Gadgetoid: Is this the error you got when trying to use p1load on the RaspberryPi?
    dbetz@raspberrypi ~/p1load $ sudo ./bin/linux/p1load fibo.binary -r -t
    Failed to write value!
    error: can't find a port with a propeller chip
    
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 06:08
    David Betz wrote: »
    Gadgetoid: Is this the error you got when trying to use p1load on the RaspberryPi?
    dbetz@raspberrypi ~/p1load $ sudo ./bin/linux/p1load fibo.binary -r -t
    Failed to write value!
    error: can't find a port with a propeller chip
    
    This didn't seem to work either:
    dbetz@raspberrypi ~/p1load $ sudo ./bin/linux/p1load -p /dev/ttyAMA0 fibo.binary -r -t
    error: no propeller chip on port '/dev/ttyAMA0'
    
    This is with the Raspberry Icing module with its reset jumper set to GPIO0.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 07:41
    I pushed a couple of minor changes to the RasperryPi build. Mainly, I added a define for GPIO_PIN at the top of osint_linux.c to select which GPIO pin is used for reset. This is currently set to 17 because that is what Heater's code used. I've tried changing it to 0 to match my Raspberry Icing board but that didn't make it work. Does someone know where I can find the sources to a working version of the pi-propeller-load program so I can compare that code to my modifications to propeller-load and p1load to find out what I did wrong?

    Thanks,
    David
  • mindrobotsmindrobots Posts: 6,506
    edited 2015-01-27 08:14
    David,

    I believe this is Heater's original repository (I believe)
    https://github.com/ZiCog/pi-propeller-load

    I haven't built from here, so I don't know if it is working.

    Hope this helps. I apologize if it is something you already are aware of.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 08:25
    Thanks Rick! I think I had that URL at one point but lost track of it. I'll compare what is in there with what I have in p1load to see if I made any transcription errors.
  • Heater.Heater. Posts: 21,230
    edited 2015-01-27 08:47
    Yep. That is the propeller loader that uses the GPIO for reset.
    It has been tested on Pi and MIPs based machines.
    It allows selection GPIO number and reset polarity from command line options.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 08:52
    Heater. wrote: »
    Yep. That is the propeller loader that uses the GPIO for reset.
    It has been tested on Pi and MIPs based machines.
    It allows selection GPIO number and reset polarity from command line options.
    Unfortunately, this loader source will no longer build because of changes in the P2 support in the default propgcc branch. I'll take your word for the fact that it was proven to work and I'll just compare the GPIO-related changes. I can't build it to verify that it still works. :-(
  • GadgetoidGadgetoid Posts: 47
    edited 2015-01-27 13:20
    I managed to build it a while back, I can confirm that it worked then and still works, it's my go-to loader for verifying everything is still sane when my Python loader is playing up.

    I could probably supply the binary if you want to use it to verify your setup?
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 13:25
    Gadgetoid wrote: »
    I managed to build it a while back, I can confirm that it worked then and still works, it's my go-to loader for verifying everything is still sane when my Python loader is playing up.

    I could probably supply the binary if you want to use it to verify your setup?
    Yes, that would be helpful. I guess I don't even know if my Propeller add-on board works at this point.
  • GadgetoidGadgetoid Posts: 47
    edited 2015-01-27 13:36
    Here we go: http://s000.tinyupload.com/index.php?file_id=53118395783859441251

    I don't believe it has any dependencies, it should *just work*

    Don't forget to specify GPIO pin and logic level with; -Dreset=gpio,PIN,low/high
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 15:30
    I verified that the loader that Gadgetoid posted works on my RaspberryPi.

    I've added handling of the "-D gpio=17,0" option to p1load.

    I've compared the source code from Heater's repository with what I have in p1load and can't find any significant differences.

    However, p1load still isn't working on the RaspberryPi. :-(

    I've pushed all of my changes to github but I'm not sure what to do next about getting this to work.

    One thing that confuses me is that I need to use gpio,17,0 to get propeller-load to work on my RaspberryPi but the instructions that came with my Raspberry Icing module says it is using GPIO0 for reset.
  • jmgjmg Posts: 15,173
    edited 2015-01-27 15:53
    David Betz wrote: »
    Yes, I believe it will work at 230400 baud by supplying top command line option "-b 230400".

    Some USB-UART devices accept only the ancient Baud choices, but most modern ones (FTDI,Silabs) will accept any baud value, and give you the nearest HW supported value.
    Usually they have a 12MHz virtual Baud Clock (FT2232H series have higher virtual baud clocks, and even better Baud Granularity, if that matters to you )

    If you have a better USB-UART path, then other intermediate baud values should also work.
  • David BetzDavid Betz Posts: 14,516
    edited 2015-01-27 18:54
    Well, I've tried lots of things and have still been unable to get p1load to work on the RaspberryPi. I guess I'll have to hook up a logic analyzer to figure out what's going wrong but I won't be able to do that until sometime next week. I'd welcome any help anyone might be willing to offer on this.
  • Bill HenningBill Henning Posts: 6,445
    edited 2015-01-27 19:27
    It has also been tested on the Banana Pi (which means it should also work on the Banana Pro).
    Heater. wrote: »
    Yep. That is the propeller loader that uses the GPIO for reset.
    It has been tested on Pi and MIPs based machines.
    It allows selection GPIO number and reset polarity from command line options.
Sign In or Register to comment.