Skip to content

Commit 4c63f8a

Browse files
committed
esp32/Makefile: Add declarations to build bootloader and partitions.
So now there is no longer a dependency on the hello_world example.
1 parent 46acf62 commit 4c63f8a

File tree

1 file changed

+66
-4
lines changed

1 file changed

+66
-4
lines changed

esp32/Makefile

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,16 +505,16 @@ SRC_QSTR += $(SRC_C) $(STM_SRC_C) $(EXTMOD_SRC_C) $(DRIVERS_SRC_C)
505505
# Append any auto-generated sources that are needed by sources listed in SRC_QSTR
506506
SRC_QSTR_AUTO_DEPS +=
507507

508-
all: $(BUILD)/firmware.bin
508+
all: $(BUILD)/bootloader.bin $(BUILD)/partitions.bin $(BUILD)/firmware.bin
509509

510510
.PHONY: idf-version deploy
511511

512512
idf-version:
513513
$(ECHO) "IDF version: c8685c200276abda4418f1367743f650d2aeacb2"
514514

515-
deploy: $(BUILD)/firmware.bin
516-
$(ECHO) "Writing $< to the board"
517-
$(Q)$(ESPTOOL) --chip esp32 --port $(PORT) --baud $(BAUD) write_flash -z --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) --flash_size $(FLASH_SIZE) 0x1000 $(ESPIDF)/examples/01_hello_world/build/bootloader/bootloader.bin 0x8000 $(ESPIDF)/examples/01_hello_world/build/partitions_singleapp.bin 0x10000 $<
515+
deploy: $(BUILD)/bootloader.bin $(BUILD)/partitions.bin $(BUILD)/firmware.bin
516+
$(ECHO) "Writing $^ to the board"
517+
$(Q)$(ESPTOOL) --chip esp32 --port $(PORT) --baud $(BAUD) write_flash -z --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) --flash_size $(FLASH_SIZE) 0x1000 $(BUILD)/bootloader.bin 0x8000 $(BUILD)/partitions.bin 0x10000 $(BUILD)/firmware.bin
518518

519519
$(BUILD)/esp32_out.ld: sdkconfig.h
520520
$(Q)$(CC) -I. -C -P -x c -E $(ESPIDF)/components/esp32/ld/esp32.ld -o $@
@@ -544,4 +544,66 @@ vpath %.cpp . $(TOP)
544544
$(BUILD)/%.o: %.cpp
545545
$(call compile_cxx)
546546

547+
################################################################################
548+
# Declarations to build the bootloader
549+
550+
$(BUILD)/bootloader/$(ESPIDF)/components/%.o: CFLAGS += -DBOOTLOADER_BUILD=1 -I$(ESPIDF)/components/bootloader_support/include_priv -I$(ESPIDF)/components/bootloader_support/include -I$(ESPIDF)/components/micro-ecc/micro-ecc -Wno-error=format
551+
BOOTLOADER_OBJ = $(addprefix $(BUILD)/bootloader/$(ESPIDF)/components/,\
552+
bootloader_support/src/bootloader_flash.o \
553+
bootloader_support/src/secure_boot_signatures.o \
554+
bootloader_support/src/secure_boot.o \
555+
bootloader_support/src/esp_image_format.o \
556+
log/log.o \
557+
spi_flash/spi_flash_rom_patch.o \
558+
micro-ecc/micro-ecc/uECC.o \
559+
bootloader/src/main/bootloader_start.o \
560+
bootloader/src/main/flash_encrypt.o \
561+
)
562+
563+
BOOTLOADER_LIBS =
564+
BOOTLOADER_LIBS += -Wl,--start-group
565+
BOOTLOADER_LIBS += $(BOOTLOADER_OBJ)
566+
BOOTLOADER_LIBS += -T $(ESPIDF)/components/bootloader/src/main/esp32.bootloader.ld
567+
BOOTLOADER_LIBS += -T $(ESPIDF)/components/esp32/ld/esp32.rom.ld
568+
BOOTLOADER_LIBS += -L$(dir $(LIBGCC_FILE_NAME)) -lgcc
569+
BOOTLOADER_LIBS += -Wl,--end-group
570+
571+
BOOTLOADER_LDFLAGS =
572+
BOOTLOADER_LDFLAGS += -nostdlib
573+
BOOTLOADER_LDFLAGS += -L$(ESPIDF)/lib
574+
BOOTLOADER_LDFLAGS += -L$(ESPIDF)/ld
575+
BOOTLOADER_LDFLAGS += -u call_user_start_cpu0
576+
BOOTLOADER_LDFLAGS += -Wl,--gc-sections
577+
BOOTLOADER_LDFLAGS += -static
578+
BOOTLOADER_LDFLAGS += -Wl,-EL
579+
BOOTLOADER_LDFLAGS += -Wl,-Map=$(@:.elf=.map) -Wl,--cref
580+
581+
BOOTLOADER_OBJ_DIRS = $(sort $(dir $(BOOTLOADER_OBJ)))
582+
$(BOOTLOADER_OBJ): | $(BOOTLOADER_OBJ_DIRS)
583+
$(BOOTLOADER_OBJ_DIRS):
584+
$(MKDIR) -p $@
585+
586+
$(BUILD)/bootloader/%.o: %.c
587+
$(call compile_c)
588+
589+
$(BUILD)/bootloader.bin: $(BUILD)/bootloader.elf
590+
$(ECHO) "Create $@"
591+
$(Q)$(ESPTOOL) --chip esp32 elf2image --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) --flash_size $(FLASH_SIZE) $<
592+
593+
$(BUILD)/bootloader.elf: $(BOOTLOADER_OBJ)
594+
$(ECHO) "LINK $@"
595+
$(Q)$(CC) $(BOOTLOADER_LDFLAGS) -o $@ $(BOOTLOADER_LIBS)
596+
597+
################################################################################
598+
# Declarations to build the partitions
599+
600+
PYTHON2 ?= python2
601+
PART_SRC = $(ESPIDF)/components/partition_table/partitions_singleapp.csv
602+
603+
$(BUILD)/partitions.bin: $(PART_SRC)
604+
$(ECHO) "Create $@"
605+
$(Q)$(PYTHON2) $(ESPIDF)/components/partition_table/gen_esp32part.py -q $< $@
606+
607+
################################################################################
608+
547609
include ../py/mkrules.mk

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy