RN rnmake  3.0.0
Arch.atmega168.mk
Go to the documentation of this file.
1 ################################################################################
2 #
3 # Arch/Arch.atmega168.mk
4 #
5 ifdef RNMAKE_DOXY
6 /*!
7 \file
8 
9 \brief RoadNarrows Make System architecture makefile.
10 
11 \par Architecture:
12 Atmel ATmega168 Microcontroller
13 
14 \par Build Host:
15 Cross-Compiler
16 
17 \par Tool-Chain:
18 avr-*
19 
20 \pkgsynopsis
21 RN Make System
22 
23 \pkgfile{Arch/Arch.atmega168.mk}
24 
25 \pkgauthor{Robin Knight,robin.knight@roadnarrows.com}
26 
27 \pkgcopyright{2009-2018,RoadNarrows LLC,http://www.roadnarrows.com}
28 
29 \license{MIT}
30 
31 \EulaBegin
32 \EulaEnd
33 
34 \cond RNMAKE_DOXY
35  */
36 endif
37 #
38 ################################################################################
39 
40 _ARCH_ATMEGA168_MK = 1
41 
42 # This architecture (required)
43 RNMAKE_ARCH = atmega168
44 RNMAKE_ARCH_FQNAME = atmega168-mcu
45 
46 # Micro-Controller Unit
47 MCU = atmega168
48 
49 # Output format. One of: srec, ihex, binary
50 # Default is ihex. Override in including make file if necessary.
51 FORMAT ?= ihex
52 
53 # RDK TODO map fuses
54 # Device High Fuse Byte
55 # Override in including make file if necessary.
56 #
57 # Field Bit Description Default
58 # ----- --- ----------- -------
59 # OCDEN 7 Enable OCD 1 (unprogrammed, OCD disabled)
60 # JTAGEN 6 Enable JTAG 0 (programmed, JTAG enabled)
61 # SPIEN 5 Enable SPI Serial Program 0 (programmed, SPI prog. enabled)
62 # and data Downloading
63 # CKOPT 4 Oscillator options 1 (unprogrammed)
64 # EESAVE 3 EEPROM memory is preserved 1 (unprogrammed, EEPROM not preserved)
65 # through the Chip Erase
66 # BOOTSZ1 2 Select Boot Size 0 (programmed)
67 # BOOTSZ0 1 Select Boot Size 0 (programmed)
68 # BOOTRST 0 Select reset vector 1 (unprogrammed)
69 FUSE_HIGH ?= 0x99
70 
71 # RDK TODO map fuses
72 # Device Low Fuse Byte
73 # Override in including make file if necessary.
74 #
75 # Field Bit Description Default
76 # ----- --- ----------- -------
77 # BODLEVEL 7 Brown-out Detector trigger 1 (unprogrammed)
78 # level
79 # BODEN 6 Brown-out Detector enable 1 (unprogrammed, BOD disabled)
80 # SUT1 5 Select start-up time 1 (unprogrammed)
81 # SUT0 4 Select start-up time 0 (programmed)
82 # CKSEL3 3 Select Clock source 0 (programmed)
83 # CKSEL2 2 Select Clock source 0 (programmed)
84 # CKSEL1 1 Select Clock source 0 (programmed)
85 # CKSEL0 0 Select Clock source 0 (unprogrammed)
86 FUSE_LOW ?= 0xE1
87 
88 
89 #------------------------------------------------------------------------------
90 # Tool Chain
91 #------------------------------------------------------------------------------
92 
93 # Cross compiler tool chain prefix
94 CROSS_COMPILE = avr-
95 
96 # Build Support Commands
97 AR = $(CROSS_COMPILE)ar
98 RANLIB = $(CROSS_COMPILE)ranlib
99 STRIP_LIB = $(CROSS_COMPILE)strip --strip-debug
100 STRIP_EXE = $(CROSS_COMPILE)strip --strip-all
101 OBJCOPY = $(CROSS_COMPILE)objcopy
102 OBJDUMP = $(CROSS_COMPILE)objdump
103 SIZE = $(CROSS_COMPILE)size
104 NM = $(CROSS_COMPILE)nm
105 
106 
107 #------------------------------------------------------------------------------
108 # C Preprocessor Options
109 #------------------------------------------------------------------------------
110 # Architecture specific include directories
111 RNMAKE_ARCH_INCDIRS =
112 
113 # Architecture specific cpp flags
114 RNMAKE_ARCH_CPPFLAGS =
115 
116 
117 #------------------------------------------------------------------------------
118 # Assembler and Options
119 #------------------------------------------------------------------------------
120 AS = $(CROSS_COMPILE)as
121 
122 # Atmel device
123 ASFLAGS_MCU = -mmcu=$(MCU)
124 
125 # Debugging format.
126 # -gstabs: Have the assembler create line number information; note that
127 # for use in COFF files, additional information about filenames
128 # and function names needs to be present in the assembler source
129 # files -- see avr-libc docs [FIXME: not yet described there]
130 ASFLAGS_DEBUG = -gstabs
131 
132 # Pass to other subprocesses
133 # -x Use CPP
134 ASFLAGS_PASS = -x assembler-with-cpp
135 
136 # Listing
137 # -Wa,...: tell GCC to pass this to the assembler.
138 # -adlms: create listing
139 CFLAGS_LISTING = -Wa,-adhlns=$(<:.S=.lst)
140 
141 # Assembler flags.
142 # -Wa,...: tell GCC to pass this to the assembler.
143 # -adlms: create listing
144 ARCH_ASFLAGS = $(ASFLAGS_MCU) \
145  $(ASFLAGS_DEBUG) \
146  $(ASFLAGS_PASS) \
147  $(ASFLAGS_LISTING)
148 
149 #------------------------------------------------------------------------------
150 # C Compiler and Options
151 #------------------------------------------------------------------------------
152 CC = $(CROSS_COMPILE)gcc
153 
154 # Atmel device
155 CFLAGS_MCU = -mmcu=$(MCU)
156 
157 # Compiler flags to generate dependency files.
158 # Not needed in rnmake system.
159 # -Wp pass comma-separated options to cpp
160 # -M build dependency rule for object file
161 # -MP add .PHONY to each rule for object file
162 # -MT set output object to next argument
163 # -MF depencency rule output in file in next argument
164 #CFLAGS_GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
165 
166 # Optimization level, can be [0, 1, 2, 3, s].
167 # 0 = turn off optimization. s = optimize for size.
168 # (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
169 CFLAGS_OPTIMIZE_LEVEL = -O1
170 
171 # Debugging format.
172 # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2.
173 # AVR (extended) COFF requires stabs, plus an avr-objcopy run.
174 #CFLAGS_DEBUG = -gstabs
175 CFLAGS_DEBUG = -gdwarf-2
176 
177 # Compiler flag to set the C Standard level.
178 # c89 - "ANSI" C
179 # gnu89 - c89 plus GCC extensions
180 # c99 - ISO C99 standard (not yet fully implemented)
181 # gnu99 - c99 plus GCC extensions
182 CFLAGS_CSTANDARD = -std=gnu99
183 
184 # Optimizations
185 # characters are unsigned
186 # bitfields are unsigned
187 # pack structure members with no holes
188 # smallest enum posible
189 CFLAGS_OPTIMIZES = -funsigned-char \
190  -funsigned-bitfields \
191  -fpack-struct \
192  -fshort-enums
193 
194 # Warnings
195 # All normal warnings
196 # Warn on strict prototypes
197 CFLAGS_WARNING = -Wall -Wstrict-prototypes
198 
199 # Listing
200 # -Wa,...: tell GCC to pass this to the assembler.
201 # -adlms: create listing
202 CFLAGS_LISTING = -Wa,-adhlns=$(<:.c=.lst)
203 
204 CFLAGS_CPP_ONLY = -E
205 CFLAGS_DEPS_ONLY = -M
206 
207 RNMAKE_ARCH_CFLAGS = $(CFLAGS_MCU) \
208  $(CFLAGS_DEBUG) \
209  $(CFLAGS_OPTIMIZE_LEVEL) \
210  $(CFLAGS_OPTIMIZES) \
211  $(CFLAGS_WARNING) \
212  $(CFLAGS_LISTING) \
213  $(CFLAGS_CSTANDARD) \
214  $(CFLAGS_GENDEPFLAGS)
215 
216 # Make AS/C/CXX Dependencies Command
217 RNMAKE_MAKEDEPS = $(CC) $(CFLAGS_DEPS_ONLY)
218 
219 
220 #------------------------------------------------------------------------------
221 # C++ Compiler and Options
222 #------------------------------------------------------------------------------
223 CXX = $(CROSS_COMPILE)g++
224 CXXFLAGS_CPP_ONLY = -E
225 CXXFLAGS_DEPS_ONLY = -M
226 
227 RNMAKE_ARCH_CXXFLAGS = $(CFLAGS_DEBUG) \
228  $(CFLAGS_OPTIMIZE_LEVEL) \
229  $(CFLAGS_OPTIMIZES) \
230  $(CFLAGS_WARNING) \
231  $(CFLAGS_OTHER) \
232  $(CFLAGS_CSTANDARD)
233 
234 
235 #------------------------------------------------------------------------------
236 # Linker and Options
237 #------------------------------------------------------------------------------
238 LD_CC = $(CC)
239 LD_CXX = $(CXX)
240 LD = $(LD_CC)
241 
242 # External memory options
243 #
244 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
245 # used for variables (.data/.bss) and heap (malloc()).
246 #ARCH_LDFLAGS_EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff
247 #
248 # 64 KB of external RAM, starting after internal RAM (ATmega128!),
249 # only used for heap (malloc()).
250 #ARCH_LDFLAGS_EXTMEMOPTS = -Wl,--defsym=__heap_start=0x801100,--defsym=__heap_end=0x80ffff
251 
252 ARCH_LDFLAGS_EXTMEMOPTS =
253 
254 # Linker flags.
255 # -Wl,...: tell GCC to pass this to linker.
256 # -Map: create map file
257 # --cref: add cross reference to map file
258 ARCH_LDFLAGS_LD = -Wl,-Map=$(TARGET).map,--cref
259 
260 ARCH_LDFLAGS = $(ARCH_LDFLAGS_LD) \
261  $(ARCH_LDFLAGS_EXTMEMOPTS)
262 ARCH_LD_LIBPATHS =
263 ARCH_LD_LIBS =
264 
265 
266 #------------------------------------------------------------------------------
267 # Static Library Archiver and Options
268 #------------------------------------------------------------------------------
269 STLIB_LD = ${AR} cr
270 STLIB_PREFIX = lib
271 STLIB_SUFFIX = .a
272 
273 
274 #------------------------------------------------------------------------------
275 # Other Useful Flags, Etc.
276 #------------------------------------------------------------------------------
277 # Minimalistic printf version
278 PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
279 
280 # Floating point printf version (requires MATH_LIB = -lm below)
281 PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
282 
283 PRINTF_LIB =
284 
285 # Minimalistic scanf version
286 SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
287 
288 # Floating point + %[ scanf version (requires MATH_LIB = -lm below)
289 SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
290 
291 SCANF_LIB =
292 
293 MATH_LIB = -lm
294 
295 
296 ifdef RNMAKE_DOXY
297 /*! \endcond RNMAKE_DOXY */
298 endif