diff --git a/Makefile b/Makefile index 8742262ef..acc023319 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,47 @@ -CC=arm-none-eabi-gcc -LD=arm-none-eabi-ld.bfd -GDB=arm-none-eabi-gdb -OBJCOPY=arm-none-eabi-objcopy -CFLAGS = -Ilib -I. -Iinclude -Iexternal/freertos/include -Iexternal -Iexternal/freertos/portable/GCC/ARM_CM4F -Iexternal/newlib/libc/include -CFLAGS += -DHAVE_CONFIG_H=1 -DPIXMAN_NO_TLS=1 -Wno-unused-const-variable -#CFLAGS += -fshort-double # Use the FPU even for doubles -#CFLAGS = -I. -Iexternal/freertos/include -Iexternal -Iexternal/freertos/portable/GCC/ARM_CM4F -Iexternal/newlib/libc/include -Iinclude -#-I/Users/romain/local/arm-none-eabi/include -CFLAGS += -std=c99 -Wall -#CFLAGS += -march=armv7e-m -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 +TOOLCHAIN=arm-none-eabi +COMPILER=llvm + +ifeq ($(COMPILER),llvm) CC=clang -CFLAGS += -target thumbv7em-unknown-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -ffreestanding - CXX=clang++ -CXXFLAGS=-target thumbv7em-unknown-eabi -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -ffreestanding -CXXFLAGS += -fno-exceptions -fno-unwind-tables -fno-rtti -nostdlib +else +CC=$(TOOLCHAIN)-gcc +CXX=$(TOOLCHAIN)-g++ +endif -# Production -CFLAGS += -g -#CFLAGS += -Os -fdata-sections -ffunction-sections -#LDFLAGS += --gc-sections +LD=$(TOOLCHAIN)-ld.bfd +GDB=$(TOOLCHAIN)-gdb +OBJCOPY=$(TOOLCHAIN)-objcopy + +# Compiler flags +# Note: We're using CFLAGS, CXXFLAGS, and SFLAGS. SFLAGS are shared flags for both C and C++ + +# Flags - Arch +ifeq ($(COMPILER),llvm) + SFLAGS += -target thumbv7em-unknown-eabi +else + SFLAGS += -mthumb -march=armv7e-m -mfloat-abi=softfp +endif +SFLAGS += -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 + +# Flags - Header search path +SFLAGS += -Ilib -I. -Iinclude -Iexternal/freertos/include -Iexternal -Iexternal/freertos/portable/GCC/ARM_CM4F -Iexternal/newlib/libc/include + +# Flags - Building options +SFLAGS += -Wall -ffreestanding + +# Flags - Optimizations +ifeq ($(PRODUCTION),1) +#echo "*** PRODUCTION BUILD ***" +SFLAGS += -Os -fdata-sections -ffunction-sections +LDFLAGS += --gc-sections +else +SFLAGS += -g +endif + +# Language-specific flags +CFLAGS = -std=c99 +CXXFLAGS = -std=c++11 -fno-exceptions -fno-unwind-tables -fno-rtti -nostdlib products := boot.elf boot.hex boot.bin @@ -28,13 +50,14 @@ objs += external/newlib/libc/string/memset.o external/newlib/libc/string/memcpy. objs += lib/assert.o -objs += math/expression.o +objs += src/hello.o default: clean boot.elf include platform/Makefile include kandinsky/Makefile +include poincare/Makefile run: boot.elf $(GDB) -x gdb_script.gdb boot.elf @@ -59,11 +82,11 @@ boot.elf: $(objs) %.o: %.c @echo "CC $@" - @$(CC) $(CFLAGS) -c $< -o $@ + @$(CC) $(CFLAGS) $(SFLAGS) -c $< -o $@ %.o: %.cpp @echo "CXX $@" - @$(CXX) $(CXXFLAGS) -c $< -o $@ + @$(CXX) $(CXXFLAGS) $(SFLAGS) -c $< -o $@ clean: @echo "CLEAN" diff --git a/kandinsky/Makefile b/kandinsky/Makefile index efa70b547..9d9bedf7b 100644 --- a/kandinsky/Makefile +++ b/kandinsky/Makefile @@ -1,5 +1,5 @@ -CFLAGS += -Ikandinsky/include -Iplatform/stm32f429 -objs += $(addprefix kandinsky/src/, line.o text.o font.o) +SFLAGS += -Ikandinsky/include -Iplatform/stm32f429 +objs += $(addprefix kandinsky/src/, line.o text.o font.o rect.o) FREETYPE_PATH := /usr/local/Cellar/freetype/2.5.5 LIBPNG_PATH := /usr/local/Cellar/libpng/1.6.17 @@ -10,7 +10,7 @@ font_files = $(addprefix kandinsky/src/, font.h font.c) $(font_files): kandinsky/fonts/rasterizer @echo "RASTER $(font_files)" - @$< kandinsky/fonts/DroidSansMono.ttf 20 20 $(font_files) + @$< kandinsky/fonts/ProggyClean.ttf 16 16 $(font_files) kandinsky/fonts/rasterizer: kandinsky/fonts/rasterizer.c @echo "HOSTCC $@" diff --git a/kandinsky/include/kandinsky.h b/kandinsky/include/kandinsky.h index b7ca2876a..1982d0dcf 100644 --- a/kandinsky/include/kandinsky.h +++ b/kandinsky/include/kandinsky.h @@ -1,7 +1,10 @@ #ifndef KANDINSKY_KANDINSKY_H #define KANDINSKY_KANDINSKY_H -#include +#include #include +#include +#include +#include #endif diff --git a/kandinsky/include/kandinsky/color.h b/kandinsky/include/kandinsky/color.h index 580cbb3b5..0f9541cd0 100644 --- a/kandinsky/include/kandinsky/color.h +++ b/kandinsky/include/kandinsky/color.h @@ -1,8 +1,7 @@ #ifndef KANDINSKY_COLOR_H #define KANDINSKY_COLOR_H -#include - -typedef uint8_t KDColor; +#include +typedef pixel_t KDColor; #endif diff --git a/kandinsky/include/kandinsky/point.h b/kandinsky/include/kandinsky/point.h index 02cc3daf5..a90c2958d 100644 --- a/kandinsky/include/kandinsky/point.h +++ b/kandinsky/include/kandinsky/point.h @@ -1,11 +1,11 @@ #ifndef KANDINSKY_POINT_H #define KANDINSKY_POINT_H -#include +#include typedef struct { - uint16_t x; - uint16_t y; + KDCoordinate x; + KDCoordinate y; } KDPoint; #endif diff --git a/kandinsky/src/line.c b/kandinsky/src/line.c index 0d8bc2d48..968e2331d 100644 --- a/kandinsky/src/line.c +++ b/kandinsky/src/line.c @@ -1,8 +1,6 @@ #include -#include "framebuffer.h" void KDDrawLine(KDPoint p1, KDPoint p2) { - for (int i=0; i<10; i++) { - PIXEL(i,i) = 0xFF; + for (KDCoordinate x = p1.x; x + typedef uint8_t pixel_t; #define FRAMEBUFFER_WIDTH 240 @@ -8,6 +10,7 @@ typedef uint8_t pixel_t; #define FRAMEBUFFER_BITS_PER_PIXEL 8 #define FRAMEBUFFER_ADDRESS (pixel_t *)(0x2001D400) -#define PIXEL(x,y) *(pixel_t *)(FRAMEBUFFER_ADDRESS+FRAMEBUFFER_WIDTH*(y)+(x)) +#define PIXEL_ADDRESS(x,y) (pixel_t *)(FRAMEBUFFER_ADDRESS+FRAMEBUFFER_WIDTH*(y)+(x)) +#define PIXEL(x,y) *PIXEL_ADDRESS(x,y) #endif diff --git a/platform/stm32f429/init.c b/platform/stm32f429/init.c index fbee6bda4..0efabfb75 100644 --- a/platform/stm32f429/init.c +++ b/platform/stm32f429/init.c @@ -1,5 +1,7 @@ #include "init_lcd.h" +#include void init() { init_lcd(); + hello(); }