Add SFP fibers support for satman #217

Merged
sb10q merged 2 commits from esavkin/artiq-zynq:213-satman-sfp-fiber-support into master 2023-02-17 17:19:30 +08:00
Owner

Make io_expander and i2c wrapper code shared by moving it from runtime to libboard_artiq.

Closes #213

Needs to be merged to release-7 branch.

Make io_expander and i2c wrapper code shared by moving it from runtime to libboard_artiq. Closes #213 Needs to be merged to release-7 branch.
Owner

Why was the busno parameter removed? Again please keep this PR and the refactoring to one thing. The changes like i2c.write -> i2c::write, while perhaps not incorrect unlike the busno change, do not belong here.

I suspect you have not tested this properly on runtime. https://github.com/m-labs/artiq/blob/master/artiq/coredevice/i2c.py

Why was the busno parameter removed? Again please keep this PR and the refactoring to one thing. The changes like i2c.write -> i2c::write, while perhaps not incorrect unlike the busno change, do not belong here. I suspect you have not tested this properly on runtime. https://github.com/m-labs/artiq/blob/master/artiq/coredevice/i2c.py
Author
Owner

I suspect you have not tested this properly on runtime. https://github.com/m-labs/artiq/blob/master/artiq/coredevice/i2c.py

I see, I didn't expect external API for this. I'll move the i2c wrapper back and untie the io_expander from wrapper

> I suspect you have not tested this properly on runtime. https://github.com/m-labs/artiq/blob/master/artiq/coredevice/i2c.py I see, I didn't expect external API for this. I'll move the i2c wrapper back and untie the io_expander from wrapper
Owner

I see, I didn't expect external API for this.

The fact that it raises exceptions should have made alarm bells go off. Normally there are no exceptions in Rust.

> I see, I didn't expect external API for this. The fact that it raises exceptions should have made alarm bells go off. Normally there are no exceptions in Rust.
sb10q reviewed 2023-02-17 16:34:03 +08:00
@ -134,2 +119,2 @@
io_expander0.service().unwrap();
io_expander1.service().unwrap();
let i2c = unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() };
for i_i2c in 0..2 {
Owner

expander_index, expander_i or just i

``expander_index``, ``expander_i`` or just ``i``
esavkin force-pushed 213-satman-sfp-fiber-support from fe1be9e272 to 394e2b2354 2023-02-17 16:54:52 +08:00 Compare
sb10q reviewed 2023-02-17 16:56:04 +08:00
@ -452,0 +452,4 @@
#[cfg(feature = "target_kasli_soc")]
{
for expander_i in &[0u8, 1] {
let mut io_expander = io_expander::IoExpander::new(&mut i2c, *expander_i).unwrap();
Owner

I doubt the & and * are necessary here.

I doubt the & and * are necessary here.
Author
Owner

& makes a slice from array (to make it iterable)

& makes a slice from array (to make it iterable)
Owner
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6f1f8688caff98619cc0d08dd6d99a27
Author
Owner

https://github.com/rust-lang/rust/issues/84837

error[E0277]: `[u8; 2]` is not an iterator
firmware>    --> runtime/src/main.rs:119:27
firmware>     |
firmware> 119 |         for expander_i in [0u8, 1] {
firmware>     |                           ^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it
firmware>     |
firmware>     = help: the trait `Iterator` is not implemented for `[u8; 2]`
firmware>     = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]`
firmware>     = note: required because of the requirements on the impl of `IntoIterator` for `[u8; 2]`
firmware>     = note: required by `into_iter`
firmware> error: aborting due to previous error
firmware> For more information about this error, try `rustc --explain E0277`.
https://github.com/rust-lang/rust/issues/84837 ```rust error[E0277]: `[u8; 2]` is not an iterator firmware> --> runtime/src/main.rs:119:27 firmware> | firmware> 119 | for expander_i in [0u8, 1] { firmware> | ^^^^^^^^ borrow the array with `&` or call `.iter()` on it to iterate over it firmware> | firmware> = help: the trait `Iterator` is not implemented for `[u8; 2]` firmware> = note: arrays are not iterators, but slices like the following are: `&[1, 2, 3]` firmware> = note: required because of the requirements on the impl of `IntoIterator` for `[u8; 2]` firmware> = note: required by `into_iter` firmware> error: aborting due to previous error firmware> For more information about this error, try `rustc --explain E0277`. ```
Owner

Doesn't seem relevant to this case?

Doesn't seem relevant to this case?
Author
Owner

Maybe the link is not really relevant, but the compiler output is

Maybe the link is not really relevant, but the compiler output is
Owner

Seems to be a peculiar issue with the particular compiler version we use here. What was the problem with 0..2 that you had written earlier?

Seems to be a peculiar issue with the particular compiler version we use here. What was the problem with 0..2 that you had written earlier?
Author
Owner

0..2 may seem be confusing, because only 0 and 1 are used, from my point of view

0..2 may seem be confusing, because only 0 and 1 are used, from my point of view
Owner

You can expect developers to know range boundaries.

You can expect developers to know range boundaries.
Owner

There's also the 0..=1 syntax...

There's also the ``0..=1`` syntax...
sb10q reviewed 2023-02-17 16:56:49 +08:00
@ -142,3 +136,3 @@
}
};
Owner

...

...
Author
Owner

Maybe leave it as it is now? IDE does such things all the time

Maybe leave it as it is now? IDE does such things all the time
Owner

Then reconfigure or change your IDE.

Then reconfigure or change your IDE.
Owner

Or run a whitespace cleanup on the entire codebase in a separate PR.

Or run a whitespace cleanup on the entire codebase in a separate PR.
Author
Owner

Or run a whitespace cleanup on the entire codebase in a separate PR.

Maybe integrate some standard tool for formatting files with appropriate config in the future?

> Or run a whitespace cleanup on the entire codebase in a separate PR. Maybe integrate some standard tool for formatting files with appropriate config in the future?
Owner

Sure, if you find something that's easy to integrate, easy to enforce (e.g. git commit hook?), works well, and isn't proprietary.

Sure, if you find something that's easy to integrate, easy to enforce (e.g. git commit hook?), works well, and isn't proprietary.
Author
Owner
For example https://github.com/rust-lang/rustfmt
esavkin force-pushed 213-satman-sfp-fiber-support from 394e2b2354 to 8822f2493e 2023-02-17 17:18:17 +08:00 Compare
sb10q merged commit 05c22792d6 into master 2023-02-17 17:19:30 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/artiq-zynq#217
No description provided.