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

Hardware extended HIL testing #123

Merged
merged 10 commits into from
Mar 1, 2024
Merged
5 changes: 5 additions & 0 deletions .github/workflows/ports_psoc6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ jobs:
devs=($(python tools/psoc6/get-devs.py port -b ${{ matrix.board }} -y tools/psoc6/${{ runner.name }}-devs.yml))
cd tests
./psoc6/run_psoc6_tests.sh -c --psoc6 --dev0 ${devs[0]}
- name: Run psoc6 hardware extended tests
run: |
devs=($(python tools/psoc6/get-devs.py port -b ${{ matrix.board }} -y tools/psoc6/${{ runner.name }}-devs.yml --hw-ext 0.1.0))
cd tests
./psoc6/run_psoc6_tests.sh -c --psoc6-hwext --dev0 ${devs[0]}
# TODO: Enable when HIL is upgraded
# - name: Run all implemented tests
# if: github.event_name == 'pull_request'
Expand Down
27 changes: 0 additions & 27 deletions tests/psoc6/dut/i2c_soft.py

This file was deleted.

5 changes: 0 additions & 5 deletions tests/psoc6/dut/i2c_soft.py.exp

This file was deleted.

33 changes: 33 additions & 0 deletions tests/psoc6/hw_ext/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Extended Hardware Setup Tests

The tests located in this folder implement the validation of hardware peripherals features (GPIO, I2C, SPI, etc.) which require additional or extended hardware configuration to the evaluation boards.

The extended setup is meant to provide the necessary circuitry, electronic system or interface for the tests to be performed. For example, interconnecting some pins (with simple cables) and/or attach some external circuit, device, or discrete electronic components.

## Boards Setup Diagram

Find below the hardware diagrams for each of the supported boards:

### CY8CPROTO-062-4343W

![CY8CPROTO-062-4343W HIL setup](img/cy8cproto-062-4343w-hil-test-diag.png)

### CY8CPROTO-063-BLE

![CY8CPROTO-063-BLE HIL setup](img/cy8cproto-063-ble-hil-test-diag.png)

## Developing Extended Hardware Setup Tests

The driving principle for designing these tests is to keep a **simple** (as simple as possible), **reproducible** and **scalable** hardware-in-the-loop setup, by aiming for **self-contained** board setups using minimal or no hardware other than the board itself.

Most of the MCU (and boards) provide a given feature and its complementary feature. What does we mean by a feature and its *complementary* feature? Conceptually, many protocols and system topologies are based on a complementary or opposite role interaction: input-output, master-slave, server-client or controller-peripheral, sender-receiver. Its operation is effective when they are interacting together. Thus, the evaluation of one of the is hardly achievable without each other.

In our case, both roles are likely to be available and implementable in a single (or worst case, with a couple of) evaluation board.
For example, testing a GPIO input API functionality can be done by using a GPIO output API, and physically connecting the 2 ports together with a cable.
Another example would be to validate an ADC by connecting it to a DAC in the same board. Or connecting an instance of a I2C master to a I2C slave, in the same board, with a few cables and pull-up resistors.

If this is the case, it will often simplify the whole testing hardware infrastructure by removing the need of external hardware devices and complex interfaces. For example, measuring equipment that is not always available, potentially expensive, and harder to reproduce and scale.

Sometimes the *complementary* feature might not be available. In that case, it is worth to evaluate which is the most convenient approach. Let´s imagine we have a master SPI API which could be easily tested with a SPI slave in the same micocontroller. If it is not available it will require to be developed for MicroPython. Sure, it is an effort, but keep in mind that such SPI slave mode is not just a testing utility, but an usable enablement for MicroPython end (primary) users. Besides, how simple, reproducible, scalalable and automatable re the other options?

Yes, also automatable. As the rests of the PSoC6 folder tests, these tests need to be able to **run automatically** under the MicroPython testing suite tools, without the requiring visual inspections and manual checks. That way they can be added to the Continuous Integration testing pipelines, and reassuring quality after every affected or relevant code change.
6 changes: 6 additions & 0 deletions tests/psoc6/dut/adc.py → tests/psoc6/hw_ext/adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@
if "CY8CPROTO-062-4343W" in machine:
adc_pin0 = "P10_0"
adc_pin1 = "P10_1"
# TODO: Refactor test for more functionality coverage
print("SKIP")
raise SystemExit
elif "CY8CPROTO-063-BLE" in machine:
adc_pin0 = "P10_0"
adc_pin1 = "P10_1"
# TODO: Refactor test for more functionality coverage
print("SKIP")
raise SystemExit

