Skip to content

Commit ff0b5a3

Browse files
committed
7.1.0
1 parent 6515610 commit ff0b5a3

File tree

11 files changed

+385
-44
lines changed

11 files changed

+385
-44
lines changed
Lines changed: 325 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,325 @@
1+
##############################################################################
2+
# Product: Makefile for QP/C on EMF32-SLSTK3401A, QXK kernel, GNU-ARM
3+
# Last Updated for Version: 7.1.0
4+
# Date of the Last Update: 2022-08-28
5+
#
6+
# Q u a n t u m L e a P s
7+
# ------------------------
8+
# Modern Embedded Software
9+
#
10+
# Copyright (C) 2005-2022 Quantum Leaps, LLC. All rights reserved.
11+
#
12+
# This program is open source software: you can redistribute it and/or
13+
# modify it under the terms of the GNU General Public License as published
14+
# by the Free Software Foundation, either version 3 of the License, or
15+
# (at your option) any later version.
16+
#
17+
# Alternatively, this program may be distributed and modified under the
18+
# terms of Quantum Leaps commercial licenses, which expressly supersede
19+
# the GNU General Public License and are specifically designed for
20+
# licensees interested in retaining the proprietary status of their code.
21+
#
22+
# This program is distributed in the hope that it will be useful,
23+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
# GNU General Public License for more details.
26+
#
27+
# You should have received a copy of the GNU General Public License
28+
# along with this program. If not, see <http://www.gnu.org/licenses>.
29+
#
30+
# Contact information:
31+
# <www.state-machine.com/licensing>
32+
33+
##############################################################################
34+
# examples of invoking this Makefile:
35+
# building configurations: Debug (default), Release, and Spy
36+
# make
37+
# make CONF=rel
38+
# make CONF=spy
39+
#
40+
# cleaning configurations: Debug (default), Release, and Spy
41+
# make clean
42+
# make CONF=rel clean
43+
# make CONF=spy clean
44+
#
45+
# NOTE:
46+
# To use this Makefile on Windows, you will need the GNU make utility, which
47+
# is included in the Qtools collection for Windows, see:
48+
# https://sourceforge.net/projects/qpc/files/QTools/
49+
#
50+
51+
#-----------------------------------------------------------------------------
52+
# project name
53+
#
54+
PROJECT := dpp-qxk
55+
56+
#-----------------------------------------------------------------------------
57+
# project directories
58+
#
59+
60+
# location of the QP/C framework (if not provided in an environemnt var.)
61+
ifeq ($(QPC),)
62+
QPC := ../../../../..
63+
endif
64+
65+
# QP port used in this project
66+
QP_PORT_DIR := $(QPC)/ports/arm-cm/qxk/gnu
67+
68+
# list of all source directories used by this project
69+
VPATH = \
70+
.. \
71+
../.. \
72+
$(QPC)/src/qf \
73+
$(QPC)/src/qxk \
74+
$(QPC)/src/qs \
75+
$(QP_PORT_DIR) \
76+
$(QPC)/3rd_party/efm32pg1b \
77+
$(QPC)/3rd_party/efm32pg1b/gnu
78+
79+
# list of all include directories needed by this project
80+
INCLUDES = \
81+
-I../.. \
82+
-I$(QPC)/include \
83+
-I$(QP_PORT_DIR) \
84+
-I$(QPC)/3rd_party/CMSIS/Include \
85+
-I$(QPC)/3rd_party/efm32pg1b
86+
87+
#-----------------------------------------------------------------------------
88+
# files
89+
#
90+
91+
# assembler source files
92+
ASM_SRCS :=
93+
94+
# C source files
95+
C_SRCS := \
96+
bsp.c \
97+
main.c \
98+
philo.c \
99+
table.c \
100+
test.c \
101+
startup_efm32pg1b.c \
102+
system_efm32pg1b.c \
103+
em_cmu.c \
104+
em_emu.c \
105+
em_gpio.c \
106+
em_usart.c
107+
108+
# C++ source files
109+
CPP_SRCS :=
110+
111+
OUTPUT := $(PROJECT)
112+
LD_SCRIPT := $(PROJECT).ld
113+
114+
QP_SRCS := \
115+
qep_hsm.c \
116+
qep_msm.c \
117+
qf_act.c \
118+
qf_actq.c \
119+
qf_defer.c \
120+
qf_dyn.c \
121+
qf_mem.c \
122+
qf_ps.c \
123+
qf_qact.c \
124+
qf_qeq.c \
125+
qf_qmact.c \
126+
qf_time.c \
127+
qxk.c \
128+
qxk_xthr.c \
129+
qxk_sema.c \
130+
qxk_mutex.c \
131+
qxk_port.c
132+
133+
QP_ASMS :=
134+
135+
QS_SRCS := \
136+
qs.c \
137+
qs_rx.c \
138+
qs_fp.c
139+
140+
LIB_DIRS :=
141+
LIBS :=
142+
143+
# defines
144+
DEFINES := -DEFM32PG1B200F256GM48=1 \
145+
-DQXK_ON_CONTEXT_SW \
146+
-DQXK_USE_IRQ_HANDLER=CRYPTO_IRQHandler \
147+
-DQXK_USE_IRQ_NUM=25 \
148+
-DQ_NASSERT
149+
150+
# ARM CPU, ARCH, FPU, and Float-ABI types...
151+
# ARM_CPU: [cortex-m0 | cortex-m0plus | cortex-m1 | cortex-m3 | cortex-m4]
152+
# ARM_FPU: [ | vfp]
153+
# FLOAT_ABI: [ | soft | softfp | hard]
154+
#
155+
ARM_CPU := -mcpu=cortex-m4
156+
ARM_FPU := -mfpu=vfp
157+
FLOAT_ABI := -mfloat-abi=softfp
158+
159+
#-----------------------------------------------------------------------------
160+
# GNU-ARM toolset (NOTE: You need to adjust to your machine)
161+
# see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
162+
#
163+
ifeq ($(GNU_ARM),)
164+
GNU_ARM := $(QTOOLS)/gnu_arm-none-eabi
165+
endif
166+
167+
# make sure that the GNU-ARM toolset exists...
168+
ifeq ("$(wildcard $(GNU_ARM))","")
169+
$(error GNU_ARM toolset not found. Please adjust the Makefile)
170+
endif
171+
172+
CC := $(GNU_ARM)/bin/arm-none-eabi-gcc
173+
CPP := $(GNU_ARM)/bin/arm-none-eabi-g++
174+
AS := $(GNU_ARM)/bin/arm-none-eabi-as
175+
LINK := $(GNU_ARM)/bin/arm-none-eabi-gcc
176+
BIN := $(GNU_ARM)/bin/arm-none-eabi-objcopy
177+
178+
179+
##############################################################################
180+
# Typically, you should not need to change anything below this line
181+
182+
# basic utilities (included in Qtools for Windows), see:
183+
# http://sourceforge.net/projects/qpc/files/Qtools
184+
185+
MKDIR := mkdir
186+
RM := rm
187+
188+
#-----------------------------------------------------------------------------
189+
# build options for various configurations for ARM Cortex-M
190+
#
191+
192+
# combine all the soruces...
193+
C_SRCS += $(QP_SRCS)
194+
ASM_SRCS += $(QP_ASMS)
195+
196+
ifeq (rel, $(CONF)) # Release configuration ..................................
197+
198+
BIN_DIR := rel
199+
200+
ASFLAGS = $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
201+
202+
CFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
203+
-std=c99 -pedantic -Wall -Wextra -W \
204+
-ffunction-sections -fdata-sections \
205+
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
206+
207+
CPPFLAGS = -c $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
208+
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
209+
-O1 $(INCLUDES) $(DEFINES) -DNDEBUG
210+
211+
else ifeq (spy, $(CONF)) # Spy configuration ................................
212+
213+
BIN_DIR := spy
214+
215+
C_SRCS += $(QS_SRCS)
216+
217+
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
218+
219+
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
220+
-std=c99 -pedantic -Wall -Wextra -W \
221+
-ffunction-sections -fdata-sections \
222+
-O $(INCLUDES) $(DEFINES) -DQ_SPY
223+
224+
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
225+
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
226+
-O $(INCLUDES) $(DEFINES) -DQ_SPY
227+
228+
else # default Debug configuration ..........................................
229+
230+
BIN_DIR := dbg
231+
232+
ASFLAGS = -g $(ARM_CPU) $(ARM_FPU) $(ASM_CPU) $(ASM_FPU)
233+
234+
CFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
235+
-std=c99 -pedantic -Wall -Wextra -W \
236+
-ffunction-sections -fdata-sections \
237+
-O $(INCLUDES) $(DEFINES)
238+
239+
CPPFLAGS = -c -g $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb -Wall \
240+
-ffunction-sections -fdata-sections -fno-rtti -fno-exceptions \
241+
-O $(INCLUDES) $(DEFINES)
242+
243+
endif # ......................................................................
244+
245+
246+
LINKFLAGS = -T$(LD_SCRIPT) $(ARM_CPU) $(ARM_FPU) $(FLOAT_ABI) -mthumb \
247+
-specs=nosys.specs -specs=nano.specs \
248+
-Wl,-Map,$(BIN_DIR)/$(OUTPUT).map,--cref,--gc-sections $(LIB_DIRS)
249+
250+
251+
ASM_OBJS := $(patsubst %.s,%.o, $(notdir $(ASM_SRCS)))
252+
C_OBJS := $(patsubst %.c,%.o, $(notdir $(C_SRCS)))
253+
CPP_OBJS := $(patsubst %.cpp,%.o,$(notdir $(CPP_SRCS)))
254+
255+
TARGET_BIN := $(BIN_DIR)/$(OUTPUT).bin
256+
TARGET_ELF := $(BIN_DIR)/$(OUTPUT).elf
257+
ASM_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(ASM_OBJS))
258+
C_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(C_OBJS))
259+
C_DEPS_EXT := $(patsubst %.o, %.d, $(C_OBJS_EXT))
260+
CPP_OBJS_EXT := $(addprefix $(BIN_DIR)/, $(CPP_OBJS))
261+
CPP_DEPS_EXT := $(patsubst %.o, %.d, $(CPP_OBJS_EXT))
262+
263+
# create $(BIN_DIR) if it does not exist
264+
ifeq ("$(wildcard $(BIN_DIR))","")
265+
$(shell $(MKDIR) $(BIN_DIR))
266+
endif
267+
268+
#-----------------------------------------------------------------------------
269+
# rules
270+
#
271+
272+
all: $(TARGET_BIN)
273+
#all: $(TARGET_ELF)
274+
275+
$(TARGET_BIN): $(TARGET_ELF)
276+
$(BIN) -O binary $< $@
277+
278+
$(TARGET_ELF) : $(ASM_OBJS_EXT) $(C_OBJS_EXT) $(CPP_OBJS_EXT)
279+
$(CC) $(CFLAGS) $(QPC)/include/qstamp.c -o $(BIN_DIR)/qstamp.o
280+
$(LINK) $(LINKFLAGS) -o $@ $^ $(BIN_DIR)/qstamp.o $(LIBS)
281+
282+
$(BIN_DIR)/%.d : %.c
283+
$(CC) -MM -MT $(@:.d=.o) $(CFLAGS) $< > $@
284+
285+
$(BIN_DIR)/%.d : %.cpp
286+
$(CPP) -MM -MT $(@:.d=.o) $(CPPFLAGS) $< > $@
287+
288+
$(BIN_DIR)/%.o : %.s
289+
$(AS) $(ASFLAGS) $< -o $@
290+
291+
$(BIN_DIR)/%.o : %.c
292+
$(CC) $(CFLAGS) $< -o $@
293+
294+
$(BIN_DIR)/%.o : %.cpp
295+
$(CPP) $(CPPFLAGS) $< -o $@
296+
297+
# include dependency files only if our goal depends on their existence
298+
ifneq ($(MAKECMDGOALS),clean)
299+
ifneq ($(MAKECMDGOALS),show)
300+
-include $(C_DEPS_EXT) $(CPP_DEPS_EXT)
301+
endif
302+
endif
303+
304+
305+
.PHONY : clean
306+
clean:
307+
-$(RM) $(BIN_DIR)/*.o \
308+
$(BIN_DIR)/*.d \
309+
$(BIN_DIR)/*.bin \
310+
$(BIN_DIR)/*.elf \
311+
$(BIN_DIR)/*.map
312+
313+
show:
314+
@echo PROJECT = $(PROJECT)
315+
@echo CONF = $(CONF)
316+
@echo DEFINES = $(DEFINES)
317+
@echo ASM_FPU = $(ASM_FPU)
318+
@echo ASM_SRCS = $(ASM_SRCS)
319+
@echo C_SRCS = $(C_SRCS)
320+
@echo CPP_SRCS = $(CPP_SRCS)
321+
@echo ASM_OBJS_EXT = $(ASM_OBJS_EXT)
322+
@echo C_OBJS_EXT = $(C_OBJS_EXT)
323+
@echo C_DEPS_EXT = $(C_DEPS_EXT)
324+
@echo CPP_DEPS_EXT = $(CPP_DEPS_EXT)
325+
@echo TARGET_ELF = $(TARGET_ELF)

ports/freertos/qf_port.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ void QActive_start_(QActive * const me, QPrioSpec const prioSpec,
146146
taskName , /* the name of the task */
147147
stkSize/sizeof(portSTACK_TYPE), /* stack length */
148148
(void *)me, /* the 'pvParameters' parameter */
149-
FREERTOS_TASK_PRIO(me->prio), /* FreeRTOS priority */
149+
FREERTOS_TASK_PRIO(me->prio), /* also FreeRTOS priority */
150150
(StackType_t *)stkSto, /* stack storage */
151151
&me->thread)); /* task buffer */
152152
}

