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

Subversion Repositories neo430

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 198 zero_gravi
#################################################################################################
2
#  < NEO430 BOOTLOADER Compile Script - Linux / Cygwin / Windows Subsystem for Linux version >  #
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 = bootloader.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_ASM = bootloader.s
92
 
93
all: $(APP_ASM) neo430_bootloader_image.vhd
94
 
95
# define all object files
96
OBJ = $(APP_SRC:.c=.o)
97
 
98
 
99
#-------------------------------------------------------------------------------
100
# Tools
101
#-------------------------------------------------------------------------------
102
#C ompiler tools
103
AS        = msp430-elf-as
104
CC        = msp430-elf-gcc
105
LD        = msp430-elf-ld
106
STRIP     = msp430-elf-strip
107
OBJDUMP   = msp430-elf-objdump
108
OBJCOPY   = msp430-elf-objcopy
109
SIZE      = msp430-elf-size
110
IMAGE_GEN = $(NEO430_EXE_PATH)/image_gen
111
 
112
# Assembler flags
113
AS_OPTS = -mY -mcpu=msp430
114
 
115
# Compiler flags
116
CC_OPTS = -mcpu=msp430 -pipe -Wall -Xassembler --mY -fno-delete-null-pointer-checks
117
CC_OPTS += -Wl,-static -mrelax -minrt -nostartfiles -fdata-sections -ffunction-sections -Xlinker --gc-sections
118
# Use NEO430 multiplier? (still experimental!)
119
ifeq (,$(findstring NEO430_HWMUL_ABI_OVERRIDE,$(CC_USER_FLAGS)))
120
        CC_OPTS += -mhwmult=none
121
else
122
        CC_OPTS += -mhwmult=16bit
123
endif
124
# Add user flags if available
125
CC_OPTS += ${CC_USER_FLAGS}
126
 
127
# Linker flags
128
LD_OPTS = -mcpu=msp430 -mrelax -minrt -nostartfiles
129
 
130
 
131
#-------------------------------------------------------------------------------
132
# Host native compiler
133
#-------------------------------------------------------------------------------
134
CC_X86 = g++ -Wall -O -g
135
 
136
 
137
#-------------------------------------------------------------------------------
138
# Tool targets
139
#-------------------------------------------------------------------------------
140
# install/compile tools
141
$(IMAGE_GEN): $(NEO430_EXE_PATH)/main.cpp
142
        @echo Compiling $(IMAGE_GEN)
143
        @$(CC_X86) $< -o $(IMAGE_GEN)
144
 
145
 
146
#-------------------------------------------------------------------------------
147
# Application Targets
148
#-------------------------------------------------------------------------------
149
# Assemble startup code
150
crt0.elf: boot_crt0.asm
151
        @$(AS) $(AS_OPTS) $< -o $@
152
 
153
# Compile app sources
154
$(OBJ): %.o : %.c crt0.elf
155
        @$(CC) -c $(CC_OPTS) $(EFFORT) -I $(NEO430_INC_PATH) $< -o $@
156
 
157
# Link object files
158
main.elf: $(OBJ)
159
        @$(CC) $(LD_OPTS) $(EFFORT) -I $(NEO430_INC_PATH) -T boot_linker_script.x $(OBJ) -o $@ -lm
160
# Using HWMUL ABI overrite?
161
ifneq (,$(findstring NEO430_HWMUL_ABI_OVERRIDE,$(CC_OPTS)))
162
        @echo "> Using implicit invocation of neo430 MULDIV multiplier unit (NEO430_HWMUL_ABI_OVERRIDE)"
163
endif
164
# Using HWMUL ABI overrite?
165
ifneq (,$(findstring NEO430_HWMUL_DSP,$(CC_OPTS)))
166
        @echo "> Assuming single cycle processing delay for neo430 MULDIV multiplier unit (NEO430_HWMUL_DSP)"
167
endif
168
# Show memory utilization
169
        @echo Memory utilization:
170
        @$(SIZE) main.elf
171
 
172
# Generate final executable (from .image section only)
173
image.dat: main.elf
174
        @$(OBJCOPY) -I elf32-little $< -j .image -O binary $@
175
 
176
# Assembly listing file (for debugging)
177
$(APP_ASM): main.elf
178
        @$(OBJDUMP) -D -S -z  $< > $@
179
        @if grep -qR "dadd" $@; then echo "NEO430: WARNING! 'DADD' instruction might be used! Make sure it is synthesized!"; fi
180
 
181
# Generate NEO430 executable VHDL boot image
182
neo430_bootloader_image.vhd: image.dat $(IMAGE_GEN)
183
        @$(IMAGE_GEN) -bld_img $< $@
184
        @echo Installing BOOTLOADER image to $(NEO430_RTL_PATH)/neo430_bootloader_image.vhd
