Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance HITL test #2209

Merged
merged 16 commits into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 77 additions & 74 deletions .github/workflows/build_iar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
# Alphabetical order
# Note: bundle multiple families into a matrix since there is only one self-hosted instance can
# run IAR build. Too many matrix can hurt due to setup/teardown overhead.
- 'stm32f0 stm32f1 stm32f7 stm32g0 stm32g4 stm32h7 stm32l4'
- 'stm32f0 stm32f1 stm32f4 stm32f7 stm32g0 stm32g4 stm32h7 stm32l4'
steps:
- name: Clean workspace
run: |
Expand All @@ -49,82 +49,85 @@ jobs:
- name: Build
run: python3 tools/build_cmake.py ${{ matrix.family }} -DTOOLCHAIN=iar -DCMAKE_BUILD_TYPE=MinSizeRel

# Upload binaries for hardware test with self-hosted
- name: Prepare stm32l412nucleo Artifacts
if: contains(matrix.family, 'stm32l4')
working-directory: ${{github.workspace}}/cmake-build/cmake-build-stm32l412nucleo
- name: Test on actual hardware (hardware in the loop)
run: |
find device/ -name "*.elf" -exec mv {} ../../ \;

- name: Upload Artifacts for stm32l412nucleo
if: contains(matrix.family, 'stm32l4') && github.repository_owner == 'hathach'
uses: actions/upload-artifact@v3
with:
name: stm32l4
path: |
*.elf
python3 test/hil/hil_test.py hil_hfp.json
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is where the script is run, CI compile with IAR using cmake build in previous step. We could pick up the elf. This will conveniently test IAR for us as well. (normally I only test with gcc)


# # Upload binaries for hardware test with self-hosted
# - name: Prepare stm32l412nucleo Artifacts
# if: contains(matrix.family, 'stm32l4')
# working-directory: ${{github.workspace}}/cmake-build/cmake-build-stm32l412nucleo
# run: |
# find device/ -name "*.elf" -exec mv {} ../../ \;
#
# - name: Upload Artifacts for stm32l412nucleo
# if: contains(matrix.family, 'stm32l4') && github.repository_owner == 'hathach'
# uses: actions/upload-artifact@v3
# with:
# name: stm32l4
# path: |
# *.elf

# ---------------------------------------
# Hardware in the loop (HIL)
# Current self-hosted instance is running on an EPYC 7232 server hosted by HiFiPhile user
# - STM32L412 Nucleo with on-board jlink as ttyACM0
# ---------------------------------------
hw-stm32l412nucleo-test:
needs: cmake
runs-on: [self-hosted, Linux, X64, hifiphile]

steps:
- name: Clean workspace
run: |
echo "Cleaning up previous run"
rm -rf "${{ github.workspace }}"
mkdir -p "${{ github.workspace }}"

- name: Download stm32l4 Artifacts
uses: actions/download-artifact@v3
with:
name: stm32l4

- name: Create flash.sh
run: |
echo > flash.sh 'echo halt > flash.jlink'
echo >> flash.sh 'echo r >> flash.jlink'
echo >> flash.sh 'echo loadfile $1 >> flash.jlink'
echo >> flash.sh 'echo r >> flash.jlink'
echo >> flash.sh 'echo go >> flash.jlink'
echo >> flash.sh 'echo exit >> flash.jlink'
echo >> flash.sh 'cmdout=$(JLinkExe -USB 774470029 -device stm32l412kb -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink)'
echo >> flash.sh 'if (( $? )) ; then echo $cmdout ; fi'
chmod +x flash.sh

- name: Test cdc_dual_ports
run: |
./flash.sh cdc_dual_ports.elf
while (! ([ -e /dev/ttyACM1 ] && [ -e /dev/ttyACM2 ])) && [ $SECONDS -le 10 ]; do :; done
test -e /dev/ttyACM1 && echo "ttyACM1 exists"
test -e /dev/ttyACM2 && echo "ttyACM2 exists"

