From 8b6b47e50d69a03ef5a13c80bb42925543d44973 Mon Sep 17 00:00:00 2001 From: rusefi Date: Wed, 29 Mar 2017 16:52:57 -0400 Subject: [PATCH] incremental simulator into build folder --- demos/various/RT-Win32-Simulator/Makefile | 258 ++++++++++-------- .../RT-Win32-Simulator/error_handling.h | 1 + demos/various/RT-Win32-Simulator/halconf.h | 2 + demos/various/RT-Win32-Simulator/main.c | 4 + os/hal/lib/streams/streams.mk | 6 + os/various/shell/shell.mk | 4 + 6 files changed, 154 insertions(+), 121 deletions(-) create mode 100644 demos/various/RT-Win32-Simulator/error_handling.h create mode 100644 os/hal/lib/streams/streams.mk create mode 100644 os/various/shell/shell.mk diff --git a/demos/various/RT-Win32-Simulator/Makefile b/demos/various/RT-Win32-Simulator/Makefile index 3795b4deb..bc4f9fd4c 100644 --- a/demos/various/RT-Win32-Simulator/Makefile +++ b/demos/various/RT-Win32-Simulator/Makefile @@ -1,152 +1,168 @@ -# -# !!!! Do NOT edit this makefile with an editor which replace tabs by spaces !!!! -# -############################################################################################## -# -# On command line: -# -# make all = Create project -# -# make clean = Clean project files. -# -# To rebuild project do "make clean" and "make all". +############################################################################## +# Build global options +# NOTE: Can be overridden externally. # -############################################################################################## -# Start of default section -# +# Compiler options here. +ifeq ($(USE_OPT),) + USE_OPT = -O2 -ggdb +endif -#TRGT = mingw32- -TRGT = i686-w64-mingw32- -CC = $(TRGT)gcc -AS = $(TRGT)gcc -x assembler-with-cpp +# C specific options here (added to USE_OPT). +ifeq ($(USE_COPT),) + USE_COPT = +endif -# List all default C defines here, like -D_DEBUG=1 -DDEFS = -DSIMULATOR +# C++ specific options here (added to USE_OPT). +ifeq ($(USE_CPPOPT),) + USE_CPPOPT = -fno-rtti +endif -# List all default ASM defines here, like -D_DEBUG=1 -DADEFS = +# Enable this if you want the linker to remove unused code and data. +ifeq ($(USE_LINK_GC),) + USE_LINK_GC = yes +endif -# List all default directories to look for include files here -DINCDIR = +# Linker extra options here. +ifeq ($(USE_LDOPT),) + USE_LDOPT = +endif -# List the default directory to look for the libraries here -DLIBDIR = +# Enable this if you want link time optimizations (LTO) +ifeq ($(USE_LTO),) + USE_LTO = no +endif -# List all default libraries here -DLIBS = -lws2_32 +# 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 # -# End of default section -############################################################################################## +# Build global options +############################################################################## -############################################################################################## -# Start of user section +############################################################################## +# Architecture or project specific options +# + +# +# Architecture or project specific options +############################################################################## + +############################################################################## +# Project, sources and paths # # Define project name here -PROJECT = ch +PROJECT = ch.exe -# Define linker script file here -LDSCRIPT = +# Imported source files and paths +CHIBIOS = ../../.. +# Startup files. +# HAL-OSAL files (optional). +include $(CHIBIOS)/os/hal/hal.mk +include $(CHIBIOS)/os/hal/boards/simulator/board.mk +include $(CHIBIOS)/os/hal/ports/simulator/win32/platform.mk +include $(CHIBIOS)/os/hal/osal/rt/osal.mk +# RTOS files (optional). +include $(CHIBIOS)/os/rt/rt.mk +include $(CHIBIOS)/os/rt/ports/SIMIA32/compilers/GCC/port.mk +# Other files (optional). +include $(CHIBIOS)/test/rt/test.mk +include $(CHIBIOS)/os/hal/lib/streams/streams.mk +include $(CHIBIOS)/os/various/shell/shell.mk + +# C sources here. +CSRC = $(STARTUPSRC) \ + $(KERNSRC) \ + $(PORTSRC) \ + $(OSALSRC) \ + $(HALSRC) \ + $(PLATFORMSRC) \ + $(BOARDSRC) \ + $(TESTSRC) \ + $(STREAMSSRC) \ + $(SHELLSRC) \ + main.c + +# C++ sources here. +CPPSRC = + +# List ASM source files here +ASMSRC = +ASMXSRC = $(STARTUPASM) $(PORTASM) $(OSALASM) + +INCDIR = $(CHIBIOS)/os/license \ + $(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \ + $(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \ + $(STREAMSINC) $(SHELLINC) + +# +# Project, sources and paths +############################################################################## + +############################################################################## +# Compiler settings +# + +#TRGT = powerpc-eabi- +#TRGT = mingw32- +TRGT = i686-w64-mingw32- + +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 +BIN = $(CP) -O binary +COV = gcov + +# 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 = +UDEFS = -DSIMULATOR # Define ASM defines here UADEFS = -# Imported source files -CHIBIOS = ../../.. -include $(CHIBIOS)/os/hal/boards/simulator/board.mk -include $(CHIBIOS)/os/hal/hal.mk -include $(CHIBIOS)/os/hal/ports/simulator/win32/platform.mk -include $(CHIBIOS)/os/hal/osal/rt/osal.mk -include $(CHIBIOS)/os/rt/ports/SIMIA32/compilers/GCC/port.mk -include $(CHIBIOS)/os/rt/rt.mk -include $(CHIBIOS)/test/rt/test.mk - -# List C source files here -SRC = $(PORTSRC) \ - $(KERNSRC) \ - $(TESTSRC) \ - $(HALSRC) \ - $(OSALSRC) \ - $(PLATFORMSRC) \ - $(BOARDSRC) \ - $(CHIBIOS)/os/various/shell.c \ - $(CHIBIOS)/os/hal/lib/streams/memstreams.c \ - $(CHIBIOS)/os/hal/lib/streams/chprintf.c \ - main.c - -# List ASM source files here -ASRC = - # List all user directories here -UINCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \ - $(HALINC) $(OSALINC) $(PLATFORMINC) $(BOARDINC) \ - $(CHIBIOS)/os/hal/lib/streams $(CHIBIOS)/os/various +UINCDIR = # List the user directory to look for the libraries here ULIBDIR = # List all user libraries here -ULIBS = - -# Define optimisation level here -OPT = -ggdb -O2 +ULIBS = -lws2_32 # # End of user defines -############################################################################################## +############################################################################## -INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR)) -LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR)) -DEFS = $(DDEFS) $(UDEFS) -ADEFS = $(DADEFS) $(UADEFS) -OBJS = $(ASRC:.s=.o) $(SRC:.c=.o) -LIBS = $(DLIBS) $(ULIBS) - -LDFLAGS = -Wl,-Map=$(PROJECT).map,--cref,--no-warn-mismatch $(LIBDIR) -ASFLAGS = -Wa,-amhls=$(<:.s=.lst) $(ADEFS) -CPFLAGS = -Wall -Wextra -Wundef -Wstrict-prototypes -fverbose-asm -Wa,-alms=$(<:.c=.lst) $(DEFS) - -# Generate dependency information -CPFLAGS += -MD -MP -MF .dep/$(@F).d - -# -# makefile rules -# - -all: $(OBJS) $(PROJECT).exe - -%.o : %.c - $(CC) -c $(OPT) $(CPFLAGS) -I . $(INCDIR) $< -o $@ - -%.o : %.s - $(AS) -c $(OPT) $(ASFLAGS) $< -o $@ - -%exe: $(OBJS) - $(CC) $(OPT) $(OBJS) $(LDFLAGS) $(LIBS) -o $@ - -gcov: - -mkdir gcov - $(COV) -u $(subst /,\,$(SRC)) - -mv *.gcov ./gcov - -clean: - -rm -f $(OBJS) - -rm -f $(PROJECT).exe - -rm -f $(PROJECT).map - -rm -f $(SRC:.c=.c.bak) - -rm -f $(SRC:.c=.lst) - -rm -f $(ASRC:.s=.s.bak) - -rm -f $(ASRC:.s=.lst) - -rm -fR .dep - -# -# Include the dependency files, should be the last of the makefile -# --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - -# *** EOF *** +RULESPATH = $(CHIBIOS)/os/common/startup/SIMIA32/compilers/GCC +include $(RULESPATH)/rules.mk diff --git a/demos/various/RT-Win32-Simulator/error_handling.h b/demos/various/RT-Win32-Simulator/error_handling.h new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/demos/various/RT-Win32-Simulator/error_handling.h @@ -0,0 +1 @@ + diff --git a/demos/various/RT-Win32-Simulator/halconf.h b/demos/various/RT-Win32-Simulator/halconf.h index 70ba5bf02..04cb3b79f 100644 --- a/demos/various/RT-Win32-Simulator/halconf.h +++ b/demos/various/RT-Win32-Simulator/halconf.h @@ -28,6 +28,8 @@ #ifndef _HALCONF_H_ #define _HALCONF_H_ + #define efiAssert(condition, message, result) { } + /*#include "mcuconf.h"*/ /** diff --git a/demos/various/RT-Win32-Simulator/main.c b/demos/various/RT-Win32-Simulator/main.c index 6540693e6..224710573 100644 --- a/demos/various/RT-Win32-Simulator/main.c +++ b/demos/various/RT-Win32-Simulator/main.c @@ -250,3 +250,7 @@ int main(void) { chEvtUnregister(chnGetEventSource(&SD2), &sd2fel); return 0; } + +int getRemainingStack(thread_t *otp) { + return 0; +} \ No newline at end of file diff --git a/os/hal/lib/streams/streams.mk b/os/hal/lib/streams/streams.mk new file mode 100644 index 000000000..31204bba3 --- /dev/null +++ b/os/hal/lib/streams/streams.mk @@ -0,0 +1,6 @@ +# RT Shell files. +STREAMSSRC = $(CHIBIOS)/os/hal/lib/streams/chprintf.c \ + $(CHIBIOS)/os/hal/lib/streams/memstreams.c \ + $(CHIBIOS)/os/hal/lib/streams/nullstreams.c + +STREAMSINC = $(CHIBIOS)/os/hal/lib/streams diff --git a/os/various/shell/shell.mk b/os/various/shell/shell.mk new file mode 100644 index 000000000..3a70fba6b --- /dev/null +++ b/os/various/shell/shell.mk @@ -0,0 +1,4 @@ +# RT Shell files. +SHELLSRC = $(CHIBIOS)/os/various/shell.c + +SHELLINC = $(CHIBIOS)/os/various/