185
        @cp neo430_bootloader_image.vhd $(NEO430_RTL_PATH)/.
186
        @rm -f neo430_bootloader_image.vhd
187
 
188
 
189
#-------------------------------------------------------------------------------
190
# Check toolchain
191
#-------------------------------------------------------------------------------
192
check: $(IMAGE_GEN)
193
        @echo "--------------- Check: NEO430_HOME folder ---------------"
194
ifneq ($(shell [ -e $(NEO430_HOME_MARKER) ] && echo 1 || echo 0 ), 1)
195
$(error NEO430_HOME folder not found!)
196
endif
197
        @echo "NEO430_HOME: $(NEO430_HOME)"
198
        @echo "--------------- Check: $(AS) ---------------"
199
        @$(AS) -version
200
        @echo "--------------- Check: $(CC) ---------------"
201
        @$(CC) -v
202
        @echo "--------------- Check: $(LD) ---------------"
203
        @$(LD) -V
204
        @echo "--------------- Check: $(STRIP) ---------------"
205
        @$(STRIP) -V
206
        @echo "--------------- Check: $(OBJDUMP) ---------------"
207
        @$(OBJDUMP) -V
208
        @echo "--------------- Check: $(OBJCOPY) ---------------"
209
        @$(OBJCOPY) -V
210
        @echo "--------------- Check: $(SIZE) ---------------"
211
        @$(SIZE) -V
212
        @echo "--------------- Check: neo430 image_gen ---------------"
213
        @$(IMAGE_GEN) -help
214
        @echo "--------------- Check: native gcc ---------------"
215
        @$(CC_X86) -v
216
        @echo
217
        @echo "Toolchain check OK"
218
 
219
 
220
#-------------------------------------------------------------------------------
221
# Show configuration
222
#-------------------------------------------------------------------------------
223
info:
224
        @echo "--------------- Info: Project ---------------"
225
        @echo "Project: $(shell basename $(CURDIR))"
226
        @echo "NEO430 home folder (NEO430_HOME): $(NEO430_HOME)"
227
        @echo "Project source files: $(APP_SRC)"
228
        @echo "Project include folders: $(NEO430_INC_PATH) $(APP_INC)"
229
        @echo "Project object files: $(OBJ)"
230
        @echo "--------------- Info: Tools ---------------"
231
        @echo " AS:        $(AS)"
232
        @echo " CC:        $(CC)"
233
        @echo " LD:        $(LD)"
234
        @echo " STRIP:     $(STRIP)"
235
        @echo " OBJDUMP:   $(OBJDUMP)"
236
        @echo " OBJCOPY:   $(OBJCOPY)"
237
        @echo " SIZE:      $(SIZE)"
238
        @echo " IMAGE_GEN: $(IMAGE_GEN)"
239
        @echo " CC_X86:    $(CC_X86)"
240
        @echo "--------------- Info: Flags ---------------"
241
        @echo " EFFORT:        $(EFFORT)"
242
        @echo " AS_OPTS:       $(AS_OPTS)"
243
        @echo " CC_OPTS:       $(CC_OPTS)"
244
        @echo " LD_OPTS:       $(LD_OPTS)"
245
        @echo " CC_USER_FLAGS: $(CC_USER_FLAGS)"
246
 
247
 
248
#-------------------------------------------------------------------------------
249
# Help
250
#-------------------------------------------------------------------------------
251
help:
252
        @echo "NEO430 BOOTLOADER Compilation Script"
253
        @echo "Make sure to add the msp430-gcc bin folder to your system's PATH variable."
254
        @echo "Targets:"
255
        @echo " help      - show this text"
256
        @echo " check     - check toolchain"
257
        @echo " info      - show compiler configuration"
258
        @echo " all       - compile and generate and install VHDL bootloader boot image"
259
        @echo " clean     - clean up this project only"
260
        @echo " clean_all - clean up everything"
261
        @echo "CC_USER_FLAGS (usage example: CC_USER_FLAGS+=-DNEO430_HWMUL_ABI_OVERRIDE)"
262
        @echo " NEO430_HWMUL_ABI_OVERRIDE - implicit usage of MULDIV.mul unit (make sure it is synthesized)"
263
        @echo " NEO430_HWMUL_DSP          - use embedded multiplier for MULDIV.mul unit (make also sure this option is synthesized)"
264
 
265
 
266
#-------------------------------------------------------------------------------
267
# Clean up
268
#-------------------------------------------------------------------------------
269
clean:
270
        @rm -f *.elf *.o *.dat *.vhd *.s
271
 
272
clean_all:
273
        @rm -f $(OBJ) *.elf *.dat *.bin *.vhd *.s $(IMAGE_GEN)
274
 
275
 
276
#-------------------------------------------------------------------------------
277
# eof

powered by: WebSVN 2.1.0

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