-
Notifications
You must be signed in to change notification settings - Fork 2.1k
{cpu/sam0_common/sam0_sdhc,drivers/mtd}: do not allocate work_area
twice
#21169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account 8000 p>
{cpu/sam0_common/sam0_sdhc,drivers/mtd}: do not allocate work_area
twice
#21169
Conversation
|
You are right, simply removing the flag does not work actually. Don´t know how it worked before. It fails here: Lines 738 to 758 in 7e33118
Is then simply the Lines 77 to 84 in 7e33118
Compared to: RIOT/cpu/sam0_common/sam0_sdhc/mtd_sdhc.c Lines 47 to 54 in 7e33118
|
I am missing the check for unaligned memory access based on Should check for unaligned access and then if |
For uint8_t tmp[FLASHPAGE_WRITE_BLOCK_SIZE]
__attribute__ ((aligned (FLASHPAGE_WRITE_BLOCK_ALIGNMENT))); The allocation of work_area could be moved to the storage driver. |
Do you mean the if (IS_USED(MODULE_SDMMC_MMC) && (dev->type == SDMMC_CARD_TYPE_MMC)) {
/* MMCs don't support the erase of a single block but only the erase of
* a group of blocks. Blocks are erased implicitly on write. */
DEBUG("[sdmmc] MMCs don't support the erase of single blocks\n");
return -ENOTSUP;
} again, with fatfs this shouldn't be an issue as we always use What filesystem are you trying to use? Or are you using a raw MTD device without a filesystem? |
That's where it fails when I remove the
For whatever reason I land here: static int mtd_sdmmc_write_page(mtd_dev_t *dev, const void *buff, uint32_t page,
uint32_t offset, uint32_t size)
{
mtd_sdmmc_t *mtd_sd = (mtd_sdmmc_t*)dev;
DEBUG("mtd_sdmmc_write_page: page:%" PRIu32 " offset:%" PRIu32 " size:%" PRIu32 "\n",
page, offset, size);
if (offset || size % SDMMC_SDHC_BLOCK_SIZE) {
#if IS_USED(MODULE_MTD_WRITE_PAGE)
if (dev->work_area == NULL) {
DEBUG("mtd_sdmmc_write_page: no work area\n");
return -ENOTSUP;
} |
Can you enable debug? What are |
921939a
to
9e7a269
Compare
I wanted to debug. But suddenly it works with two different boards. I do not 100% trust it still. Its very strange. |
work_area
twice
There is still something else required. The fatfs filesystem does only do aligned reads and writes, but when I want to call Proposal: allocate work_area when write_size is not 1? |
still should be depended on a module (and then on init) - you don't want to pull on all that malloc and copy-on-write code if you just have a fatfs and don't want to interact with the raw MTD |
@@ -46,9 +46,11 @@ static int _init(mtd_dev_t *dev) | |||
|
|||
#if IS_USED(MODULE_MTD_WRITE_PAGE) | |||
/* TODO: move to MTD layer */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that TODO still valid?
Almost looks like it has been moved to mtd and can be removed here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, mtd_sam0_sdhc_driver
has the MTD_DRIVER_FLAG_DIRECT_WRITE
flag set which means the MTD layer would not allocate the work area, but the driver needs it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difference is that the mtd_sam0_sdhc_driver.init
allocates a work_area
, but mtd_sdmmc_driver.init
does not.
Is this actually the work around for the original motivation of the PR?
Contribution description
The MTD
work_area
could be allocated multiple times when MTD is reinitialized.A check for not
NULL
is added.Testing procedure
Custom board with an eMMC. I can craete a fatfs filesystem on it with:
Issues/PRs references