AVR  Tool  Set

These are a set of four (4) executable programs which are NOT owned or revised by HomeSCADA.  They are provided here simply as a courtesy in obtaining a complete tool set.  If you already have the Arduino IDE (Integrated Development Environment) installed, then it's likely that you already have a copy of each of them and can already execute them.  To see if this is the case, presented first is a handly batch file which you might consider saving.  It searches along the path to see if a specific file can be found.  Although most useful for verifying that a program or batch file can executed at the command prompt (and its location), the file specified doesn't have to be an .EXE or .BAT file.  We call it WhereIs.Bat, and is then invoked by simply using "WhereIs AVR-As.Exe", for example:

@Echo OFF
If Exist "%1" Echo %1 is in the present directory.
If Exist "%1" Exit /B 0
Echo Searching along the Path for "%1"
If "%~$Path:1" == "" Echo Not found in the current directory or along the PATH.
If NOT "%~$Path:1" == "" Echo Results: %~$Path:1

Each of the programs below is part of the GNU GCC Compiler Collection, customized for the AVR.  They are all Copyright (C) 2014 Free Software Foundation, Inc. or Copyright (C) 2015 Free Software Foundation, Inc.  Later versions may be available.  Those, as well as source code, may be obtained directly from the copyright holder.  Each program' version number can be output using "--version" after the program name.  Also, each of these programs supports the "--help" command line option to output a help sequence listing all of its options.  Note that there are two (2) dashes before "version" or "help".  It is beyond the scope of this document to explain all of the command line options of each program.  Presented below is an explanation of how each is used in the Asm.Bat and Assemble.Bat batch files.

AVR-As.Exe
This program is the Assembler.  It accepts Assembly Language source code, as well as any files which that source file pulls in (using .INCLUDE, e.g., ".INCLUDE Filename.Ptr") and attempts to create an .ELF file from it.  There are many target device options, as well as quite a few other options.  Here is an example command line, taken from the batch files, which invokes AVR-AS.Exe:
AVR-AS %1.Asm -mmcu=atmega328p --defsym MCU=328 -o %1.Elf -I X:\

Explanation of each portion of the command line above:
  AVR-AS   is the executable Assembler program's name.
  %1.Asm   specifies the source code file, as used within a batch file.
  -mmcu=atmega328p   specifies which microcontroller (MCU) is the target.
  --defsym MCU=328   defines a symbol that the .ASM source can use to know the MCU target.
  -o %1.Elf   specifies the name of the output file.
  -I X:\   adds X:\ to the directories searched for .INCLUDE files.

Note that the "X:\" refers to a substituted directory, which has been preset using the Subst command, e.g., "Subst X: C:\Source\FileSet".  The command could have been "-I C:\Source\FileSet" instead, but using Subst allows an already long command line to be shortened.

AVR-ObjCopy.Exe
This program is used to duplicate all or a portion of one object file to another object file.  While this may not initially seem to be of much use, its options reveal that it can translate the file format while copying.  This program is the program which generates the file in .HEX format, which is the standard ASCII format that each MIRTOS device can understand and use to make changes to its FLASH memory.  Each MIRTOS device can both output (i.e., "dump") in .HEX format and accept input in .HEX format to report the contents of or make changes to each its memory types: SRAM, EEPROM, and FLASH.

Here is an example of the relatively simple way that the batch files use this program:
AVR-ObjCopy -O ihex %1.Elf %1.Hex

Explanation of each portion:
  AVR-ObjCopy   is the executable program's name.
  -O ihex   selects the output format to be in Intel HEX.
  %1.Elf   specifies the name of the input object file to read.
  %1.Hex   specifies the name of the output object to write.

AVR-ObjCopy.Exe is most often used to generate a .HEX file in order to make FLASH (program) memory changes.  It can also be used to make changes to EEPROM or SRAM, but does not know about the two extensions which MIRTOS uses to change how it is to utilize the file.  To select EEPROM or SRAM instead of the default FLASH as the target, one of these iHex Extended Segment Address Record strings must be placed before any other iHex record:
:02000002E0001C   ; Select EEPROM as the target instead of FLASH 
:02000002F0000C ; Select SRAM as the target instead of FLASH
The comments (actually the first space above and everything after it) are merely informational and are not required:

AVR-ObjDump.Exe
This program simply dumps, or displays, information contained in an object file.  Like the other programs above, it has many options which are not utilized for our purpose, which is simple: generate a listing of the Assembly source just assembled.  This listing is very useful in debugging and verifying that all constant names and addresses were correctly resolved.  Notice that the default output is to the system console.

Here is how the batch files use this program:
AVR-ObjDump -d %1.Elf > %1.Lst

Explanation of each portion:
  AVR-ObjDump   is the executable program's name.
  -d %1.Elf   specifies the name of the input object file to read.
  > %1.Lst   redirects the standard output from the console to a .LST file with the same base name.

Of course, additional parameters, such as the starting and stopping addresses could be specified, but they are left for you to explore.

AVR-ReadELF.Exe
Finally, the last program in this set is used to generate information about the content of an .ELF file.  The information desired is a list of all symbols that the object file contains for the program of interest.  There are numerous other options which could be selected via the command line.  This is the way that this program is invoked withing the batch files to generate the complete symbol set:
AVR-ReadELF -s -W %1.Elf > %1.Sym

Explanation of each portion:
  AVR-ReadELF   is the executable program's name.
  -s   specifies the desired information: the symbol table.
  -W   allows each output line to go beyond 80 characters.
  %1.Elf   specifies the name of the input object file to read.
  > %1.Sym   redirects the standard output from the console to a .SYM file with the same base name.

The .SYM symbol file is often quite long and includes every constant address and defined value generated by the Assembly.  After that file is created, it is read by the MakePtr program to create a file with all of the named addresses, or pointers.  This most recent .PTR file is then pulled in at the beginning of the subsequent assembly pass.

Downloads page