Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

A filesystem and raw block access to the same QSPI flash

Hello.

I'd like to split an external QSPI flash chip so that part of the memory is accessible as raw blocks, and the other part holds a filesystem such as fatfs. Essentially I'd need to combine the nRF5 SDK examples peripheral/qspi and peripheral/usbd_msc. Also the raw block access would need to hold the lowest addresses starting from zero.

Slightly longer version:

I have a device that uses a QSPI flash for storing some data. The data is stored as raw bytes starting at address zero. The code is based on the qspi example, so quite simple. This part is working, and I have devices already out with customers, so I'd like to leave it as it is.

Now for a different feature it would be really helpful if I could also have a small filesystem. I don't want to start moving all the existing data, so the filesystem would occupy a part of the flash starting at some nonzero address.

Looking at the two Nordic examples, it seems to me that this could be doable with fairly limited changes. For low power operation I need to uninit the QSPI anyway, so re-initializing it between these two uses seems fairly straightforward. My simple raw access routines essentially only need to know that a write or read has completed, so modifying the event handlers to pass this info to the correct caller also seems simple.

What is keeping me from trying all this right now is that I can't see an easy way to specify in the usbd_msc example that I'd like the flash start address to be nonzero. My current plan is to go to the lowest level: the block device geometry settings (nrf_block_dev_geometry_t) and add an offset there. I would need to modify a number of places where clearly a start address of zero is assumed.

Before I start down this path I'd like to ask if this seems reasonable. Or if I should do this in some another way. I do realize that moving my existing data would get me around the start address issue, but I really would like to leave that part as it is.

Parents
  • Hi 

    Unfortunately the guy that developed the nrf_block_dev modules is on vacation at the moment, but looking at the code I can't see any reference to any offset variables or similar that would allow you to start at an address > 0 in the external flash. 

    As far as I can tell the nrf_block_dev_qspi.c implementation would have to be changed, in order to add a constant offset to the block index for every call to one of the nrf_drv_qspi_read/write/erase functions. 

    The blk_count variable in the nrf_block_dev_geometry_t struct would then need to be reduced by the same amount, to make sure you don't try to access memory beyond the boundaries of the flash module. 

    Best regards
    Torbjørn

  • Sorry for the delay, I needed to work on something else last week.

    I got this part working. I checked how the block_dev_ram implementation specified an address range, and followed that. So instead of altering the shared geometry struct, I added the offset and size to the block_dev_qspi's config-structure.

    This seems to be working. I still need to integrate the raw block access routines and verify that I can alternate between the two.

Reply
  • Sorry for the delay, I needed to work on something else last week.

    I got this part working. I checked how the block_dev_ram implementation specified an address range, and followed that. So instead of altering the shared geometry struct, I added the offset and size to the block_dev_qspi's config-structure.

    This seems to be working. I still need to integrate the raw block access routines and verify that I can alternate between the two.

Children
Related