OpenCores
URL https://opencores.org/ocsvn/neo430/neo430/trunk

Subversion Repositories neo430

[/] [neo430/] [trunk/] [neo430/] [sw/] [example/] [timer_simple/] [makefile] - Blame information for rev 198

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 198 zero_gravi
#################################################################################################
2
# < NEO430 Application Compile Script - Linux / Windows Powershell / Windows Linux Subsystem >  #
3
# ********************************************************************************************* #
4
# BSD 3-Clause License                                                                          #
5
#                                                                                               #
6
# Copyright (c) 2020, Stephan Nolting. All rights reserved.                                     #
7
#                                                                                               #
8
# Redistribution and use in source and binary forms, with or without modification, are          #
9
# permitted provided that the following conditions are met:                                     #
10
#                                                                                               #
11
# 1. Redistributions of source code must retain the above copyright notice, this list of        #
12
#    conditions and the following disclaimer.                                                   #
13
#                                                                                               #
14
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of     #
15
#    conditions and the following disclaimer in the documentation and/or other materials        #
16
#    provided with the distribution.                                                            #
17
#                                                                                               #
18
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to  #
19
#    endorse or promote products derived from this software without specific prior written      #
20
#    permission.                                                                                #
21
#                                                                                               #
22
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS   #
23
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF               #
24
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE    #
25
# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,     #
26
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE #
27
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED    #
28
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     #
29
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED  #
30
# OF THE POSSIBILITY OF SUCH DAMAGE.                                                            #
31
# ********************************************************************************************* #
32
# The NEO430 Processor - https://github.com/stnolting/neo430                                    #
33
#################################################################################################
34
 
35
 
36
#*******************************************************************************
37
# USER CONFIGURATION
38
#*******************************************************************************
39
# Compiler effort (-Os = optimize for size)
40
EFFORT = -Os
41
 
42
# User's application sources (add additional files here)
43
APP_SRC = main.c
44
 
45
# User's application include folders (don't forget the '-I' before each entry)
46
APP_INC = -I .
47
 
48
# Relative or absolute path to the NEO430 home folder (use default if not set by user)
49
NEO430_HOME ?= ../../..
50
 
51
# Additional user flags:
52
CC_USER_FLAGS +=
53
#*******************************************************************************
54
 
55
 
56
 
57
#-------------------------------------------------------------------------------
58
# NEO430 framework
59
#-------------------------------------------------------------------------------
60
# Path to NEO430 linker script and startup file
61
NEO430_COM_PATH=$(NEO430_HOME)/sw/common
62
# Path to main NEO430 library include files
63
NEO430_INC_PATH=$(NEO430_HOME)/sw/lib/neo430/include
64
# Path to main NEO430 library source files
65
NEO430_SRC_PATH=$(NEO430_HOME)/sw/lib/neo430/source
66
# Path to NEO430 executable generator
67
NEO430_EXE_PATH=$(NEO430_HOME)/sw/tools/image_gen
68
# Path to NEO430 core rtl folder
69
NEO430_RTL_PATH=$(NEO430_HOME)/rtl/core
70
# Marker file to verify NEO430 home folder
71
NEO430_HOME_MARKER=$(NEO430_INC_PATH)/neo430.h
72
 
73
 
