Skip to content

Commit

Permalink
Update app_template to use .bin format
Browse files Browse the repository at this point in the history
  • Loading branch information
SnailMath committed Apr 28, 2021
1 parent 149df77 commit 0c1d734
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
1 change: 1 addition & 0 deletions app_template/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Compiled files
*.o
*.hhk
*.bin
16 changes: 13 additions & 3 deletions app_template/Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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
25 changes: 24 additions & 1 deletion app_template/linker.ld
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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)
}
}



7 changes: 6 additions & 1 deletion app_template/main.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
#include <appdef.hpp>
#include <sdk/os/lcd.hpp>
#include <sdk/os/debug.hpp>

/*
* 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")

extern "C"
void main() {
// Put your app's code here!
Debug_SetCursorPosition(1,2);
Debug_PrintString("HelloWorld",0);
LCD_Refresh();
}
9 changes: 9 additions & 0 deletions app_template/start.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.section .init
mov.l main_addr, r0
jmp @r0
nop
.align 2
main_addr:
.long _main
load_addr:
.long 0x8cff0000

0 comments on commit 0c1d734

Please sign in to comment.