Compare commits
3 Commits
d74785d34d
...
7cc4199342
Author | SHA1 | Date |
---|---|---|
Lephenixnoir | 7cc4199342 | |
Lephenixnoir | 15712b4f5b | |
Lephenixnoir | 46b19bab62 |
|
@ -660,6 +660,9 @@ def convert(input, params, target, output=None, model=None):
|
|||
if "name" not in params:
|
||||
raise FxconvError(f"no name specified for conversion '{input}'")
|
||||
|
||||
if target["arch"] is None:
|
||||
target["arch"] = model
|
||||
|
||||
if "type" not in params:
|
||||
raise FxconvError(f"missing type in conversion '{input}'")
|
||||
elif params["type"] == "binary":
|
||||
|
@ -682,20 +685,28 @@ def elf(data, output, symbol, toolchain=None, arch=None, section=None):
|
|||
The symbol name must have a leading underscore if it is to be declared and
|
||||
used from a C program.
|
||||
|
||||
The toolchain can be any target triplet for which the compiler is
|
||||
available. The architecture is deduced from some typical triplets;
|
||||
otherwise it can be set, usually as "sh3" or "sh4-nofpu". This affects the
|
||||
--binary-architecture flag of objcopy. If arch is set to "fx" or "cg", this
|
||||
function tries to be smart and:
|
||||
|
||||
* Uses the name of the compiler if it contains a full architecture name
|
||||
such as "sh3", "sh4" or "sh4-nofpu";
|
||||
* Uses "sh3" for fx9860g and "sh4-nofpu" for fxcg50 if the toolchain is
|
||||
"sh-elf", which is a custom set;
|
||||
* Fails otherwise.
|
||||
|
||||
The section name can be specified, along with its flags. A typical example
|
||||
would be section=".rodata,contents,alloc,load,readonly,data", which is the
|
||||
default.
|
||||
|
||||
The architecture can be either "sh3" or "sh4". This affects the choice of
|
||||
the toolchain (sh3eb-elf-objcopy versus sh4eb-nofpu-elf-objcopy) and the
|
||||
--binary-architecture flag of objcopy.
|
||||
|
||||
Arguments:
|
||||
data -- A bytes-like object with data to embed into the object file
|
||||
output -- Name of output file
|
||||
symbol -- Chosen symbol name
|
||||
toolchain -- Target triplet [default: "sh3eb-elf"]
|
||||
arch -- Target architecture [default: from toolchain, if trivial]
|
||||
arch -- Target architecture [default: try to guess]
|
||||
section -- Target section [default: above variation of .rodata]
|
||||
|
||||
Produces an output file and returns nothing.
|
||||
|
@ -706,9 +717,16 @@ def elf(data, output, symbol, toolchain=None, arch=None, section=None):
|
|||
if section is None:
|
||||
section = ".rodata,contents,alloc,load,readonly,data"
|
||||
|
||||
if arch is None and toolchain in "sh3eb-elf sh4eb-elf sh4eb-nofpu-elf":
|
||||
if arch in ["fx", "cg", None] and toolchain in ["sh3eb-elf", "sh4eb-elf",
|
||||
"sh4eb-nofpu-elf"]:
|
||||
arch = toolchain.replace("eb-", "-")[:-4]
|
||||
if arch is None:
|
||||
|
||||
elif arch == "fx" and toolchain == "sh-elf":
|
||||
arch = "sh3"
|
||||
elif arch == "cg" and toolchain == "sh-elf":
|
||||
arch = "sh4-nofpu"
|
||||
|
||||
elif arch in ["fx", "cg", None]:
|
||||
raise FxconvError(f"non-trivial architecture for {toolchain} must be "+
|
||||
"specified")
|
||||
|
||||
|
|
|
@ -10,42 +10,70 @@
|
|||
include project.cfg
|
||||
|
||||
# Compiler flags
|
||||
cf := -mb -ffreestanding -nostdlib -Wall -Wextra \
|
||||
-fstrict-volatile-bitfields $(CFLAGS)
|
||||
cf-fx := $(cf) -m3 -DFX9860G
|
||||
cf-cg := $(cf) -m4-nofpu -DFXCG50
|
||||
CFLAGSFX := $(CFLAGS) $(CFLAGS_FX) $(INCLUDE)
|
||||
CFLAGSCG := $(CFLAGS) $(CFLAGS_CG) $(INCLUDE)
|
||||
|
||||
# Linker flags
|
||||
lf-fx := -Tfx9860g.ld -lgint-fx $(LDFLAGS) -lgcc -Wl,-Map=build-fx/map
|
||||
lf-cg := -Tfxcg50.ld -lgint-cg $(LDFLAGS) -lgcc -Wl,-Map=build-cg/map
|
||||
LDFLAGSFX := $(LDFLAGS) $(LDFLAGS_FX)
|
||||
LDFLAGSCG := $(LDFLAGS) $(LDFLAGS_CG)
|
||||
|
||||
dflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
|
||||
cpflags := -R .bss -R .gint_bss
|
||||
# Dependency list generation flags
|
||||
depflags = -MMD -MT $@ -MF $(@:.o=.d) -MP
|
||||
# ELF to binary flags
|
||||
BINFLAGS := -R .bss -R .gint_bss
|
||||
|
||||
g1af := -i "$(ICON_FX)" -n "$(NAME)" --internal="$(INTERNAL)"
|
||||
g3af := -n basic:"$(NAME)" -i uns:"$(ICON_CG_UNS)" -i sel:"$(ICON_CG_SEL)"
|
||||
# G1A and G3A generation flags
|
||||
NAME_G1A ?= $(NAME)
|
||||
NAME_G3A ?= $(NAME)
|
||||
G1AF := -i "$(ICON_FX)" -n "$(NAME_G1A)" --internal="$(INTERNAL)"
|
||||
G3AF := -n basic:"$(NAME_G3A)" -i uns:"$(ICON_CG_UNS)" -i sel:"$(ICON_CG_SEL)"
|
||||
|
||||
ifeq "$(TOOLCHAIN_FX)" ""
|
||||
TOOLCHAIN_FX := sh3eb-elf
|
||||
endif
|
||||
|
||||
ifeq "$(TOOLCHAIN_CG)" ""
|
||||
TOOLCHAIN_CG := sh4eb-elf
|
||||
endif
|
||||
|
||||
# fxconv flags
|
||||
FXCONVFX := --fx --toolchain=$(TOOLCHAIN_FX)
|
||||
FXCONVCG := --cg --toolchain=$(TOOLCHAIN_CG)
|
||||
|
||||
#
|
||||
# File listings
|
||||
#
|
||||
|
||||
null :=
|
||||
filename := $(subst $(null) $(null),-,$(NAME))
|
||||
NULL :=
|
||||
TARGET := $(subst $(NULL) $(NULL),-,$(NAME))
|
||||
|
||||
elf = $(dir $<)$(filename).elf
|
||||
bin = $(dir $<)$(filename).bin
|
||||
target-fx := $(filename).g1a
|
||||
target-cg := $(filename).g3a
|
||||
ifeq "$(TARGET_FX)" ""
|
||||
TARGET_FX := $(TARGET).g1a
|
||||
endif
|
||||
|
||||
ifeq "$(TARGET_CG)" ""
|
||||
TARGET_CG := $(TARGET).g3a
|
||||
endif
|
||||
|
||||
ELF_FX := build-fx/$(shell basename -s .g1a $(TARGET_FX)).elf
|
||||
BIN_FX := $(ELF_FX:.elf=.bin)
|
||||
|
||||
ELF_CG := build-cg/$(shell basename -s .g3a $(TARGET_CG)).elf
|
||||
BIN_CG := $(ELF_CG:.elf=.bin)
|
||||
|
||||
# Source files
|
||||
src := $(wildcard src/*.[csS] src/*/*.[csS] src/*/*/*.[csS] \
|
||||
src := $(wildcard src/*.[csS] \
|
||||
src/*/*.[csS] \
|
||||
src/*/*/*.[csS] \
|
||||
src/*/*/*/*.[csS])
|
||||
assets-fx := $(wildcard assets-fx/*/*)
|
||||
assets-cg := $(wildcard assets-cg/*/*)
|
||||
|
||||
# Object files
|
||||
obj-fx := $(src:%.c=build-fx/%.o) $(assets-fx:assets-fx/%=build-fx/assets/%.o)
|
||||
obj-cg := $(src:%.c=build-cg/%.o) $(assets-cg:assets-cg/%=build-cg/assets/%.o)
|
||||
obj-fx := $(src:%=build-fx/%.o) \
|
||||
$(assets-fx:assets-fx/%=build-fx/assets/%.o)
|
||||
obj-cg := $(src:%=build-cg/%.o) \
|
||||
$(assets-cg:assets-cg/%=build-cg/assets/%.o)
|
||||
|
||||
# Additional dependencies
|
||||
deps-fx := $(ICON_FX)
|
||||
|
@ -66,60 +94,68 @@ endif
|
|||
|
||||
all: $(all)
|
||||
|
||||
all-fx: $(target-fx)
|
||||
all-cg: $(target-cg)
|
||||
all-fx: $(TARGET_FX)
|
||||
all-cg: $(TARGET_CG)
|
||||
|
||||
$(target-fx): $(obj-fx) $(deps-fx)
|
||||
$(TARGET_FX): $(obj-fx) $(deps-fx)
|
||||
@ mkdir -p $(dir $@)
|
||||
$(TOOLCHAIN_FX)-gcc -o $(ELF_FX) $(obj-fx) $(CFLAGSFX) $(LDFLAGSFX)
|
||||
$(TOOLCHAIN_FX)-objcopy -O binary $(BINFLAGS) $(ELF_FX) $(BIN_FX)
|
||||
fxg1a $(BIN_FX) -o $@ $(G1AF)
|
||||
|
||||
sh3eb-elf-gcc -o $(elf) $(obj-fx) $(cf-fx) $(lf-fx)
|
||||
sh3eb-elf-objcopy -O binary $(cpflags) $(elf) $(bin)
|
||||
fxg1a $(bin) -o $@ $(g1af)
|
||||
|
||||
$(target-cg): $(obj-cg) $(deps-cg)
|
||||
|
||||
sh4eb-elf-gcc -o $(elf) $(obj-cg) $(cf-cg) $(lf-cg)
|
||||
sh4eb-elf-objcopy -O binary $(cpflags) $(elf) $(bin)
|
||||
mkg3a $(g3af) $(bin) $@
|
||||
$(TARGET_CG): $(obj-cg) $(deps-cg)
|
||||
@ mkdir -p $(dir $@)
|
||||
$(TOOLCHAIN_CG)-gcc -o $(ELF_CG) $(obj-cg) $(CFLAGSCG) $(LDFLAGSCG)
|
||||
$(TOOLCHAIN_CG)-objcopy -O binary $(BINFLAGS) $(ELF_CG) $(BIN_CG)
|
||||
mkg3a $(G3AF) $(BIN_CG) $@
|
||||
|
||||
# C sources
|
||||
build-fx/%.o: %.c
|
||||
build-fx/%.c.o: %.c
|
||||
@ mkdir -p $(dir $@)
|
||||
sh3eb-elf-gcc -c $< -o $@ $(cf-fx) $(dflags)
|
||||
build-cg/%.o: %.c
|
||||
$(TOOLCHAIN_FX)-gcc -c $< -o $@ $(CFLAGSFX) $(depflags)
|
||||
build-cg/%.c.o: %.c
|
||||
@ mkdir -p $(dir $@)
|
||||
sh4eb-elf-gcc -c $< -o $@ $(cf-cg) $(dflags)
|
||||
$(TOOLCHAIN_CG)-gcc -c $< -o $@ $(CFLAGSCG) $(depflags)
|
||||
|
||||
# Assembler sources
|
||||
build-fx/%.o: %.s
|
||||
build-fx/%.s.o: %.s
|
||||
@ mkdir -p $(dir $@)
|
||||
sh3eb-elf-gcc -c $< -o $@
|
||||
build-fx/%.o: %.S
|
||||
$(TOOLCHAIN_FX)-gcc -c $< -o $@
|
||||
build-cg/%.s.o: %.s
|
||||
@ mkdir -p $(dir $@)
|
||||
sh3eb-elf-gcc -c $< -o $@ $(sflags)
|
||||
build-cg/%.o: %.s
|
||||
$(TOOLCHAIN_CG)-gcc -c $< -o $@
|
||||
|
||||
# Preprocessed assembler sources
|
||||
build-fx/%.S.o: %.S
|
||||
@ mkdir -p $(dir $@)
|
||||
sh4eb-elf-gcc -c $< -o $@
|
||||
build-cg/%.o: %.S
|
||||
$(TOOLCHAIN_FX)-gcc -c $< -o $@ $(INCLUDE)
|
||||
build-cg/%.S.o: %.S
|
||||
@ mkdir -p $(dir $@)
|
||||
sh4eb-elf-gcc -c $< -o $@ $(sflags)
|
||||
$(TOOLCHAIN_CG)-gcc -c $< -o $@ $(INCLUDE)
|
||||
|
||||
# Images
|
||||
build-fx/assets/img/%.o: assets-fx/img/%
|
||||
@ mkdir -p $(dir $@)
|
||||
fxconv -i $< -o $@ --fx name:img_$(basename $*)
|
||||
|
||||
fxconv -i $< -o $@ $(FXCONVFX) name:img_$(basename $*) $(IMG.$*)
|
||||
build-cg/assets/img/%.o: assets-cg/img/%
|
||||
@ mkdir -p $(dir $@)
|
||||
fxconv -i $< -o $@ --cg name:img_$(basename $*)
|
||||
fxconv -i $< -o $@ $(FXCONVCG) name:img_$(basename $*) $(IMG.$*)
|
||||
|
||||
# Fonts
|
||||
build-fx/assets/fonts/%.o: assets-fx/fonts/%
|
||||
@ mkdir -p $(dir $@)
|
||||
fxconv -f $< -o $@ name:font_$(basename $*) $(FONT.$*)
|
||||
|
||||
fxconv -f $< -o $@ $(FXCONVFX) name:font_$(basename $*) $(FONT.$*)
|
||||
build-cg/assets/fonts/%.o: assets-cg/fonts/%
|
||||
@ mkdir -p $(dir $@)
|
||||
fxconv -f $< -o $@ name:font_$(basename $*) $(FONT.$*)
|
||||
fxconv -f $< -o $@ $(FXCONVCG) name:font_$(basename $*) $(FONT.$*)
|
||||
|
||||
# Binaries
|
||||
build-fx/assets/bin/%.o: assets-fx/bin/%
|
||||
@ mkdir -p $(dir $@)
|
||||
fxconv -b $< -o $@ $(FXCONVFX) name:bin_$(basename $*) $(BIN.$*)
|
||||
build-cg/assets/bin/%.o: assets-cg/bin/%
|
||||
@ mkdir -p $(dir $@)
|
||||
fxconv -b $< -o $@ $(FXCONVCG) name:bin_$(basename $*) $(BIN.$*)
|
||||
|
||||
#
|
||||
# Cleaning and utilities
|
||||
|
@ -131,14 +167,23 @@ build-fx/%.d: ;
|
|||
build-cg/%.d: ;
|
||||
.PRECIOUS: build-fx build-cg build-fx/%.d build-cg/%.d %/
|
||||
|
||||
clean:
|
||||
@ rm -rf build*
|
||||
distclean: clean
|
||||
@ rm -f $(target-fx) $(target-cg)
|
||||
clean-fx:
|
||||
@ rm -rf build-fx/
|
||||
clean-cg:
|
||||
@ rm -rf build-cg/
|
||||
|
||||
install-fx: $(target-fx)
|
||||
distclean-fx: clean-fx
|
||||
@ rm -f $(TARGET_FX)
|
||||
distclean-cg: clean-cg
|
||||
@ rm -f $(TARGET_CG)
|
||||
|
||||
clean: clean-fx clean-cg
|
||||
|
||||
distclean: distclean-fx distclean-cg
|
||||
|
||||
install-fx: $(TARGET_FX)
|
||||
p7 send -f $<
|
||||
install-cg: $(target-cg)
|
||||
install-cg: $(TARGET_CG)
|
||||
@ while [[ ! -h /dev/Prizm1 ]]; do sleep 0.25; done
|
||||
@ while ! mount /dev/Prizm1; do sleep 0.25; done
|
||||
@ rm -f /mnt/prizm/$<
|
||||
|
|
|
@ -38,7 +38,7 @@ Installation:
|
|||
|
||||
Sends the target file to the calculator. Uses p7 (which must be installed
|
||||
externally) for fx-9860G. Currently not implemented for fx-CG 50, as it
|
||||
requires detecting and mounting the calculator (same of the Graph 35+E II).
|
||||
requires detecting and mounting the calculator (same for the Graph 35+E II).
|
||||
|
||||
Project update:
|
||||
fxsdk update
|
||||
|
@ -103,7 +103,8 @@ fxsdk_new_project_interactive() {
|
|||
echo -ne "Full project name ? (at most 8 characters)\n> "
|
||||
read NAME
|
||||
|
||||
echo -ne "Internal name ? ('@' followed by at most 7 uppercase letters)\n> "
|
||||
echo "Internal name ? ('@' followed by at most 7 uppercase letters)"
|
||||
echo -ne "(Add-in might not appear on calc if format is wrong)\n> "
|
||||
read INTERNAL
|
||||
|
||||
mkdir -p "$1"/{,src,assets-fx,assets-cg}
|
||||
|
@ -133,9 +134,18 @@ fxsdk_create_config() {
|
|||
#---
|
||||
|
||||
# Project name, should be at most 8 bytes long.
|
||||
NAME = $NAME
|
||||
# (You can also specify NAME_G1A or NAME_G3A to override individually.)
|
||||
NAME := $NAME
|
||||
|
||||
# Internal name, should be '@' followed by at most 7 uppercase letters.
|
||||
INTERNAL = $INTERNAL
|
||||
# WARNING: If this convention is not followed, the add-in might not appear in
|
||||
# the main menu of the calculator!
|
||||
INTERNAL := $INTERNAL
|
||||
|
||||
# Output file name. The default is to take <NAME>, replace spaces with dashes,
|
||||
# and add .g1a (or .g3a). You can specify a different folder if you want.
|
||||
TARGET_FX :=
|
||||
TARGET_CG :=
|
||||
|
||||
# fx-9860G icon location
|
||||
ICON_FX = assets-fx/icon-fx.png
|
||||
|
@ -143,11 +153,66 @@ ICON_FX = assets-fx/icon-fx.png
|
|||
ICON_CG_UNS = assets-cg/icon-cg-uns.png
|
||||
ICON_CG_SEL = assets-cg/icon-cg-sel.png
|
||||
|
||||
# Additional compiler flags
|
||||
CFLAGS = -std=c11 -Os
|
||||
# Additional linker flags. This is followed by -lgcc. When using fxlib, add
|
||||
# libfx.a to the projet directory and set LDFLAGS to "-L . -lfx".
|
||||
LDFLAGS =
|
||||
#---
|
||||
# Toolchain selection
|
||||
#---
|
||||
|
||||
# Toolchain for fx9860g. Please see also CFLAGS_FX below.
|
||||
TOOLCHAIN_FX := sh3eb-elf
|
||||
|
||||
# Toolchain for fxcg50. Please see also CFLAGS_CG below.
|
||||
TOOLCHAIN_CG := sh4eb-elf
|
||||
|
||||
#---
|
||||
# Compiler flags
|
||||
#---
|
||||
|
||||
# Base compiler flags for the fxSDK, you usually want to keep these.
|
||||
CFLAGS := -mb -ffreestanding -nostdlib -fstrict-volatile-bitfields
|
||||
|
||||
# Platform-specific compiler flags.
|
||||
# <> If you are using sh3eb-elf, use -m3. (You can do this on both FX and CG.)
|
||||
# <> If you are using sh4eb-elf, use -m4-nofpu. (Not ideal on FX but works.)
|
||||
# <> If you are using sh4eb-nofpu-elf, then your compiler will likely use the
|
||||
# FPU and cause problems on the calculator. Consider another configuration.
|
||||
# <> If you are using an sh-elf with several targets, specify whichever you
|
||||
# support. I recommend -m3 on FX and -m4-nofpu on CG.
|
||||
# Please see also TOOLCHAIN_FX and TOOLCHAIN_CG above.
|
||||
CFLAGS_FX := -D FX9860G -m3
|
||||
CFLAGS_CG := -D FXCG50 -m4-nofpu
|
||||
|
||||
# Additional compiler flags, change to your own taste!
|
||||
CFLAGS += -Wall -Wextra -Os
|
||||
|
||||
# Include paths. Add one -I option for each folder from which you want to
|
||||
# be able to include files with #include<>.
|
||||
INCLUDE := -I include
|
||||
|
||||
# Libraries. Add one -l option for each library you are using, and also
|
||||
# suitable -L options if you have library files in custom folders. To use
|
||||
# fxlib, add libfx.a to the project directory and use "-L . -lfx".
|
||||
LIBS :=
|
||||
|
||||
# Base linker flags for the fxSDK, you usually want to keep these.
|
||||
LDFLAGS_FX := -T fx9860g.ld -lgint-fx \$(LIBS) -lgint-fx -lgcc
|
||||
LDFLAGS_CG := -T fxcg50.ld -lgint-cg \$(LIBS) -lgint-cg -lgcc
|
||||
|
||||
# Additional linker flags, if you need any.
|
||||
LDFLAGS :=
|
||||
|
||||
# Additional platform-specific linker flags.
|
||||
LDFLAGS_FX += -Wl,-Map=build-fx/map
|
||||
LDFLAGS_CG += -Wl,-Map=build-cg/map
|
||||
|
||||
#---
|
||||
# File conversion parameters
|
||||
#---
|
||||
|
||||
# Here you can add fxconv options for each converted file, individually.
|
||||
# The syntax is "<type>.<file>". For example, to specify the parameters for a
|
||||
# font name "hexa.png", you might write:
|
||||
#
|
||||
# FONT.hexa.png = charset:print grid:size:3x5 grid.padding:1
|
||||
EOF
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue