Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Copyright 2016, Pablo Ridolfi
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put your copyright here like this:
Copyright 2016, Iván Castellucci Vidal ivanc.vidal@gmail.com

# All rights reserved.
#
# Changes:
# 2016-10-16: Iván Castellucci Vidal <ivanc.vidal@gmail.com>
# Added support for C++ projects.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should go in a CREDITS file

#
# This file is part of Workspace.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -34,6 +38,8 @@
PROJECT ?= examples/blinky
TARGET ?= lpc4337_m4
BOARD ?= edu_ciaa_nxp
CC := gcc
CXX := g++

include $(PROJECT)/Makefile

Expand All @@ -47,13 +53,16 @@ PROJECT_OBJ_FILES := $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_C_FILES:.c=.o))

PROJECT_OBJ_FILES += $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_ASM_FILES:.S=.o)))

PROJECT_OBJ_FILES += $(addprefix $(OBJ_PATH)/,$(notdir $(PROJECT_CXX_FILES:.cpp=.o)))

PROJECT_OBJS := $(notdir $(PROJECT_OBJ_FILES))

INCLUDES := $(addprefix -I,$(PROJECT_INC_FOLDERS)) \
$(addprefix -I,$(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_INC_FOLDERS)))

vpath %.o $(OBJ_PATH)
vpath %.c $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS))
vpath %.cpp $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS))
vpath %.S $(PROJECT_SRC_FOLDERS) $(foreach MOD,$(notdir $(PROJECT_MODULES)),$($(MOD)_SRC_FOLDERS))
vpath %.a $(OUT_PATH)

Expand All @@ -66,25 +75,31 @@ lib$(1).a: $(2)
@$(CROSS_PREFIX)size $(OUT_PATH)/lib$(1).a
endef

$(foreach MOD,$(notdir $(PROJECT_MODULES)), $(eval $(call makemod,$(MOD),$(notdir $(patsubst %.c,%.o,$(patsubst %.S,%.o,$($(MOD)_SRC_FILES)))))))
$(foreach MOD,$(notdir $(PROJECT_MODULES)), $(eval $(call makemod,$(MOD),$(notdir $(patsubst %.c,%.o,$(patsubst %.S,%.o,$(patsubst %.cpp,%.o,$($(MOD)_SRC_FILES))))))))

%.o: %.c
@echo "*** compiling C file $< ***"
@$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@
@$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d)
@$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@
@$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d)

%.o: %.S
@echo "*** compiling asm file $< ***"
@$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@
@$(CROSS_PREFIX)gcc $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d)
@$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@
@$(CROSS_PREFIX)$(CC) $(SYMBOLS) $(CFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d)

%.o: %.cpp
@echo "*** compiling C++ file $< ***"
@$(CROSS_PREFIX)$(CXX) $(XSYMBOLS) $(CXXFLAGS) $(INCLUDES) -c $< -o $(OBJ_PATH)/$@
@$(CROSS_PREFIX)$(CXX) $(XSYMBOLS) $(CXXFLAGS) $(INCLUDES) -c $< -MM > $(OBJ_PATH)/$(@:.o=.d)


