diff --git a/ports/fx9860g3/.gitignore b/ports/fx9860g3/.gitignore new file mode 100644 index 000000000..acd544225 --- /dev/null +++ b/ports/fx9860g3/.gitignore @@ -0,0 +1 @@ +/PythonExtra.g1a diff --git a/ports/fx9860g3/Makefile b/ports/fx9860g3/Makefile new file mode 100644 index 000000000..0ffbe84c2 --- /dev/null +++ b/ports/fx9860g3/Makefile @@ -0,0 +1,14 @@ +include ../../py/mkenv.mk + +SH_CFLAGS := -DFX9860G +SH_LDFLAGS := -T fx9860g.ld -lm -lgint-fx -lc -lgint-fx -lgcc + +all: PythonExtra.g1a + +PythonExtra.g1a: $(BUILD)/firmware.bin icon.png + fxgxa --g1a -n PythonExtra -i icon.png $< -o $@ + +send: all + fxlink -sw PythonExtra.g1a + +include $(TOP)/ports/sh/Makefile diff --git a/ports/fx9860g3/icon.png b/ports/fx9860g3/icon.png new file mode 100644 index 000000000..83d9bf6da Binary files /dev/null and b/ports/fx9860g3/icon.png differ diff --git a/ports/fx9860g3/mpconfigport.h b/ports/fx9860g3/mpconfigport.h new file mode 120000 index 000000000..ebddc1d9a --- /dev/null +++ b/ports/fx9860g3/mpconfigport.h @@ -0,0 +1 @@ +../sh/mpconfigport.h \ No newline at end of file diff --git a/ports/sh/.gitignore b/ports/fxcg50/.gitignore similarity index 100% rename from ports/sh/.gitignore rename to ports/fxcg50/.gitignore diff --git a/ports/fxcg50/Makefile b/ports/fxcg50/Makefile new file mode 100644 index 000000000..3ede7876c --- /dev/null +++ b/ports/fxcg50/Makefile @@ -0,0 +1,14 @@ +include ../../py/mkenv.mk + +SH_CFLAGS := -DFXCG50 +SH_LDFLAGS := -T fxcg50.ld -lm -lgint-cg -lc -lgint-cg -lgcc + +all: PythonExtra.g3a + +PythonExtra.g3a: $(BUILD)/firmware.bin icon-uns.png icon-sel.png + fxgxa --g3a -n PythonExtra --icon-uns=icon-uns.png --icon-sel=icon-sel.png $< -o $@ + +send: all + fxlink -sw PythonExtra.g3a + +include $(TOP)/ports/sh/Makefile diff --git a/ports/sh/icon-sel.png b/ports/fxcg50/icon-sel.png similarity index 100% rename from ports/sh/icon-sel.png rename to ports/fxcg50/icon-sel.png diff --git a/ports/sh/icon-uns.png b/ports/fxcg50/icon-uns.png similarity index 100% rename from ports/sh/icon-uns.png rename to ports/fxcg50/icon-uns.png diff --git a/ports/fxcg50/mpconfigport.h b/ports/fxcg50/mpconfigport.h new file mode 120000 index 000000000..ebddc1d9a --- /dev/null +++ b/ports/fxcg50/mpconfigport.h @@ -0,0 +1 @@ +../sh/mpconfigport.h \ No newline at end of file diff --git a/ports/sh/Makefile b/ports/sh/Makefile index 9d8f2095c..90e4db887 100644 --- a/ports/sh/Makefile +++ b/ports/sh/Makefile @@ -1,21 +1,20 @@ -include ../../py/mkenv.mk - -# Use the sh-elf toolchain CROSS_COMPILE := sh-elf- include $(TOP)/py/py.mk include $(TOP)/extmod/extmod.mk -CFLAGS += -m4-nofpu -mb -fstrict-volatile-bitfields -I. -I$(BUILD) -I$(TOP) -DFXCG50 -O2 -Wall -Wextra -Wno-unused-parameter -LIBS += -nostdlib -Wl,--no-warn-rwx-segments -T fxcg50.ld -lm -lgint-cg -lc -lgint-cg -lgcc -Wl,-Map=build/map +CFLAGS += -m4-nofpu -mb -fstrict-volatile-bitfields \ + -I. -I$(TOP)/ports/sh -I$(BUILD) -I$(TOP) \ + $(SH_CFLAGS) -Os -Wall -Wextra -Wno-unused-parameter +LIBS += -nostdlib -Wl,--no-warn-rwx-segments $(SH_LDFLAGS) -Wl,-Map=build/map # Source files SRC_C = \ - main.c \ - console.c \ - keymap.c \ - modgint.c \ - mphalport.c \ + ports/sh/main.c \ + ports/sh/console.c \ + ports/sh/keymap.c \ + ports/sh/modgint.c \ + ports/sh/mphalport.c \ shared/readline/readline.c \ shared/runtime/gchelper_generic.c \ shared/runtime/pyexec.c \ @@ -23,15 +22,10 @@ SRC_C = \ SRC_QSTR += \ shared/readline/readline.c \ - modgint.c \ + ports/sh/modgint.c \ OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o)) -all: $(BUILD)/firmware.elf PythonExtra.g3a - -PythonExtra.g3a: $(BUILD)/firmware.bin icon-uns.png icon-sel.png - fxgxa --g3a -n PythonExtra --icon-uns=icon-uns.png --icon-sel=icon-sel.png $< -o $@ - $(BUILD)/firmware.bin: $(BUILD)/firmware.elf $(Q)$(CC:gcc=objcopy) -O binary -R .bss -R .gint_bss $< $@ @@ -40,7 +34,4 @@ $(BUILD)/firmware.elf: $(OBJ) $(Q)$(CC) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ -send: all - fxlink -sw PythonExtra.g3a - include $(TOP)/py/mkrules.mk diff --git a/ports/sh/console.h b/ports/sh/console.h index 2846a7577..4fafab715 100644 --- a/ports/sh/console.h +++ b/ports/sh/console.h @@ -8,7 +8,11 @@ #define PE_CONSOLE_LINE_MAX_LENGTH 1024 /* Line spacing in the console */ -#define PE_CONSOLE_LINE_SPACING 13 +#ifdef FX9860G +# define PE_CONSOLE_LINE_SPACING 8 +#else +# define PE_CONSOLE_LINE_SPACING 13 +#endif //=== Dynamic console lines ===// diff --git a/ports/sh/main.c b/ports/sh/main.c index 3e221096d..84ec07986 100644 --- a/ports/sh/main.c +++ b/ports/sh/main.c @@ -15,11 +15,6 @@ #include #include "console.h" -// Allocate memory for the MicroPython GC heap. -static char heap[32768]; - -int parse_compile_execute(const void *source, mp_parse_input_kind_t input_kind, mp_uint_t exec_flags); - //=== Console-based standard streams ===// ssize_t stdouterr_write(void *data, void const *buf, size_t size) @@ -43,19 +38,28 @@ static console_t *cons = NULL; void pe_draw(void) { dclear(C_WHITE); +#ifdef FX9860G + int rows = 8; + console_render(1, 1, cons, DWIDTH-2, rows); +#else dprint(3, 3, C_BLACK, "PythonExtra, very much WIP :)"); dline(2, 16, DWIDTH-3, 16, C_BLACK); int rows = 12; console_render(3, 20, cons, DWIDTH-6, rows); int y = 20 + PE_CONSOLE_LINE_SPACING * rows; dline(2, y, DWIDTH-3, y, C_BLACK); +#endif dupdate(); } void pe_exithandler(void) { pe_draw(); +#ifdef FX9860G + drect(DWIDTH-4, 0, DWIDTH-1, 3, C_BLACK); +#else drect(DWIDTH-8, 0, DWIDTH-1, 7, C_RED); +#endif dupdate(); getkey(); } @@ -72,8 +76,17 @@ int main(int argc, char **argv) atexit(pe_exithandler); /* Initialize MicroPython */ + #define HEAP_SIZE 32768 + void *heap = malloc(32768); + if(!heap) { + dclear(C_WHITE); + dtext(1, 1, C_BLACK, "No heap!"); + getkey(); + return 1; + } + mp_stack_ctrl_init(); - gc_init(heap, heap + sizeof(heap)); + gc_init(heap, heap + HEAP_SIZE); // TODO: gc_add(start, end) for each area we want to allocate to // fx-9860G III: // * (nothing? x_x)