You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/11/08 04:00:02 UTC

[incubator-nuttx] branch master updated: esp32/esp32c3: Fix MMU pages number calculation error

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new a59aae6  esp32/esp32c3: Fix MMU pages number calculation error
a59aae6 is described below

commit a59aae69270f547d976651da82543daccaa4bb3c
Author: Dong Heng <do...@espressif.com>
AuthorDate: Fri Nov 5 16:20:06 2021 +0800

    esp32/esp32c3: Fix MMU pages number calculation error
---
 arch/risc-v/src/esp32c3/esp32c3_spiflash.c | 2 +-
 arch/xtensa/src/esp32/esp32_spiflash.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/risc-v/src/esp32c3/esp32c3_spiflash.c b/arch/risc-v/src/esp32c3/esp32c3_spiflash.c
index f2c0ee0..8003f3d 100644
--- a/arch/risc-v/src/esp32c3/esp32c3_spiflash.c
+++ b/arch/risc-v/src/esp32c3/esp32c3_spiflash.c
@@ -290,7 +290,7 @@ static int IRAM_ATTR esp32c3_mmap(struct spiflash_map_req_s *req)
     }
 
   flash_page = MMU_ADDR2PAGE(req->src_addr);
-  page_cnt   = MMU_BYTES2PAGES(req->size);
+  page_cnt   = MMU_BYTES2PAGES(MMU_ADDR2OFF(req->src_addr) + req->size);
 
   if (start_page + page_cnt < DROM0_PAGES_END)
     {
diff --git a/arch/xtensa/src/esp32/esp32_spiflash.c b/arch/xtensa/src/esp32/esp32_spiflash.c
index 7c085ab..6119e8d 100644
--- a/arch/xtensa/src/esp32/esp32_spiflash.c
+++ b/arch/xtensa/src/esp32/esp32_spiflash.c
@@ -1344,7 +1344,7 @@ static int IRAM_ATTR esp32_mmap(struct esp32_spiflash_s *priv,
     }
 
   flash_page = MMU_ADDR2PAGE(req->src_addr);
-  page_cnt = MMU_BYTES2PAGES(req->size);
+  page_cnt = MMU_BYTES2PAGES(MMU_ADDR2OFF(req->src_addr) + req->size);
 
   if (start_page + page_cnt < DROM0_PAGES_END)
     {