[spi_host] Low-level SD card support#446
Conversation
08ccd27 to
db2ad39
Compare
c1e2865 to
0510cd1
Compare
|
Reduced the level of UART logging when |
| #include "runtime/filesys_utils.h" | ||
| #include "runtime/print.h" | ||
| #include "runtime/sdcard.h" | ||
| // #include <assert.h> |
There was a problem hiding this comment.
Are we not going to be adding support for asserts in the future?
There was a problem hiding this comment.
@engdoreis do you have any new thoughts on this now that the future of this file is clearer?
There was a problem hiding this comment.
I think that any comment code should be removed. A TODO command can be used to remind that asserts should be added.
There was a problem hiding this comment.
Alright, I guess if this file is likely to be deleted, then it is unlikely that there will be an opportunity to enable these asserts
There was a problem hiding this comment.
Alright, I've removed the assert stuff from this file, and removed or added TODOs to assert stuff in sdcard.c. Does that work for you?
marnovandermaas
left a comment
There was a problem hiding this comment.
Thanks for working on this! I've left some initial comments.
| .rst_ni, | ||
|
|
||
| .gpio_i (gpio_inputs), | ||
| .gpio_i ({gpio_inputs[31:10], microsd_det, gpio_inputs[8:0]}), |
There was a problem hiding this comment.
This is a little bit ugly because the gpio_input now will just ignore any writes to bit index 9. I'm not sure how to solve it more cleanly though.
There was a problem hiding this comment.
Indeed, I'm open to better ideas
There was a problem hiding this comment.
The only thing I can think of is that it is probably better to put the microSD detection in the most significant bit rather than in the middle. What do you think?
There was a problem hiding this comment.
If you do change the GPIO, make sure to update this line in the devicetree and regenerate it: https://github.com/lowRISC/mocha/blob/main/sw/device/devicetree/mocha.dts#L76
There was a problem hiding this comment.
Introducing a gap in the range of GPI lines in use might make things trickier on the FPGA-side, where at the moment the input signal is only wide enough for the number of GPI lines assigned to pins. We could change it so that the FPGA GPI input is 32-bits wide and only assign some a subset to pins in the XDC file, or we could adopt #411 and have the mapping of board signals to GPI lines in the RTL rather than constraints, where it would be easier to assign some constant values.
There was a problem hiding this comment.
@marnovandermaas your thoughts would be appreciated
There was a problem hiding this comment.
I think I would go for a gap where the most significant bits are ones you cannot affect by the DPI and any future general purpose inputs that can be affected by the DPI can be added contiguously at the bottom. I'm happy for you to also implement the #411 at the same time if you think that's not too much work.
There was a problem hiding this comment.
Alright, I'll move the input to a higher index. I might do the rest of the FPGA pin remapping an a subsequent PR.
@ziuziakowska Is there documentation you could point me to for how to re-generate the device tree?
|
Use |
|
Rework uart printing to use |
|
Rebase |
|
Lint fixes (I forgot to run the formatter after the last round of changes) |
|
Rebase and tweak documentation change to better match new dev guide section on additional hardware |
|
Rework log2 to use builtins |
|
Rebase to resolve RTL conflicts |
Replace the initial SPI Host loopback connections with connections to the microSD card slot for Genesys2 and an SD card model for Verilator. This includes allocating a GPI pin for card presence detection and a GPO pin for SD card reset (power supply switching). Also output the SPI Host signals on an otherwise unused Genesys2 PMOD header for easier debugging using a logic analyser.
|
Removed commented-out XDC lines (they can always be re-created from the schematic) |
Add SD card and minimal filesystem helpers for SPI Host, and some tests. These have been ported from sonata-system, which required changes for the different spi_host hardware and translating from C++ to C. Only a subset of the tests will run in Verilator unless an SD card image is provided.
|
Removed commented-out assertion lines from filesys code, and removed/TODO-ed in sdcard code |
Replace the initial SPI Host loopback connections with connections to the microSD card slot for Genesys2 and an SD card model for Verilator. This includes allocating a GPI pin for card presence detection and a GPO pin for SD card reset (power supply switching).
Also output the SPI Host signals on an otherwise unused Genesys2 PMOD header for easier debugging using a logic analyser.
Add SD card and minimal filesystem helpers for SPI Host, and some tests. These have been ported from sonata-system, which required changes for the different spi_host hardware and translating from C++ to C.
Only a subset of the tests will run in Verilator unless an SD card image is provided.