adc0 = ADC(adc_pin0, sample_ns=1000)
adc1 = ADC(adc_pin1, sample_ns=1000)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/psoc6/dut/i2c.py → tests/psoc6/hw_ext/i2c.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
elif "CY8CPROTO-063-BLE" in machine:
scl_master_pin = "P6_4"
sda_master_pin = "P6_5"
scl_master_soft_pin = "P5_2"
sda_master_soft_pin = "P5_3"
scl_master_soft_pin = "P7_2"
sda_master_soft_pin = "P0_5"
scl_slave_pin = "P10_0"
sda_slave_pin = "P10_1"

Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions tests/psoc6/dut/i2s.py → tests/psoc6/hw_ext/i2s.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@
sck_rx_pin = "P5_4"
ws_rx_pin = "P5_5"
sd_rx_pin = "P5_6"
elif "CY8CPROTO-063-BLE" in machine:
# This would be the right pins for this test, but unfortunately
# the P5_1 is allocated for the UART serial comm terminal communication.
# So this tests is not currently possible for this board.
# sck_tx_pin = "P5_1"
# ws_tx_pin = "P5_2"
# sd_tx_pin = "P5_3"
# sck_rx_pin = "P5_4"
# ws_rx_pin = "P5_5"
# sd_rx_pin = "P5_6"
print("SKIP")
raise SystemExit


