Author Topic: Info: Propeller 1 Boot Sequence and Serial Load (3-Bit) Protocol  (Read 5259 times)

trodoss

  • Guest
Info: Propeller 1 Boot Sequence and Serial Load (3-Bit) Protocol
« on: December 19, 2012, 11:08:05 AM »
Hi all!

I figured that it would be a help to find and document the Propeller 1 Boot Sequence and load protocol, as it is important in moving away from being dependent on Propellent.dll (for cross-platform applications).

As I find additional information I will add them to this thread, and/or eventually added to a Wiki somewhere.  If you have anything you have found useful/helpful, please feel free to do so.  The more information we can collect the better ;)

If you look in the Propeller Manual, there is a description under "Boot Up Procedure," where the boot sequence is described.

In a thread, Chip Gracey posted the following (in Spin code) about how the serial load process works:
Code: [Select]
BOOT SEQUENCE
-------------

PC:     set 115200-8-N-1
        DTR low
        wait at least 10ms
        DTR high
        wait 100ms (+-10% tolerance)
        send $F9 (%0100111111 timing calibration)
        LFSR: taps = $B2, initialy = "P"
        send bitwise LFSR[250] ($FF/$FE)
        send $F9[250+8] for bitwise responses ($FE/$FF)
        receive bitwise LFSR[250] + version[8] within 50ms
                if timeout or mismatch, done (hardware not found error)
        send encoded command long (up to 3 bits sent per serial byte):

                0 = shutdown
                1 = load ram, then run
                2 = load ram+eeprom+verify, then shutdown
                3 = load ram+eeprom+verify, then run

                if command 0, done (okay)

        send encoded length long
        send encoded data longs
        send $F9 every 10ms for bitwise response(s):

                if command 1-3, receive bitwise checksum pass/fail within 10(?) seconds
                                        if timeout, done (connection error)
                                        if checksum fail, done (checksum error)

                if command 1,   done (okay)

                if command 2-3, receive bitwise program pass/fail within 5 seconds
                                        if timeout, done (connection error)
                                        if program fail, done (program error)
                                receive bitwise verify pass/fail within 2 seconds
                                        if timeout, done (connection error)
                                        if verify fail, done (verify error)
                                done (okay)


CHIP:   <reset>
        wait for up to 150ms @20MHz for $F9 + bitwise LFSR[250]
                if timeout or mismatch, EEBOOT

        use incoming $F9 bytes to convey bitwise LFSR[250] + version[8]

        receive encoded command[32]:

            if command 0, 4+: SHUTDOWN

            if command 1..3:

                receive encoded length[32]
                receive encoded data[32], dump into $0000..length<<2-1
                fill length<<2..$7FFC with $00
                write dbase @$000A structure: long[dbase-4] = $FFF9FFFF, long[dbase-8] = $FFF9FFFF
                bytewise sum $0000..$7FFF for checksum verify
                        if checksum failure, convey error on next $F9, SHUTDOWN
                        else, convey okay on next $F9

                if command 1, LAUNCH

            if command 2-3:

                program eeprom from ram
                        if eeprom timeout (10ms @20MHz), convey error on 2nd $F9, SHUTDOWN
                        else, convey okay on next $F9
                verify eeprom against ram
                        if verify fail, convey error on 2nd $F9, SHUTDOWN
                        else, convey okay on next $F9

                if command 2, SHUTDOWN

                if command 3, LAUNCH


EEBOOT:         read eeprom into ram
                LAUNCH

LAUNCH:         if word at $0006 is not $0010, SHUTDOWN
                setclk(byte[$0004] & $78)
                wait 20ms at 20MHz
                setclk(byte[$0004])
                launch interpreter from $0004 in current cog

SHUTDOWN:       dira=0, setclk($02)

Useful Code:
In the OBEX, there is Propeller Loader v1.0 (PropellerLoader.spin)
Chip Gracey posted Delphi loader code.
Louis Digital on the Parallax forums posted this code in Pascal.
Jasper_M posted .Net code here.
The PropGCC implementation of the serial load protocol (Michael Betz, Steven Denson) can be found here.