74
#-------------------------------------------------------------------------------
75
# Add NEO430 sources to input SRCs
76
#-------------------------------------------------------------------------------
77
APP_SRC += $(wildcard $(NEO430_SRC_PATH)/*.c)
78
 
79
 
80
#-------------------------------------------------------------------------------
81
# Make defaults
82
#-------------------------------------------------------------------------------
83
.SUFFIXES:
84
.PHONY: all
85
.DEFAULT_GOAL := help
86
 
87
 
88
#-------------------------------------------------------------------------------
89
# Application output definitions
90
#-------------------------------------------------------------------------------
91
APP_BIN = main.bin
92
APP_ASM = main.s
93
 
94
compile: $(APP_ASM) $(APP_BIN)
95
install: $(APP_ASM) neo430_application_image.vhd
96
all:     $(APP_ASM) $(APP_BIN) neo430_application_image.vhd
97
 
98
# define all object files
99
OBJ = $(APP_SRC:.c=.o)
100
 
101
 
102
#-------------------------------------------------------------------------------
103
# Tools
104
#-------------------------------------------------------------------------------
105
#C ompiler tools
106
AS        = msp430-elf-as
107
CC        = msp430-elf-gcc
108
LD        = msp430-elf-ld
109
STRIP     = msp430-elf-strip
110
OBJDUMP   = msp430-elf-objdump
111
OBJCOPY   = msp430-elf-objcopy
112
SIZE      = msp430-elf-size
113
IMAGE_GEN = $(NEO430_EXE_PATH)/image_gen
114
 
115
# Assembler flags
116
AS_OPTS = -mY -mcpu=msp430
117
 
118
# Compiler flags
119
CC_OPTS = -mcpu=msp430 -pipe -Wall -Xassembler --mY -fno-delete-null-pointer-checks
120
CC_OPTS += -Wl,-static -mrelax -minrt -nostartfiles -fdata-sections -ffunction-sections -Xlinker --gc-sections
121
# Use NEO430 multiplier? (still experimental!)
122
ifeq (,$(findstring NEO430_HWMUL_ABI_OVERRIDE,$(CC_USER_FLAGS)))
123
        CC_OPTS += -mhwmult=none
124
else
125
        CC_OPTS += -mhwmult=16bit
126
endif
127
# Add user flags if available
128
CC_OPTS += ${CC_USER_FLAGS}
129
 
130
# Linker flags
131
LD_OPTS = -mcpu=msp430 -mrelax -minrt -nostartfiles
132
 
133
 
134
#-------------------------------------------------------------------------------
135
# Host native compiler
136
#-------------------------------------------------------------------------------
137
CC_X86 = gcc -Wall -O -g
138
 
139
 
140
#-------------------------------------------------------------------------------
141
# Tool targets
142
#-------------------------------------------------------------------------------
143
# install/compile tools
144
$(IMAGE_GEN): $(NEO430_EXE_PATH)/main.cpp
145
        @echo Compiling $(IMAGE_GEN)
146
        @$(CC_X86) $< -o $(IMAGE_GEN)
147
 
148
 
149
#-------------------------------------------------------------------------------
150
# Application Targets
151
#-------------------------------------------------------------------------------
152
# Assemble startup code
153
crt0.elf: $(NEO430_COM_PATH)/crt0.asm
154
        @$(AS) $(AS_OPTS) $< -o $@
155
 
156
# Compile app sources
157
$(OBJ): %.o : %.c crt0.elf
158
        @$(CC) -c $(CC_OPTS) $(EFFORT) -I $(NEO430_INC_PATH) $(APP_INC) $< -o $@
159
 
160
# Link object files
161
main.elf: $(OBJ)
162
        @$(CC) $(LD_OPTS) $(EFFORT) -I $(NEO430_INC_PATH) $(APP_INC) -T $(NEO430_COM_PATH)/neo430_linker_script.x $(OBJ) -o $@ -lm
163
# Using HWMUL ABI overrite?
164
ifneq (,$(findstring NEO430_HWMUL_ABI_OVERRIDE,$(CC_OPTS)))
165
        @echo "> Using implicit invocation of neo430 MULDIV multiplier unit (NEO430_HWMUL_ABI_OVERRIDE)"
166
endif
167
# Using HWMUL ABI overrite?
168
ifneq (,$(findstring NEO430_HWMUL_DSP,$(CC_OPTS)))
169
        @echo "> Assuming single cycle processing delay for neo430 MULDIV multiplier unit (NEO430_HWMUL_DSP)"
170
endif
171
# Show memory utilization
172
        @echo Memory utilization:
173
        @$(SIZE) main.elf
174
 
175
# Generate final executable (from .image section only)
176
image.dat: main.elf
177
        @$(OBJCOPY) -I elf32-little $< -j .text   -O binary text.dat
178
        @$(OBJCOPY) -I elf32-little $< -j .rodata -O binary rodata.dat
179
        @$(OBJCOPY) -I elf32-little $< -j .data   -O binary data.dat
180
        @cat text.dat rodata.dat data.dat > $@
181
        @rm -f text.dat rodata.dat data.dat
182
 
183
# Assembly listing file (for debugging) and check for DADD instruction
184
$(APP_ASM): main.elf
185
        @$(OBJDUMP) -D -S -z  $< > $@
186
        @if grep -qR "dadd" $@; then echo "NEO430: WARNING! 'DADD' instruction might be used!"; fi
187
 
188
# Generate NEO430 executable image for bootloader update
189
$(APP_BIN): image.dat $(IMAGE_GEN)
190
        @set -e
191
        @$(IMAGE_GEN) -app_bin $< $@
192
 
193
# Generate NEO430 executable VHDL boot image
194
neo430_application_image.vhd: image.dat $(IMAGE_GEN)
195
        @$(IMAGE_GEN) -app_img $< $@
196
        @echo Installing application image to $(NEO430_RTL_PATH)/neo430_application_image.vhd
197
        @cp neo430_application_image.vhd $(NEO430_RTL_PATH)/.
198
        @rm -f neo430_application_image.vhd
199
 
200
 
201
#-------------------------------------------------------------------------------
202
# Check toolchain
203
#-------------------------------------------------------------------------------
204
check: $(IMAGE_GEN)
205
        @echo "--------------- Check: NEO430_HOME folder ---------------"
206
ifneq ($(shell [ -e $(NEO430_HOME_MARKER) ] && echo 1 || echo 0 ), 1)
207
$(error NEO430_HOME folder not found!)
208
endif
209
        @echo "NEO430_HOME: $(NEO430_HOME)"
210
        @echo "--------------- Check: $(AS) ---------------"
211
        @$(AS) -version
212
        @echo "--------------- Check: $(CC) ---------------"
213
        @$(CC) -v
214
        @echo "--------------- Check: $(LD) ---------------"
215
        @$(LD) -V
216
        @echo "--------------- Check: $(STRIP) ---------------"
217
        @$(STRIP) -V
218
        @echo "--------------- Check: $(OBJDUMP) ---------------"
219
        @$(OBJDUMP) -V
220
        @echo "--------------- Check: $(OBJCOPY) ---------------"
221
        @$(OBJCOPY) -V
222
        @echo "--------------- Check: $(SIZE) ---------------"
223
        @$(SIZE) -V
224
        @echo "--------------- Check: neo430 image_gen ---------------"
225
        @$(IMAGE_GEN) -help
226
        @echo "--------------- Check: native gcc ---------------"
227
        @$(CC_X86) -v
228
        @echo
229
        @echo "Toolchain check OK"
230
 
231
 
232
#-------------------------------------------------------------------------------
233
# Show configuration
234
#-------------------------------------------------------------------------------
235
info:
236
        @echo "--------------- Info: Project ---------------"
237
        @echo "Project: $(shell basename $(CURDIR))"
238
        @echo "NEO430 home folder (NEO430_HOME): $(NEO430_HOME)"
239
        @echo "Project source files: $(APP_SRC)"
240
        @echo "Project include folders: $(NEO430_INC_PATH) $(APP_INC)"
241
        @echo "Project object files: $(OBJ)"
242
        @echo "--------------- Info: Tools ---------------"
243
        @echo " AS:        $(AS)"
244
        @echo " CC:        $(CC)"
245
        @echo " LD:        $(LD)"
246
        @echo " STRIP:     $(STRIP)"
247
        @echo " OBJDUMP:   $(OBJDUMP)"
248
        @echo " OBJCOPY:   $(OBJCOPY)"
249
        @echo " SIZE:      $(SIZE)"
250
        @echo " IMAGE_GEN: $(IMAGE_GEN)"
251
        @echo " CC_X86:    $(CC_X86)"
252
        @echo "--------------- Info: Flags ---------------"
253
        @echo " EFFORT:        $(EFFORT)"
254
        @echo " AS_OPTS:       $(AS_OPTS)"
255
        @echo " CC_OPTS:       $(CC_OPTS)"
256
        @echo " LD_OPTS:       $(LD_OPTS)"
257
        @echo " CC_USER_FLAGS: $(CC_USER_FLAGS)"
258
 
259
 
260
#-------------------------------------------------------------------------------
261
# Help
262
#-------------------------------------------------------------------------------
263
help:
264
        @echo "NEO430 Application Compilation Script"
265
        @echo "Make sure to add the msp430-gcc bin folder to your system's PATH variable."
266
        @echo "Targets:"
267
        @echo " help      - show this text"
268
        @echo " check     - check toolchain"
269
        @echo " info      - show makefile configuration"
270
        @echo " compile   - compile and generate *.bin executable for upload via bootloader"
271
        @echo " install   - compile, generate and install VHDL boot image"
272
        @echo " all       - compile and generate *.bin executable for upload via bootloader and generate and install VHDL boot image"
273
        @echo " clean     - clean up project"
274
        @echo " clean_all - clean up project, core libraries and helper tools"
275
        @echo "CC_USER_FLAGS (usage example: CC_USER_FLAGS+=-DNEO430_HWMUL_ABI_OVERRIDE)"
276
        @echo " NEO430_HWMUL_ABI_OVERRIDE - implicit usage of MULDIV.mul unit (make sure it is synthesized)"
277
        @echo " NEO430_HWMUL_DSP          - use embedded multiplier for MULDIV.mul unit (make also sure this option is synthesized)"
278
 
279
 
280
#-------------------------------------------------------------------------------
281
# Clean up
282
#-------------------------------------------------------------------------------
283
clean:
284
        @rm -f *.elf *.o *.dat *.vhd *.bin *.out *.s
285
 
286
clean_all: clean
287
        @rm -f $(OBJ) $(IMAGE_GEN)
288
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.