These instructions are for the Debian distribution and its derivatives (e.g. Ubuntu), which use apt as a package manager. If your distribution doesn't have apt, you'll need to use its package manager (yum, rpm, or whatever else.).
There are two overall tasks. Firstly, getting ArdEx installed on the Arduino. Secondly, installing a terminal emulator on Linux.
This uses the program avrdude to upload the ArdEx interpreter to the Arduino through the USB cable. This only needs to be done once. From then on, the Arduino will be running ArdEx whenever it's turned on.
Firstly, download ardex.zip and save it as /tmp/ardex.zip.
Bring up a console window and enter
cd /tmp unzip ardex.zip sudo su - apt-get install avrdude
The first two commands unpack the ArdEx firmware in /tmp. The next command makes you the root user with authority to install new packages. The last command installs the necessary package. Here is example output:
$ cd /tmp $ unzip ardex.zip Archive: ardex.zip inflating: ardex.hex $ sudo su - # apt-get install avrdude Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libftdi1 libhidapi-libusb0 libusb-0.1-4 Suggested packages: dfu-programmer avrdude-doc The following NEW packages will be installed: avrdude libftdi1 libhidapi-libusb0 libusb-0.1-4 0 upgraded, 4 newly installed, 0 to remove and 4 not upgraded. Need to get 387 kB of archives. After this operation, 1,345 kB of additional disk space will be used. Do you want to continue? [Y/n] y Get:1 http://mirror.linux.org.au/debian stable/main i386 libusb-0.1-4 i386 2:0.1.12-32 [24.0 kB] Get:2 http://mirror.linux.org.au/debian stable/main i386 libftdi1 i386 0.20-4 [19.5 kB] Get:3 http://mirror.linux.org.au/debian stable/main i386 libhidapi-libusb0 i386 0.8.0~rc1+git20140818.d17db57+dfsg-2 [14.3 kB] Get:4 http://mirror.linux.org.au/debian stable/main i386 avrdude i386 6.3-20171130+svn1429-2 [330 kB] Fetched 387 kB in 1s (389 kB/s) Selecting previously unselected package libusb-0.1-4:i386. (Reading database ... 102185 files and directories currently installed.) Preparing to unpack .../libusb-0.1-4_2%3a0.1.12-32_i386.deb ... Unpacking libusb-0.1-4:i386 (2:0.1.12-32) ... Selecting previously unselected package libftdi1:i386. Preparing to unpack .../libftdi1_0.20-4_i386.deb ... Unpacking libftdi1:i386 (0.20-4) ... Selecting previously unselected package libhidapi-libusb0:i386. Preparing to unpack .../libhidapi-libusb0_0.8.0~rc1+git20140818.d17db57+dfsg-2_i386.deb ... Unpacking libhidapi-libusb0:i386 (0.8.0~rc1+git20140818.d17db57+dfsg-2) ... Selecting previously unselected package avrdude. Preparing to unpack .../avrdude_6.3-20171130+svn1429-2_i386.deb ... Unpacking avrdude (6.3-20171130+svn1429-2) ... Setting up libusb-0.1-4:i386 (2:0.1.12-32) ... Setting up libhidapi-libusb0:i386 (0.8.0~rc1+git20140818.d17db57+dfsg-2) ... Setting up libftdi1:i386 (0.20-4) ... Setting up avrdude (6.3-20171130+svn1429-2) ... Processing triggers for man-db (2.8.5-2) ... Processing triggers for libc-bin (2.28-10) ... localepurge: Disk space freed in /usr/share/locale: 0 KiB localepurge: Disk space freed in /usr/share/man: 0 KiB Total disk space freed by localepurge: 0 KiB #
Assuming you got similar results, it's time to plug your Arduino into a USB port. We need to work out which USB port gets assigned. Genuine Arduinos will usually be given /dev/ttyACM0, and clones often are assigned /dev/ttyUSB0. The easy way to tell is to type (still as root)
dmesg | tail
Here is what an Arduino clone shows me:
# dmesg | tail [ 9900.497387] usb 2-8: new full-speed USB device number 6 using xhci_hcd [ 9900.646685] usb 2-8: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54 [ 9900.646690] usb 2-8: New USB device strings: Mfr=0, Product=2, SerialNumber=0 [ 9900.646693] usb 2-8: Product: USB2.0-Serial [ 9900.679119] usbcore: registered new interface driver usbserial_generic [ 9900.679128] usbserial: USB Serial support registered for generic [ 9900.974185] usbcore: registered new interface driver ch341 [ 9900.974207] usbserial: USB Serial support registered for ch341-uart [ 9900.974234] ch341 2-8:1.0: ch341-uart converter detected [ 9900.975271] usb 2-8: ch341-uart converter now attached to ttyUSB0 #
And here is what I get with a genuine Arduino:
# dmesg | tail [ 15.970003] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready [ 8251.352387] usb 2-8: new full-speed USB device number 5 using xhci_hcd [ 8251.502723] usb 2-8: New USB device found, idVendor=2341, idProduct=0001, bcdDevice= 0.01 [ 8251.502729] usb 2-8: New USB device strings: Mfr=1, Product=2, SerialNumber=220 [ 8251.502732] usb 2-8: Product: Arduino Uno [ 8251.502734] usb 2-8: Manufacturer: Arduino (www.arduino.cc) [ 8251.502736] usb 2-8: SerialNumber: 856333434393511042E0 [ 8251.555069] cdc_acm 2-8:1.0: ttyACM0: USB ACM device [ 8251.555372] usbcore: registered new interface driver cdc_acm [ 8251.555373] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters #
As you can see, in this case the device is /dev/ttyACM0. Take note of whatever device your Arduino is given.
Now you can type exit to log out as root. We don't need special permissions to install the firmware which we're now ready to do. Type this in, using your Arduino's USB device name of course.
avrdude -q -V -p atmega328p -D -c arduino -b 115200 -P /dev/ttyACM0 -U flash:w:/tmp/ardex.hex:i
Here is the result:
$ avrdude -q -V -p atmega328p -D -c arduino -b 115200 -P /dev/ttyACM0 -U flash:w:/tmp/ardex.hex:i avrdude: AVR device initialized and ready to accept instructions avrdude: Device signature = 0x1e950f (probably m328p) avrdude: reading input file "/tmp/ardex.hex" avrdude: writing flash (12466 bytes): avrdude: 12466 bytes of flash written avrdude: safemode: Fuses OK (E:00, H:00, L:00) avrdude done. Thank you. $
Job done. And so polite too.
You can repeat those last few steps with multiple Arduinos if you need to install for a group of students or whatever.
There is a wide choice of terminal emulators on Linux. I like picocom which works well from the command line and has the features I want. However it doesn't come with an upload program, so I use ascii-xfr which is part of the minicom package. I keep both installed — they're not large packages.
Install both packages by typing:
sudo apt-get install minicom picocom
Which results in:
$ apt-get install minicom picocom Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libftdi1 libhidapi-libusb0 libusb-0.1-4 Use 'apt autoremove' to remove them. The following NEW packages will be installed: minicom picocom 0 upgraded, 2 newly installed, 0 to remove and 4 not upgraded. Need to get 318 kB of archives. After this operation, 1,062 kB of additional disk space will be used. Get:1 http://mirror.linux.org.au/debian stable/main i386 minicom i386 2.7.1-1+b1 [273 kB] Get:2 http://mirror.linux.org.au/debian stable/main i386 picocom i386 3.1-2 [45.4 kB] Fetched 318 kB in 12s (25.7 kB/s) Selecting previously unselected package minicom. (Reading database ... 102129 files and directories currently installed.) Preparing to unpack .../minicom_2.7.1-1+b1_i386.deb ... Unpacking minicom (2.7.1-1+b1) ... Selecting previously unselected package picocom. Preparing to unpack .../picocom_3.1-2_i386.deb ... Unpacking picocom (3.1-2) ... Setting up picocom (3.1-2) ... Setting up minicom (2.7.1-1+b1) ... Processing triggers for man-db (2.8.5-2) ... Processing triggers for mime-support (3.62) ... localepurge: Disk space freed in /usr/share/locale: 520 KiB localepurge: Disk space freed in /usr/share/man: 0 KiB Total disk space freed by localepurge: 520 KiB $
I use a simple script to run picocom with all the right options to talk to ArdEx. I suggest you use the same script (feel free to change that default TTY to suit):
#!/bin/sh # Start picocomm talking to Arduino on USB port. Default port # can be overridden on the command line. # TTY=/dev/ttyACM0 # default [ $# -eq 1 ] && TTY=$1 exec picocom -b 19200 --send-cmd "ascii-xfr -s -l 20 -n" $TTY
The key option is the send command. Ascii-xfr has an option -l 20, which pauses for 20 ms at the end of each line it transmits. This gives ArdEx time to do its work.
Save this script as /tmp/ardex then make it permanent by typing:
chmod 755 /tmp/ardex sudo mv /tmp/ardex /usr/local/bin/and just typing ardex should have you talking to the Arduino from your terminal. Picocom sends most keystrokes straight to the Arduino, but intercepts anything starting with <Ctrl>-a. In particular <Ctrl>-a <Ctrl>-s is used to send a file to ArdEx. And <Ctrl>-a <Ctrl>-x is how you exit picocom.
If you have had bother with these instructions, please let me know and I will do my best to improve them. You can e-mail suggested improvements to email@example.com.