aboutsummaryrefslogtreecommitdiffstats
path: root/demos/STM32/RT-STM32F302R8-NUCLEO64/Makefile
blob: 344395d09f1063abb97879c2f27ab05352b46cdb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#

# Compiler options here.
ifeq ($(USE_OPT),)
  USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif

# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
  USE_COPT = 
endif

# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
  USE_CPPOPT = -fno-rtti
endif

# Enable this if you want the linker to remove unused code and data
ifeq ($(USE_LINK_GC),)
  USE_LINK_GC = yes
endif

# Linker extra options here.
ifeq ($(USE_LDOPT),)
  USE_LDOPT = 
endif

# Enable this if you want link time optimizations (LTO)
ifeq ($(USE_LTO),)
  USE_LTO = yes
endif

# If enabled, this option allows to compile the application in THUMB mode.
ifeq ($(USE_THUMB),)
  USE_THUMB = yes
endif

# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
  USE_VERBOSE_COMPILE = no
endif

# If enabled, this option makes the build process faster by not compiling
# modules not used in the current configuration.
ifeq ($(USE_SMART_BUILD),)
  USE_SMART_BUILD = yes
endif

#
# Build global options
##############################################################################

##############################################################################
# Architecture or project specific options
#

# Stack size to be allocated to the Cortex-M process stack. This stack is
# the stack used by the main() thread.
ifeq ($(USE_PROCESS_STACKSIZE),)
  USE_PROCESS_STACKSIZE = 0x400
endif

# Stack size to the allocated to the Cortex-M main/exceptions stack. This
# stack is used for processing interrupts and exceptions.
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
  USE_EXCEPTIONS_STACKSIZE = 0x400
endif

# Enables the use of FPU (no, softfp, hard).
ifeq ($(USE_FPU),)
  USE_FPU = no
endif

#
# Architecture or project specific options
##############################################################################

##############################################################################
# Project, sources and paths
#

# Define project name here
PROJECT = ch

# Imported source files and paths
CHIBIOS = ../../..
# Startup files.
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f3xx.mk
# HAL-OSAL files (optional).
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/hal/ports/STM32/STM32F3xx/platform.mk
include $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_F302R8/board.mk
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
# RTOS files (optional).
include $(CHIBIOS)/os/rt/rt.mk
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Other files (optional).
include $(CHIBIOS)/test/rt/test.mk

# Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32F302x8.ld

# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(STARTUPSRC) \
       $(KERNSRC) \
       $(PORTSRC) \
       $(OSALSRC) \
       $(HALSRC) \
       $(PLATFORMSRC) \
       $(BOARDSRC) \
       $(TESTSRC) \
       main.c

# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC =

# C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
#       option that results in lower performance and larger code size.
ACSRC =

# C++ sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
#       option that results in lower performance and larger code size.
ACPPSRC =

# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
#       option that results in lower performance and larger code size.
TCSRC =

# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
#       option that results in lower performance and larger code size.
TCPPSRC =

# List ASM source files here
ASMSRC =
ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM)

INCDIR = $(CHIBIOS)/os/license \
         $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
         $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
         $(CHIBIOS)/os/various

#
# Project, sources and paths
##############################################################################

##############################################################################
# Compiler settings
#

MCU  = cortex-m4

#TRGT = arm-elf-
TRGT = arm-none-eabi-
CC   = $(TRGT)gcc
CPPC = $(TRGT)g++
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
#       runtime support makes code size explode.
LD   = $(TRGT)gcc
#LD   = $(TRGT)g++
CP   = $(TRGT)objcopy
AS   = $(TRGT)gcc -x assembler-with-cpp
AR   = $(TRGT)ar
OD   = $(TRGT)objdump
SZ   = $(TRGT)size
HEX  = $(CP) -O ihex
BIN  = $(CP) -O binary

# ARM-specific options here
AOPT =

# THUMB-specific options here
TOPT = -mthumb -DTHUMB

# Define C warning options here
CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes

# Define C++ warning options here
CPPWARN = -Wall -Wextra -Wundef

#
# Compiler settings
##############################################################################

##############################################################################
# Start of user section
#

# List all user C define here, like -D_DEBUG=1
UDEFS =

# Define ASM defines here
UADEFS =

# List all user directories here
UINCDIR =

# List the user directory to look for the libraries here
ULIBDIR =

# List all user libraries here
ULIBS =

#
# End of user defines
##############################################################################

RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
include $(RULESPATH)/rules.mk
>hdr->oem_table_id, "rx2600") || !strcmp(hdr->oem_table_id, "cx2600")) { ns16550_com1.irq = ns16550_com1_gsi = uart->gsi; ns16550_com1_polarity = IOSAPIC_POL_HIGH; ns16550_com1_trigger = IOSAPIC_EDGE; } else if (!strcmp(hdr->oem_table_id, "rx2620") || !strcmp(hdr->oem_table_id, "cx2620") || !strcmp(hdr->oem_table_id, "rx1600") || !strcmp(hdr->oem_table_id, "rx1620")) { ns16550_com1.irq = ns16550_com1_gsi = uart->gsi; ns16550_com1_polarity = IOSAPIC_POL_LOW; ns16550_com1_trigger = IOSAPIC_LEVEL; } } static void __init setup_pcdp_irq(struct pcdp *pcdp, struct pcdp_uart *uart) { /* PCDP provides full interrupt info */ if (pcdp->rev >= 3) { if (uart->flags & PCDP_UART_IRQ) { ns16550_com1.irq = ns16550_com1_gsi = uart->gsi, ns16550_com1_polarity = uart->flags & PCDP_UART_ACTIVE_LOW ? IOSAPIC_POL_LOW : IOSAPIC_POL_HIGH; ns16550_com1_trigger = uart->flags & PCDP_UART_EDGE_SENSITIVE ? IOSAPIC_EDGE : IOSAPIC_LEVEL; } return; } /* HCDP support */ if (uart->pci_func & PCDP_UART_IRQ) { /* * HCDP tables don't provide interrupt polarity/trigger * info. If the UART is a PCI device, we know to program * it as low/level. Otherwise rely on platform hacks or * default to polling (irq = 0). */ if (uart->pci_func & PCDP_UART_PCI) { ns16550_com1.irq = ns16550_com1_gsi = uart->gsi; ns16550_com1_polarity = IOSAPIC_POL_LOW; ns16550_com1_trigger = IOSAPIC_LEVEL; } else if (!strcmp((char *)pcdp->oemid, "HP")) pcdp_hp_irq_fixup(pcdp, uart); } } static int __init setup_serial_console(struct pcdp_uart *uart) { ns16550_com1.baud = uart->baud ? uart->baud : BAUD_AUTO; ns16550_com1.io_base = uart->addr.address; if (uart->bits) ns16550_com1.data_bits = uart->bits; #ifndef XEN setup_pcdp_irq(efi.hcdp, uart); /* Hide the HCDP table from dom0, xencons will be the console */ efi.hcdp = NULL; #else setup_pcdp_irq(__va(efi.hcdp), uart); /* Hide the HCDP table from dom0, xencons will be the console */ efi.hcdp = EFI_INVALID_TABLE_ADDR; #endif return 0; } static int __init setup_vga_console(struct pcdp_vga *vga) { #ifdef CONFIG_VGA /* * There was no console= in the original cmdline, and the PCDP * is telling us VGA is the primary console. We can call * cmdline_parse() manually to make things appear automagic. * * NB - cmdline_parse() expects the first part of the cmdline * to be the image name. So "pcdp" below is just filler. */ char *console_cmdline = "pcdp console=vga"; cmdline_parse(console_cmdline); /* * Leave efi.hcdp intact since dom0 will take ownership. * vga=keep is handled in start_kernel(). */ return 0; #else return -ENODEV; #endif } #else /* XEN */ static int __init setup_serial_console(struct pcdp_uart *uart) { #ifdef CONFIG_SERIAL_8250_CONSOLE int mmio; static char options[64]; mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY); snprintf(options, sizeof(options), "console=uart,%s,0x%lx,%lun%d", mmio ? "mmio" : "io", uart->addr.address, uart->baud, uart->bits ? uart->bits : 8); return early_serial_console_init(options); #else return -ENODEV; #endif } static int __init setup_vga_console(struct pcdp_vga *vga) { #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE) if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) { printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n"); return -ENODEV; } conswitchp = &vga_con; printk(KERN_INFO "PCDP: VGA console\n"); return 0; #else return -ENODEV; #endif } #endif /* XEN */ int __init efi_setup_pcdp_console(char *cmdline) { struct pcdp *pcdp; struct pcdp_uart *uart; struct pcdp_device *dev, *end; int i, serial = 0; #ifndef XEN pcdp = efi.hcdp; if (!pcdp) return -ENODEV; #else if (efi.hcdp == EFI_INVALID_TABLE_ADDR) return -ENODEV; pcdp = __va(efi.hcdp); #endif printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, __pa(pcdp)); if (strstr(cmdline, "console=hcdp")) { if (pcdp->rev < 3) serial = 1; } else if (strstr(cmdline, "console=")) { printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n"); return -ENODEV; } if (pcdp->rev < 3 && efi_uart_console_only()) serial = 1; for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) { if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) { if (uart->type == PCDP_CONSOLE_UART) { return setup_serial_console(uart); } } } end = (struct pcdp_device *) ((u8 *) pcdp + pcdp->length); for (dev = (struct pcdp_device *) (pcdp->uart + pcdp->num_uarts); dev < end; dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) { if (dev->flags & PCDP_PRIMARY_CONSOLE) { if (dev->type == PCDP_CONSOLE_VGA) { return setup_vga_console((struct pcdp_vga *) dev); } } } return -ENODEV; }