lowRISC / sonata-system

A full micro-controller system utilizing the CHERIoT Ibex core, part of the Sunburst project funded by UKRI
Apache License 2.0
29 stars 17 forks source link

Add I2C test for CHERI #202

Closed AlexJones0 closed 1 month ago

AlexJones0 commented 1 month ago

This PR adds an I2C test to the existing baremetal CHERI test runner. For now, these are simple smoketests that test a few possible connected I2C devices by reading out some information and checking it matches what we expect. The tests are made based on the existing i2c_hat_id demo being used as a non-CHERI check (see i2c_hat_id.c), and have been adapted for CHERI. Please suggest if you have any other ideas for small tests that you think would be appropriate to add here.

There are three tests, which can be configured based on which devices are present:

  1. Read the Raspberry Pi HAT ID EEPROM header and check it.
  2. Read the Raspberry Pi HAT Accelerometer & Gyroscope and Magnetic Sensor WHO_AM_I registers and check these.
  3. Read the config and temperature value from the AS6212 Temperature sensor and check these values are sensible.

The number of test iterations, and the devices that are available, as well as whether to check the contents of the RPi HAT ID EEPROM header, can all be configured via compilation flags.

This has been tested on both FPGA and in Verilator. Currently, it passes on FPGA with the devices connected and fails on Verilator. With #194 applied on top, it passes on Verilator also. This test has also been confirmed to pass 100 iterations for consistency on FPGA.

AlexJones0 commented 1 month ago

Test is failing CI because #194 has not yet been merged.