Skip to content

Commit

Permalink
esp32: Adds support for SW breakpoints in flash
Browse files Browse the repository at this point in the history
  • Loading branch information
gerekon committed Jul 18, 2018
1 parent 771107c commit fa6cf62
Show file tree
Hide file tree
Showing 22 changed files with 1,973 additions and 928 deletions.
8 changes: 6 additions & 2 deletions contrib/loaders/flash/esp32/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,21 @@ CFLAGS = -std=c99 -Wall -Werror -Os \

INCLUDES += -I. -I$(IDF_PATH)/components/esp32/include -I$(IDF_PATH)/components/soc/esp32/include -I$(IDF_PATH)/components/soc/include \
-I$(IDF_PATH)/components/app_trace/include -I$(IDF_PATH)/components/xtensa-debug-module/include -I$(IDF_PATH)/components/driver/include \
-I$(IDF_PATH)/components/freertos/include -I$(IDF_PATH)/components/log/include -I$(IDF_PATH)/components/heap/include
-I$(IDF_PATH)/components/freertos/include -I$(IDF_PATH)/components/log/include -I$(IDF_PATH)/components/heap/include \
-I$(IDF_PATH)/components/bootloader_support/include/\

DEFINES = -Dasm=__asm__

CFLAGS += $(INCLUDES) $(DEFINES)

LDFLAGS += -L$(IDF_PATH)/components/esp32/ld -Tstub.ld -T$(IDF_PATH)/components/esp32/ld/esp32.rom.ld \
LDFLAGS += -ustub_idle_loop -L$(IDF_PATH)/components/esp32/ld -Tstub.ld -T$(IDF_PATH)/components/esp32/ld/esp32.rom.ld \
-T$(IDF_PATH)/components/esp32/ld/esp32.rom.spiram_incompatible_fns.ld -T$(IDF_PATH)/components/esp32/ld/esp32.peripherals.ld \
-Wl,--start-group -lgcc -lc -Wl,--end-group

$(STUB_ELF): $(SRCS) stub.ld $(BUILD_DIR)
@echo " CC $^ -> $@"
$(Q) $(CROSS)gcc $(CFLAGS) -DSTUB_IMAGE=1 -Wl,-Map=$(@:.elf=.map) -o $@ $(LDFLAGS) $(filter %.c, $^)
$(Q) $(CROSS)size $@

$(STUB_OBJ): $(SRCS) sdkconfig.h Makefile
@echo " CC $^ -> $@"
Expand All @@ -98,6 +100,8 @@ $(STUB_IMAGE_HDR): $(STUB_ELF)
$(Q) $(CROSS)readelf -S $^ | fgrep .bss | awk '{print $$7"UL"}' >> $(STUB_IMAGE_HDR)
$(Q) @echo -n "\n#define ESP32_STUB_ENTRY_ADDR 0x0" >> $(STUB_IMAGE_HDR)
$(Q) $(CROSS)readelf -s $^ | fgrep stub_main | awk '{print $$2"UL"}' >> $(STUB_IMAGE_HDR)
$(Q) @echo -n "\n#define ESP32_STUB_IDLE_CORE_ENTRY 0x0" >> $(STUB_IMAGE_HDR)
$(Q) $(CROSS)readelf -s $^ | fgrep stub_idle_loop | awk '{print $$2"UL"}' >> $(STUB_IMAGE_HDR)

clean:
$(Q) rm -rf $(BUILD_DIR) $(STUB_CODE_SECT) $(STUB_DATA_SECT) $(STUB_WRAPPER) $(STUB_IMAGE_HDR)
2 changes: 2 additions & 0 deletions contrib/loaders/flash/esp32/sdkconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@
// TODO: use current clk, get it from PLL settings
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240

#define CONFIG_PARTITION_TABLE_OFFSET 0x8000

#endif //_STUB_SDKCONFIG_H_
2 changes: 1 addition & 1 deletion contrib/loaders/flash/esp32/stub.ld
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ MEMORY {
/* place stub at the beginning of the OpenOCD working area,
remaining space will be used for other chunks */
iram : org = 0x40090000, len = 0x3100
dram : org = 0x3FFC0000, len = 0xB00
dram : org = 0x3FFC0000, len = 0x3000
}

PHDRS
Expand Down
Loading

0 comments on commit fa6cf62

Please sign in to comment.