mirror of
https://github.com/badgeteam/mch2022-template-app.git
synced 2024-11-15 21:21:04 +00:00
Replace shell scripts with makefile
This commit is contained in:
parent
e2f9affae5
commit
fde7246ec2
10 changed files with 41 additions and 138 deletions
41
Makefile
Normal file
41
Makefile
Normal 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
|
||||
|
10
build.sh
10
build.sh
|
@ -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
|
10
clean.sh
10
clean.sh
|
@ -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
|
18
command.sh
18
command.sh
|
@ -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
|
18
erase.sh
18
erase.sh
|
@ -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
|
18
flash.sh
18
flash.sh
|
@ -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
|
11
install.sh
11
install.sh
|
@ -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
|
|
@ -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
|
18
monitor.sh
18
monitor.sh
|
@ -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
25
qemu.sh
|
@ -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'
|
Loading…
Reference in a new issue