Changeset 36


Ignore:
Timestamp:
04/06/2007 07:38:18 AM (5 years ago)
Author:
npereira
Message:

Updated makefile.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • nano-RK/projects/basic_rf/rf_rx/makefile

    r1 r36  
    1 #------------------------------------------------------------------------------- 
    2 # Based on the WinAVR sample makefile written by Eric B. Weddington,  
    3 # Jörg Wunsch, et al. 
    4 # 
    5 # Additional material for this makefile was submitted by: 
    6 #  Tim Henigan 
    7 #  Peter Fleury 
    8 #  Reiner Patommel 
    9 #  Sander Pool 
    10 #  Frederik Rouleau 
    11 #  Markus Pfaff 
    12 #  Anthony Rowe 
    13 # 
    14 # On command line: 
    15 #    make all = Make software. 
    16 #    make clean = Clean out built project files. 
    17 #    make coff = Convert ELF to AVR COFF (for use with AVR Studio 3.x or VMLAB). 
    18 #    make extcoff = Convert ELF to AVR Extended COFF (for use with AVR  
    19 #                   Studio 4.07 or greater). 
    20 #    make program = Download the hex file to the device, using avrdude.  
    21 #                   Please customize the avrdude 
    22 #                    settings below first! 
    23 #    make filename.s = Just compile filename.c into the assembler code only 
    24 # 
    25 # To rebuild project do "make clean" then "make all". 
    26 # 
    27 #------------------------------------------------------------------------------- 
    28  
    29  
    30 # Platform name  cc2420DK, firefly, micaZ 
    31 PLATFORM = firefly2 
    32  
    33 ROOT_DIR = ../../.. 
    34  
    35 # We use the stripped version to avoid typos  
    36 PLATFORM_TYPE = $(strip $(PLATFORM)) 
    37  
    38 # Output format. (can be srec, ihex, binary) 
    39 FORMAT = ihex 
     1# Platform name  cc2420DK, firefly, micaZ, firefly2, firefly2_2 
     2PLATFORM = firefly2  
    403 
    414 
     
    436TARGET = main 
    447 
     8# Set the Port that you programmer is connected to  
     9PROGRAMMING_PORT = /dev/ttyUSB1 # programmer connected to serial device 
    4510 
    46 # Optimization level, can be [0, 1, 2, 3, s]. 0 turns off optimization. 
    47 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.) 
    48 OPT = s 
     11# Set this such that the nano-RK directory is the base path 
     12ROOT_DIR = ../../../ 
     13 
     14# Set platform specific defines  
     15# The following will be defined based on the PLATFORM variable: 
     16# PROG_TYPE  (e.g. avrdude, or uisp) 
     17# MCU (e.g. atmega32, atmega128, atmega1281)  
     18# RADIO (e.g. cc2420) 
     19include $(ROOT_DIR)/include/platform.mk 
    4920 
    5021 
    51 ifeq ($(PLATFORM_TYPE),firefly) 
    52 # FireFly Architecture specific includes should go here... 
    53 # Notice that this sets architecture path, the mcu type and the radio 
    54 MCU = atmega32 
    55 RADIO = cc2420 
    56 SRC = 
     22SRC = $(TARGET).c 
     23 
     24# Add extra source files.  
     25# For example: 
     26# SRC += $(ROOT_DIR)/src/platform/$(PLATFORM_TYPE)/source/my_src1.c  
     27# SRC += $(ROOT_DIR)/src/platform/$(PLATFORM_TYPE)/source/my_src2.c  
     28 
     29# Add extra includes files.  
     30# For example: 
     31# EXTRAINCDIRS += $(ROOT_DIR)/src/platform/include 
    5732EXTRAINCDIRS = 
    58 PLATFORM_FOUND= true  
    59 endif 
    60  
    61 ifeq ($(PLATFORM_TYPE),firefly2) 
    62 # micaZ Architecture specific includes should go here... 
    63 # Notice that this sets architecture path, the mcu type and the radio 
    64 MCU = atmega128 
    65 RADIO = cc2420 
    66 SRC = 
    67 EXTRAINCDIRS = 
    68 PLATFORM_FOUND = true  
    69 endif 
    70  
    71 ifeq ($(PLATFORM_TYPE),micaZ) 
    72 # micaZ Architecture specific includes should go here... 
    73 # Notice that this sets architecture path, the mcu type and the radio 
    74 MCU = atmega128 
    75 RADIO = cc2420 
    76 SRC = 
    77 EXTRAINCDIRS = 
    78 PLATFORM_FOUND = true  
    79 endif 
    80  
    81 ifeq ($(PLATFORM_TYPE),cc2420DK) 
    82 # micaZ Architecture specific includes should go here... 
    83 # Notice that this sets architecture path, the mcu type and the radio 
    84 MCU = atmega128 
    85 RADIO = cc2420 
    86 SRC = 
    87 EXTRAINCDIRS = 
    88 PLATFORM_FOUND = true  
    89 endif 
    9033 
    9134 
    92 RADIO_TYPE = $(strip $(RADIO)) 
    93  
    94 ifdef PLATFORM_FOUND 
    95 SRC += $(TARGET).c 
    96  
    97 SRC += $(ROOT_DIR)/src/radio/$(RADIO_TYPE)/source/hal_rf_set_channel.c 
    98 SRC += $(ROOT_DIR)/src/radio/$(RADIO_TYPE)/source/hal_rf_wait_for_crystal_oscillator.c 
    99 SRC += $(ROOT_DIR)/src/radio/$(RADIO_TYPE)/source/basic_rf.c  
    100  
    101 SRC += $(ROOT_DIR)/src/platform/$(PLATFORM_TYPE)/source/ulib.c  
    102 SRC += $(ROOT_DIR)/src/platform/$(PLATFORM_TYPE)/source/hal_wait.c 
    103  
    104  
    105 SRC += $(ROOT_DIR)/src/kernel/source/nrk.c 
    106 SRC += $(ROOT_DIR)/src/kernel/source/nrk_events.c 
    107 SRC += $(ROOT_DIR)/src/kernel/source/nrk_cpu.c 
    108 SRC += $(ROOT_DIR)/src/kernel/source/nrk_error.c 
    109 SRC += $(ROOT_DIR)/src/kernel/source/nrk_stack_check.c 
    110 SRC += $(ROOT_DIR)/src/kernel/source/nrk_task.c 
    111 SRC += $(ROOT_DIR)/src/kernel/source/nrk_time.c 
    112 SRC += $(ROOT_DIR)/src/kernel/source/nrk_idle_task.c 
    113 SRC += $(ROOT_DIR)/src/kernel/source/nrk_scheduler.c 
    114 SRC += $(ROOT_DIR)/src/kernel/source/nrk_driver.c 
    115 SRC += $(ROOT_DIR)/src/kernel/hal/$(MCU)/nrk_timer.c 
    116 SRC += $(ROOT_DIR)/src/kernel/hal/$(MCU)/nrk_status.c 
    117  
    118 SRC += $(ROOT_DIR)/src/net/rt_link/rtl_scheduler.c 
    119  
    120 # List any extra directories to look for include files here. 
    121 #     Each directory must be seperated by a space. 
    122 EXTRAINCDIRS += $(ROOT_DIR)/src/platform/include 
    123 EXTRAINCDIRS += $(ROOT_DIR)/src/platform/$(PLATFORM_TYPE)/include 
    124 EXTRAINCDIRS += $(ROOT_DIR)/src/radio/$(RADIO_TYPE)/include 
    125 EXTRAINCDIRS += $(ROOT_DIR)/src/drivers/include 
    126 EXTRAINCDIRS += $(ROOT_DIR)/src/drivers/platform/$(PLATFORM_TYPE)/include 
    127 EXTRAINCDIRS += $(ROOT_DIR)/src/kernel/include 
    128 EXTRAINCDIRS += $(ROOT_DIR)/src/kernel/hal/include 
    129 EXTRAINCDIRS += $(ROOT_DIR)/src/net/rt_link 
    130 EXTRAINCDIRS += $(ROOT_DIR)/src/net/rt_net 
    131  
    132  
    133 # List Assembler source files here. 
    134 # Make them always end in a capital .S.  Files ending in a lowercase .s 
    135 # will not be considered source files but generated files (assembler 
    136 # output from the compiler), and will be deleted upon "make clean"! 
    137 # Even though the DOS/Win* filesystem matches both .s and .S the same, 
    138 # it will preserve the spelling of the filenames, and gcc itself does 
    139 # care about how the name is spelled on its command-line. 
    140 ASRC = $(ROOT_DIR)/src/kernel/hal/$(MCU)/atmel_hw_specific.S 
    141  
    142 else 
    143  
    144 PLATFORM_ERROR="ERROR Unknown platform:" 
    145 endif 
    146  
    147 # Optional compiler flags. 
    148 #  -g:        generate debugging information (for GDB, or for COFF conversion) 
    149 #  -O*:       optimization level 
    150 #  -f...:     tuning, see gcc manual and avr-libc documentation 
    151 #  -Wall...:  warning level 
    152 #  -Wa,...:   tell GCC to pass this to the assembler. 
    153 #    -ahlms:  create assembler listing 
    154 CFLAGS = -g -D NANORK -O$(OPT) \ 
    155 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums \ 
    156 -Wall \ 
    157 -Wa,-adhlns=$(<:.c=.lst) \ 
    158 $(patsubst %,-I%,$(EXTRAINCDIRS)) 
    159  
    160  
    161 # Set a "language standard" compiler flag. 
    162 #   Unremark just one line below to set the language standard to use. 
    163 #   gnu99 = C99 + GNU extensions. See GCC manual for more information. 
    164 #CFLAGS += -std=c89 
    165 #CFLAGS += -std=gnu89 
    166 #CFLAGS += -std=c99 
    167 CFLAGS += -std=gnu99 
    168  
    169  
    170 # Optional assembler flags. 
    171 #  -Wa,...:   tell GCC to pass this to the assembler. 
    172 #  -ahlms:    create listing 
    173 #  -gstabs:   have the assembler create line number information; note that 
    174 #             for use in COFF files, additional information about filenames 
    175 #             and function names needs to be present in the assembler source 
    176 #             files -- see avr-libc docs [FIXME: not yet described there] 
    177 ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs  
    178  
    179  
    180 # Optional linker flags. 
    181 #  -Wl,...:   tell GCC to pass this to linker. 
    182 #  -Map:      create map file 
    183 #  --cref:    add cross reference to  map file 
    184 LDFLAGS = -Wl,-Map=$(TARGET).map,--cref 
    185  
    186  
    187 # Additional libraries 
    188  
    189 # Minimalistic printf version 
    190 LDFLAGS += -Wl,-u,vfprintf -lprintf_min 
    191  
    192 # Floating point printf version (requires -lm below) 
    193 #LDFLAGS += -Wl,-u,vfprintf -lprintf_flt 
    194  
    195 # -lm = math library 
    196 LDFLAGS += -lm 
    197  
    198  
    199 # Programming support using avrdude. Settings and variables. 
    200  
    201 # Programming hardware: alf avr910 avrisp bascom bsd  
    202 # dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 
    203 # 
    204 # Type: avrdude -c ? 
    205 # to get a full listing. 
    206 # 
    207 AVRDUDE_PROGRAMMER = avr109 
    208  
    209  
    210 AVRDUDE_PORT = /dev/ttyUSB1 # programmer connected to serial device 
    211 #AVRDUDE_PORT = lpt1    # programmer connected to parallel port 
    212  
    213 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex 
    214 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep 
    215  
    216 AVRDUDE_FLAGS = -b115200 -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) 
    217  
    218 # Uncomment the following if you want avrdude's erase cycle counter. 
    219 # Note that this counter needs to be initialized first using -Yn, 
    220 # see avrdude manual. 
    221 #AVRDUDE_ERASE += -y 
    222  
    223 # Uncomment the following if you do /not/ wish a verification to be 
    224 # performed after programming the device. 
    225 AVRDUDE_FLAGS += -V 
    226  
    227 # Increase verbosity level.  Please use this when submitting bug 
    228 # reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>  
    229 # to submit bug reports. 
    230 #AVRDUDE_FLAGS += -v -v 
    231  
    232  
    233 #------------------------------------------------------------------------------- 
    234  
    235 # Define directories, if needed. 
    236 DIRAVR = c:/winavr 
    237 DIRAVRBIN = $(DIRAVR)/bin 
    238 DIRAVRUTILS = $(DIRAVR)/utils/bin 
    239 DIRINC = . 
    240 DIRLIB = $(DIRAVR)/avr/lib 
    241  
    242  
    243 # Define programs and commands. 
    244 SHELL = sh 
    245  
    246 CC = avr-gcc -g 
    247  
    248 OBJCOPY = avr-objcopy 
    249 OBJDUMP = avr-objdump 
    250 SIZE = avr-size 
    251  
    252  
    253 # Programming support using avrdude. 
    254 AVRDUDE = avrdude 
    255  
    256  
    257 REMOVE = rm -f 
    258 COPY = cp 
    259  
    260 HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex 
    261 ELFSIZE = $(SIZE) -A $(TARGET).elf 
    262  
    263  
    264 # Define Messages 
    265 # English 
    266 MSG_ERRORS_NONE = Errors: none 
    267 MSG_BEGIN = -------- begin -------- 
    268 MSG_END = --------  end  -------- 
    269 MSG_SIZE_BEFORE = Size before:  
    270 MSG_SIZE_AFTER = Size after: 
    271 MSG_COFF = Converting to AVR COFF: 
    272 MSG_EXTENDED_COFF = Converting to AVR Extended COFF: 
    273 MSG_FLASH = Creating load file for Flash: 
    274 MSG_EEPROM = Creating load file for EEPROM: 
    275 MSG_EXTENDED_LISTING = Creating Extended Listing: 
    276 MSG_SYMBOL_TABLE = Creating Symbol Table: 
    277 MSG_LINKING = Linking: 
    278 MSG_COMPILING = Compiling: 
    279 MSG_ASSEMBLING = Assembling: 
    280 MSG_CLEANING = Cleaning project: 
    281  
    282  
    283 TARGET_PLATFORM  = -DCC2420DB 
    284  
    285 # Define all object files. 
    286 OBJ = $(SRC:.c=.o) $(ASRC:.S=.o)  
    287  
    288 # Define all listing files. 
    289 LST = $(ASRC:.S=.lst) $(SRC:.c=.lst) 
    290  
    291 # Combine all necessary flags and optional flags. 
    292 # Add target processor to flags. 
    293 ALL_CFLAGS = -mmcu=$(MCU) -Os -I. $(CFLAGS) $(TARGET_PLATFORM) 
    294 ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) 
    295  
    296  
    297 # Default target. 
    298 all: begin gccversion sizebefore $(TARGET).elf $(TARGET).hex $(TARGET).eep \ 
    299         $(TARGET).lss $(TARGET).sym sizeafter finished end 
    300  
    301  
    302 # Eye candy. 
    303 # AVR Studio 3.x does not check make's exit code but relies on 
    304 # the following magic strings to be generated by the compile job. 
    305 begin: 
    306         @echo 
    307         @echo 
    308         @echo $(MSG_BEGIN) 
    309  
    310 finished: 
    311         @echo $(MSG_ERRORS_NONE) 
    312         @echo Platform: $(PLATFORM_TYPE) 
    313  
    314 end: 
    315         @echo $(MSG_END) 
    316 ifdef PLATFORM_ERROR 
    317         @echo $(PLATFORM_ERROR)  $(PLATFORM_TYPE) 
    318 endif 
    319  
    320  
    321 # Display size of file. 
    322 sizebefore: 
    323         @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); echo; fi 
    324  
    325 sizeafter: 
    326         @if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); echo; fi 
    327  
    328  
    329  
    330 # Display compiler version information. 
    331 gccversion :  
    332         @$(CC) --version 
    333  
    334  
    335 # Convert ELF to COFF for use in debugging / simulating in 
    336 # AVR Studio or VMLAB. 
    337 COFFCONVERT=$(OBJCOPY) --debugging \ 
    338         --change-section-address .data-0x800000 \ 
    339         --change-section-address .bss-0x800000 \ 
    340         --change-section-address .noinit-0x800000 \ 
    341         --change-section-address .eeprom-0x810000  
    342  
    343  
    344 coff: $(TARGET).elf 
    345         @echo 
    346         @echo $(MSG_COFF) $(TARGET).cof 
    347         $(COFFCONVERT) -O coff-avr $< $(TARGET).cof 
    348  
    349  
    350 extcoff: $(TARGET).elf 
    351         @echo 
    352         @echo $(MSG_EXTENDED_COFF) $(TARGET).cof 
    353         $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof 
    354  
    355  
    356 # Program the device.   
    357 program: $(TARGET).hex $(TARGET).eep 
    358         $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM) 
    359  
    360  
    361 # Create final output files (.hex, .eep) from ELF output file. 
    362 %.hex: %.elf 
    363         @echo 
    364         @echo $(MSG_FLASH) $@ 
    365         $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ 
    366  
    367 %.eep: %.elf 
    368         @echo 
    369         @echo $(MSG_EEPROM) $@ 
    370         -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ 
    371         --change-section-lma .eeprom=0 -O $(FORMAT) $< $@ 
    372  
    373 # Create extended listing file from ELF output file. 
    374 %.lss: %.elf 
    375         @echo 
    376         @echo $(MSG_EXTENDED_LISTING) $@ 
    377         $(OBJDUMP) -h -S $< > $@ 
    378  
    379 # Create a symbol table from ELF output file. 
    380 %.sym: %.elf 
    381         @echo 
    382         @echo $(MSG_SYMBOL_TABLE) $@ 
    383         avr-nm -n $< > $@ 
    384  
    385  
    386 # Link: create ELF output file from object files. 
    387 .SECONDARY : $(TARGET).elf 
    388 .PRECIOUS : $(OBJ) 
    389 %.elf: $(OBJ) 
    390         @echo 
    391         @echo $(MSG_LINKING) $@ 
    392         $(CC) $(ALL_CFLAGS) $(OBJ) --output $@ $(LDFLAGS) 
    393  
    394  
    395 # Compile: create object files from C source files. 
    396 %.o : %.c 
    397         @echo 
    398         @echo $(MSG_COMPILING) $< 
    399         $(CC) -c $(ALL_CFLAGS) $< -o $@ 
    400  
    401  
    402 # Compile: create assembler files from C source files. 
    403 %.s : %.c 
    404         $(CC) -S $(ALL_CFLAGS) $< -o $@ 
    405  
    406  
    407 # Assemble: create object files from assembler source files. 
    408 %.o : %.S 
    409         @echo 
    410         @echo $(MSG_ASSEMBLING) $< 
    411         $(CC) -c $(ALL_ASFLAGS) $< -o $@ 
    412  
    413  
    414 # Target: clean project. 
    415 clean: begin clean_list finished end 
    416  
    417 clean_list : 
    418         @echo 
    419         @echo $(MSG_CLEANING) 
    420         $(REMOVE) $(TARGET).hex 
    421         $(REMOVE) $(TARGET).eep 
    422         $(REMOVE) $(TARGET).obj 
    423         $(REMOVE) $(TARGET).cof 
    424         $(REMOVE) $(TARGET).elf 
    425         $(REMOVE) $(TARGET).map 
    426         $(REMOVE) $(TARGET).obj 
    427         $(REMOVE) $(TARGET).a90 
    428         $(REMOVE) $(TARGET).sym 
    429         $(REMOVE) $(TARGET).lnk 
    430         $(REMOVE) $(TARGET).lss 
    431         $(REMOVE) $(OBJ) 
    432         $(REMOVE) $(LST) 
    433         $(REMOVE) $(SRC:.c=.s) 
    434         $(REMOVE) $(SRC:.c=.d) 
    435  
    436  
    437 # Automatically generate C source code dependencies.  
    438 # (Code originally taken from the GNU make user manual and modified  
    439 # (See README.txt Credits).) 
    440 # 
    441 # Note that this will work with sh (bash) and sed that is shipped with WinAVR 
    442 # (see the SHELL variable defined above). 
    443 # This may not work with other shells or other seds. 
    444 # 
    445 %.d: %.c 
    446         set -e; $(CC) -MM $(ALL_CFLAGS) $< \ 
    447         | sed 's,\(.*\)\.o[ :]*,\1.o \1.d : ,g' > $@; \ 
    448         [ -s $@ ] || rm -f $@ 
    449  
    450  
    451 # Remove the '-' if you want to see the dependency files generated. 
    452 -include $(SRC:.c=.d) 
    453  
    454  
    455 # Listing of phony targets. 
    456 .PHONY : all begin finish end sizebefore sizeafter gccversion coff extcoff \ 
    457         clean clean_list program 
    458  
     35#  This is where the final compile and download happens 
     36include $(ROOT_DIR)/include/common.mk 
Note: See TracChangeset for help on using the changeset viewer.