-include $(wildcard $(OBJ_PATH)/*.d)

all : $(PROJECT_NAME)

$(PROJECT_NAME): $(foreach MOD,$(notdir $(PROJECT_MODULES)),lib$(MOD).a) $(PROJECT_OBJS)
@echo "*** linking project $@ ***"
@$(CROSS_PREFIX)gcc $(LFLAGS) $(LD_FILE) -o $(OUT_PATH)/$(PROJECT_NAME).axf $(PROJECT_OBJ_FILES) $(SLAVE_OBJ_FILE) -L$(OUT_PATH) $(addprefix -l,$(notdir $(PROJECT_MODULES))) $(addprefix -L,$(EXTERN_LIB_FOLDERS)) $(addprefix -l,$(notdir $(EXTERN_LIBS)))
@$(CROSS_PREFIX)$(CXX) $(LFLAGS) $(LD_FILE) -o $(OUT_PATH)/$(PROJECT_NAME).axf $(PROJECT_OBJ_FILES) $(SLAVE_OBJ_FILE) -L$(OUT_PATH) $(addprefix -l,$(notdir $(PROJECT_MODULES))) $(addprefix -L,$(EXTERN_LIB_FOLDERS)) $(addprefix -l,$(notdir $(EXTERN_LIBS)))
@$(CROSS_PREFIX)size $(OUT_PATH)/$(PROJECT_NAME).axf
@$(CROSS_PREFIX)objcopy -v -O binary $(OUT_PATH)/$(PROJECT_NAME).axf $(OUT_PATH)/$(PROJECT_NAME).bin
@echo "*** post-build ***"
Expand Down
1 change: 1 addition & 0 deletions etc/ld/lpc11u68_lib.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

GROUP(
librdimon.a
libgcc.a
libc.a
libm.a
Expand Down
1 change: 1 addition & 0 deletions etc/ld/lpc1769_lib.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


GROUP(
librdimon.a
libgcc.a
libc.a
libm.a
Expand Down
1 change: 1 addition & 0 deletions etc/ld/lpc4337_m0_lib.ld
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

GROUP(
librdimon.a
libgcc.a
libc.a
libm.a
Expand Down
1 change: 1 addition & 0 deletions etc/ld/lpc4337_m4_lib.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


GROUP(
librdimon.a
libgcc.a
libc.a
libm.a
Expand Down
1 change: 1 addition & 0 deletions etc/ld/lpc54102_m0_lib.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

GROUP(
librdimon.a
libgcc.a
libc.a
libm.a
Expand Down
1 change: 1 addition & 0 deletions etc/ld/lpc54102_m4_lib.ld
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

GROUP(
librdimon.a
libgcc.a
libc.a
libm.a
Expand Down
5 changes: 5 additions & 0 deletions etc/target/lpc11u68.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ OBJ_PATH = $(OUT_PATH)/obj
SYMBOLS += -DDEBUG -DCORE_M0PLUS -D__USE_LPCOPEN -D__CODE_RED \
-D__MTB_BUFFER_SIZE=256 -D__USE_ROMDIVIDE

XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS

# Compilation flags
CFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin

# Compilation CXX flags
CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin

# Linking flags
LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m0 -mthumb \
-Xlinker -Map=$(OUT_PATH)/$(PROY_NOMBRE).map \
Expand Down
6 changes: 6 additions & 0 deletions etc/target/lpc1769.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ CROSS_PREFIX ?= arm-none-eabi-
# Defined symbols
SYMBOLS := -DDEBUG -DCORE_M3 -D__USE_LPCOPEN -D__LPC17XX__ -D__CODE_RED

XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS

# Compilation flags
CFLAGS := -Wall -ggdb3 -mcpu=cortex-m3 -mthumb -fdata-sections \
-ffunction-sections -c

# Compilation CXX flags
CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m3 -mthumb -fdata-sections \
-ffunction-sections -c

# Linking flags
LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m3 -mthumb -Xlinker \
-Map=$(OUT_PATH)/$(PROJECT_NAME).map -Wl,--gc-sections
Expand Down
5 changes: 5 additions & 0 deletions etc/target/lpc4337_m0.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ OBJ_PATH = $(OUT_PATH)/obj
SYMBOLS += -DDEBUG -DCORE_M0 -D__USE_LPCOPEN -D__LPC43XX__ -D__CODE_RED \
-D__MULTICORE_M0APP -DCORE_M0APP

XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS

# Compilation flags
CFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections

# Compilation CXX flags
CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections

# Linking flags
LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m0 -mthumb \
-Xlinker -Map=$(OUT_PATH)/$(PROJECT_NAME).map \
Expand Down
6 changes: 6 additions & 0 deletions etc/target/lpc4337_m4.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,16 @@ SYMBOLS += -DDEBUG -DCORE_M4 -D__USE_LPCOPEN -D__LPC43XX__ -D__CODE_RED \
-DLPC43_MULTICORE_M0APP -D__MULTICORE_MASTER \
-D__MULTICORE_MASTER_SLAVE_M0APP

XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS

# Compilation flags
CFLAGS := -Wall -ggdb3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \
-mfloat-abi=softfp -fdata-sections -ffunction-sections

# Compliation CXX flags
CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \
-mfloat-abi=softfp -fdata-sections -ffunction-sections

# Linking flags
LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \
-mfloat-abi=softfp -Xlinker -Map=$(OUT_PATH)/$(PROJECT_NAME).map \
Expand Down
5 changes: 5 additions & 0 deletions etc/target/lpc54102_m0.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ OBJ_PATH = $(OUT_PATH)/obj
SYMBOLS += -DDEBUG -DCORE_M0PLUS -D__USE_LPCOPEN -D__LPC5410X__ -D__CODE_RED \
-D__MULTICORE_M0SLAVE

XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS

# Compilation flags
CFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin

# Compilation CXX flags
CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m0 -mthumb -fdata-sections -ffunction-sections -fmessage-length=0 -fno-builtin

# Linking flags
LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m0 -mthumb \
-Xlinker -Map=$(OUT_PATH)/$(PROY_NOMBRE).map \
Expand Down
6 changes: 6 additions & 0 deletions etc/target/lpc54102_m4.mk
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,16 @@ OBJ_PATH = $(OUT_PATH)/obj
SYMBOLS += -DDEBUG -DCORE_M4 -D__USE_LPCOPEN -D__LPC5410X__ -D__CODE_RED \
-D__MULTICORE_MASTER -D__MULTICORE_MASTER_SLAVE_M0SLAVE

XSYMBOLS += $(SYMBOLS) -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS

# Compilation flags
CFLAGS := -Wall -ggdb3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \
-mfloat-abi=softfp -fdata-sections -ffunction-sections

# Compilation CXX flags
CXXFLAGS := -Wall -ggdb3 -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \
-mfloat-abi=softfp -fdata-sections -ffunction-sections

# Linking flags
LFLAGS := -nostdlib -fno-builtin -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 \
-mfloat-abi=softfp -Xlinker -Map=$(OUT_PATH)/$(PROJECT_NAME).map \
Expand Down
54 changes: 54 additions & 0 deletions examples/blinky_cpp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Copyright 2016, Pablo Ridolfi
# All rights reserved.
#
# This file is part of Workspace.
# Changes:
# 2016-10-16: Iván Castellucci Vidal <ivanc.vidal@gmail.com>
# Added C++ sources to compilation process
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

# application name
PROJECT_NAME := $(notdir $(PROJECT))

# Modules needed by the application
PROJECT_MODULES := modules/$(TARGET)/base \
modules/$(TARGET)/board \
modules/$(TARGET)/chip

# source files folder
PROJECT_SRC_FOLDERS := $(PROJECT)/src

# header files folder
PROJECT_INC_FOLDERS := $(PROJECT)/inc

# source files
PROJECT_C_FILES := $(wildcard $(PROJECT)/src/*.c)

# Don't forget to add your CPP files to any C++ project
PROJECT_CXX_FILES := $(wildcard $(PROJECT)/src/*.cpp)
PROJECT_ASM_FILES := $(wildcard $(PROJECT)/src/*.S)
75 changes: 75 additions & 0 deletions examples/blinky_cpp/inc/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/* Copyright 2016, Pablo Ridolfi
* All rights reserved.
*
* This file is part of Workspace.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/

#ifndef _MAIN_H_
#define _MAIN_H_

/** \addtogroup blink Bare-metal blink example
** @{ */

/*==================[inclusions]=============================================*/

/*==================[cplusplus]==============================================*/

#ifdef __cplusplus
extern "C" {
#endif

/*==================[macros]=================================================*/

/** delay in milliseconds */
#define DELAY_MS 500

/** led number to toggle */
#define LED 0

/*==================[typedef]================================================*/

/*==================[external data declaration]==============================*/

/*==================[external functions declaration]=========================*/

/** @brief main function
* @return main function should never return
*/
int main(void);

/*==================[cplusplus]==============================================*/

#ifdef __cplusplus
}
#endif

/** @} doxygen end group definition */
/*==================[end of file]============================================*/
#endif /* #ifndef _MAIN_H_ */
Loading