mirror of
https://github.com/andreili/klipper.git
synced 2025-08-24 03:44:06 +02:00
This option seems to be confusing ld's region usage checks (builds that could fit in small chips are being reported as not fitting). The option was disabled back in commit 4e8674d5 because it showed worse results. However, recent versions of gcc seem to produce the same results even if this option is enabled, so change the build to avoid disabling that option on newer versions of gcc (those that have the -ffat-lto-objects option - which is needed to ensure compile_time_requests sections can be extracted with objcopy). The PRU build is dependent on -fuse-linker-plugin, so enable that option explicitly in its build. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
44 lines
1.5 KiB
Makefile
44 lines
1.5 KiB
Makefile
# Additional PRU build rules
|
|
|
|
# Setup the toolchain
|
|
CROSS_PREFIX=pru-
|
|
|
|
dirs-y += src/pru src/generic
|
|
dirs-y += lib/pru_rpmsg
|
|
|
|
CFLAGS += -Os -minrt -mmcu=am335x.pru1
|
|
CFLAGS += -Ilib/pru_rpmsg/include -Ilib/pru_rpmsg/include/am335x
|
|
CFLAGS += -fno-use-linker-plugin
|
|
|
|
CFLAGS_klipper.elf := $(filter-out -mmcu=%, $(CFLAGS))
|
|
CFLAGS_klipper.elf += -Wl,-r -nostdlib -Wl,-T,src/pru/pru.lds
|
|
CFLAGS_pru0.elf := $(filter-out -mmcu=%, $(CFLAGS)) -mmcu=am335x.pru0
|
|
CFLAGS_pru1.elf := $(CFLAGS)
|
|
|
|
# Add source files
|
|
src-y += pru/main.c pru/gpio.c generic/timer_irq.c
|
|
src-$(CONFIG_HAVE_GPIO_ADC) += pru/adc.c
|
|
|
|
pru0-y := pru/pru0.c generic/crc16_ccitt.c command.c
|
|
pru0-y += ../lib/pru_rpmsg/pru_rpmsg.c ../lib/pru_rpmsg/pru_virtqueue.c
|
|
|
|
# Build the PRU binaries
|
|
target-y += $(OUT)pru0.elf $(OUT)pru1.elf
|
|
|
|
$(OUT)pru0.elf: $(patsubst %.c, $(OUT)src/%.o,$(pru0-y))
|
|
@echo " Linking $@"
|
|
$(Q)$(CC) $(CFLAGS_klipper.elf) $^ -o $(OUT)pru0.o
|
|
# dumping info about INTC
|
|
$(Q)$(OBJCOPY) --dump-section '.pru_irq_map'=$(OUT)pru0.pru_irq_map.bin $(OUT)src/pru/pru0.o $(OUT)pru0.o.discard
|
|
$(Q)$(CC) $(CFLAGS_pru0.elf) $(OUT)pru0.o -o $@
|
|
# in previous step linker did loose info about INTC during optimization, restoring it here (P.S. pru.lds is not helping)
|
|
$(Q)$(OBJCOPY) --add-section '.pru_irq_map'=$(OUT)pru0.pru_irq_map.bin $@
|
|
|
|
$(OUT)pru1.elf: $(OUT)klipper.elf
|
|
@echo " Linking $@"
|
|
$(Q)$(CC) $(CFLAGS_pru1.elf) $< -o $@
|
|
|
|
flash: $(OUT)pru0.elf $(OUT)pru1.elf
|
|
@echo " Flashing"
|
|
$(Q)sudo ./scripts/flash-pru.sh
|