From 0c1d734d34e463cdfda09fed61210b9466ac028a Mon Sep 17 00:00:00 2001 From: SnailMath Date: Wed, 28 Apr 2021 10:48:55 +0200 Subject: [PATCH] Update app_template to use .bin format --- app_template/.gitignore | 1 + app_template/Makefile | 16 +++++++++++++--- app_template/linker.ld | 25 ++++++++++++++++++++++++- app_template/main.cpp | 7 ++++++- app_template/start.s | 9 +++++++++ 5 files changed, 53 insertions(+), 5 deletions(-) mode change 100644 => 100755 app_template/linker.ld create mode 100755 app_template/start.s diff --git a/app_template/.gitignore b/app_template/.gitignore index e7b964e..310e50f 100644 --- a/app_template/.gitignore +++ b/app_template/.gitignore @@ -1,3 +1,4 @@ # Compiled files *.o *.hhk +*.bin diff --git a/app_template/Makefile b/app_template/Makefile index 4c8cdf2..f4df56e 100644 --- a/app_template/Makefile +++ b/app_template/Makefile @@ -1,3 +1,5 @@ +# run `make all` to compile the .hhk and .bin file, use `make` to compile only the .bin file. +# The .hhk file is the original format, the bin file is a newer format. APP_NAME:=app_template ifndef SDK_DIR @@ -25,11 +27,16 @@ CXX_SOURCES:=$(wildcard *.cpp) OBJECTS:=$(AS_SOURCES:.s=.o) $(CC_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o) APP_ELF:=$(APP_NAME).hhk +APP_BIN:=$(APP_NAME).bin -all: $(APP_ELF) Makefile +bin: $(APP_BIN) Makefile + +hhk: $(APP_ELF) Makefile + +all: $(APP_ELF) $(APP_BIN) Makefile clean: - rm -f $(OBJECTS) $(APP_ELF) + rm -f $(OBJECTS) $(APP_ELF) $(APP_BIN) $(APP_ELF): $(OBJECTS) $(SDK_DIR)/sdk.o linker.ld $(LD) -T linker.ld -o $@ $(LD_FLAGS) $(OBJECTS) $(SDK_DIR)/sdk.o @@ -38,6 +45,9 @@ $(APP_ELF): $(OBJECTS) $(SDK_DIR)/sdk.o linker.ld $(OBJCOPY) --set-section-flags .hollyhock_author=contents,strings,readonly $(APP_ELF) $(APP_ELF) $(OBJCOPY) --set-section-flags .hollyhock_version=contents,strings,readonly $(APP_ELF) $(APP_ELF) +$(APP_BIN): $(OBJECTS) $(SDK_DIR)/sdk.o linker.ld + $(LD) --oformat binary -T linker.ld -o $@ $(LD_FLAGS) $(OBJECTS) $(SDK_DIR)/sdk.o + # We're not actually building sdk.o, just telling the user they need to do it # themselves. Just using the target to trigger an error when the file is # required but does not exist. @@ -59,4 +69,4 @@ $(SDK_DIR)/sdk.o: $(CXX) -c $< -o $@ $(CXX_FLAGS) @$(READELF) $@ -S | grep ".ctors" > /dev/null && echo "ERROR: Global constructors aren't supported." && rm $@ && exit 1 || exit 0 -.PHONY: all clean +.PHONY: bin hhk all clean diff --git a/app_template/linker.ld b/app_template/linker.ld old mode 100644 new mode 100755 index 7217949..ed8efa6 --- a/app_template/linker.ld +++ b/app_template/linker.ld @@ -1,5 +1,28 @@ ENTRY(_main); SECTIONS { - . = 0x8CFF0000; + start_address = 0x8CFF0000; + .init start_address : AT(start_address) { + *(.init) + } + info_address = 0x8CFF0010; + . = info_address; + .hollyhock_name : { + *(.hollyhock_name) + } + .hollyhock_description : { + *(.hollyhock_description) + } + .hollyhock_author : { + *(.hollyhock_author) + } + .hollyhock_version : { + *(.hollyhock_version) + } + .text : { + *(.text) + } } + + + diff --git a/app_template/main.cpp b/app_template/main.cpp index badf5e8..2abadbd 100644 --- a/app_template/main.cpp +++ b/app_template/main.cpp @@ -1,10 +1,12 @@ #include +#include +#include /* * Fill this section in with some information about your app. * All fields are optional - so if you don't need one, take it out. */ -APP_NAME("My app name") +APP_NAME("My app name 2") APP_DESCRIPTION("A short description of my app") APP_AUTHOR("My name") APP_VERSION("1.0.0") @@ -12,4 +14,7 @@ APP_VERSION("1.0.0") extern "C" void main() { // Put your app's code here! + Debug_SetCursorPosition(1,2); + Debug_PrintString("HelloWorld",0); + LCD_Refresh(); } diff --git a/app_template/start.s b/app_template/start.s new file mode 100755 index 0000000..8ad8dbe --- /dev/null +++ b/app_template/start.s @@ -0,0 +1,9 @@ +.section .init +mov.l main_addr, r0 +jmp @r0 +nop +.align 2 +main_addr: +.long _main +load_addr: +.long 0x8cff0000