Copying files to NuttX over serial (the slow way)

Some years ago I show it was possible to copy files to Linux over serial without using zmodem or other protocol:

Today I faced a similar issue, I need to copy a file from host computer to NuttX over serial without using zmodem support.

Then I created a simple 48 bytes file on Linux side and ran these commands on NuttX console (using minicom) :

NuttShell (NSH)                                                                                 
nsh> mount -t vfat /dev/sda /mnt                                
nsh> dd if=/dev/console of=/mnt/test.txt bs=16 count=3                                         

Now on minicom type: Ctrl + A – Y to select a file to paste.

It worked fine, see:

nsh> ls -l /mnt
 -rw-rw-rw-      48 test.txt
nsh> cat /mnt/test.txt
This is a small test!
Just to prove the idea!!!

Now I decided to send a bigger file (4KiB) :

I used the COPYING file of NuttX, just cutting it to 4KiB:

$ sudo dd if=COPYING of=/COPYING bs=1 count=4096

Then on minicom:

nsh> dd if=/dev/console of=/mnt/COPYING bs=64 count=64                                          

Ctrl + A - Y

After selecting the file I noticed that the TXD LED on USB/Serial adapter was blinking at each 1 second. So after about 64 seconds it transfered the 4KiB file.

nsh> ls -l /mnt
 -rw-rw-rw-      48 test.txt
 -rw-rw-rw-    4096 COPYING

nsh> cat /mnt/COPYING
COPYING -- Describes the terms under which Nuttx is distributed. A
copy of the BSD-style licensing is included in this file. In my
words -- I believe that you should free to use NuttX in any
environment, private, private, commercial, open, closed, etc.
provided only that you repect the modest copyright notices as

Many lower-level networking components of NuttX derive from uIP which
has a similar BSD style

That is it! It is not the faster transfer solution but it proved to work.
I think this same approach should have worked on Linux at that time.

2 thoughts on “Copying files to NuttX over serial (the slow way)

  1. Using /dev/console as your input is not binary safe. There are quite a few characters that will cause something odd to happen, possibly interrupting your “dd” command and then performing crazy commands on your behalf.

    1. Hi Paul,
      Yes, it could fail to binary file. But as we can find in the link inside this post, you can transfer text encoded binary and convert it to binary. But I think it is safer to use ZMODEM on NuttX.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s