Useful Threads for Reference:
Serial Boot Loader Thread:
http://forums.parallax.com/showthread.php?96822-serial-boot-loader&p=670593#post670593

Boot Sequence I would need some help Thread:

http://forums.parallax.com/showthread.php?101114-Boot-Sequence-I-would-need-some-help

Propeller Loader Thread:

http://forums.parallax.com/showthread.php?86311-Propeller-Loader&p=591445#post591445

The 3-Bit Protocol Thread:
http://forums.parallax.com/showthread.php?97913-The-3-Bit-Protocol
« Last Edit: December 19, 2012, 11:53:40 AM by trodoss »

blittled

  • Out chasing squirrels
  • Sr. Member
  • ****
  • Posts: 391
  • I don't know the meaning of the word impossible!
    • View Profile
Re: Info: Propeller 1 Boot Sequence and Serial Load (3-Bit) Protocol
« Reply #1 on: December 19, 2012, 12:21:01 PM »
Thanks, Trodoss. I've been looking into finding some "Propellent free" alternative since I'm looking into some cross-platform Java as a possibility for a scope pc interface.

Here is another link with a C Code loader https://code.google.com/p/propgcc/source/browse/loader/src/PLoadLib.c  and https://code.google.com/p/propgcc/source/browse/loader/src/PLoadLib.h

trodoss

  • Guest
Re: Info: Propeller 1 Boot Sequence and Serial Load (3-Bit) Protocol
« Reply #2 on: December 19, 2012, 12:36:43 PM »
No problem.  I had added the PropGCC loader in the code section, however it is easy to miss.

Since there is no "official" documentation on the serial load protocol/process (other than what Chip provided in various posts), and what is there is sometimes incomplete, it may still come down to experimentation.  I haven't looked into getting code to work in Java, however the .Net code that Jasper_M provided might be the closest translation currently available. 

That code works pretty well, and provided that you have a more recent build of Mono on Linux (tried on Ubuntu 12.04 LTS and 12.10, Debian 6.0) it is possible to iterate the serial ports "safely" (only picking up ones that are possible serial ports).  Technically that has to do more with the Mono code base being used ;)  There were changes made around 2010 and 2011 that seem to have been making their way into the OS distributions which are making at least Mono better for serial.

The same is likely true for Java as well.  I have to think that some form of managed code (Java/C#/Pyhon) would be a very good way to go.
« Last Edit: December 19, 2012, 12:41:31 PM by trodoss »

blittled

  • Out chasing squirrels
  • Sr. Member
  • ****
  • Posts: 391
  • I don't know the meaning of the word impossible!
    • View Profile
Re: Info: Propeller 1 Boot Sequence and Serial Load (3-Bit) Protocol
« Reply #3 on: December 19, 2012, 01:04:20 PM »
Oops missed that link :). I agree that managed code is the way to go and a cross platform language I feel will produce something that is more popular with the end user. I see many posts on Parallax's forum complaining about OS specific apps.

As for Java I'm looking at RXTX for serial communication and the GLG toolkit http://www.genlogic.com/free_community_edition.html which has some impressive Java control plugins.

rosco_pc

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Info: Propeller 1 Boot Sequence and Serial Load (3-Bit) Protocol
« Reply #4 on: December 26, 2012, 01:35:43 AM »
Jut to be complete.
There is also the Catalina loader: http://forums.parallax.com/showthread.php?143979-Catalina-3.10-Black-is-Back!

And a python loader: http://forums.parallax.com/showthrea...354#post622354

(and yes, I like Python much better then Java, C#. Although I'm pretty agnostic with regards to languages, as I code in Erlang, PHP, Python, Javascript and VBA  on a regular basis. And have coded in Pascal, Oberon-2, C, Java, Plex, Perl and some obscure others I don't even remember the name of :D )

cjohnweb

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Info: Propeller 1 Boot Sequence and Serial Load (3-Bit) Protocol
« Reply #5 on: February 22, 2016, 01:10:35 PM »
Hello,

I am interested in the Python Loader but the link seems to be dead. If I run a Python interpreter on an android phone do you think I could get this to work on Android? Or does anyone know of an Android compatible solution?

Many thanks!