Replace shell scripts with makefile

This commit is contained in:
Renze Nicolai 2022-05-11 22:25:50 +02:00
parent e2f9affae5
commit fde7246ec2
10 changed files with 41 additions and 138 deletions

41
Makefile Normal file
View file

@ -0,0 +1,41 @@
PORT ?= /dev/ttyACM0
BUILDDIR ?= build
IDF_PATH ?= $(shell pwd)/esp-idf
IDF_EXPORT_QUIET ?= 0
SHELL := /usr/bin/env bash
.PHONY: prepare clean build flash erase monitor menuconfig image qemu install
prepare:
git submodule update --init --recursive
cd esp-idf; bash install.sh
clean:
rm -rf $(BUILDDIR)
build:
source $(IDF_PATH)/export.sh && idf.py build
flash: build
source $(IDF_PATH)/export.sh && idf.py flash -p $(PORT)
erase:
source $(IDF_PATH)/export.sh && idf.py erase-flash -p $(PORT)
monitor:
source $(IDF_PATH)/export.sh && idf.py monitor -p $(PORT)
menuconfig:
source $(IDF_PATH)/export.sh && idf.py menuconfig
image:
cd $(BUILDDIR); dd if=/dev/zero bs=1M count=16 of=flash.bin
cd $(BUILDDIR); dd if=bootloader/bootloader.bin bs=1 seek=4096 of=flash.bin conv=notrunc
cd $(BUILDDIR); dd if=partition_table/partition-table.bin bs=1 seek=36864 of=flash.bin conv=notrunc
cd $(BUILDDIR); dd if=main.bin bs=1 seek=65536 of=flash.bin conv=notrunc
qemu: image
cd $(BUILDDIR); qemu-system-xtensa -nographic -machine esp32 -drive 'file=flash.bin,if=mtd,format=raw'
install: flash

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
export IDF_PATH="$PWD/esp-idf"
export IDF_EXPORT_QUIET=0
source "$IDF_PATH"/export.sh
idf.py build

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
export IDF_PATH="$PWD/esp-idf"
export IDF_EXPORT_QUIET=0
source "$IDF_PATH"/export.sh
idf.py clean

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
export IDF_PATH="$PWD/esp-idf"
export IDF_EXPORT_QUIET=0
source "$IDF_PATH"/export.sh
if [ "$#" -eq 2 ]; then
idf.py $2 -p $1
else
if [ "$#" -ne 1 ]; then
echo "Illegal number of parameters"
else
idf.py $1
fi
fi

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
export IDF_PATH="$PWD/esp-idf"
export IDF_EXPORT_QUIET=0
source "$IDF_PATH"/export.sh
if [ "$#" -eq 1 ]; then
idf.py erase-flash -p $1
else
if [ "$#" -ne 0 ]; then
echo "Illegal number of parameters"
else
idf.py erase-flash
fi
fi

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
export IDF_PATH="$PWD/esp-idf"
export IDF_EXPORT_QUIET=0
source "$IDF_PATH"/export.sh
if [ "$#" -eq 1 ]; then
idf.py flash -p $1
else
if [ "$#" -ne 0 ]; then
echo "Illegal number of parameters"
else
idf.py flash
fi
fi

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
# Fetch the SDK and all other submodules
git submodule update --init --recursive || exit 1
# Install the toolchain and other SDK tools
cd esp-idf
bash install.sh

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
export IDF_PATH="$PWD/esp-idf"
export IDF_EXPORT_QUIET=0
source "$IDF_PATH"/export.sh
idf.py menuconfig

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
export IDF_PATH="$PWD/esp-idf"
export IDF_EXPORT_QUIET=0
source "$IDF_PATH"/export.sh
if [ "$#" -eq 1 ]; then
idf.py monitor -p $1
else
if [ "$#" -ne 0 ]; then
echo "Illegal number of parameters"
else
idf.py monitor
fi
fi

25
qemu.sh
View file

@ -1,25 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
export IDF_PATH="$PWD/esp-idf"
export IDF_EXPORT_QUIET=0
source "$IDF_PATH"/export.sh
cd build
# Create an empty file, 16MB in size
dd if=/dev/zero bs=1M count=16 of=flash.bin
# Copy the bootloader into the file
dd if=bootloader/bootloader.bin bs=1 seek=$((0x1000)) of=flash.bin conv=notrunc
# Copy the partition table into the file
dd if=partition_table/partition-table.bin bs=1 seek=$((0x9000)) of=flash.bin conv=notrunc
# Copy the firmware into the file
dd if=main.bin bs=1 seek=$((0x10000)) of=flash.bin conv=notrunc
# Run QEMU
qemu-system-xtensa -nographic -machine esp32 -drive 'file=flash.bin,if=mtd,format=raw'