# Debian does not auto mount usb drive. skip this test for now
- name: Test cdc_msc
if: false
run: |
./flash.sh cdc_msc.elf
readme='/media/pi/TinyUSB MSC/README.TXT'
while (! ([ -e /dev/ttyACM1 ] && [ -f "$readme" ])) && [ $SECONDS -le 10 ]; do :; done
test -e /dev/ttyACM1 && echo "ttyACM1 exists"
test -f "$readme" && echo "$readme exists"
cat "$readme"

- name: Test dfu
run: |
./flash.sh dfu.elf
while (! (dfu-util -l | grep "Found DFU")) && [ $SECONDS -le 10 ]; do :; done
dfu-util -d cafe -a 0 -U dfu0
dfu-util -d cafe -a 1 -U dfu1
grep "TinyUSB DFU! - Partition 0" dfu0
grep "TinyUSB DFU! - Partition 1" dfu1

- name: Test dfu_runtime
run: |
./flash.sh dfu_runtime.elf
while (! (dfu-util -l | grep "Found Runtime")) && [ $SECONDS -le 10 ]; do :; done
# hw-stm32l412nucleo-test:
# needs: cmake
# runs-on: [self-hosted, Linux, X64, hifiphile]
#
# steps:
# - name: Clean workspace
# run: |
# echo "Cleaning up previous run"
# rm -rf "${{ github.workspace }}"
# mkdir -p "${{ github.workspace }}"
#
# - name: Download stm32l4 Artifacts
# uses: actions/download-artifact@v3
# with:
# name: stm32l4
#
# - name: Create flash.sh
# run: |
# echo > flash.sh 'echo halt > flash.jlink'
# echo >> flash.sh 'echo r >> flash.jlink'
# echo >> flash.sh 'echo loadfile $1 >> flash.jlink'
# echo >> flash.sh 'echo r >> flash.jlink'
# echo >> flash.sh 'echo go >> flash.jlink'
# echo >> flash.sh 'echo exit >> flash.jlink'
# echo >> flash.sh 'cmdout=$(JLinkExe -USB 774470029 -device stm32l412kb -if swd -JTAGConf -1,-1 -speed auto -NoGui 1 -ExitOnError 1 -CommandFile flash.jlink)'
# echo >> flash.sh 'if (( $? )) ; then echo $cmdout ; fi'
# chmod +x flash.sh
#
# - name: Test cdc_dual_ports
# run: |
# ./flash.sh cdc_dual_ports.elf
# while (! ([ -e /dev/ttyACM1 ] && [ -e /dev/ttyACM2 ])) && [ $SECONDS -le 10 ]; do :; done
# test -e /dev/ttyACM1 && echo "ttyACM1 exists"
# test -e /dev/ttyACM2 && echo "ttyACM2 exists"
#
# # Debian does not auto mount usb drive. skip this test for now
# - name: Test cdc_msc
# if: false
# run: |
# ./flash.sh cdc_msc.elf
# readme='/media/pi/TinyUSB MSC/README.TXT'
# while (! ([ -e /dev/ttyACM1 ] && [ -f "$readme" ])) && [ $SECONDS -le 10 ]; do :; done
# test -e /dev/ttyACM1 && echo "ttyACM1 exists"
# test -f "$readme" && echo "$readme exists"
# cat "$readme"
#
# - name: Test dfu
# run: |
# ./flash.sh dfu.elf
# while (! (dfu-util -l | grep "Found DFU")) && [ $SECONDS -le 10 ]; do :; done
# dfu-util -d cafe -a 0 -U dfu0
# dfu-util -d cafe -a 1 -U dfu1
# grep "TinyUSB DFU! - Partition 0" dfu0
# grep "TinyUSB DFU! - Partition 1" dfu1
#
# - name: Test dfu_runtime
# run: |
# ./flash.sh dfu_runtime.elf
# while (! (dfu-util -l | grep "Found Runtime")) && [ $SECONDS -le 10 ]; do :; done
3 changes: 2 additions & 1 deletion .idea/cmake.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ Notable contributors
- Add new DCD port for Microchip SAMx7x
- Add IAR compiler support
- Improve UAC2, CDC, DFU class driver
- Improve stm32_fsdev, chipidea_ci_hs, lpc_ip3511 DCD
- Host IAR Build CI & hardware in the loop (HITL) test