ports/threadx/qf_port.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,6 @@ void QActive_start_(QActive * const me, QPrioSpec const prioSpec,
9595
QHSM_INIT(&me->super, par, me->prio); /* initial tran. (virtual) */
9696
QS_FLUSH(); /* flush the trace buffer to the host */
9797

98-
/* convert QF priority to the ThreadX priority */
99-
UINT tx_prio = QF_TX_PRIO_OFFSET + QF_MAX_ACTIVE - me->prio;
100-
UINT tx_pthre = QF_TX_PRIO_OFFSET + QF_MAX_ACTIVE - me->pthre;
101-
10298
Q_ALLEGE_ID(220,
10399
tx_thread_create(
104100
&me->thread, /* ThreadX thread control block */
@@ -107,8 +103,8 @@ void QActive_start_(QActive * const me, QPrioSpec const prioSpec,
107103
(ULONG)me, /* thread parameter */
108104
stkSto, /* stack start */
109105
stkSize, /* stack size in bytes */
110-
tx_prio, /* ThreadX priority */
111-
tx_pthre, /* ThreadX preemption threshold */
106+
QF_TX_PRIO_OFFSET + QF_MAX_ACTIVE - me->prio, /* ThreadX prio */
107+
QF_TX_PRIO_OFFSET + QF_MAX_ACTIVE - me->pthre, /* preempt-thre */
112108
TX_NO_TIME_SLICE,
113109
TX_AUTO_START)
114110
== TX_SUCCESS);

0 commit comments

Comments
 (0)