summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2020-04-03 12:08:06 +0700
committerhathach <[email protected]>2020-04-03 12:08:06 +0700
commit7c33a7127f009c54fa43b94243def846284865af (patch)
tree63b378e113639d448b749eb04cd0980d789c9119
parent2824e5c97aedfe46a621d786fb6577f632a0097c (diff)
make as wrapper to idf.py for consistency
update ci build script to only build esp32-s2 target with freertos examples
-rw-r--r--.github/workflows/build.yml18
-rw-r--r--.github/workflows/esp32s2.yml38
-rw-r--r--examples/rules.mk30
-rw-r--r--tools/build_all.py22
4 files changed, 55 insertions, 53 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 551c7cb92..7edb1fcba 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -36,15 +36,23 @@ jobs:
- name: Install Toolchains
run: |
+ # ARM & RISC-V GCC from xpack
npm install --global xpm
xpm install --global @xpack-dev-tools/arm-none-eabi-gcc@latest
xpm install --global @xpack-dev-tools/riscv-none-embed-gcc@latest
- wget http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/8_3_0_0/exports/msp430-gcc-8.3.0.16_linux64.tar.bz2 -O /tmp/msp430-gcc.tar.bz2
- tar -C $HOME -xaf /tmp/msp430-gcc.tar.bz2
echo "::add-path::`echo $HOME/opt/xPacks/@xpack-dev-tools/arm-none-eabi-gcc/*/.content/bin`"
echo "::add-path::`echo $HOME/opt/xPacks/@xpack-dev-tools/riscv-none-embed-gcc/*/.content/bin`"
+
+ # TI MSP430 GCC
+ wget http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/8_3_0_0/exports/msp430-gcc-8.3.0.16_linux64.tar.bz2 -O /tmp/msp430-gcc.tar.bz2
+ tar -C $HOME -xaf /tmp/msp430-gcc.tar.bz2
echo "::add-path::`echo $HOME/msp430-gcc-*_linux64/bin`"
-
+
+ # ESP IDF
+ git clone https://github.com/espressif/esp-idf.git $HOME/esp-idf
+ cd $HOME/esp-idf
+ ./install.sh
+
- name: Checkout TinyUSB
uses: actions/checkout@v2
@@ -54,5 +62,7 @@ jobs:
git submodule update --init --recursive
- name: Build
- run: python3 tools/build_all.py ${{ matrix.example }}
+ run: |
+ . $HOME/esp-idf/export.sh
+ python3 tools/build_all.py ${{ matrix.example }}
diff --git a/.github/workflows/esp32s2.yml b/.github/workflows/esp32s2.yml
deleted file mode 100644
index a3f30c8f8..000000000
--- a/.github/workflows/esp32s2.yml
+++ /dev/null
@@ -1,38 +0,0 @@
-name: Build ESP32-S2
-
-on: [pull_request, push, repository_dispatch]
-
-jobs:
- build:
- runs-on: ubuntu-latest
- strategy:
- fail-fast: false
- matrix:
- example: ['cdc_msc_freertos']
-
- steps:
- - name: Setup Python
- uses: actions/setup-python@v1
-
- - name: Install ESP-IDF
- run: |
- git clone https://github.com/espressif/esp-idf.git $HOME/esp-idf
- cd $HOME/esp-idf
- ./install.sh
- #echo "::add-path::`echo $HOME/msp430-gcc-*_linux64/bin`"
-
- - name: Checkout TinyUSB
- uses: actions/checkout@v2
-
-# - name: Checkout Submodules
-# run: |
-# git submodule sync --recursive
-# git submodule update --init --recursive
-
- - name: Build
- run: |
- . $HOME/esp-idf/export.sh
- cd examples/device/cdc_msc_freertos
- idf.py build
- #python3 tools/build_all.py ${{ matrix.example }}
-
diff --git a/examples/rules.mk b/examples/rules.mk
index 55c70af4b..92204cf72 100644
--- a/examples/rules.mk
+++ b/examples/rules.mk
@@ -1,6 +1,25 @@
-#
-# Common make definition for all examples
-#
+# ---------------------------------------
+# Common make rules for all examples
+# ---------------------------------------
+
+ifeq ($(CROSS_COMPILE),xtensa-esp32-elf-)
+# Espressif IDF use CMake build system, this add wrapper target to call idf.py
+
+.PHONY: all clean flash
+.DEFAULT_GOAL := all
+
+all:
+ idf.py -B$(BUILD) -DBOARD=$(BOARD) build
+
+clean:
+ idf.py clean
+
+flash:
+ @:$(call check_defined, SERIAL, example: SERIAL=/dev/ttyUSB0)
+ idf.py -p $(SERIAL) flash
+
+else
+# GNU Make build system
# libc
LIBS += -lgcc -lm -lnosys
@@ -28,8 +47,9 @@ SRC_C += \
# TinyUSB stack include
INC += $(TOP)/src
-#
CFLAGS += $(addprefix -I,$(INC))
+
+# TODO Skip nanolib for MSP430
ifeq ($(BOARD), msp_exp430f5529lp)
LDFLAGS += $(CFLAGS) -fshort-enums -Wl,-T,$(TOP)/$(LD_FILE) -Wl,[email protected] -Wl,-cref -Wl,-gc-sections
else
@@ -135,3 +155,5 @@ flash-jlink: $(BUILD)/$(BOARD)-firmware.hex
# flash STM32 MCU using stlink with STM32 Cube Programmer CLI
flash-stlink: $(BUILD)/$(BOARD)-firmware.elf
STM32_Programmer_CLI --connect port=swd --write $< --go
+
+endif # Make target
diff --git a/tools/build_all.py b/tools/build_all.py
index c95f88b79..a5e29a4ae 100644
--- a/tools/build_all.py
+++ b/tools/build_all.py
@@ -27,8 +27,7 @@ if len(sys.argv) > 2:
all_boards.append(sys.argv[2])
else:
for entry in os.scandir("hw/bsp"):
- # Skip board without board.mk e.g esp32s2
- if entry.is_dir() and os.path.exists(entry.path + "/board.mk"):
+ if entry.is_dir():
all_boards.append(entry.name)
all_boards.sort()
@@ -40,7 +39,8 @@ def build_example(example, board):
stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
def build_size(example, board):
- elf_file = 'examples/device/{}/_build/build-{}/{}-firmware.elf'.format(example, board, board)
+ #elf_file = 'examples/device/{}/_build/build-{}/{}-firmware.elf'.format(example, board, board)
+ elf_file = 'examples/device/{}/_build/build-{}/*.elf'.format(example, board)
size_output = subprocess.run('size {}'.format(elf_file), shell=True, stdout=subprocess.PIPE).stdout.decode("utf-8")
size_list = size_output.split('\n')[1].split('\t')
flash_size = int(size_list[0])
@@ -50,10 +50,18 @@ def build_size(example, board):
def skip_example(example, board):
ex_dir = 'examples/device/' + example
board_mk = 'hw/bsp/{}/board.mk'.format(board)
- for skip_file in glob.iglob(ex_dir + '/.skip.MCU_*'):
- mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2]
- with open(board_mk) as mk:
- if mcu_cflag in mk.read():
+
+ with open(board_mk) as mk:
+ mk_contents = mk.read()
+
+ # Skip ESP32-S2 board if example is not FreeRTOS one
+ if 'freertos' not in example and 'CROSS_COMPILE = xtensa-esp32-elf-' in mk_contents:
+ return 1
+
+ # Skip if CFG_TUSB_MCU in board.mk to match skip file
+ for skip_file in glob.iglob(ex_dir + '/.skip.MCU_*'):
+ mcu_cflag = '-DCFG_TUSB_MCU=OPT_' + os.path.basename(skip_file).split('.')[2]
+ if mcu_cflag in mk_contents:
return 1
return 0