mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
Cleanup
This commit is contained in:
30
Makefile
30
Makefile
@@ -2,30 +2,40 @@ CC=arm-none-eabi-gcc
|
||||
LD=arm-none-eabi-ld.bfd
|
||||
GDB=arm-none-eabi-gdb
|
||||
OBJCOPY=arm-none-eabi-objcopy
|
||||
CFLAGS = -I. -Iinclude -Iexternal/freertos/include -Iexternal -Iexternal/freertos/portable/GCC/ARM_CM4F -Iexternal/newlib/libc/include
|
||||
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 -g -Wall
|
||||
CFLAGS += -std=c99 -Wall
|
||||
#CFLAGS += -march=armv7e-m -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16
|
||||
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
|
||||
|
||||
# Production
|
||||
CFLAGS += -g
|
||||
#CFLAGS += -Os -fdata-sections -ffunction-sections
|
||||
#LDFLAGS += --gc-sections
|
||||
|
||||
objs := platform/stm32f429/boot/crt0.o
|
||||
products := boot.elf boot.hex boot.bin
|
||||
|
||||
objs += external/freertos/tasks.o external/freertos/list.o external/freertos/queue.o external/freertos/portable/GCC/ARM_CM4F/port.o external/freertos/portable/MemMang/heap_1.o
|
||||
objs += external/newlib/libc/string/memset.o external/newlib/libc/string/memcpy.o
|
||||
|
||||
objs += platform/stm32f429/boot/isr.o
|
||||
#platform/stm32f429/registers/gpio.o platform/stm32f429/registers/rcc.o platform/stm32f429/registers/spi.o platform/stm32f429/registers/ltdc.o
|
||||
objs += lib/assert.o
|
||||
|
||||
objs += math/expression.o
|
||||
|
||||
objs += platform/stm32f429/init.o platform/stm32f429/init_lcd.o
|
||||
objs += platform/ili9341/ili9341.o
|
||||
|
||||
default: clean boot.elf
|
||||
|
||||
include platform/Makefile
|
||||
include kandinsky/Makefile
|
||||
|
||||
run: boot.elf
|
||||
$(GDB) -x gdb_script.gdb boot.elf
|
||||
|
||||
@@ -51,6 +61,10 @@ boot.elf: $(objs)
|
||||
@echo "CC $@"
|
||||
@$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
%.o: %.cpp
|
||||
@echo "CXX $@"
|
||||
@$(CXX) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
clean:
|
||||
@echo "CLEAN"
|
||||
@rm -f $(objs) boot.elf boot.bin boot.hex
|
||||
@rm -f $(objs) $(products)
|
||||
|
||||
@@ -140,12 +140,12 @@ int main(int argc, char * argv[]) {
|
||||
fprintf(headerFile, "#define BITMAP_FONT_LAST_CHARACTER 0x%2x\n\n", CHARACTER_RANGE_END);
|
||||
fprintf(headerFile, "#define BITMAP_FONT_CHARACTER_WIDTH %d\n", glyph_width);
|
||||
fprintf(headerFile, "#define BITMAP_FONT_CHARACTER_HEIGHT %d\n\n", glyph_height);
|
||||
fprintf(headerFile, "extern unsigned char bitmapFont[%d][%d][%d];\n", CHARACTER_RANGE_END-CHARACTER_RANGE_START+1, glyph_width, glyph_height);
|
||||
fprintf(headerFile, "extern unsigned char bitmapFont[%d][%d][%d];\n", CHARACTER_RANGE_END-CHARACTER_RANGE_START+1, glyph_height, glyph_width);
|
||||
fclose(headerFile);
|
||||
|
||||
FILE * sourceFile = fopen("out.c", "w");
|
||||
fprintf(sourceFile, "/* Auto-generated by rasterizer */\n\n");
|
||||
fprintf(sourceFile, "unsigned char bitmapFont[%d][%d][%d] = {\n", CHARACTER_RANGE_END-CHARACTER_RANGE_START+1, glyph_width, glyph_height);
|
||||
fprintf(sourceFile, "unsigned char bitmapFont[%d][%d][%d] = {\n", CHARACTER_RANGE_END-CHARACTER_RANGE_START+1, glyph_height, glyph_width);
|
||||
for (unsigned char character = CHARACTER_RANGE_START; character <= CHARACTER_RANGE_END; character++) {
|
||||
fprintf(sourceFile, " {\n");
|
||||
int characterX = ((character-CHARACTER_RANGE_START)%GRID_WIDTH * (glyph_width+grid_size));
|
||||
|
||||
@@ -8,6 +8,7 @@ load boot.elf
|
||||
monitor reset halt
|
||||
|
||||
break init
|
||||
break _halt
|
||||
break abort
|
||||
break __assert
|
||||
|
||||
continue
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
CFLAGS += -Ikandinsky/include
|
||||
CFLAGS += -Ikandinsky/include -Iplatform/stm32f429
|
||||
objs += $(addprefix kandinsky/src/, line.o text.o font.o)
|
||||
|
||||
FREETYPE_PATH := /usr/local/Cellar/freetype/2.5.5
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
typedef uint8_t kdpixel_t;
|
||||
|
||||
#define FRAMEBUFFER_WIDTH 240
|
||||
#define FRAMEBUFFER_HEIGHT 320
|
||||
#define FRAMEBUFFER_ADDRESS (kdpixel_t *)(0x2001D400)
|
||||
|
||||
#define PIXEL(x,y) *(kdpixel_t *)(FRAMEBUFFER_ADDRESS + y*FRAMEBUFFER_WIDTH + x)
|
||||
@@ -1,9 +1,8 @@
|
||||
#include <kandinsky/text.h>
|
||||
#include "framebuffer.h"
|
||||
#include <framebuffer.h>
|
||||
#include "font.h"
|
||||
|
||||
void KDDrawChar(char character, KDPoint p) {
|
||||
char * framebuffer = FRAMEBUFFER_ADDRESS;
|
||||
for (int j=0; j<BITMAP_FONT_CHARACTER_HEIGHT;j++) {
|
||||
for (int i=0; i<BITMAP_FONT_CHARACTER_WIDTH;i++) {
|
||||
PIXEL(p.x+i, p.y+j) = bitmapFont[character-BITMAP_FONT_FIRST_CHARACTER][j][i];
|
||||
|
||||
11
lib/assert.c
Normal file
11
lib/assert.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assert(e) ((void)0)
|
||||
#else
|
||||
#define assert(e) ((void) ((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__)))
|
||||
#endif
|
||||
|
||||
void __assert(const char * expression, const char * file, int line) {
|
||||
abort();
|
||||
}
|
||||
14
lib/assert.h
Normal file
14
lib/assert.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef ASSERT_H
|
||||
#define ASSERT_H
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define assert(e) ((void)0)
|
||||
#else
|
||||
#define assert(e) ((void) ((e) ? ((void)0) : __assert(#e, __FILE__, __LINE__)))
|
||||
#endif
|
||||
|
||||
void __assert(const char * expression, const char * file, int line);
|
||||
|
||||
void abort(void);
|
||||
|
||||
#endif
|
||||
2
platform/Makefile
Normal file
2
platform/Makefile
Normal file
@@ -0,0 +1,2 @@
|
||||
objs += $(addprefix platform/stm32f429/, boot/isr.o boot/crt0.o init.o init_lcd.o)
|
||||
objs += platform/ili9341/ili9341.o
|
||||
@@ -9,7 +9,8 @@ extern const void * _bss_section_end_ram;
|
||||
|
||||
void init();
|
||||
|
||||
void _halt() {
|
||||
void abort() {
|
||||
// TODO: #ifdef NDEBUG, maybe trigger a reset?
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
@@ -33,5 +34,5 @@ void _start(void) {
|
||||
|
||||
init();
|
||||
|
||||
_halt();
|
||||
abort();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ SECTIONS {
|
||||
* HardFault one to crt0's _halt. */
|
||||
|
||||
PROVIDE(_ResetServiceRoutine = _start);
|
||||
PROVIDE(_HardFaultServiceRoutine = _halt);
|
||||
PROVIDE(_HardFaultServiceRoutine = abort);
|
||||
|
||||
*(.text)
|
||||
*(.text.*)
|
||||
|
||||
13
platform/stm32f429/framebuffer.h
Normal file
13
platform/stm32f429/framebuffer.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef STM32F4_FRAMEBUFFER_H
|
||||
#define STM32F4_FRAMEBUFFER_H
|
||||
|
||||
typedef uint8_t pixel_t;
|
||||
|
||||
#define FRAMEBUFFER_WIDTH 240
|
||||
#define FRAMEBUFFER_HEIGHT 320
|
||||
#define FRAMEBUFFER_BITS_PER_PIXEL 8
|
||||
#define FRAMEBUFFER_ADDRESS (pixel_t *)(0x2001D400)
|
||||
|
||||
#define PIXEL(x,y) *(pixel_t *)(FRAMEBUFFER_ADDRESS+FRAMEBUFFER_WIDTH*(y)+(x))
|
||||
|
||||
#endif
|
||||
@@ -27,12 +27,18 @@
|
||||
#include "registers/gpio.h"
|
||||
#include "registers/spi.h"
|
||||
#include "registers/ltdc.h"*/
|
||||
#include <assert.h>
|
||||
#include "registers.h"
|
||||
#include "framebuffer.h"
|
||||
#include <platform/ili9341/ili9341.h>
|
||||
|
||||
extern pixel_t _framebuffer_start;
|
||||
extern pixel_t _framebuffer_end;
|
||||
|
||||
static void init_spi_interface();
|
||||
static void init_rgb_interface();
|
||||
static void init_panel();
|
||||
static void check_framebuffer();
|
||||
|
||||
void init_lcd() {
|
||||
/* This routine is responsible for initializing the LCD panel.
|
||||
@@ -45,6 +51,10 @@ void init_lcd() {
|
||||
init_rgb_interface();
|
||||
|
||||
init_panel();
|
||||
|
||||
#ifndef NDEBUG
|
||||
check_framebuffer();
|
||||
#endif
|
||||
}
|
||||
|
||||
// SPI interface
|
||||
@@ -187,7 +197,6 @@ static void init_rgb_clocks() {
|
||||
}
|
||||
}
|
||||
|
||||
extern const void * _framebuffer_start;
|
||||
|
||||
static void init_rgb_timings() {
|
||||
// Configure the Synchronous timings: VSYNC, HSYNC, Vertical and Horizontal
|
||||
@@ -340,3 +349,12 @@ void gpio_c2_write(bool pin_state) {
|
||||
void gpio_d13_write(bool pin_state) {
|
||||
REGISTER_SET_VALUE(GPIO_ODR(GPIOD), ODR(13), pin_state);
|
||||
}
|
||||
|
||||
// Framebuffer checks
|
||||
|
||||
static void check_framebuffer() {
|
||||
assert(&_framebuffer_start == FRAMEBUFFER_ADDRESS);
|
||||
pixel_t * fb_end = &_framebuffer_start + (FRAMEBUFFER_WIDTH*FRAMEBUFFER_HEIGHT*FRAMEBUFFER_BITS_PER_PIXEL)/8;
|
||||
assert(&_framebuffer_end == fb_end);
|
||||
assert(8*sizeof(pixel_t) == FRAMEBUFFER_BITS_PER_PIXEL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user