Building the Project

Once we have created a project and populated it with a sample C file, it can now be build.

  1. Check that the automatic build option is turned off. Otherwise the project is rebuild everytime a source file is saved which might take some time (depending on project size and processor speed).




  2. With auto-build switched off, it makes sense to have Eclipse save all open files when the project is build.
    Open the Preferences (Window -> Preferences...) and go the the General -> Workspace tab, then set the Save automatically before build option.



  3. Right click on the AVRtest Project in the Project Explorer and select Build Project.

    The project is build with Debug configuration (which is the default configuration). The log of the build process is shown in the Console View and should look something like this:
    **** Build of configuration Debug for project AVRtest ****
    
    make all 
    Building file: ../main.c
    Invoking: AVR Compiler
    avr-gcc -Wall -g2 -gstabs -O0 -fpack-struct -fshort-enums -funsigned-char -funsigned-bitfields -mmcu=atmega16 
     -DF_CPU=1000000UL -MMD -MP -MF"main.d" -MT"main.d" -c -o"main.o" "../main.c"
    Finished building: ../main.c
     
    Building target: AVRtest.elf
    Invoking: AVR C Linker
    avr-gcc -Wl,-Map,AVRtest.map -mmcu=atmega16 -o"AVRtest.elf"  ./main.o   
    Finished building target: AVRtest.elf
     
    Invoking: AVR Create Extended Listing
    avr-objdump -h -S AVRtest.elf  >"AVRtest.lss"
    Finished building: AVRtest.lss
     
    Invoking: Print Size
    avr-size --format=avr --mcu=atmega16 AVRtest.elf
    AVR Memory Usage
    ----------------
    Device: atmega16
    
    Program:     160 bytes (1.0% Full)
    (.text + .data + .bootloader)
    
    Data:          0 bytes (0.0% Full)
    (.data + .bss + .noinit)
    Finished building: sizedummy
    
    Note: The format option --format=avr for the AVR Print Size tool is not available on all platforms.

  4. Within your project folder two new folders have appeared, Binaries and Debug.

    The Debug folder contains all generated files:

    • makefile: a makefile automatically generated by the build process.
    • *.mk: Automatically generated files required for the build process.
    • main.o: Object file containing the compiled code from main.c-
    • AVRtest.lss: A text file with a mixture of the original C source with the assembler output from the compiler.
    • AVRtest.elf: ELF format file containing the compiled application. This file can be used for most available AVR Simulators (like simulavr).

    The (virtual) folder Binaries contains a link to the generated elf file in the Debug folder.


Next: Changing the Build Configuration

Back: Creating a sample AVR C file