Skip to content

Implement XMODEM bootloader #1

Description

@troeger

The bootstrap loader should wait on the serial line for receiving a Python script to be executed.

My recommendation is the XMODEM protocol - the sending clients are given for all operating systems and the protocol is trivial enough to go directly into the bootloader.

Example implementations for the server / receiver side are here:

https://github.com/Bandicoot/xmodem.c/blob/master/xmodem.c (without CRC, as described below)
https://github.com/crazyleen/rx/blob/master/xmodem.c (with CRC)

The protocol specification is here:

http://pauillac.inria.fr/~doligez/zmodem/ymodem.txt (page 20ff)

The server / receiver protocol (XMODEM without CRC) works like this:

  • <soh> is 0x01
  • <eot> is 0x04
  • <ack> is 0x06
  • <nak> is 0x15
  • <can> is 0x18
  • Serial line with 8N1 setup, 8bit characters sent
  • Receive protocol blocks of the following layout:
    • <soh>
    • <block number> (starts at 0x01, increments by 1, and wraps 0x0FF to 0x00)
    • <255-block number> (ones complement of the block number)
    • <--128 data bytes-->
    • <cksum> (sum of all data bytes, overflow ignored)
  • While waiting for data on the serial line, perform a timeout after 10s, and then send <nak>.
  • On protocol start, the sender will simply wait for the first <nak>. The server therefore may skip the initial timeout.
  • During the receiving of a block, the timeout should be 1 second, and then <nak> is sent.
  • Receiving of a correct protocol block is acknowledged by sending <ack>.
  • Receiving of an incorrect protocol block is acknowledged by sending <nak>.
  • Sender sends an <eot> if no more data is available, must be acknowledged by sending <ack>.
  • The last block is filled up to also have 128 data abytes.
  • Same block number being sent is ok and should be ignored.
  • In case anything goes horribly wrong, kill the connection by sending <can>.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions