Repository navigation
stm32 / spiflash: Support defining exact flash chip(s) connected. - #12722
andrewleech wants to merge 13 commits into
Conversation
01d336f to
b3e145b
Compare
b3e145b to
07c5c79
Compare
There was a problem hiding this comment.
This is a bit strange, the function here is read_cmd_qaddr_qdata which explicitly asks for 4-lines of addr and data. But then this special case is using 1-line for addr and data.
So either:
- add a new function called
read_cmd_addr_datawhich is used for commands like this one - change this function to be called
read_cmd_addr_dataand make it select the width of addr and data based on the cmd value, which is what you've done here
The first option feels more correct, because the bus shouldn't care about the values going over it, it should just do as instructed and write the data over the requested number of data lines.
The first option also means softqspi.c and qspi.c don't need to know about (or have a definition of) CMD_RD_SFDP.
There was a problem hiding this comment.
I did start going down a path of passing in args to read_cmd_qaddr_qdata to select the required settings... the problem I ran into was that it's not just the number of lines, it's also the dummy cycles. And if both those settings are exposed, the alternate-bytes should be as well arguably. And it all got quite messy and I reverted back to this.
If I ignore the other settings and just base the difference on the number of lines used, passing that in as a function arg is less code space use than duplicating the function and adding the extra entry to the mp_qspi_proto_t.
To be fair these existing functions have dummy/AB settings all hard-coded apparently to suit the commands that just happen to be used by spiflash, so continuing down that path doesn't seem too bad until someone needs them to be more flexible for a new reason.
There was a problem hiding this comment.
Oh yeah, I also noticed last time that the new octospi driver in stm only support 1 and 2 line modes currently, auto-selected by which pins are defined...
There was a problem hiding this comment.
Yeah I agree it's not all consistent and could be more flexible. You're right that adding a new function takes up more code space, compared to reusing an existing one.
How about calling it read_cmd_addr_data() and passing in the number of lines to use? It could just be an enum with only 2 options to start with, eg:
enum qspi_tranfer_mode {
QSPI_TRANSFER_CMD_ADDR_DATA,
QSPI_TRANSFER_CMD_QADDR_QDATA,
};
There was a problem hiding this comment.
I'm just finishing up implementing it as an uint8_t lines arg which gets passed 1 or 4 so far.... the enum approach gives better flexibility in future to make a labelled mode that changes different settings.
There was a problem hiding this comment.
The enum approach has been added and looks like it works well for me thanks.
There was a problem hiding this comment.
This should use mp_printf(MICROPY_ERROR_PRINTER, ...).
There was a problem hiding this comment.
Sure, I did initially think that but saw printf had already been used in this file. I'll change it everywhere to use the preferred approach.
f5bd1e3 to
8003704
Compare
860cfba to
66c719d
Compare
66c719d to
a4456ee
Compare
|
This is an automated heads-up that we've just merged a Pull Request See #13763 A search suggests this PR might apply the STATIC macro to some C code. If it Although this is an automated message, feel free to @-reply to me directly if |
Signed-off-by: Andrew Leech <[email protected]>
Add some more details to the struct definition. Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
Fixes support for 4 line communication with chip, but maintains fallback to 2 or 1 line if hardware needs it. Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
The Serial Flash Discoverable Parameters (SFDP) is a jedec standard interface on (most/newer) spiflash chips that allows querying the flash size (amongst other things). Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
Signed-off-by: Andrew Leech <[email protected]>
a4456ee to
3033161
Compare
Different spiflash brands / models can require slightly different settings to use.
This PR allows a board profile to declare the model spiflash being used directly.
It's re-using a header of spiflash definitions already available in
drivers/memory/external_flash_device.h, however new ones could be added inline in mpconfigboard.h if needed.This started as an additional commit in #12512 and also provides functionality first presented in #11932