From fde7246ec2321f4acb1ed423d5d519ac9aa739d6 Mon Sep 17 00:00:00 2001 From: Renze Nicolai Date: Wed, 11 May 2022 22:25:50 +0200 Subject: [PATCH] Replace shell scripts with makefile --- Makefile | 41 +++++++++++++++++++++++++++++++++++++++++ build.sh | 10 ---------- clean.sh | 10 ---------- command.sh | 18 ------------------ erase.sh | 18 ------------------ flash.sh | 18 ------------------ install.sh | 11 ----------- menuconfig.sh | 10 ---------- monitor.sh | 18 ------------------ qemu.sh | 25 ------------------------- 10 files changed, 41 insertions(+), 138 deletions(-) create mode 100644 Makefile delete mode 100755 build.sh delete mode 100755 clean.sh delete mode 100755 command.sh delete mode 100755 erase.sh delete mode 100755 flash.sh delete mode 100755 install.sh delete mode 100755 menuconfig.sh delete mode 100755 monitor.sh delete mode 100755 qemu.sh diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2040beb --- /dev/null +++ b/Makefile @@ -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 + diff --git a/build.sh b/build.sh deleted file mode 100755 index 9d6d247..0000000 --- a/build.sh +++ /dev/null @@ -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 diff --git a/clean.sh b/clean.sh deleted file mode 100755 index 168ef4b..0000000 --- a/clean.sh +++ /dev/null @@ -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 diff --git a/command.sh b/command.sh deleted file mode 100755 index d8e433d..0000000 --- a/command.sh +++ /dev/null @@ -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 diff --git a/erase.sh b/erase.sh deleted file mode 100755 index 59dd567..0000000 --- a/erase.sh +++ /dev/null @@ -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 diff --git a/flash.sh b/flash.sh deleted file mode 100755 index 56bb2fb..0000000 --- a/flash.sh +++ /dev/null @@ -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 diff --git a/install.sh b/install.sh deleted file mode 100755 index c24fb98..0000000 --- a/install.sh +++ /dev/null @@ -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 diff --git a/menuconfig.sh b/menuconfig.sh deleted file mode 100755 index ab28488..0000000 --- a/menuconfig.sh +++ /dev/null @@ -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 diff --git a/monitor.sh b/monitor.sh deleted file mode 100755 index 8c809b3..0000000 --- a/monitor.sh +++ /dev/null @@ -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 diff --git a/qemu.sh b/qemu.sh deleted file mode 100755 index 8f92b67..0000000 --- a/qemu.sh +++ /dev/null @@ -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'