Shop OBEX P1 Docs P2 Docs Learn Events
Is there a document that exists to explain how the byte codes are sent to the propeller? — Parallax Forums

Is there a document that exists to explain how the byte codes are sent to the propeller?

Was looking at the communication between Propeller Tool and the Prop 1 with a logic analyzer. Is there a specific baud rate used? I thought I'd seen some conversation way back in the day that explains how the code is sent but can't seem to find it.

Thanks in advance.

Comments

  • Don MDon M Posts: 1,652
    edited 2024-09-07 02:01

    The reason for my asking is I would like to try and have the RP2040 Pico send a binary file that was saved from Propeller Tool to a connected Propeller 1. I have a project in mind that I will be using the 2 connected together and thought maybe the Pico could emulate the programming of the Propeller. I'm able to read the binary file on the Pico. I'm guessing there must be a specific baud rate and timing that needs to be adhered to.

  • JonnyMacJonnyMac Posts: 9,068
    edited 2024-09-07 15:58

    Look in the Propeller Tool library for an object called ProperLoader.spin. It shows how to use a P1 to program a P1 -- you'd have to convert this to C or Python for the Pico. This might be tricky but your logic analyzer should be helpful it sorting out timing stuff.

    Or... you could roll your own (more code, but you decide how it works). If you have serial coms between the Pico and the P1 you could send a command that says, "Hey, here comes a new program to load into memory." Send the data from the Pico to the P1 and on the P1 side write it to the EEPROM. Once finished, the P1 could do a checksum of the EEPROM to send back to the Pico. If the Pico agrees, the P1 can reboot into the new code.

    In the laser tag product I designed we read the binary image from an SD card into the EE and reboot. This lets us break laser tag into constituent applications (Editor, Player, Referee). The compiled binary stops at the code; the P1 side clears the rest of the EEPROM and writes the initial stack frame. @"Jeff Martin" (Parallax) showed me how to do this but I cannot find the email that contains the details.

    This code works. In your case you could send a buffer across, maybe even with a checksum per buffer. Write that the the EEPROM and tell the Pico you're ready for the next. Once all the blocks are written do the clean-up (this is why all global variables start as 0) and setup the stack frame.

    pub load_eeprom(p_filename) | check, dbase, eeaddr, cs, p_buf
    
    '' Loads binary image file into eeprom.
    '' -- performs checksum validation on EEPROM
    
      check := wav.open_file(p_filename, "r")                       ' attempt to open file
      if (check <> 0)
        return false
    
      wav.rd_buf(@buf1, 16)                                         ' read initialization values
      dbase := buf1.word[5]                                         ' get DBASE (start of stack)
    
      wav.open_file(p_filename, "r")                                ' re-open file (resets file pointer)
      eeaddr := $0000
    
      repeat
        longfill(@buf1, 0,  BUF_SIZE >> 2)                          ' clear buffer
        check := wav.rd_buf(@buf1, BUF_SIZE)                        ' read block from file
        ee.wr_block(eeaddr, BUF_SIZE, @buf1)                        ' write to eeprom
        eeaddr += BUF_SIZE                                          ' update ee address
        if (check < BUF_SIZE)                                       ' if partial block
          quit                                                      '  we're done
    
      wav.close_file
    
      longfill(@buf1, 0,  BUF_SIZE >> 2)                            ' clear buffer
      repeat while (eeaddr < PGM_MEM)                               ' clear rest of non-protected eeprom
        ee.wr_block(eeaddr, BUF_SIZE, @buf1)                        ' write 0s to vars/stack space
        eeaddr += BUF_SIZE                                          ' update ee address
    
      ee.wr_long(dbase-8, $FFF9_FFFF)                               ' write initial stack frame
      ee.wr_long(dbase-4, $FFF9_FFFF)
    
      ' verify eeprom checksum
      ' -- checks entire image
    
      eeaddr := $0000                                               ' reset eeprom address
      cs := $00                                                     ' clear checksum
    
      repeat while (eeaddr < PGM_MEM)                               ' loop through 32K
        ee.rd_block(eeaddr, BUF_SIZE, @buf2)                        ' read block from eeprom
        p_buf := @buf2                                              ' point to buffer
        repeat BUF_SIZE                                             ' iterate through buffer
          cs += byte[p_buf++]                                       ' add byte to checksum
        eeaddr += BUF_SIZE                                          ' update address
    
      return (cs.byte[0] == $00)                                    ' return true if cs.0 is $00
    
  • @"Don M" said:
    Was looking at the communication between Propeller Tool and the Prop 1 with a logic analyzer. Is there a specific baud rate used? I thought I'd seen some conversation way back in the day that explains how the code is sent but can't seem to find it.

    Thanks in advance.

    https://github.com/rosco-pc/propeller-wiki/wiki/Download-Protocol

  • Don MDon M Posts: 1,652
    edited 2024-09-07 13:16

    Thanks @JonnyMac. I had forgotten about that program. I've actually used it is some previous projects. That helps a lot.

    Thanks @rosco_pc Very informative. Just what I was looking for.

  • Here's a PDF with some propeller programming info.

Sign In or Register to comment.