audio_out = I2S(
0,
Expand Down
File renamed without changes.
Copy link
Member

Choose a reason for hiding this comment

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

In case you see more connection to come here, having a table of connections would be more readable?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes... but if we need some resistors and so on.
It is simpler to maintain a table.
Graphically it was handy to decide where else we can connect for new tests.
Or you mean also in the graph?

Copy link
Member Author

Choose a reason for hiding this comment

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

I merge not to have to rebase again :D But we can make changes in upcoming PRs

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 14 additions & 11 deletions tests/psoc6/dut/pin.py → tests/psoc6/hw_ext/pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
pin1_name = "P13_7"
pin2_name = "P13_6"
elif "CY8CPROTO-063-BLE" in machine:
pin1_name = "P6_3"
pin2_name = "P6_2"
pin1_name = "P12_6"
pin2_name = "P12_7"

# Pin out and pin in must be connected
# together in the board
Expand Down Expand Up @@ -57,18 +57,21 @@
print("pin out callable 0: ", pin_in.value() == 0)


# TODO: Check how to tests the PULLUP enablement functionality.
# This is not really working because of the hardware setup? init value set?
# pull up hardware configuration not working?
# Validating pull resistors configurations and open drain mode
pin_out.deinit()
pin_out = Pin(pin1_name, pull=None, mode=Pin.OPEN_DRAIN)
print("pin out with pull none initially 0 or 1: ", pin_in.value() == 0 or pin_in.value() == 1)
# pin_out.deinit()
# pin_out = Pin(pin1_name, pull=None, mode=Pin.OPEN_DRAIN)
# print("pin out with pull none initially 0 or 1: ", pin_in.value() == 0 or pin_in.value() == 1)

pin_out.deinit()
pin_out = Pin(pin1_name, pull=Pin.PULL_DOWN, mode=Pin.OUT)
print("pin out with pull down initially down: ", pin_in.value() == 1)
# pin_out.deinit()
# pin_out = Pin(pin1_name, pull=Pin.PULL_DOWN, mode=Pin.OUT)
# print("pin out with pull down initially down: ", pin_in.value() == 0)

pin_out.deinit()
pin_out = Pin(pin1_name, pull=Pin.PULL_UP, mode=Pin.OUT)
print("pin out with pull up initially high: ", pin_in.value() == 0)
# pin_out.deinit()
# pin_out = Pin(pin1_name, pull=Pin.PULL_UP, mode=Pin.OUT)
# print("pin out with pull up initially high: ", pin_in.value() == 1)


# Validating interrupts
Expand Down
3 changes: 0 additions & 3 deletions tests/psoc6/dut/pin.py.exp → tests/psoc6/hw_ext/pin.py.exp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,5 @@ pin out value on: True
pin out value off: True
pin out callable 1: True
pin out callable 0: True
pin out with pull none initially 0 or 1: True
pin out with pull down initially down: True
pin out with pull up initially high: True
interrupt triggered rising
interrupt triggered falling
6 changes: 3 additions & 3 deletions tests/psoc6/dut/pwm.py → tests/psoc6/hw_ext/pwm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
# Allocate pin based on board
machine = os.uname().machine
if "CY8CPROTO-062-4343W" in machine:
pwm_pin = "P12_0"
pwm_pin = "P13_7"
pin_in = "P13_6"

elif "CY8CPROTO-063-BLE" in machine:
pwm_pin = "P6_2"
pin_in = "P5_2"
pwm_pin = "P12_6"
pin_in = "P12_7"

input_pin = Pin(pin_in, Pin.IN)

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions tests/psoc6/dut/signal.py → tests/psoc6/hw_ext/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
pin1_name = "P13_7"
pin2_name = "P13_6"
elif "CY8CPROTO-063-BLE" in machine:
pin1_name = "P6_3"
pin2_name = "P6_2"
pin1_name = "P12_6"
pin2_name = "P12_7"

# Pin out and pin in must be connected
# together in the board
Expand Down
File renamed without changes.
16 changes: 0 additions & 16 deletions tests/psoc6/i2c_hard.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/psoc6/i2c_hard.py.exp

This file was deleted.

16 changes: 0 additions & 16 deletions tests/psoc6/i2c_soft.py

This file was deleted.

1 change: 0 additions & 1 deletion tests/psoc6/i2c_soft.py.exp

This file was deleted.

34 changes: 0 additions & 34 deletions tests/psoc6/pin.py

This file was deleted.

4 changes: 0 additions & 4 deletions tests/psoc6/pin.py.exp

This file was deleted.

17 changes: 0 additions & 17 deletions tests/psoc6/pwm.py

This file was deleted.

4 changes: 0 additions & 4 deletions tests/psoc6/pwm.py.exp

This file was deleted.

26 changes: 25 additions & 1 deletion tests/psoc6/run_psoc6_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ usage() {
echo " --dev0 device to be used"
echo " --dev1 second device to be used (for multi test)"
echo " --psoc6 run only psoc6 port related tests"
echo " --psoc6-hwext run only psoc6 port hardware extended related tests"
echo " --psoc6-multi run only psoc6 port multi tests (requires 2 instances)"
exit 1;
}
Expand All @@ -33,11 +34,12 @@ for arg in "$@"; do
'--dev1') set -- "$@" '-e' ;;
'--psoc6') set -- "$@" '-p' ;;
'--psoc6-multi') set -- "$@" '-m' ;;
'--psoc6-hwext') set -- "$@" '-t' ;;
*) set -- "$@" "$arg" ;;
esac
done

while getopts "acd:e:fhimnpwvx" o; do
while getopts "acd:e:fhimnptwvx" o; do
case "${o}" in
a)
all=1
Expand Down Expand Up @@ -78,6 +80,9 @@ while getopts "acd:e:fhimnpwvx" o; do
x)
afs=1
;;
t)
hwext=1
;;
*)
usage
;;
Expand Down Expand Up @@ -138,6 +143,11 @@ if [ -z "${psoc6Only}" ]; then
psoc6Only=0
fi

if [ -z "${hwext}" ]; then
hwext=0
fi


resultsFile="psoc6_test_results.log"
passResultsFile="psoc6_test_passed.log"
skipResultsFile="psoc6_test_skipped.log"
Expand Down Expand Up @@ -406,6 +416,20 @@ if [ ${psoc6OnlyMulti} -eq 1 ]; then

fi

if [ ${hwext} -eq 1 ]; then

echo " running only psoc6 hardware extended tests ..."
echo

./run-tests.py --target psoc6 --device ${device0} -d psoc6/hw_ext \
| tee -a ${resultsFile}

echo
echo " done."
echo

fi


### not yet enabled/implemented, therefore failing
if [ ${notYetImplemented} -eq 1 ]; then
Expand Down
Loading
Loading