From b5b03e6c7f598a0ba8540d19acf798e35d24faf9 Mon Sep 17 00:00:00 2001 From: hathach Date: Wed, 29 Sep 2021 15:33:44 +0700 Subject: add mm32 to ci build, also re-enable esp32s3 --- .github/workflows/build.yml | 1 + .github/workflows/build_esp.yml | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8ef19b0a0..1ef0bf5ea 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -44,6 +44,7 @@ jobs: - 'lpc18' - 'lpc54' - 'lpc55' + - 'mm32' - 'nrf' - 'rp2040' - 'samd11' diff --git a/.github/workflows/build_esp.yml b/.github/workflows/build_esp.yml index 25f4e68f8..93d582361 100644 --- a/.github/workflows/build_esp.yml +++ b/.github/workflows/build_esp.yml @@ -18,8 +18,7 @@ jobs: # ESP32-S2 - 'espressif_saola_1' # ESP32-S3 - # latest IDF does not define USB0 in linker - #- 'espressif_addax_1' + - 'espressif_addax_1' steps: - name: Setup Python -- cgit v1.3.1 From b26cc2cc4694d883cc060c03c57d201753b4c72a Mon Sep 17 00:00:00 2001 From: Ha Thach Date: Wed, 13 Oct 2021 00:57:45 +0700 Subject: Add linkermap for size analysis (#1136) * add NO_LTO option to make * add linkermap submodule and linkermap target * add linkermap to ci build * linkermap doesn't work with esp32sx map file yet * add note for linkermap target --- .github/workflows/build.yml | 14 ++++++++++++++ .github/workflows/build_esp.yml | 14 ++++++++++++++ .github/workflows/build_msp430.yml | 14 ++++++++++++++ .github/workflows/build_renesas.yml | 14 ++++++++++++++ .github/workflows/build_riscv.yml | 14 ++++++++++++++ docs/reference/getting_started.rst | 15 ++++++++++++--- examples/rules.mk | 31 +++++++++++++++++++++---------- hw/bsp/esp32s2/family.mk | 5 +---- 8 files changed, 104 insertions(+), 17 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1ef0bf5ea..b16cf3f87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,6 +66,12 @@ jobs: - name: Checkout common submodules in lib run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel + - name: Checkout hathach/linkermap + uses: actions/checkout@v2 + with: + repository: hathach/linkermap + path: linkermap + - name: Checkout pico-sdk if: matrix.family == 'rp2040' run: | @@ -95,6 +101,14 @@ jobs: - name: Build run: python3 tools/build_family.py ${{ matrix.family }} + - name: Linker Map + run: | + pip install linkermap/ + for ex in `ls -d examples/device/*/`; do \ + find ${ex} -name *.map -print -quit | \ + xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ + done + # --------------------------------------- # Build all no-family (opharned) boards # --------------------------------------- diff --git a/.github/workflows/build_esp.yml b/.github/workflows/build_esp.yml index 93d582361..15071b178 100644 --- a/.github/workflows/build_esp.yml +++ b/.github/workflows/build_esp.yml @@ -30,5 +30,19 @@ jobs: - name: Checkout TinyUSB uses: actions/checkout@v2 + - name: Checkout hathach/linkermap + uses: actions/checkout@v2 + with: + repository: hathach/linkermap + path: linkermap + - name: Build run: docker run --rm -v $PWD:/project -w /project espressif/idf:latest python3 tools/build_esp32sx.py ${{ matrix.board }} + + - name: Linker Map + run: | + pip install linkermap/ + for ex in `ls -d examples/device/*/`; do \ + find ${ex} -maxdepth 3 -name *.map -print -quit | \ + xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ + done diff --git a/.github/workflows/build_msp430.yml b/.github/workflows/build_msp430.yml index ff2ce72c9..98dc36cd9 100644 --- a/.github/workflows/build_msp430.yml +++ b/.github/workflows/build_msp430.yml @@ -26,6 +26,12 @@ jobs: - name: Checkout common submodules in lib run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip + - name: Checkout hathach/linkermap + uses: actions/checkout@v2 + with: + repository: hathach/linkermap + path: linkermap + - name: Set Toolchain URL run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://software-dl.ti.com/msp430/msp430_public_sw/mcu/msp430/MSPGCC/9_2_0_0/export/msp430-gcc-9.2.0.50_linux64.tar.bz2 @@ -48,3 +54,11 @@ jobs: - name: Build run: python3 tools/build_family.py ${{ matrix.family }} + + - name: Linker Map + run: | + pip install linkermap/ + for ex in `ls -d examples/device/*/`; do \ + find ${ex} -name *.map -print -quit | \ + xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ + done diff --git a/.github/workflows/build_renesas.yml b/.github/workflows/build_renesas.yml index ee9ba8289..6eb042d72 100644 --- a/.github/workflows/build_renesas.yml +++ b/.github/workflows/build_renesas.yml @@ -26,6 +26,12 @@ jobs: - name: Checkout common submodules in lib run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip + - name: Checkout hathach/linkermap + uses: actions/checkout@v2 + with: + repository: hathach/linkermap + path: linkermap + - name: Set Toolchain URL run: echo >> $GITHUB_ENV TOOLCHAIN_URL=http://gcc-renesas.com/downloads/get.php?f=rx/8.3.0.202004-gnurx/gcc-8.3.0.202004-GNURX-ELF.run @@ -49,3 +55,11 @@ jobs: - name: Build run: python3 tools/build_family.py ${{ matrix.family }} + + - name: Linker Map + run: | + pip install linkermap/ + for ex in `ls -d examples/device/*/`; do \ + find ${ex} -name *.map -print -quit | \ + xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ + done diff --git a/.github/workflows/build_riscv.yml b/.github/workflows/build_riscv.yml index 78510751c..0c7b2d154 100644 --- a/.github/workflows/build_riscv.yml +++ b/.github/workflows/build_riscv.yml @@ -27,6 +27,12 @@ jobs: - name: Checkout common submodules in lib run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip + - name: Checkout hathach/linkermap + uses: actions/checkout@v2 + with: + repository: hathach/linkermap + path: linkermap + - name: Set Toolchain URL run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v10.1.0-1.1/xpack-riscv-none-embed-gcc-10.1.0-1.1-linux-x64.tar.gz @@ -49,3 +55,11 @@ jobs: - name: Build run: python3 tools/build_family.py ${{ matrix.family }} + + - name: Linker Map + run: | + pip install linkermap/ + for ex in `ls -d examples/device/*/`; do \ + find ${ex} -name *.map -print -quit | \ + xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ + done diff --git a/docs/reference/getting_started.rst b/docs/reference/getting_started.rst index be2e1b5ea..044792993 100644 --- a/docs/reference/getting_started.rst +++ b/docs/reference/getting_started.rst @@ -89,6 +89,15 @@ A MCU can support multiple operational speed. By default, the example build syst $ make BOARD=stm32f746disco SPEED=full all +Size Analysis +~~~~~~~~~~~~~ + +First install `linkermap tool `_ then ``linkermap`` target can be used to analyze code size. You may want to compile with ``NO_LTO=1`` since -flto merges code across .o files and make it difficult to analyze. + +.. code-block:: + + $ make BOARD=feather_nrf52840_express NO_LTO=1 all linkermap + Debug ^^^^^ @@ -153,7 +162,7 @@ Some board use uf2 bootloader for drag & drop in to mass storage device, uf2 can $ make BOARD=feather_nrf52840_express all uf2 IAR Support ------------ +^^^^^^^^^^^ IAR Project Connection files are provided to import TinyUSB stack into your project. @@ -171,12 +180,12 @@ IAR Project Connection files are provided to import TinyUSB stack into your proj for example `C:\\tinyusb` Import stack only -^^^^^^^^^^^^^^^^^ +~~~~~~~~~~~~~~~~~ 1. Open `Project -> Add project Connection ...`, click `OK`, choose `tinyusb\\tools\\iar_template.ipcf`. Run examples -^^^^^^^^^^^^ +~~~~~~~~~~~~ 1. (Python3 is needed) Run `iar_gen.py` to generate .ipcf files of examples: diff --git a/examples/rules.mk b/examples/rules.mk index 7e494b3d8..92fa4e14d 100644 --- a/examples/rules.mk +++ b/examples/rules.mk @@ -5,12 +5,11 @@ # Set all as default goal .DEFAULT_GOAL := all -# ESP32-SX and RP2040 has its own CMake build system -ifneq ($(FAMILY),esp32s2) -ifneq ($(FAMILY),esp32s3) -ifneq ($(FAMILY),rp2040) +# ESP32-Sx and RP2040 has its own CMake build system +ifeq (,$(findstring $(FAMILY),esp32s2 esp32s3 rp2040)) + # --------------------------------------- -# GNU Make build system +# Compiler Flags # --------------------------------------- # libc @@ -44,6 +43,12 @@ INC += $(TOP)/src CFLAGS += $(addprefix -I,$(INC)) +# LTO makes it difficult to analyze map file for optimizing size purpose +# We will run this option in ci +ifeq ($(NO_LTO),1) +CFLAGS := $(filter-out -flto,$(CFLAGS)) +endif + LDFLAGS += $(CFLAGS) -Wl,-T,$(TOP)/$(LD_FILE) -Wl,-Map=$@.map -Wl,-cref -Wl,-gc-sections ifneq ($(SKIP_NANOLIB), 1) LDFLAGS += -specs=nosys.specs -specs=nano.specs @@ -67,6 +72,10 @@ $(info LDFLAGS $(LDFLAGS)) $(info ) $(info ASFLAGS $(ASFLAGS)) $(info ) endif +# --------------------------------------- +# Rules +# --------------------------------------- + all: $(BUILD)/$(PROJECT).bin $(BUILD)/$(PROJECT).hex size uf2: $(BUILD)/$(PROJECT).uf2 @@ -126,11 +135,17 @@ $(BUILD)/obj/%_asm.o: %.S @echo AS $(notdir $@) @$(CC) -x assembler-with-cpp $(ASFLAGS) -c -o $@ $< +endif # GNU Make + size: $(BUILD)/$(PROJECT).elf -@echo '' @$(SIZE) $< -@echo '' +# linkermap must be install previously at https://github.com/hathach/linkermap +linkermap: $(BUILD)/$(PROJECT).elf + @linkermap -v $<.map + .PHONY: clean clean: ifeq ($(CMDEXE),1) @@ -139,10 +154,6 @@ else $(RM) -rf $(BUILD) endif -endif -endif -endif # GNU Make - # --------------------------------------- # Flash Targets # --------------------------------------- @@ -204,4 +215,4 @@ copy-artifact: $(BIN) # Print out the value of a make variable. # https://stackoverflow.com/questions/16467718/how-to-print-out-a-variable-in-makefile print-%: - @echo $* = $($*) + @echo $* = $($*) \ No newline at end of file diff --git a/hw/bsp/esp32s2/family.mk b/hw/bsp/esp32s2/family.mk index fb9b21641..4b9000a6a 100644 --- a/hw/bsp/esp32s2/family.mk +++ b/hw/bsp/esp32s2/family.mk @@ -7,14 +7,11 @@ all: build: all -clean: - idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) clean - fullclean: if test -f sdkconfig; then $(RM) -f sdkconfig ; fi if test -d $(BUILD); then $(RM) -rf $(BUILD) ; fi -flash bootloader-flash app-flash erase monitor dfu-flash dfu: +clean flash bootloader-flash app-flash erase monitor dfu-flash dfu size size-components size-files: idf.py -B$(BUILD) -DFAMILY=$(FAMILY) -DBOARD=$(BOARD) $(CMAKE_DEFSYM) $@ uf2: $(BUILD)/$(PROJECT).uf2 -- cgit v1.3.1 From 4431ced598ca8ee1f07d6acd7f1424f17755c155 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 2 Nov 2021 16:20:39 +0700 Subject: add L4 to ci, update doc --- .github/workflows/build.yml | 1 + README.rst | 2 +- docs/reference/supported.rst | 39 ++++++++++++++++++++++++++++++++++----- 3 files changed, 36 insertions(+), 6 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b16cf3f87..53a1628a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -56,6 +56,7 @@ jobs: - 'stm32f4' - 'stm32f7' - 'stm32h7' + - 'stm32l4' steps: - name: Setup Python uses: actions/setup-python@v2 diff --git a/README.rst b/README.rst index 11804ccd1..329c0da53 100644 --- a/README.rst +++ b/README.rst @@ -47,7 +47,7 @@ The stack supports the following MCUs: - **Renesas:** RX63N, RX65N - **Silabs:** EFM32GG12 - **Sony:** CXD56 -- **ST:** STM32 series: L0, L1, F0, F1, F2, F3, F4, F7, H7 both FullSpeed and HighSpeed +- **ST:** STM32 series: L0, L1, L4, F0, F1, F2, F3, F4, F7, H7 both FullSpeed and HighSpeed - **TI:** MSP430 - **ValentyUSB:** eptri diff --git a/docs/reference/supported.rst b/docs/reference/supported.rst index c8a441f18..ef924adb4 100644 --- a/docs/reference/supported.rst +++ b/docs/reference/supported.rst @@ -305,29 +305,58 @@ Sony ST STM32 -------- -- `Adafruit Feather STM32F405 `__ -- `Micro Python PyBoard v1.1 `__ -- `STLink-V3 Mini `__ -- `STM32 L035c8 Discovery `__ -- `STM32 L4R5zi Nucleo `__ +F0 +^^ - `STM32 F070rb Nucleo `__ - `STM32 F072 Evaluation `__ - `STM32 F072rb Discovery `__ + +F1 +^^ - `STM32 F103c8 Blue Pill `__ - `STM32 F103rc Mini v2.0 `__ + +F2 +^^ - `STM32 F207zg Nucleo `__ + +F3 +^^ - `STM32 F303vc Discovery `__ + +F4 +^^ +- `Adafruit Feather STM32F405 `__ +- `Micro Python PyBoard v1.1 `__ - `STM32 F401cc Black Pill `__ - `STM32 F407vg Discovery `__ - `STM32 F411ce Black Pill `__ - `STM32 F411ve Discovery `__ - `STM32 F412zg Discovery `__ - `STM32 F412zg Nucleo `__ + +F7 +^^ + +- `STLink-V3 Mini `__ - `STM32 F723e Discovery `__ - `STM32 F746zg Nucleo `__ - `STM32 F746g Discovery `__ - `STM32 F767zi Nucleo `__ - `STM32 F769i Discovery `__ + +L0 +^^ +- `STM32 L035c8 Discovery `__ + +L4 +^^ +- `STM32 L476vg Discovery `__ +- `STM32 L4P5zg Nucleo `__ +- `STM32 L4R5zi Nucleo `__ + +H7 +^^ - `STM32 H743zi Nucleo `__ - `STM32 H743i Evaluation `__ - `STM32 H745i Discovery `__ -- cgit v1.3.1 From 0e733ae14bf4c165abcd27ccb1408927b72a0047 Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 2 Nov 2021 21:46:23 +0700 Subject: add pi4 to ci build in build_aarch64 --- .github/workflows/build.yml | 160 --------------------- .github/workflows/build_aarch64.yml | 67 +++++++++ .github/workflows/build_arm.yml | 160 +++++++++++++++++++++ .gitmodules | 1 + examples/device/audio_4_channel_mic/src/main.c | 2 +- examples/device/audio_test/src/main.c | 2 +- examples/device/cdc_msc_freertos/.skip.MCU_BCM2711 | 0 .../hid_composite_freertos/.skip.MCU_BCM2711 | 0 hw/bsp/raspberrypi4/family.mk | 5 +- 9 files changed, 232 insertions(+), 165 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/build_aarch64.yml create mode 100644 .github/workflows/build_arm.yml create mode 100644 examples/device/cdc_msc_freertos/.skip.MCU_BCM2711 create mode 100644 examples/device/hid_composite_freertos/.skip.MCU_BCM2711 (limited to '.github/workflows') diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 53a1628a0..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,160 +0,0 @@ -name: Build ARM - -on: - pull_request: - push: - release: - types: - - created - -jobs: - # --------------------------------------- - # Unit testing with Ceedling - # --------------------------------------- - unit-test: - runs-on: ubuntu-latest - steps: - - name: Setup Ruby - uses: actions/setup-ruby@v1 - with: - ruby-version: '2.7' - - - name: Checkout TinyUSB - uses: actions/checkout@v2 - - - name: Unit Tests - run: | - # Install Ceedling - gem install ceedling - cd test - ceedling test:all - - # --------------------------------------- - # Build ARM family - # --------------------------------------- - build-arm: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - family: - # Alphabetical order - - 'imxrt' - - 'lpc15' - - 'lpc18' - - 'lpc54' - - 'lpc55' - - 'mm32' - - 'nrf' - - 'rp2040' - - 'samd11' - - 'samd21' - - 'samd51' - - 'saml2x' - - 'stm32f0' - - 'stm32f1' - - 'stm32f4' - - 'stm32f7' - - 'stm32h7' - - 'stm32l4' - steps: - - name: Setup Python - uses: actions/setup-python@v2 - - - name: Checkout TinyUSB - uses: actions/checkout@v2 - - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel - - - name: Checkout hathach/linkermap - uses: actions/checkout@v2 - with: - repository: hathach/linkermap - path: linkermap - - - name: Checkout pico-sdk - if: matrix.family == 'rp2040' - run: | - git clone --depth 1 -b develop https://github.com/raspberrypi/pico-sdk ~/pico-sdk - echo >> $GITHUB_ENV PICO_SDK_PATH=~/pico-sdk - - - name: Set Toolchain URL - run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-linux-x64.tar.gz - - - name: Cache Toolchain - uses: actions/cache@v2 - id: cache-toolchain - with: - path: ~/cache/ - key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }} - - - name: Install Toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' - run: | - mkdir -p ~/cache/toolchain - wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz - tar -C ~/cache/toolchain -xaf toolchain.tar.gz - - - name: Set Toolchain Path - run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - - - name: Build - run: python3 tools/build_family.py ${{ matrix.family }} - - - name: Linker Map - run: | - pip install linkermap/ - for ex in `ls -d examples/device/*/`; do \ - find ${ex} -name *.map -print -quit | \ - xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ - done - - # --------------------------------------- - # Build all no-family (opharned) boards - # --------------------------------------- - build-board: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - example: - # Alphabetical order, a group of 4 - - 'device/audio_test device/board_test device/cdc_dual_ports device/cdc_msc' - - 'device/cdc_msc_freertos device/dfu_runtime device/hid_composite device/hid_composite_freertos' - - 'device/hid_generic_inout device/hid_multiple_interface device/midi_test device/msc_dual_lun' - - 'device/net_lwip_webserver' - - 'device/uac2_headset device/usbtmc device/webusb_serial host/cdc_msc_hid' - - steps: - - name: Setup Python - uses: actions/setup-python@v2 - - - name: Checkout TinyUSB - uses: actions/checkout@v2 - - - name: Checkout common submodules in lib - run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip - - - name: Set Toolchain URL - run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-linux-x64.tar.gz - - - name: Cache Toolchain - uses: actions/cache@v2 - id: cache-toolchain - with: - path: ~/cache/ - key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }} - - - name: Install Toolchain - if: steps.cache-toolchain.outputs.cache-hit != 'true' - run: | - mkdir -p ~/cache/toolchain - wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz - tar -C ~/cache/toolchain -xaf toolchain.tar.gz - - - name: Set Toolchain Path - run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` - - - name: Build - run: python3 tools/build_board.py ${{ matrix.example }} diff --git a/.github/workflows/build_aarch64.yml b/.github/workflows/build_aarch64.yml new file mode 100644 index 000000000..0cc7a5de1 --- /dev/null +++ b/.github/workflows/build_aarch64.yml @@ -0,0 +1,67 @@ +name: Build AArch64 + +on: + pull_request: + push: + release: + types: + - created + +jobs: + # --------------------------------------- + # Build AARCH64 family + # --------------------------------------- + build-arm: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + family: + # Alphabetical order + - 'raspberrypi4' + steps: + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Checkout TinyUSB + uses: actions/checkout@v2 + + - name: Checkout common submodules in lib + run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel + + - name: Checkout hathach/linkermap + uses: actions/checkout@v2 + with: + repository: hathach/linkermap + path: linkermap + + - name: Set Toolchain URL + run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://developer.arm.com/-/media/Files/downloads/gnu-a/10.3-2021.07/binrel/gcc-arm-10.3-2021.07-x86_64-aarch64-none-elf.tar.xz + + - name: Cache Toolchain + uses: actions/cache@v2 + id: cache-toolchain + with: + path: ~/cache/ + key: ${{ runner.os }}-21-11-02-${{ env.TOOLCHAIN_URL }} + + - name: Install Toolchain + if: steps.cache-toolchain.outputs.cache-hit != 'true' + run: | + mkdir -p ~/cache/toolchain + wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz + tar -C ~/cache/toolchain -xaf toolchain.tar.gz + + - name: Set Toolchain Path + run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` + + - name: Build + run: python3 tools/build_family.py ${{ matrix.family }} + + - name: Linker Map + run: | + pip install linkermap/ + for ex in `ls -d examples/device/*/`; do \ + find ${ex} -name *.map -print -quit | \ + xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ + done diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml new file mode 100644 index 000000000..53a1628a0 --- /dev/null +++ b/.github/workflows/build_arm.yml @@ -0,0 +1,160 @@ +name: Build ARM + +on: + pull_request: + push: + release: + types: + - created + +jobs: + # --------------------------------------- + # Unit testing with Ceedling + # --------------------------------------- + unit-test: + runs-on: ubuntu-latest + steps: + - name: Setup Ruby + uses: actions/setup-ruby@v1 + with: + ruby-version: '2.7' + + - name: Checkout TinyUSB + uses: actions/checkout@v2 + + - name: Unit Tests + run: | + # Install Ceedling + gem install ceedling + cd test + ceedling test:all + + # --------------------------------------- + # Build ARM family + # --------------------------------------- + build-arm: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + family: + # Alphabetical order + - 'imxrt' + - 'lpc15' + - 'lpc18' + - 'lpc54' + - 'lpc55' + - 'mm32' + - 'nrf' + - 'rp2040' + - 'samd11' + - 'samd21' + - 'samd51' + - 'saml2x' + - 'stm32f0' + - 'stm32f1' + - 'stm32f4' + - 'stm32f7' + - 'stm32h7' + - 'stm32l4' + steps: + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Checkout TinyUSB + uses: actions/checkout@v2 + + - name: Checkout common submodules in lib + run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip lib/sct_neopixel + + - name: Checkout hathach/linkermap + uses: actions/checkout@v2 + with: + repository: hathach/linkermap + path: linkermap + + - name: Checkout pico-sdk + if: matrix.family == 'rp2040' + run: | + git clone --depth 1 -b develop https://github.com/raspberrypi/pico-sdk ~/pico-sdk + echo >> $GITHUB_ENV PICO_SDK_PATH=~/pico-sdk + + - name: Set Toolchain URL + run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-linux-x64.tar.gz + + - name: Cache Toolchain + uses: actions/cache@v2 + id: cache-toolchain + with: + path: ~/cache/ + key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }} + + - name: Install Toolchain + if: steps.cache-toolchain.outputs.cache-hit != 'true' + run: | + mkdir -p ~/cache/toolchain + wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz + tar -C ~/cache/toolchain -xaf toolchain.tar.gz + + - name: Set Toolchain Path + run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` + + - name: Build + run: python3 tools/build_family.py ${{ matrix.family }} + + - name: Linker Map + run: | + pip install linkermap/ + for ex in `ls -d examples/device/*/`; do \ + find ${ex} -name *.map -print -quit | \ + xargs -I % sh -c 'echo "::group::%"; linkermap -v %; echo "::endgroup::"'; \ + done + + # --------------------------------------- + # Build all no-family (opharned) boards + # --------------------------------------- + build-board: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + example: + # Alphabetical order, a group of 4 + - 'device/audio_test device/board_test device/cdc_dual_ports device/cdc_msc' + - 'device/cdc_msc_freertos device/dfu_runtime device/hid_composite device/hid_composite_freertos' + - 'device/hid_generic_inout device/hid_multiple_interface device/midi_test device/msc_dual_lun' + - 'device/net_lwip_webserver' + - 'device/uac2_headset device/usbtmc device/webusb_serial host/cdc_msc_hid' + + steps: + - name: Setup Python + uses: actions/setup-python@v2 + + - name: Checkout TinyUSB + uses: actions/checkout@v2 + + - name: Checkout common submodules in lib + run: git submodule update --init lib/FreeRTOS-Kernel lib/lwip + + - name: Set Toolchain URL + run: echo >> $GITHUB_ENV TOOLCHAIN_URL=https://github.com/xpack-dev-tools/arm-none-eabi-gcc-xpack/releases/download/v10.2.1-1.1/xpack-arm-none-eabi-gcc-10.2.1-1.1-linux-x64.tar.gz + + - name: Cache Toolchain + uses: actions/cache@v2 + id: cache-toolchain + with: + path: ~/cache/ + key: ${{ runner.os }}-21-03-04-${{ env.TOOLCHAIN_URL }} + + - name: Install Toolchain + if: steps.cache-toolchain.outputs.cache-hit != 'true' + run: | + mkdir -p ~/cache/toolchain + wget --progress=dot:mega $TOOLCHAIN_URL -O toolchain.tar.gz + tar -C ~/cache/toolchain -xaf toolchain.tar.gz + + - name: Set Toolchain Path + run: echo >> $GITHUB_PATH `echo ~/cache/toolchain/*/bin` + + - name: Build + run: python3 tools/build_board.py ${{ matrix.example }} diff --git a/.gitmodules b/.gitmodules index 79dec144e..a95e64ee6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -130,3 +130,4 @@ [submodule "hw/mcu/broadcom"] path = hw/mcu/broadcom url = https://github.com/adafruit/broadcom-peripherals.git + branch = main-build diff --git a/examples/device/audio_4_channel_mic/src/main.c b/examples/device/audio_4_channel_mic/src/main.c index 983b87e5b..d085dd43a 100644 --- a/examples/device/audio_4_channel_mic/src/main.c +++ b/examples/device/audio_4_channel_mic/src/main.c @@ -141,7 +141,7 @@ void tud_resume_cb(void) void audio_task(void) { // Yet to be filled - e.g. put meas data into TX FIFOs etc. - asm("nop"); + // asm("nop"); } //--------------------------------------------------------------------+ diff --git a/examples/device/audio_test/src/main.c b/examples/device/audio_test/src/main.c index 9a2fdd3a1..ed13ce993 100644 --- a/examples/device/audio_test/src/main.c +++ b/examples/device/audio_test/src/main.c @@ -142,7 +142,7 @@ void tud_resume_cb(void) void audio_task(void) { // Yet to be filled - e.g. put meas data into TX FIFOs etc. - asm("nop"); + // asm("nop"); } //--------------------------------------------------------------------+ diff --git a/examples/device/cdc_msc_freertos/.skip.MCU_BCM2711 b/examples/device/cdc_msc_freertos/.skip.MCU_BCM2711 new file mode 100644 index 000000000..e69de29bb diff --git a/examples/device/hid_composite_freertos/.skip.MCU_BCM2711 b/examples/device/hid_composite_freertos/.skip.MCU_BCM2711 new file mode 100644 index 000000000..e69de29bb diff --git a/hw/bsp/raspberrypi4/family.mk b/hw/bsp/raspberrypi4/family.mk index b1d14a6ec..2e61b9e74 100644 --- a/hw/bsp/raspberrypi4/family.mk +++ b/hw/bsp/raspberrypi4/family.mk @@ -1,9 +1,8 @@ -UF2_FAMILY_ID = 0x57755a57 +MCU_DIR = hw/mcu/broadcom +DEPS_SUBMODULES += $(MCU_DIR) include $(TOP)/$(BOARD_PATH)/board.mk -MCU_DIR = hw/mcu/broadcom - CC = clang CFLAGS += \ -- cgit v1.3.1 From 3fc3e400b0ad91a0f15fe0c45bb924a9b1d65249 Mon Sep 17 00:00:00 2001 From: hathach Date: Fri, 5 Nov 2021 13:23:31 +0700 Subject: add xmc4000 to ci build --- .github/workflows/build_arm.yml | 1 + hw/bsp/board_mcu.h | 4 ++++ 2 files changed, 5 insertions(+) (limited to '.github/workflows') diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml index 53a1628a0..8db0fe04f 100644 --- a/.github/workflows/build_arm.yml +++ b/.github/workflows/build_arm.yml @@ -57,6 +57,7 @@ jobs: - 'stm32f7' - 'stm32h7' - 'stm32l4' + - 'xmc4000' steps: - name: Setup Python uses: actions/setup-python@v2 diff --git a/hw/bsp/board_mcu.h b/hw/bsp/board_mcu.h index c840db89e..1e2577de0 100644 --- a/hw/bsp/board_mcu.h +++ b/hw/bsp/board_mcu.h @@ -136,6 +136,10 @@ #elif CFG_TUSB_MCU == OPT_MCU_MM32F327X #include "mm32_device.h" + +#elif CFG_TUSB_MCU == OPT_MCU_XMC4000 + #include "xmc_device.h" + #else #error "Missing MCU header" #endif -- cgit v1.3.1 From f65917f51a3046c828ced5fbb982348542b382a5 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 8 Nov 2021 17:24:58 +0700 Subject: rename to simply OPT_MCU_MSP432E4, add msp432e to ci --- .github/workflows/build_arm.yml | 1 + hw/bsp/board_mcu.h | 2 +- hw/bsp/msp432e4/family.mk | 2 +- src/class/audio/audio_device.c | 2 +- src/device/dcd_attr.h | 2 +- src/portable/mentor/musb/dcd_musb.c | 4 ++-- src/tusb_option.h | 4 ++-- 7 files changed, 9 insertions(+), 8 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml index 8db0fe04f..cf9246d52 100644 --- a/.github/workflows/build_arm.yml +++ b/.github/workflows/build_arm.yml @@ -45,6 +45,7 @@ jobs: - 'lpc54' - 'lpc55' - 'mm32' + - 'msp430e4' - 'nrf' - 'rp2040' - 'samd11' diff --git a/hw/bsp/board_mcu.h b/hw/bsp/board_mcu.h index 2928ea657..f8b5c061c 100644 --- a/hw/bsp/board_mcu.h +++ b/hw/bsp/board_mcu.h @@ -98,7 +98,7 @@ #elif CFG_TUSB_MCU == OPT_MCU_MSP430x5xx #include "msp430.h" -#elif CFG_TUSB_MCU == OPT_MCU_MSP432E4xx +#elif CFG_TUSB_MCU == OPT_MCU_MSP432E4 #include "msp.h" #elif CFG_TUSB_MCU == OPT_MCU_VALENTYUSB_EPTRI diff --git a/hw/bsp/msp432e4/family.mk b/hw/bsp/msp432e4/family.mk index ee7faa208..b664c4c1b 100644 --- a/hw/bsp/msp432e4/family.mk +++ b/hw/bsp/msp432e4/family.mk @@ -9,7 +9,7 @@ CFLAGS += \ -mfloat-abi=hard \ -mfpu=fpv4-sp-d16 \ -D__MSP432E401Y__ \ - -DCFG_TUSB_MCU=OPT_MCU_MSP432E4xx + -DCFG_TUSB_MCU=OPT_MCU_MSP432E4 # mcu driver cause following warnings CFLAGS += -Wno-error=cast-qual -Wno-error=format= diff --git a/src/class/audio/audio_device.c b/src/class/audio/audio_device.c index 38bfc023b..d9f2e284e 100644 --- a/src/class/audio/audio_device.c +++ b/src/class/audio/audio_device.c @@ -103,7 +103,7 @@ CFG_TUSB_MCU == OPT_MCU_LPC18XX || \ CFG_TUSB_MCU == OPT_MCU_LPC43XX || \ CFG_TUSB_MCU == OPT_MCU_MIMXRT10XX || \ - CFG_TUSB_MCU == OPT_MCU_MSP432E4xx + CFG_TUSB_MCU == OPT_MCU_MSP432E4 #if TUD_AUDIO_PREFER_RING_BUFFER #define USE_LINEAR_BUFFER 0 #else diff --git a/src/device/dcd_attr.h b/src/device/dcd_attr.h index 7254f3362..73d592e5c 100644 --- a/src/device/dcd_attr.h +++ b/src/device/dcd_attr.h @@ -146,7 +146,7 @@ #elif TU_CHECK_MCU(OPT_MCU_MSP430x5xx) #define DCD_ATTR_ENDPOINT_MAX 8 -#elif TU_CHECK_MCU(OPT_MCU_MSP432E4xx, OPT_MCU_TM4C123, OPT_MCU_TM4C129) +#elif TU_CHECK_MCU(OPT_MCU_MSP432E4, OPT_MCU_TM4C123, OPT_MCU_TM4C129) #define DCD_ATTR_ENDPOINT_MAX 8 //------------- ValentyUSB -------------// diff --git a/src/portable/mentor/musb/dcd_musb.c b/src/portable/mentor/musb/dcd_musb.c index c745b4969..4b4c2f9b2 100644 --- a/src/portable/mentor/musb/dcd_musb.c +++ b/src/portable/mentor/musb/dcd_musb.c @@ -26,7 +26,7 @@ #include "tusb_option.h" -#if TU_CHECK_MCU(OPT_MCU_MSP432E4xx, OPT_MCU_TM4C123, OPT_MCU_TM4C129) +#if TU_CHECK_MCU(OPT_MCU_MSP432E4, OPT_MCU_TM4C123, OPT_MCU_TM4C129) #if __GNUC__ > 8 && defined(__ARM_FEATURE_UNALIGNED) /* GCC warns that an address may be unaligned, even though @@ -36,7 +36,7 @@ _Pragma("GCC diagnostic ignored \"-Waddress-of-packed-member\""); #include "device/dcd.h" -#if TU_CHECK_MCU(OPT_MCU_MSP432E4xx) +#if TU_CHECK_MCU(OPT_MCU_MSP432E4) #include "musb_msp432e.h" #elif TU_CHECK_MCU(OPT_MCU_TM4C123, OPT_MCU_TM4C129) diff --git a/src/tusb_option.h b/src/tusb_option.h index 246893ddb..2edd310fa 100644 --- a/src/tusb_option.h +++ b/src/tusb_option.h @@ -84,9 +84,9 @@ // Sony #define OPT_MCU_CXD56 400 ///< SONY CXD56 -// TI MSP430 +// TI #define OPT_MCU_MSP430x5xx 500 ///< TI MSP430x5xx -#define OPT_MCU_MSP432E4xx 510 ///< TI MSP432E4xx +#define OPT_MCU_MSP432E4 510 ///< TI MSP432E4xx #define OPT_MCU_TM4C123 511 ///< TI Tiva-C 123x #define OPT_MCU_TM4C129 512 ///< TI Tiva-C 129x -- cgit v1.3.1 From 17ef1503c8adc96e1874fb4bf497b7fcf6b4808a Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 8 Nov 2021 17:37:21 +0700 Subject: move tm4c132 into bsp family, add it into ci --- .github/workflows/build_arm.yml | 1 + hw/bsp/ek-tm4c123gxl/board.mk | 40 ------ hw/bsp/ek-tm4c123gxl/tm4c123.ld | 65 --------- hw/bsp/ek-tm4c123gxl/tm4c123gxl.c | 180 ------------------------- hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h | 52 +++++++ hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk | 11 ++ hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld | 65 +++++++++ hw/bsp/tm4c123/family.c | 167 +++++++++++++++++++++++ hw/bsp/tm4c123/family.mk | 35 +++++ 9 files changed, 331 insertions(+), 285 deletions(-) delete mode 100644 hw/bsp/ek-tm4c123gxl/board.mk delete mode 100644 hw/bsp/ek-tm4c123gxl/tm4c123.ld delete mode 100644 hw/bsp/ek-tm4c123gxl/tm4c123gxl.c create mode 100644 hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h create mode 100644 hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk create mode 100644 hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld create mode 100644 hw/bsp/tm4c123/family.c create mode 100644 hw/bsp/tm4c123/family.mk (limited to '.github/workflows') diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml index cf9246d52..e4d64826e 100644 --- a/.github/workflows/build_arm.yml +++ b/.github/workflows/build_arm.yml @@ -58,6 +58,7 @@ jobs: - 'stm32f7' - 'stm32h7' - 'stm32l4' + - 'tm4c123' - 'xmc4000' steps: - name: Setup Python diff --git a/hw/bsp/ek-tm4c123gxl/board.mk b/hw/bsp/ek-tm4c123gxl/board.mk deleted file mode 100644 index 9d0d67e1c..000000000 --- a/hw/bsp/ek-tm4c123gxl/board.mk +++ /dev/null @@ -1,40 +0,0 @@ -DEPS_SUBMODULES += hw/mcu/ti - -CFLAGS += \ - -flto \ - -mthumb \ - -mabi=aapcs \ - -mcpu=cortex-m4 \ - -mfloat-abi=hard \ - -mfpu=fpv4-sp-d16 \ - -DCFG_TUSB_MCU=OPT_MCU_TM4C123 \ - -uvectors \ - -DTM4C123GH6PM - -# mcu driver cause following warnings -CFLAGS += -Wno-error=strict-prototypes -Wno-error=cast-qual - -MCU_DIR=hw/mcu/ti/tm4c123xx/ - -# All source paths should be relative to the top level. -LD_FILE = $(BOARD_PATH)/tm4c123.ld - -INC += \ - $(TOP)/$(MCU_DIR)/CMSIS/5.7.0/CMSIS/Include \ - $(TOP)/$(MCU_DIR)/Include/TM4C123 \ - $(TOP)/hw/bsp - -SRC_C += \ - src/portable/mentor/musb/dcd_musb.c \ - $(MCU_DIR)/Source/system_TM4C123.c \ - $(MCU_DIR)/Source/GCC/tm4c123_startup.c - -# For freeRTOS port source -FREERTOS_PORT = ARM_CM4F - -# For flash-jlink target -JLINK_DEVICE = TM4C123GH6PM - -# flash using openocd -OPENOCD_OPTION = -f board/ti_ek-tm4c123gxl.cfg -flash: flash-openocd diff --git a/hw/bsp/ek-tm4c123gxl/tm4c123.ld b/hw/bsp/ek-tm4c123gxl/tm4c123.ld deleted file mode 100644 index e2720a9ac..000000000 --- a/hw/bsp/ek-tm4c123gxl/tm4c123.ld +++ /dev/null @@ -1,65 +0,0 @@ -ENTRY(Reset_Handler) - -_estack = 0x20008000; /* end of RAM */ -/* Generate a link error if heap and stack don't fit into RAM */ -_Min_Heap_Size = 0; /* required amount of heap */ -_Min_Stack_Size = 0x1000; /* required amount of stack */ - - -MEMORY -{ - FLASH(rx) : ORIGIN = 0x00000000, LENGTH = 256K - SRAM(rwx) : ORIGIN = 0x20000000, LENGTH = 32K -} - -SECTIONS -{ - .text : - { - . = ALIGN(4) ; - *(.vectors) - *(.text) - *(.text.*) - *(.init) - *(.fini) - *(.rodata) - *(.rodata.*) - . = ALIGN(4) ; - __end_text = . ; - } >FLASH - - .data : AT(ADDR(.text) + SIZEOF(.text)) - { - . = ALIGN(4); - __start_data = . ; - __la_data = LOADADDR(.data); - *(.data) - *(.data.*) - . = ALIGN(4); - __end_data = . ; - - } >SRAM - - .bss : - { - . = ALIGN(4) ; - __start_bss = . ; - __bss_start__ = __start_bss; - *(.bss) - *(.bss.*) - *(.COMMON) - __end_bss = . ; - . = ALIGN(4); - }>SRAM - - /* User_heap_stack section, used to check that there is enough RAM left */ - ._user_heap_stack : - { - . = ALIGN(8); - PROVIDE ( end = . ); - PROVIDE ( _end = . ); - . = . + _Min_Heap_Size; - . = . + _Min_Stack_Size; - . = ALIGN(8); - } >SRAM -} diff --git a/hw/bsp/ek-tm4c123gxl/tm4c123gxl.c b/hw/bsp/ek-tm4c123gxl/tm4c123gxl.c deleted file mode 100644 index 663fbf127..000000000 --- a/hw/bsp/ek-tm4c123gxl/tm4c123gxl.c +++ /dev/null @@ -1,180 +0,0 @@ -#include -#include - -#define BOARD_UART UART0 -#define BOARD_UART_PORT GPIOA - -#define BOARD_BTN_PORT GPIOF -#define BOARD_BTN 4 -#define BOARD_BTN_Msk (1u<<4) -#define BUTTON_STATE_ACTIVE 0 - -#define LED_PORT GPIOF -#define LED_PIN_RED 1 -#define LED_PIN_BLUE 2 -#define LED_PIN_GREEN 3 -#define LED_STATE_ON 1 - -//--------------------------------------------------------------------+ -// Forward USB interrupt events to TinyUSB IRQ Handler -//--------------------------------------------------------------------+ -void USB0_Handler(void) -{ - tud_int_handler(0); -} - -//--------------------------------------------------------------------+ -// MACRO TYPEDEF CONSTANT ENUM -//--------------------------------------------------------------------+ - -static void board_uart_init (void) -{ - SYSCTL->RCGCUART |= (1 << 0); // Enable the clock to UART0 - SYSCTL->RCGCGPIO |= (1 << 0); // Enable the clock to GPIOA - - GPIOA->AFSEL |= (1 << 1) | (1 << 0); // Enable the alternate function on pin PA0 & PA1 - GPIOA->PCTL |= (1 << 0) | (1 << 4); // Configure the GPIOPCTL register to select UART0 in PA0 and PA1 - GPIOA->DEN |= (1 << 0) | (1 << 1); // Enable the digital functionality in PA0 and PA1 - - /** BAUDRATE = 9600 bits per second, refer manual for calculation **/ - UART0->CTL &= ~(1 << 0); // Disable UART0 by clearing UARTEN bit in the UARTCTL register - UART0->IBRD = 325; // Write the integer portion of the BRD to the UARTIRD register - UART0->FBRD = 33; // Write the fractional portion of the BRD to the UARTFBRD registerer - - UART0->LCRH = (0x3 << 5); // 8-bit, no parity, 1 stop bit - UART0->CC = 0x0; // Configure the UART clock source as system clock - - UART0->CTL = (1 << 0) | (1 << 8) | (1 << 9); // UART0 Enable, Transmit Enable, Recieve Enable -} - -static void initialize_board_led (GPIOA_Type *port, uint8_t PinMsk, uint8_t dirmsk) -{ - /* Enable PortF Clock */ - SYSCTL->RCGCGPIO |= (1 << 5); - - /* Let the clock stabilize */ - while ( !((SYSCTL->PRGPIO) & (1 << 5)) ) - ; - - /* Port Digital Enable */ - port->DEN |= PinMsk; - - /* Set direction */ - port->DIR = dirmsk; -} - -static void board_switch_init (void) -{ - GPIOF->DIR &= ~(1 << BOARD_BTN); - GPIOF->PUR |= (1 << BOARD_BTN); - GPIOF->DEN |= (1 << BOARD_BTN); -} - -static void WriteGPIOPin (GPIOA_Type *port, uint8_t PinMsk, bool state) -{ - if ( state ) - port->DATA |= PinMsk; - else - port->DATA &= ~(PinMsk); -} - -static uint32_t ReadGPIOPin (GPIOA_Type *port, uint8_t pinMsk) -{ - return (port->DATA & pinMsk); -} - -void board_init (void) -{ - SystemCoreClockUpdate(); - -#if CFG_TUSB_OS == OPT_OS_NONE - // 1ms tick timer - SysTick_Config(SystemCoreClock / 1000); -#elif CFG_TUSB_OS == OPT_OS_FREERTOS - // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) - NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); -#endif - - /* Reset USB */ - SYSCTL->SRCR2 |= (1u << 16); - - for ( volatile uint8_t i = 0; i < 20; i++ ) {} - - SYSCTL->SRCR2 &= ~(1u << 16); - - /* Open the USB clock gate */ - SYSCTL->RCGCUSB |= (1 << 0); - - /* Power-up USB PLL */ - SYSCTL->RCC2 &= ~(1u << 14); - - /* USB IO Initialization */ - SYSCTL->RCGCGPIO |= (1u << 3); - - /* Let the clock stabilize */ - while ( !(SYSCTL->PRGPIO & (1u << 3)) ) - ; - - /* USB IOs to Analog Mode */ - GPIOD->AFSEL &= ~((1u << 4) | (1u << 5)); - GPIOD->DEN &= ~((1u << 4) | (1u << 5)); - GPIOD->AMSEL |= ((1u << 4) | (1u << 5)); - - uint8_t leds = (1 << LED_PIN_RED) | (1 << LED_PIN_BLUE) | (1 << LED_PIN_GREEN); - uint8_t dirmsk = (1 << LED_PIN_RED) | (1 << LED_PIN_BLUE) | (1 << LED_PIN_GREEN); - - /* Configure GPIO for board LED */ - initialize_board_led(LED_PORT, leds, dirmsk); - - /* Configure GPIO for board switch */ - board_switch_init(); - - /* Initialize board UART */ - board_uart_init(); - -} - -void board_led_write (bool state) -{ - WriteGPIOPin(LED_PORT, (1 << LED_PIN_BLUE), state); -} - -uint32_t board_button_read (void) -{ - uint32_t gpio_value = ReadGPIOPin(BOARD_BTN_PORT, BOARD_BTN_Msk); - return BUTTON_STATE_ACTIVE ? gpio_value : !gpio_value; -} - -int board_uart_write (void const *buf, int len) -{ - uint8_t const * data = buf; - - for ( int i = 0; i < len; i++ ) - { - while ( (UART0->FR & (1 << 5)) != 0 ) {} // Poll until previous data was shofted out - UART0->DR = data[i]; // Write UART0 DATA REGISTER - } - - return len; -} - -int board_uart_read (uint8_t *buf, int len) -{ - (void) buf; - (void) len; - return 0; -} - -#if CFG_TUSB_OS == OPT_OS_NONE -volatile uint32_t system_ticks = 0; -void SysTick_Handler (void) -{ - system_ticks++; -} - -uint32_t board_millis (void) -{ - return system_ticks; -} -#endif - diff --git a/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h b/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h new file mode 100644 index 000000000..5732056ae --- /dev/null +++ b/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.h @@ -0,0 +1,52 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2021, Ha Thach (tinyusb.org) + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * This file is part of the TinyUSB stack. + */ + +#ifndef _BOARD_H_ +#define _BOARD_H_ + +#ifdef __cplusplus + extern "C" { +#endif + +#define BOARD_UART UART0 +#define BOARD_UART_PORT GPIOA + +#define BOARD_BTN_PORT GPIOF +#define BOARD_BTN 4 +#define BOARD_BTN_Msk (1u<<4) +#define BUTTON_STATE_ACTIVE 0 + +#define LED_PORT GPIOF +#define LED_PIN_RED 1 +#define LED_PIN_BLUE 2 +#define LED_PIN_GREEN 3 +#define LED_STATE_ON 1 + +#ifdef __cplusplus + } +#endif + +#endif diff --git a/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk b/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk new file mode 100644 index 000000000..d60365d1d --- /dev/null +++ b/hw/bsp/tm4c123/boards/ek-tm4c123gxl/board.mk @@ -0,0 +1,11 @@ +CFLAGS += -DTM4C123GH6PM + +LD_FILE = $(BOARD_PATH)/tm4c123.ld + +# For flash-jlink target +JLINK_DEVICE = TM4C123GH6PM + +# flash using openocd +OPENOCD_OPTION = -f board/ti_ek-tm4c123gxl.cfg + +flash: flash-openocd diff --git a/hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld b/hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld new file mode 100644 index 000000000..e2720a9ac --- /dev/null +++ b/hw/bsp/tm4c123/boards/ek-tm4c123gxl/tm4c123.ld @@ -0,0 +1,65 @@ +ENTRY(Reset_Handler) + +_estack = 0x20008000; /* end of RAM */ +/* Generate a link error if heap and stack don't fit into RAM */ +_Min_Heap_Size = 0; /* required amount of heap */ +_Min_Stack_Size = 0x1000; /* required amount of stack */ + + +MEMORY +{ + FLASH(rx) : ORIGIN = 0x00000000, LENGTH = 256K + SRAM(rwx) : ORIGIN = 0x20000000, LENGTH = 32K +} + +SECTIONS +{ + .text : + { + . = ALIGN(4) ; + *(.vectors) + *(.text) + *(.text.*) + *(.init) + *(.fini) + *(.rodata) + *(.rodata.*) + . = ALIGN(4) ; + __end_text = . ; + } >FLASH + + .data : AT(ADDR(.text) + SIZEOF(.text)) + { + . = ALIGN(4); + __start_data = . ; + __la_data = LOADADDR(.data); + *(.data) + *(.data.*) + . = ALIGN(4); + __end_data = . ; + + } >SRAM + + .bss : + { + . = ALIGN(4) ; + __start_bss = . ; + __bss_start__ = __start_bss; + *(.bss) + *(.bss.*) + *(.COMMON) + __end_bss = . ; + . = ALIGN(4); + }>SRAM + + /* User_heap_stack section, used to check that there is enough RAM left */ + ._user_heap_stack : + { + . = ALIGN(8); + PROVIDE ( end = . ); + PROVIDE ( _end = . ); + . = . + _Min_Heap_Size; + . = . + _Min_Stack_Size; + . = ALIGN(8); + } >SRAM +} diff --git a/hw/bsp/tm4c123/family.c b/hw/bsp/tm4c123/family.c new file mode 100644 index 000000000..048832dc9 --- /dev/null +++ b/hw/bsp/tm4c123/family.c @@ -0,0 +1,167 @@ +#include "TM4C123.h" +#include "bsp/board.h" +#include "board.h" + +//--------------------------------------------------------------------+ +// Forward USB interrupt events to TinyUSB IRQ Handler +//--------------------------------------------------------------------+ +void USB0_Handler(void) +{ + tud_int_handler(0); +} + +//--------------------------------------------------------------------+ +// MACRO TYPEDEF CONSTANT ENUM +//--------------------------------------------------------------------+ + +static void board_uart_init (void) +{ + SYSCTL->RCGCUART |= (1 << 0); // Enable the clock to UART0 + SYSCTL->RCGCGPIO |= (1 << 0); // Enable the clock to GPIOA + + GPIOA->AFSEL |= (1 << 1) | (1 << 0); // Enable the alternate function on pin PA0 & PA1 + GPIOA->PCTL |= (1 << 0) | (1 << 4); // Configure the GPIOPCTL register to select UART0 in PA0 and PA1 + GPIOA->DEN |= (1 << 0) | (1 << 1); // Enable the digital functionality in PA0 and PA1 + + /** BAUDRATE = 9600 bits per second, refer manual for calculation **/ + UART0->CTL &= ~(1 << 0); // Disable UART0 by clearing UARTEN bit in the UARTCTL register + UART0->IBRD = 325; // Write the integer portion of the BRD to the UARTIRD register + UART0->FBRD = 33; // Write the fractional portion of the BRD to the UARTFBRD registerer + + UART0->LCRH = (0x3 << 5); // 8-bit, no parity, 1 stop bit + UART0->CC = 0x0; // Configure the UART clock source as system clock + + UART0->CTL = (1 << 0) | (1 << 8) | (1 << 9); // UART0 Enable, Transmit Enable, Recieve Enable +} + +static void initialize_board_led (GPIOA_Type *port, uint8_t PinMsk, uint8_t dirmsk) +{ + /* Enable PortF Clock */ + SYSCTL->RCGCGPIO |= (1 << 5); + + /* Let the clock stabilize */ + while ( !((SYSCTL->PRGPIO) & (1 << 5)) ) + ; + + /* Port Digital Enable */ + port->DEN |= PinMsk; + + /* Set direction */ + port->DIR = dirmsk; +} + +static void board_switch_init (void) +{ + GPIOF->DIR &= ~(1 << BOARD_BTN); + GPIOF->PUR |= (1 << BOARD_BTN); + GPIOF->DEN |= (1 << BOARD_BTN); +} + +static void WriteGPIOPin (GPIOA_Type *port, uint8_t PinMsk, bool state) +{ + if ( state ) + port->DATA |= PinMsk; + else + port->DATA &= ~(PinMsk); +} + +static uint32_t ReadGPIOPin (GPIOA_Type *port, uint8_t pinMsk) +{ + return (port->DATA & pinMsk); +} + +void board_init (void) +{ + SystemCoreClockUpdate(); + +#if CFG_TUSB_OS == OPT_OS_NONE + // 1ms tick timer + SysTick_Config(SystemCoreClock / 1000); +#elif CFG_TUSB_OS == OPT_OS_FREERTOS + // If freeRTOS is used, IRQ priority is limit by max syscall ( smaller is higher ) + NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY ); +#endif + + /* Reset USB */ + SYSCTL->SRCR2 |= (1u << 16); + + for ( volatile uint8_t i = 0; i < 20; i++ ) {} + + SYSCTL->SRCR2 &= ~(1u << 16); + + /* Open the USB clock gate */ + SYSCTL->RCGCUSB |= (1 << 0); + + /* Power-up USB PLL */ + SYSCTL->RCC2 &= ~(1u << 14); + + /* USB IO Initialization */ + SYSCTL->RCGCGPIO |= (1u << 3); + + /* Let the clock stabilize */ + while ( !(SYSCTL->PRGPIO & (1u << 3)) ) + ; + + /* USB IOs to Analog Mode */ + GPIOD->AFSEL &= ~((1u << 4) | (1u << 5)); + GPIOD->DEN &= ~((1u << 4) | (1u << 5)); + GPIOD->AMSEL |= ((1u << 4) | (1u << 5)); + + uint8_t leds = (1 << LED_PIN_RED) | (1 << LED_PIN_BLUE) | (1 << LED_PIN_GREEN); + uint8_t dirmsk = (1 << LED_PIN_RED) | (1 << LED_PIN_BLUE) | (1 << LED_PIN_GREEN); + + /* Configure GPIO for board LED */ + initialize_board_led(LED_PORT, leds, dirmsk); + + /* Configure GPIO for board switch */ + board_switch_init(); + + /* Initialize board UART */ + board_uart_init(); + +} + +void board_led_write (bool state) +{ + WriteGPIOPin(LED_PORT, (1 << LED_PIN_BLUE), state); +} + +uint32_t board_button_read (void) +{ + uint32_t gpio_value = ReadGPIOPin(BOARD_BTN_PORT, BOARD_BTN_Msk); + return BUTTON_STATE_ACTIVE ? gpio_value : !gpio_value; +} + +int board_uart_write (void const *buf, int len) +{ + uint8_t const * data = buf; + + for ( int i = 0; i < len; i++ ) + { + while ( (UART0->FR & (1 << 5)) != 0 ) {} // Poll until previous data was shofted out + UART0->DR = data[i]; // Write UART0 DATA REGISTER + } + + return len; +} + +int board_uart_read (uint8_t *buf, int len) +{ + (void) buf; + (void) len; + return 0; +} + +#if CFG_TUSB_OS == OPT_OS_NONE +volatile uint32_t system_ticks = 0; +void SysTick_Handler (void) +{ + system_ticks++; +} + +uint32_t board_millis (void) +{ + return system_ticks; +} +#endif + diff --git a/hw/bsp/tm4c123/family.mk b/hw/bsp/tm4c123/family.mk new file mode 100644 index 000000000..9665a2d7d --- /dev/null +++ b/hw/bsp/tm4c123/family.mk @@ -0,0 +1,35 @@ +DEPS_SUBMODULES += hw/mcu/ti + +include $(TOP)/$(BOARD_PATH)/board.mk + +CFLAGS += \ + -flto \ + -mthumb \ + -mabi=aapcs \ + -mcpu=cortex-m4 \ + -mfloat-abi=hard \ + -mfpu=fpv4-sp-d16 \ + -DCFG_TUSB_MCU=OPT_MCU_TM4C123 \ + -uvectors \ + -DTM4C123GH6PM + +# mcu driver cause following warnings +CFLAGS += -Wno-error=strict-prototypes -Wno-error=cast-qual + +MCU_DIR=hw/mcu/ti/tm4c123xx/ + +# All source paths should be relative to the top level. +LD_FILE = $(BOARD_PATH)/tm4c123.ld + +INC += \ + $(TOP)/$(MCU_DIR)/CMSIS/5.7.0/CMSIS/Include \ + $(TOP)/$(MCU_DIR)/Include/TM4C123 \ + $(TOP)/$(BOARD_PATH) + +SRC_C += \ + src/portable/mentor/musb/dcd_musb.c \ + $(MCU_DIR)/Source/system_TM4C123.c \ + $(MCU_DIR)/Source/GCC/tm4c123_startup.c + +# For freeRTOS port source +FREERTOS_PORT = ARM_CM4F -- cgit v1.3.1 From 1c77f9f6694151beca9a490eadf545b30557e9a0 Mon Sep 17 00:00:00 2001 From: hathach Date: Mon, 8 Nov 2021 20:03:47 +0700 Subject: msp432e4 ci typo, skip dfu example for tm4c123 --- .github/workflows/build_arm.yml | 2 +- examples/device/dfu/.skip.MCU_TM4C123 | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 examples/device/dfu/.skip.MCU_TM4C123 (limited to '.github/workflows') diff --git a/.github/workflows/build_arm.yml b/.github/workflows/build_arm.yml index e4d64826e..dc4d9fcfb 100644 --- a/.github/workflows/build_arm.yml +++ b/.github/workflows/build_arm.yml @@ -45,7 +45,7 @@ jobs: - 'lpc54' - 'lpc55' - 'mm32' - - 'msp430e4' + - 'msp432e4' - 'nrf' - 'rp2040' - 'samd11' diff --git a/examples/device/dfu/.skip.MCU_TM4C123 b/examples/device/dfu/.skip.MCU_TM4C123 new file mode 100644 index 000000000..6260e6e25 --- /dev/null +++ b/examples/device/dfu/.skip.MCU_TM4C123 @@ -0,0 +1,4 @@ +LINK _build/ek-tm4c123gxl/dfu.elf +/home/runner/cache/toolchain/xpack-arm-none-eabi-gcc-10.2.1-1.1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld: section .ARM.exidx.text._close LMA [0000000000002980,0000000000002987] overlaps section .data LMA [0000000000002980,0000000000002a03] +collect2: error: ld returned 1 exit status +make: *** [../../rules.mk:94: _build/ek-tm4c123gxl/dfu.elf] Error 1 \ No newline at end of file -- cgit v1.3.1 From 1d1e75236c4bed4346e6ed840869de2c3acf7220 Mon Sep 17 00:00:00 2001 From: hathach Date: Thu, 2 Dec 2021 12:02:25 +0700 Subject: temporarily skip s3 build on ci --- .github/workflows/build_esp.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to '.github/workflows') diff --git a/.github/workflows/build_esp.yml b/.github/workflows/build_esp.yml index 15071b178..57dbf33e3 100644 --- a/.github/workflows/build_esp.yml +++ b/.github/workflows/build_esp.yml @@ -18,7 +18,8 @@ jobs: # ESP32-S2 - 'espressif_saola_1' # ESP32-S3 - - 'espressif_addax_1' + #- 'espressif_addax_1' + # S3 compile error with "dangerous relocation: call8: call target out of range: memcpy" steps: - name: Setup Python -- cgit v1.3.1