drivers: `I2C_Device.Address.check_reserved` rejects 0x08-0x0F and accepts 0x04-0x07 (HighSpeedMaster range is off by one bit)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 1/5
- Thời gian dự kiến
- Dưới một giờ
- Mức phù hợp với người mới
- 69/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- zig
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
Bắt đầu tại drivers/src/base/I2C_Device.zig, ở Address.check_reserved, rồi đọc bảng kiểm thử hiện có trong cùng tệp. Issue nêu các dải địa chỉ sai và được mong đợi, cùng cách tái hiện chỉ trên host. Cập nhật kiểm tra dải địa chỉ và các kỳ vọng trong kiểm thử, sau đó chạy cách tái hiện hoặc zig build test từ drivers/; hoàn tất khi 0x04–0x07 bị từ chối và 0x08–0x0F được chấp nhận.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Address.check_reserved (drivers/src/base/I2C_Device.zig:55 on master) returns
error.HighSpeedMaster for 0b0001000...0b0001111 (0x08-0x0F). The Hs-mode
controller code is 0000 1XX, i.e. 0x04-0x07 — the page the doc comment links
(https://www.i2c-bus.org/addressing/ lists 00001XX X as "High-Speed Master
Code"), and the doc comment itself: "Reserved addresses are ones that match
0b0000XXX or 0b1111XXX". So:
- 0x08-0x0F, ordinary 7-bit addresses, are refused. Through the rp2xxx HAL every
read (.dont_allow_reserved) returnserror.IllegalAddressfor them before
anything reaches the bus. A bus scan that starts at 0x08 (the usual first
address) sees an error rather than a NACK at its first address. The same check runs
in the nrf5x, stm32 (i2c_v2) and espressif HALs. Real parts live at these
addresses. One is the AK09916 magnetometer at 0x0C: the in-treeICM_20948
driver names itMAG_ADDRESS = 0x0C. That driver reaches it through the ICM's own
aux I2C master, so it is unaffected, but on a board that wires the AK09916 straight
to the host bus the HAL refuses its address. - 0x04-0x07, the reserved Hs-mode codes, are accepted.
It is a regression from #648 (c058aa4, 2025-08-16). The bool version it
replaced was ((value & 0x78) == 0) or ((value & 0x78) == 0x78), which was right.
When that became a switch, 0000 1XX was written as 0001 XXX, and the new test table
encoded the same values (0x08 and 0x0F expect HighSpeedMaster).
Versions
| tree | toolchain | result |
|---|---|---|
microzig 0.15.1 release (mz_drivers-0.0.1-bvRa3F…) |
zig 0.15.2 | reproduces (rc=1) |
| microzig master f36d59fb7b22 (tag 0.17.17, 2026-10-10) | zig 0.17.0 | reproduces (rc=1) |
| master + the fix below | zig 0.17.0 | fixed (rc=0) |
Repro (host-only, no hardware)
repro.zig:
const std = @import("std");
const Address = @import("I2C_Device").Address;
fn reserved(a: u7) bool {
const addr: Address = @enumFromInt(a);
addr.check_reserved() catch return true;
return false;
}
test "0x04-0x07 (0000 1XX, Hs-mode controller code) are reserved" {
for ([_]u7{ 0x04, 0x05, 0x06, 0x07 }) |a| try std.testing.expect(reserved(a));
}
test "0x08-0x0F are ordinary addresses" {
for ([_]u7{ 0x08, 0x09, 0x0C, 0x0F }) |a| try std.testing.expect(!reserved(a));
}
zig test repro.zig --dep I2C_Device -Mroot=repro.zig -MI2C_Device=<microzig>/drivers/src/base/I2C_Device.zig
Expected: both tests pass.
Actual (master f36d59f, zig 0.17.0):
1/2 repro.test.0x04-0x07 (0000 1XX, Hs-mode controller code) are reserved...0x04 accepted, expected reserved
FAIL (TestUnexpectedResult)
2/2 repro.test.0x08-0x0F are ordinary addresses...0x08 rejected, expected usable
FAIL (TestUnexpectedResult)
0 passed; 0 skipped; 2 failed.
Fix
One switch arm, plus the two test-table rows that encoded the wrong range:
- 0b0001000...0b0001111 => return Address.Error.HighSpeedMaster,
+ 0b0000100...0b0000111 => return Address.Error.HighSpeedMaster,
and the existing test in the same file now expects HighSpeedMaster at 0x04/0x07 and
"valid" at 0x08/0x0F. With the patch, zig build test in drivers/ gives
123/123 tests passed (rc=0), the same count as unpatched master. The repro above
passes.
Behaviour change worth a line in the release notes: callers that pass 0x04-0x07
with .dont_allow_reserved / .allow_general now get IllegalAddress, and
0x08-0x0F start working.
I have the patch ready and can open it as a PR if you'd like.
- Ngôn ngữ chính
- Zig
- Star
- 2.3k
- Fork
- 198
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 37
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ZigEmbeddedGroup/microzig
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
ZigEmbeddedGroup/microzig#1086 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ZigEmbeddedGroup/microzig#1061 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
ZigEmbeddedGroup/microzig#1059 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
regz: AVR peripherals generated at address 0 when the register-group name matches the module (ATDF)Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
ZigEmbeddedGroup/microzig#1072 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
AVR (ATmega328P): UART/SPI HAL, drivers.zig, and nRF24L01+ driver (Emakefun RF-Nano V3.0)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
ZigEmbeddedGroup/microzig#1069 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của ZigEmbeddedGroup/microzig
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
1 type: problem 2 scope: firmware 3 good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
SpaceTeam/STS1_COBC_SW#511 ·
-
documentation good first issue
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 60/100
imaaiagent/fumi#1 ·
-
[BUG] OTA Requestor accepts reserved provider endpoint 0xFFFFCó thể đã có người làm @Chapoly1305 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
project-chip/connectedhomeip#74742 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 63/100
Xinyuan-LilyGO/T-Display-S3#352 · 3 bình luận ·