Building and compiling project code using command line

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi.
I need some support for compiling and building Atmel Studio project code using command line. There are enough documents explaining programming Atmel studio project but I want to build and compile to generate the hex file.

Thanks in advance.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

but I want to build and compile to generate the hex file

The build inside AS6 already does this?

But anyway. When you build inside AS6 it simply creates a Makefile in either the Debug or Release sub-directory of the project directory and then invokes "make" to build that. So once you have built once that Makefile will exist and you can just star ta command prompt in that directory and (as long as PATH includes the location of make.exe and the avr-gcc.exe) you can then simply "make" there. In fact As6 makes this very easy indeed as the Tools menu has "Command Prompt" at the top. If you use that it not only starts a Command Prompt but it ensures that within it PATH holds the location of those tools. So just use Tools-Command Prompt then "make" there.

For example:

C:\Documents and Settings\asl\My Documents\Atmel Studio\test\test\Debug>make clean
rm -rf  test.o
rm -rf  test.d
rm -rf "test.elf" "test.a" "test.hex" "test.lss" "test.eep" "test.map" "test.srec"

C:\Documents and Settings\asl\My Documents\Atmel Studio\test\test\Debug>make
Building file: .././test.c
Invoking: AVR/GNU C Compiler : 3.4.2
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin\avr-gcc.exe"  -funsigned-char -funsigned-bitfields -Os -ffunction-sections -fdata-sections -fpack-struct -fshort-enums -mrelax -g2 -Wall -mmcu=atmega32
 -c -std=gnu99 -fno-inline-small-functions -save-temps -MD -MP -MF "test.d" -MT"
test.d" -MT"test.o"   -o "test.o" ".././test.c"
Finished building: .././test.c
Building target: test.elf
Invoking: AVR/GNU Linker : 3.4.2
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin\avr-gcc.exe" -o test.elf  test.o   -Wl,-Map="test.map" -Wl,--start-group -Wl,-lm  -Wl,--end-group -Wl,--gc-sections -mrelax -mmcu=atmega32
Finished building target: test.elf
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O ihex -R .eeprom -R .fuse -R .lock -R .signature  "test.elf" "test.hex"
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin\avr-objcopy.exe" -j .eeprom  --set-section-flags=.eeprom=alloc,load --change-section-lma .eeprom=0  --no-change-warnings -O ihex "test.elf" "test.eep"
|| exit 0
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin\avr-objdump.exe" -h -S "test.elf" > "test.lss"
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin\avr-objcopy.exe" -O srec -R .eeprom -R .fuse -R .lock -R .signature  "test.elf" "test.srec"
"C:\Program Files\Atmel\Atmel Toolchain\AVR8 GCC\Native\3.4.2.939\avr8-gnu-toolchain\bin\avr-size.exe" "test.elf"
   text    data     bss     dec     hex filename
    868       8       7     883     373 test.elf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Or you can call atmelstudio.exe /? to get the different switches.

This will build the whole project, but currently it's a non-blocking build, e.g. it seems to do nothing while it is running in the background.

:: Morten

 

(yes, I work for Atmel, yes, I do this in my spare time, now stop sending PMs)

 

The postings on this site are my own and do not represent Microchip’s positions, strategies, or opinions.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

go into debug/release folder and type make clean all..