Cowascript - AVRDUDE HEX uploader etc for MacOS & Linux

Cowascript

I've written a script for uploading HEX files to Atmel chips using AVRDUDE.

The script will also verify, erase, read (eeprom, flash and fuses) and perform multi-writes.

This was written to allow "customers" the ability to upload replacement programs themselves without them having access to the sketch. The script is written to work with BASH and works on MacOS and should also work in Linux.

Setup

Download the zip, un-compress it and place it in the Applications directory.

Inside the folder is a directory "Drivers". Run the relevant driver file (if this computer does not have the Arduino IDE already), the driver directory can then be deleted or just left as it is.

To run the script double click on "Cowascript"

The folders are:

hex - This is where the script looks for new HEX files and will list them all for the user to select one.
bin - This is where the script keeps the AVRDUDE program and config files
read - This is where the script writes the contents of the chip when it reads them

What it does....

The script starts by asking the user what they want to do: program/erase/read or verify a chip or multi-write a batch of chips.

The script then reads all the serial ports on the computer, it decides which of these are relevant and if there is just one it automatically selects it, if there are more than one it gives the user the ability to select the right one and if none it aborts.

The user can also select the chip type (but by setting a labelled variable in the script this question can be automated too).

The user will also be shown all the HEX files within the "hex" folder.

Making changes....

The script will work as it is but it may be necessary to make a few minor changes......

The chip select menu is defined using the following lines:

chip[1]="atmega328p" ; name[1]="Atmel Mega 328p"
chip[2]="atmega8" ; name[2]="Atmel Mega 8a"
chip[3]="atmega1280" ; name[3]="Atmel Mega 1280"
chip[4]="atmega2560" ; name[4]="Atmel Mega 2560"
chip[5]="atmega1284P" ; name[5]="Atmel Mega 1284P"

If you wish to add a chip just follow the same layout. So lets add a Tiny4, we do this by adding the following line:

chip[6]="t4" ; name[6]="Atmel Tiny 4"

The array "chip" is the definition code for the specific chip, there is a full list at the end of the script. The array "name" is a user readable title for that device or chip. You could just list devices as I have done so far or you could use the name array for the device names instead.

chip[1]="atmega328p" ; name[1]="Device 1"
chip[2]="atmega328p" ; name[1]="Device 2"
chip[3]="atmega328p" ; name[1]="Device 3"
chip[4]="atmega328p" ; name[1]="Device 4"
chip[5]="atmega1280" ; name[1]="Device 4 serial number 20000 onwards"
chip[6]="atmega1280" ; name[1]="Device 5"
chip[7]="atmega1280" ; name[1]="Device 6"
chip[8]="atmega2560" ; name[1]="Device 7"

etc etc

If your only want the user to be able to upload a new program then you can force the "menu" to option 1 by setting menuoption=1 after the chip definitions. You could set this to any of the menu options by selecting that number. If you do specify the option number then the menu will not display.

The sketch makes an intelligent guess at which serial ports are relevant. If this missed ones you need such as bluetooth ones etc then you can list them all by going to the serial port select section and removing the "if" and "fi" lines. There is a label in the script which explains this.

I have created this script for everyones use. If there are any suggestions for improvements, bug fixes, changes etc then post them and I can add them to the download.

I did post this in the wrong section so deleted it and sticking it in here instead :slight_smile:

DOWNLOAD CURRENT VERSION : www.cowasaki.co.uk/cowascript/Cowascript100.zip

It this script work on window7 ? Like basic stamp parallax software, it can be compile to .exe, customer just connect rs232 port and run the .exe file it will be load program to basic stamp. Can arduino being setup like that?

majdi_mohammad:
It this script work on window7 ? Like basic stamp parallax software, it can be compile to .exe, customer just connect rs232 port and run the .exe file it will be load program to basic stamp. Can arduino being setup like that?

NO it is a MacOS script. You could write a batch file in Windows to do the same, it would be a simple matter to re-write this script as a Windows batch file.

Hello,

i tried the script on OpenSuse 12.2 with a Duemillanove connected on ttyUSB0.
I can us the Arduino IDE for upload without any problem.

> ./Cowascript

Cowasaki's

AVRDUDE / Atmel chip utilty script.

What would you like to do:

1. Program new HEX file
2. Read chip into files
3. Verify chip
4. Erase chip
5. Multi program mode

Choose menu option

1

##############################################################################

The following is a list of the available serial ports:

ls: cannot access /dev/*.*: No such file or directory

No relevant port

>

Changing lin 78 :
sport=$(ls /dev/.)
to
sport=$(ls /dev/*)
does not fix it

any idea ?

wally

OK,
1 step ahead:

changed line 77-87 to:

cd $DIR
sport=$(ls /dev/)
i=0
for j in $sport
do
  if [[ "$j" == ttyUSB* ]] ; then
    i=$(( i + 1 ))
    echo "$i. $j"
    port[i]=$j
  fi
done

now i get :

....
HEX file installation script

Writing - Blink.cpp.hex
to port - ttyUSB0
IC      - atmega328p

Are you sure (yes/no)

yes
./Cowascript_mod: line 209: bin/avrdude: cannot execute binary file
>

You are getting there :smiley:

Looks like it just cannot locate the AVRDUDE application. Should just be a matter of changing the location in the script.

me too,Looks like it just cannot locate the AVRDUDE application. Should just be a matter of changing the location in the script.

I know this is an old thread but I just wanted to send a THANK YOU to cowasaki. This is exactly what I needed. There are plenty of GUI options for uploading HEX files in Windows, but this appears to be the only option on OS X. Cheers.

Great script. If you need to distribute a HEX file you can use Platypus - Create Mac apps from command line scripts | to make an app out of the script. With some modifications in the script you can make a an one click install. I used it for SafeCast Updater.

regards
rob oudendijk

Ive written a desktop program that can update an arduino but thanks

I know this is a old post but I am new to all this and have tried to load a hex file to an Uno
but come up with this screen