Xmodem sends a multiple of 128 bytes?

Go To Last Post
16 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am trying to send a file using TeraTerm using 128B size Xmodem transfer. I receive using ATSAMD21. It seems to be the PC is always sending a multiple of 128B? I would have expected the PC to send all 128B except for the last one where it would send a packet less than 128B when the filesize is not modulo 128? I cant seem to find this info anywhere...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

That should be available in Xmodem specs, not TeraTerm, I would think.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK have done some reading...it seems Xmodem always sends in 128B size including the last packet. Which is a pain...so it means the firmware file must be created in size of modulo 128. Or I could use xtended Xmodem which puts the file size and name in packet 0 at start. But which serial terminal program support this?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does anyone know the command sequence to get srec_cat to generate filesize modulo 128 padding?

 

In order words if the file size of the bin is say 12001, it's modulo 128 is 97. Meaning another 31 bytes and it would have been 0 for mod 128.

How can I say fill this 31 bytes with zero and pad. Well that bit is not too hard...but how do I find this modulo number 31 for a given filesize?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just started using srec_cat so not very versed, yet. BUT, I think you can have it fill up to any specified address. My application fills it to the very last byte (or maybe last byte - 2), then puts a crc16 in the last two bytes. 

 

Jim

 

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Normally the xmodem sender will pad if required.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

With ctrl-z...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ctrl Z is fine when its a text file...but when binary...its easy to have a byte that is 26 in value.

 

I need to consider padding to modulo 128 using srec_cat...someone tell me a way please... still wondering.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is the downside of Xmodem. There's nothing in the protocol to send the file size. Ymodem is a better choice. Otherwise arrange to send the exact number of bytes before you start.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

luvocean1 wrote:
Or I could use xtended Xmodem which puts the file size and name in packet 0 at start. But which serial terminal program support this?
I probably haven't used that stuff in 30 years.  HyperTerm claims to use Zmodem.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My experience of implementing Xmodem is that Hyperterminal is one of few programs that does not do it right. Just one of many reasons why I would always choose a decent terminal program and not the excrable Hyperterminal!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My memory of Xmodem on 300 baud telephone line modems was that it was terrible.

Xmodem-CRC or Ymodem were a dramatic improvement.

Zmodem has other features.

 

Nowadays,  telephone modems have Error Correction.   All protocols will benefit from this.

 

How are you transmitting your files?   Radio, phone, wired link, ... ?

 

Different transmission mediums will have different types of error.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I am transfering using usb to serial and off to micro...

I would like to use Xmodem if I can. So if i just crop and cut the firmware to 128byte boundary it should all be fine.

There has to be an option for padding to modulo 128 in srec_cat. :(

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
My experience of implementing Xmodem is that Hyperterminal is one of few programs that does not do it right.

I never had any problems with it in that respect!

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

luvocean1 wrote:
it seems Xmodem always sends in 128B size including the last packet.

Correct.

 

And XModem-1K always sends 1KB size blocks.

 

Or I could use xtended Xmodem which puts the file size and name in packet 0 at start. But which serial terminal program support this?

Loads of them - it is called, "YModem"

 

EDIT

 

http://www.rogtronics.net/files/...

 

http://web.cecs.pdx.edu/~rootd/c...

 

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Sat. Jun 3, 2017 - 11:44 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ctrl Z is fine when its a text file...but when binary...its easy to have a byte that is 26 in value.

I don't understand the problem.  It's only the last block that is padded with ctrl-Zs; if you have a binary file, it would have to actually END with ctrl-Z for there to be a problem.  And usually you can just write the ctrl-Zs anyway; it's not like wherever you're putting the data doesn't have its own idea of a block size.  (that's where XMODEM gets it from; 128byte floppy sectors.)

 

XMODEM was a simple block-oriented file transfer.

YMODEM added file info (length and filename) and used a CRC for error checking.  It permitted wildcard transfers...

ZMODEM added windowing...