SPI EasyDMA UB
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 20/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- cpp
- Lĩnh vực
- embedded-iot
Hướng nghiên cứu
Bắt đầu tại src/components/ble/DfuService.cpp, quanh dòng 390, và lần theo các thao tác ghi SPI thông qua Spi::Write. Đọc tài liệu Nordic EasyDMA và cuộc thảo luận nrf-hal được liên kết để xác minh những bộ đệm nào hợp lệ trong khi truyền. Công việc được xem là hoàn tất khi đã chọn và triển khai một chiến lược an toàn để xử lý các bộ đệm ghi hằng hoặc nằm trong flash trên các đường dẫn mã bị ảnh hưởng.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I was looking into https://github.com/InfiniTimeOrg/InfiniTime/blob/main/src/components/ble/DfuService.cpp#L390 and it turns out that the EasyDMA engine cannot read from flash! - See https://docs.nordicsemi.com/bundle/ps_nrf52832/page/easydma.html
Further reading: https://github.com/nrf-rs/nrf-hal/issues/37
There is potential UB across the codebase here - any SPI writes using constant buffers may be stored in flash and therefore be invalid. In particular, all of the display writes may be invalid if the compiler is moving constant arrays to flash (and not copying them to the stack first). Oddly all of the display commands seem to be fine (they clearly work!), while the DFU magic clearly isn't.
I don't know the exact method the compiler uses to decide the storage location. Does anyone know it?
It's certainly affected by constexpr etc.
I might try to analyse the compiler output, but I don't have the tooling to load the binary set up, and it wouldn't be as good as understanding the actual allocation algorithm.
I've got a few ideas here:
- Add a check that hard crashes if a flash pointer gets passed into Spi::Write to prevent this from happening in the future
- Introduce some kind of blocking write. A lot of these writes are small, but we still don't want to store this data in static RAM. So instead we can load them onto the stack, and then block until the write is complete (won't be waiting long as they are small). We need to wait as data in the stack frame can be overwritten as soon as the function returns by future function's stack frame.
- An alternative to (2) would be allocating write buffers on the heap and then the SPI controller freeing them when done. In practice InfiniTime pretty much never runs out of heap, and when it does it usually hangs pretty quickly anyway (LVGL dies).
It looks like the nrf-hal team implemented (1), but only support blocking writes currently.
I'm sure I've missed other good options too, so I'd love any input on this.
- Ngôn ngữ chính
- C
- Star
- 3.4k
- Fork
- 1.1k
- Merge trung bình
- 23 giờ 18 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
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 InfiniTimeOrg/InfiniTime
-
BLE handlers use length fields from the packet without checking how much data arrivedCó thể đã có người làm @DustinHab đã nhận 37 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 56/100
InfiniTimeOrg/InfiniTime#2485 ·
-
Unexpected jump back to watch face when button pressedCó thể đã có người làm @SteveAmor đã nhận 80 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
InfiniTimeOrg/InfiniTime#2461 · 2 bình luận ·
-
Screen doesn't go to sleep after reset countdown appCó thể đã có người làm @SteveAmor đã nhận 78 ngày trước. Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
InfiniTimeOrg/InfiniTime#2419 · 4 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
InfiniTimeOrg/InfiniTime#2410 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
InfiniTimeOrg/InfiniTime#2407 · 4 bình luận ·
Tất cả issue của InfiniTimeOrg/InfiniTime
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
quickjs-ng/quickjs#1836 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
open-quantum-safe/liboqs#2637 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Go device SDK: Whisper transcriber keeps buffering and transcribing audio appended after Stop()Có thể đã có người làm @apoorvdarshan đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
BasedHardware/omi#22770 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fido_do_ecdh() reports any getKeyAgreement failure as FIDO_ERR_INTERNALCó thể đã có người làm @brlumen đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
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 78/100
joncampbell123/dosbox-x#6698 ·
Maintainer thường phản hồi trong vòng 1 ngày