`Full contributors list <https://github.com/hathach/tinyusb/contributors>`__
Expand Down
1 change: 1 addition & 0 deletions examples/device/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ family_add_subdirectory(cdc_uac2)
family_add_subdirectory(dfu)
family_add_subdirectory(dfu_runtime)
family_add_subdirectory(dynamic_configuration)
family_add_subdirectory(hid_boot_interface)
family_add_subdirectory(hid_composite)
family_add_subdirectory(hid_composite_freertos)
family_add_subdirectory(hid_generic_inout)
Expand Down
59 changes: 59 additions & 0 deletions hw/bsp/lpc54/boards/lpcxpresso54608/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* 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_LPCXPRESSO54608_H_
#define BOARD_LPCXPRESSO54608_H_

#ifdef __cplusplus
extern "C" {
#endif

// LED
#define LED_PORT 2
#define LED_PIN 2
#define LED_STATE_ON 0

// WAKE button
#define BUTTON_PORT 1
#define BUTTON_PIN 1
#define BUTTON_STATE_ACTIVE 0

// UART
#define UART_DEV USART0
#define UART_RX_PINMUX 0, 29, IOCON_PIO_DIG_FUNC1_EN
#define UART_TX_PINMUX 0, 30, IOCON_PIO_DIG_FUNC1_EN

// USB0 VBUS
#define USB0_VBUS_PINMUX 0, 22, IOCON_PIO_DIG_FUNC7_EN

// XTAL
//#define XTAL0_CLK_HZ (16 * 1000 * 1000U)

#ifdef __cplusplus
}
#endif

#endif
18 changes: 18 additions & 0 deletions hw/bsp/lpc54/boards/lpcxpresso54608/board.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MCU_VARIANT = LPC54608
MCU_CORE = LPC54608

PORT ?= 1

CFLAGS += -DCPU_LPC54608J512ET180
CFLAGS += -Wno-error=double-promotion

LD_FILE = $(MCU_DIR)/gcc/LPC54608J512_flash.ld

LIBS += $(TOP)/$(MCU_DIR)/gcc/libpower_hardabi.a

JLINK_DEVICE = LPC54608J512
PYOCD_TARGET = LPC54608

#flash: flash-pyocd

flash: flash-jlink
22 changes: 22 additions & 0 deletions hw/bsp/lpc54/boards/lpcxpresso54628/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set(MCU_VARIANT LPC54628)
set(MCU_CORE LPC54628)

set(JLINK_DEVICE LPC54628J512)
set(PYOCD_TARGET LPC54628)
set(NXPLINK_DEVICE LPC54628:LPCXpresso54628)

set(LD_FILE_GNU ${SDK_DIR}/devices/${MCU_VARIANT}/gcc/LPC54628J512_flash.ld)

# Device port default to PORT1 Highspeed
if (NOT DEFINED PORT)
set(PORT 1)
endif()

function(update_board TARGET)
target_compile_definitions(${TARGET} PUBLIC
CPU_LPC54628J512ET180
)
target_link_libraries(${TARGET} PUBLIC
${SDK_DIR}/devices/${MCU_VARIANT}/gcc/libpower_hardabi.a
)
endfunction()
2 changes: 1 addition & 1 deletion hw/bsp/lpc54/boards/lpcxpresso54628/board.mk
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MCU_VARIANT = LPC54628
MCU_CORE = LPC54628

PORT ?= 0
PORT ?= 1

CFLAGS += -DCPU_LPC54628J512ET180
CFLAGS += -Wno-error=double-promotion
Expand Down
6 changes: 2 additions & 4 deletions hw/bsp/lpc54/family.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,11 @@
//--------------------------------------------------------------------+
// Forward USB interrupt events to TinyUSB IRQ Handler
//--------------------------------------------------------------------+
void USB0_IRQHandler(void)
{
void USB0_IRQHandler(void) {
tud_int_handler(0);
}

void USB1_IRQHandler(void)
{
void USB1_IRQHandler(void) {
tud_int_handler(1);
}

Expand Down
Loading