2

I'm using XMODEM to transfer a binary file from an Ubuntu VM to an embedded Linux target, like so:

$ sudo screen /dev/ttyUSB0 115200
$ rx test

CTRL-A:

$ exec !! sx -b test

Now, "test" transfers successfully, but when I inspect it on both the VM and the target, I get the following:

  • VM: Size = 22938 bytes
  • Target: Size = 23040 bytes

In addition, the permissions are reduced on the target.

Why is this, and how can I ensure the file transferred is the same as the source?

1 Answer 1

4

XMODEM transfers in 128-byte blocks, so the file will always be padded up to the next 128-byte boundary. YMODEM and ZMODEM include the filesize in the protocol and can transfer the correct number of bytes, but if you are limited to XMODEM, I suggest using tar to wrap up the file on the host, which will encode the file size and perms, then untar it on the target. tar might complain about the spare padding bytes, but it should still work.

2
  • Thanks, that's useful. Now I just have to work out how to enable decompressing tars in my Busybox configuration!
    – Ed King
    Commented Mar 4, 2016 at 15:47
  • If your busybox config has tar but no support for gzip or bzip, you don't need them. Just use tar -cvf files.tar binaryfile on the VM side, and tar -xvf files.tar on the target. As a bonus, you can pack as many files in there as you want. But you might want to enable compression (-z or -j options) if the files are large. Commented Mar 4, 2016 at 16:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.