Skip to content
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

fix(spi_nand_flash): fix memory alignment issue occurring on esp32c3 #480

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions spi_nand_flash/src/nand_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,12 @@ esp_err_t nand_is_bad(spi_nand_flash_device_t *handle, uint32_t block, bool *is_
ESP_GOTO_ON_ERROR(read_page_and_wait(handle, first_block_page, NULL), fail, TAG, "");

// Read the first 2 bytes on the OOB of the first page in the block. This should be 0xFFFF for a good block
ESP_GOTO_ON_ERROR(spi_nand_read(handle->config.device_handle, (uint8_t *) &bad_block_indicator, handle->chip.page_size, 2),
ESP_GOTO_ON_ERROR(spi_nand_read(handle->config.device_handle, (uint8_t *) handle->read_buffer, handle->chip.page_size, 2),
fail, TAG, "");

bad_block_indicator = *(uint16_t *)handle->read_buffer;
ESP_LOGD(TAG, "is_bad, block=%"PRIu32", page=%"PRIu32",indicator = %04x", block, first_block_page, bad_block_indicator);
if (bad_block_indicator == 0xFFFF) {
*is_bad_status = false;
} else {
*is_bad_status = true;
}
*is_bad_status = (bad_block_indicator != 0xFFFF);
return ret;

fail:
Expand Down Expand Up @@ -232,16 +229,13 @@ esp_err_t nand_is_free(spi_nand_flash_device_t *handle, uint32_t page, bool *is_
uint16_t used_marker;

ESP_GOTO_ON_ERROR(read_page_and_wait(handle, page, NULL), fail, TAG, "");
ESP_GOTO_ON_ERROR(spi_nand_read(handle->config.device_handle, (uint8_t *)&used_marker,
ESP_GOTO_ON_ERROR(spi_nand_read(handle->config.device_handle, (uint8_t *)handle->read_buffer,
handle->chip.page_size + 2, 2),
fail, TAG, "");

used_marker = *(uint16_t *)handle->read_buffer;
ESP_LOGD(TAG, "is free, page=%"PRIu32", used_marker=%04x,", page, used_marker);
if (used_marker == 0xFFFF) {
*is_free_status = true;
} else {
*is_free_status = false;
}
*is_free_status = (used_marker == 0xFFFF);
return ret;
fail:
ESP_LOGE(TAG, "Error in nand_is_free %d", ret);
Expand Down