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

I3C peripheral updates and integration tests #41

Merged
merged 4 commits into from
Dec 3, 2024
Merged

Conversation

swenson
Copy link
Collaborator

@swenson swenson commented Nov 28, 2024

This progresses more on the I3C peripheral, correctly queueing writes how the hardware does.

We also start on writing a socket protocol so that another thread or program can send reads and writes to the I3C bus. This hasn't been teste yet though.

I noticed two bugs that I will address in separate PRs:

  • The I3C interrupts are not quite working yet. When enabled, they are routed correctly to the kernel handler, but keep getting retriggered and not handled properly. I've disabled the interrupts for now, so the read/write methods need to be called manually.
  • Alarms are not firing properly. I tried to work around the interrupts not handling correctly by scheduling an alarm to call the read/write methods periodically, but the alarms never fire. I've noticed something similar to this before. I will debug this separately.

The biggest piece though is adding new integration tests for the kernel:

  • A test can be added to tests/integration/src/lib.rs
  • This will build the emulator and firmware with the feature equal to the test name, and then run them.
  • The test can exit with a non-zero exit code to signal failure.

The tests need to built sequentially so that they don't conflict when writing the layout.ld linker script (this has to have the same name each time to avoid modifying RUSTFLAGS with every invocation; otherwise dependencies are recompiled every single time).

use emulator_cpu::Irq;
use emulator_registers_generated::i3c::I3cPeripheral;
use emulator_types::{RvData, RvSize};
use registers_generated::i3c::bits::InterruptEnable;
use registers_generated::i3c::bits::InterruptStatus;
use registers_generated::i3c::bits::StbyCrDeviceAddr;
Copy link
Collaborator

Choose a reason for hiding this comment

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

minor: is it better to combine them into a single use statement?

/// TX Command in u32
tti_tx_desc_queue_raw: VecDeque<u32>,
/// TX DATA in u32
tti_tx_data_raw: VecDeque<u8>,
tti_tx_data_raw: VecDeque<Vec<u8>>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor: comment should be updated. /// TX DATA in u8

@@ -273,18 +273,10 @@ impl<'a, A: Alarm<'a>> I3CCore<'a, A> {
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is interrupt-status register a regular type or write1toclear? If it is write1toclear, I think we should change this piece of code accordingly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, you're correct, the docs say "woclr".

This progresses more on the I3C peripheral, correctly queueing writes
how the hardware does.

We also start on writing a socket protocol so that another thread or
program can send reads and writes to the I3C bus. This hasn't been teste
yet though.

I noticed two bugs that I will address in separate PRs:
* The I3C interrupts are not quite working yet. When enabled, they are
  routed correctly to the kernel handler, but keep getting retriggered
  and not handled properly. I've disabled the interrupts for now, so the
  read/write methods need to be called manually.
* Alarms are not firing properly. I tried to work around the interrupts
  not handling correctly by scheduling an alarm to call the read/write
  methods periodically, but the alarms never fire. I've noticed
  something similar to this before. I will debug this separately.

The biggest piece though is adding new integration tests for the kernel:

* A test can be added to `tests/integration/src/lib.rs`
* This will build the emulator and firmware with the feature equal to
  the test name, and then run them.
* The test can exit with a non-zero exit code to signal failure.

The tests need to built sequentially so that they don't conflict when
writing the `layout.ld` linker script (this has to have the same name
each time to avoid modifying `RUSTFLAGS` with every invocation;
otherwise dependencies are recompiled every single time).
@swenson
Copy link
Collaborator Author

swenson commented Dec 3, 2024

Thanks!

@swenson swenson merged commit ff42d9f into main Dec 3, 2024
1 check passed
@swenson swenson deleted the i3c-peripheral branch December 3, 2024 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants