Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for custom tools #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions Makefile.defines
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ ifeq ($(CC),)
CC = clang
endif

SYSROOT = $(shell $(GCCPATH)arm-none-eabi-gcc -print-sysroot)
ifeq ($(SYSROOT),)
CFLAGS += -I/usr/include
else
CFLAGS += --sysroot="$(SYSROOT)"
TOOL_PREFIX ?= arm-none-eabi-
USE_SYSROOT ?= 1

ifneq ($(USE_SYSROOT),)
SYSROOT = $(shell $(GCCPATH)$(TOOL_PREFIX)gcc -print-sysroot)
ifeq ($(SYSROOT),)
CFLAGS += -I/usr/include
else
CFLAGS += --sysroot="$(SYSROOT)"
endif
endif

CFLAGS += -gdwarf-2 -gstrict-dwarf
Expand Down Expand Up @@ -116,7 +121,14 @@ ifeq ($(CLANGPATH),)
$(info CLANGPATH is not set: clang will be used from PATH)
endif
ifeq ($(GCCPATH),)
$(info GCCPATH is not set: arm-none-eabi-* will be used from PATH)
$(info GCCPATH is not set: $(TOOL_PREFIX)* will be used from PATH)
endif

ifeq ($(OBJCOPY),)
OBJCOPY = $(GCCPATH)$(TOOL_PREFIX)objcopy
endif
ifeq ($(OBJDUMP),)
OBJDUMP = $(GCCPATH)$(TOOL_PREFIX)objdump
endif

# define the default makefile target (high in include to avoid glyph.h or what not specific target to be the default one when no target passed on the make command line)
Expand Down
4 changes: 2 additions & 2 deletions Makefile.rules_generic
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ LDFLAGS += -T$(SCRIPT_LD)
bin/app.elf: $(OBJECT_FILES) $(SCRIPT_LD)
@echo "[LINK] $@"
$(L)$(call link_cmdline,$(OBJECT_FILES) $(LDLIBS),$@)
$(L)$(GCCPATH)arm-none-eabi-objcopy -O ihex -S bin/app.elf bin/app.hex
$(L)$(OBJCOPY) -O ihex -S bin/app.elf bin/app.hex
$(L)cp bin/app.elf obj
$(L)$(GCCPATH)arm-none-eabi-objdump -S -d bin/app.elf > debug/app.asm
$(L)$(OBJDUMP) -S -d bin/app.elf > debug/app.asm

bin/app.apdu bin/app.sha256: bin/app.elf
$(L)python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS) --offline bin/app.apdu | grep "Application" | cut -f5 -d' ' > bin/app.sha256
Expand Down