<commit_before>ifeq ($(CPU),esp8266)
  ifneq (,$(filter esp_log_colored,$(USEMODULE)))
    BOOTLOADER_COLOR = _colors
  endif
  ifneq (,$(filter esp_log_startup,$(USEMODULE)))
    BOOTLOADER_INFO = _info
  endif
  # Full path to the bootloader binary. In the ESP32 case this is set by the
  # esp_bootloader module.
  BOOTLOADER_BIN ?= $(RIOTCPU)/$(CPU)/bin/bootloader$(BOOTLOADER_COLOR)$(BOOTLOADER_INFO).bin
endif

ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool.py

# flasher configuration
ifneq (,$(filter esp_qemu,$(USEMODULE)))
  FLASHER =
  FFLAGS =
  FLASHDEPS += esp-qemu
else
  PROGRAMMER_SPEED ?= 460800
  FLASHER = $(ESPTOOL)
  FFLAGS += --chip $(FLASH_CHIP) --port $(PROG_DEV) --baud $(PROGRAMMER_SPEED)
  FFLAGS += --before default_reset write_flash -z
  FFLAGS += --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ)
  FFLAGS += --flash_size detect
  FFLAGS += $(BOOTLOADER_POS) $(BOOTLOADER_BIN)
  FFLAGS += 0x8000 $(BINDIR)/partitions.bin
  FFLAGS += 0x10000 $(FLASHFILE)
endif

.PHONY: esp-qemu

esp-qemu:
ifeq (esp32,$(CPU))
	$(Q)echo \
		"--flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) " \
		"--flash_size $(FLASH_SIZE)MB" \
		"$(BOOTLOADER_POS) $(BOOTLOADER_BIN)" \
		"0x8000 $(BINDIR)/partitions.bin" \
		"0x10000 $(FLASHFILE)" > $(BINDIR)/qemu_flash_args
	$(Q)$(ESPTOOL) \
		--chip $(CPU_FAM) merge_bin \
		--fill-flash-size 4MB \
		-o $(BINDIR)/qemu_flash_image.bin @$(BINDIR)/qemu_flash_args
	$(Q)cp $(RIOTCPU)/$(CPU)/bin/rom_0x3ff90000_0x00010000.bin $(BINDIR)/rom1.bin
	$(Q)cp $(RIOTCPU)/$(CPU)/bin/rom_0x40000000_0x000c2000.bin $(BINDIR)/rom.bin
else
	$(Q)dd if=/dev/zero bs=1M count=$(FLASH_SIZE) | \
	  tr "\\000" "\\377" > tmp.bin && cat tmp.bin | \
		head -c $$(($(BOOTLOADER_POS))) | \
		cat - $(BOOTLOADER_BIN) tmp.bin | \
		head -c $$((0x8000)) | \
		cat - $(BINDIR)/partitions.bin tmp.bin | \
		head -c $$((0x10000)) | \
		cat - $(FLASHFILE) tmp.bin | \
		head -c $(FLASH_SIZE)MB > $(BINDIR)/$(CPU)flash.bin && rm tmp.bin
endif

# reset tool configuration
RESET ?= $(RIOTTOOLS)/esptools/espreset.py
RESET_FLAGS ?= --port $(PROG_DEV)
<commit_msg>makefile/tools/esptool: use dio instead of qout or qio flash mode<commit_after>ifeq ($(CPU),esp8266)
  ifneq (,$(filter esp_log_colored,$(USEMODULE)))
    BOOTLOADER_COLOR = _colors
  endif
  ifneq (,$(filter esp_log_startup,$(USEMODULE)))
    BOOTLOADER_INFO = _info
  endif
  # Full path to the bootloader binary. In the ESP32 case this is set by the
  # esp_bootloader module.
  BOOTLOADER_BIN ?= $(RIOTCPU)/$(CPU)/bin/bootloader$(BOOTLOADER_COLOR)$(BOOTLOADER_INFO).bin
else
  # ESP-IDF uses dio as flash mode for esptool.py when qout or qio mode are
  # configured to always boot in dual SPI mode
  ifneq (,$(filter qout qio,$(FLASH_MODE)))
    FLASH_MODE = dio
  endif
endif

ESPTOOL ?= $(RIOTTOOLS)/esptools/esptool.py

# flasher configuration
ifneq (,$(filter esp_qemu,$(USEMODULE)))
  FLASHER =
  FFLAGS =
  FLASHDEPS += esp-qemu
else
  PROGRAMMER_SPEED ?= 460800
  FLASHER = $(ESPTOOL)
  FFLAGS += --chip $(FLASH_CHIP) --port $(PROG_DEV) --baud $(PROGRAMMER_SPEED)
  FFLAGS += --before default_reset write_flash -z
  FFLAGS += --flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ)
  FFLAGS += --flash_size detect
  FFLAGS += $(BOOTLOADER_POS) $(BOOTLOADER_BIN)
  FFLAGS += 0x8000 $(BINDIR)/partitions.bin
  FFLAGS += 0x10000 $(FLASHFILE)
endif

.PHONY: esp-qemu

esp-qemu:
ifeq (esp32,$(CPU))
	$(Q)echo \
		"--flash_mode $(FLASH_MODE) --flash_freq $(FLASH_FREQ) " \
		"--flash_size $(FLASH_SIZE)MB" \
		"$(BOOTLOADER_POS) $(BOOTLOADER_BIN)" \
		"0x8000 $(BINDIR)/partitions.bin" \
		"0x10000 $(FLASHFILE)" > $(BINDIR)/qemu_flash_args
	$(Q)$(ESPTOOL) \
		--chip $(CPU_FAM) merge_bin \
		--fill-flash-size 4MB \
		-o $(BINDIR)/qemu_flash_image.bin @$(BINDIR)/qemu_flash_args
	$(Q)cp $(RIOTCPU)/$(CPU)/bin/rom_0x3ff90000_0x00010000.bin $(BINDIR)/rom1.bin
	$(Q)cp $(RIOTCPU)/$(CPU)/bin/rom_0x40000000_0x000c2000.bin $(BINDIR)/rom.bin
else
	$(Q)dd if=/dev/zero bs=1M count=$(FLASH_SIZE) | \
	  tr "\\000" "\\377" > tmp.bin && cat tmp.bin | \
		head -c $$(($(BOOTLOADER_POS))) | \
		cat - $(BOOTLOADER_BIN) tmp.bin | \
		head -c $$((0x8000)) | \
		cat - $(BINDIR)/partitions.bin tmp.bin | \
		head -c $$((0x10000)) | \
		cat - $(FLASHFILE) tmp.bin | \
		head -c $(FLASH_SIZE)MB > $(BINDIR)/$(CPU)flash.bin && rm tmp.bin
endif

# reset tool configuration
RESET ?= $(RIOTTOOLS)/esptools/espreset.py
RESET_FLAGS ?= --port $(PROG_DEV)

{'fraction_non_alphanumeric': 0.17704324201947022, 'fraction_numerical': 0.04029884537016074, 'mean_word_length': 4.060710194730813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5977274', 'n_tokens_mistral': 1992, 'n_tokens_neox': 1860, 'n_words': 355}