Browse Source

[fal] using rt-thread raw API instead of std API

Meco Man 7 months ago
parent
commit
13e0671f65
41 changed files with 621 additions and 652 deletions
  1. 6 6
      bsp/allwinner/d1s/ports/fal/fal_norflash_sfud_port.c
  2. 9 9
      bsp/allwinner/d1s/ports/fal/fal_sd_sfud_port.c
  3. 12 12
      bsp/hc32/ev_hc32f448_lqfp80/board/ports/fal/fal_flash_sfud_port.c
  4. 12 12
      bsp/hc32/ev_hc32f460_lqfp100_v2/board/ports/fal/fal_flash_sfud_port.c
  5. 12 12
      bsp/hc32/ev_hc32f4a0_lqfp176/board/ports/fal/fal_flash_sfud_port.c
  6. 12 12
      bsp/hc32/lckfb-hc32f4a0-lqfp100/board/ports/fal/fal_flash_sfud_port.c
  7. 12 12
      bsp/hc32/platform/fal/fal_flash_sfud_nor.c
  8. 25 25
      bsp/hpmicro/hpm5300evk/board/fal_flash_port.c
  9. 25 25
      bsp/hpmicro/hpm5301evklite/board/fal_flash_port.c
  10. 25 25
      bsp/hpmicro/hpm6200evk/board/fal_flash_port.c
  11. 25 25
      bsp/hpmicro/hpm6300evk/board/fal_flash_port.c
  12. 25 25
      bsp/hpmicro/hpm6750evk/board/fal_flash_port.c
  13. 25 25
      bsp/hpmicro/hpm6750evk2/board/fal_flash_port.c
  14. 25 25
      bsp/hpmicro/hpm6750evkmini/board/fal_flash_port.c
  15. 25 25
      bsp/hpmicro/hpm6800evk/board/fal_flash_port.c
  16. 25 25
      bsp/hpmicro/hpm6e00evk/board/fal_flash_port.c
  17. 9 9
      bsp/nrf5x/libraries/drivers/drv_qspi_flash.c
  18. 6 6
      bsp/nxp/lpc/lpc55sxx/lpc55s69_nxp_evk/board/ports/easyflash/ef_fal_port.c
  19. 2 2
      bsp/nxp/lpc/lpc55sxx/lpc55s69_nxp_evk/board/ports/fal/fal_sample.c
  20. 12 12
      bsp/stm32/stm32f407-atk-explorer/board/ports/fal/fal_spi_flash_sfud_port.c
  21. 6 6
      bsp/stm32/stm32f407-lckfb-skystar/board/ports/ef_fal_port.c
  22. 12 12
      bsp/stm32/stm32f407-lckfb-skystar/board/ports/fal/fal_spi_flash_sfud_port.c
  23. 6 6
      bsp/stm32/stm32f407-rt-spark/board/ports/ef_fal_port.c
  24. 12 12
      bsp/stm32/stm32f407-rt-spark/board/ports/fal/fal_spi_flash_sfud_port.c
  25. 6 6
      bsp/stm32/stm32h750-artpi/board/port/ef_fal_port.c
  26. 12 12
      bsp/stm32/stm32h750-weact-ministm32h7xx/board/port/drv_qspi_flash.c
  27. 6 6
      bsp/stm32/stm32l475-atk-pandora/board/ports/easyflash/ef_fal_port.c
  28. 3 3
      bsp/stm32/stm32l475-atk-pandora/board/ports/fal/fal_flash_sfud_port.c
  29. 12 12
      bsp/yichip/yc3122-pos/drivers/ports/fal_flash_yc3122_port.c
  30. 3 7
      components/fal/Kconfig
  31. 5 5
      components/fal/docs/fal_api.md
  32. 5 5
      components/fal/docs/fal_api_en.md
  33. 5 5
      components/fal/inc/fal.h
  34. 12 67
      components/fal/inc/fal_def.h
  35. 3 3
      components/fal/samples/porting/README.md
  36. 12 12
      components/fal/samples/porting/fal_flash_sfud_port.c
  37. 29 29
      components/fal/samples/porting/fal_flash_stm32f2_port.c
  38. 12 3
      components/fal/src/fal.c
  39. 21 13
      components/fal/src/fal_flash.c
  40. 67 59
      components/fal/src/fal_partition.c
  41. 43 40
      components/fal/src/fal_rtt.c

+ 6 - 6
bsp/allwinner/d1s/ports/fal/fal_norflash_sfud_port.c

@@ -16,9 +16,9 @@
 #include <sfud.h>
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 extern sfud_flash sfud_norflash0;
 struct fal_flash_dev nor_flash0 =
@@ -30,13 +30,13 @@ struct fal_flash_dev nor_flash0 =
      {init, read, write, erase}
 };
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
     sfud_read(&sfud_norflash0, nor_flash0.addr + offset, size, buf);
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
     if (sfud_write(&sfud_norflash0, nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
     {
@@ -46,7 +46,7 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
     if (sfud_erase(&sfud_norflash0, nor_flash0.addr + offset, size) != SFUD_SUCCESS)
     {

+ 9 - 9
bsp/allwinner/d1s/ports/fal/fal_sd_sfud_port.c

@@ -19,9 +19,9 @@
 rt_device_t sd_dev;
 #define SECTOR_SIZE 512
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 struct fal_flash_dev sd_card = {
     "sdcard0",  /* name string match yml file */
@@ -31,13 +31,13 @@ struct fal_flash_dev sd_card = {
     {init, read, write, erase}
 };
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
     rt_size_t sector_pos;
     rt_size_t sector_offset;
     rt_size_t remain_size = size;
     rt_size_t req_size;
-    rt_align(4) uint8_t buffer[SECTOR_SIZE];
+    rt_align(4) rt_uint8_t buffer[SECTOR_SIZE];
 
     while (remain_size)
     {
@@ -54,13 +54,13 @@ static int read(long offset, uint8_t *buf, size_t size)
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
     rt_size_t sector_pos;
     rt_size_t sector_offset;
     rt_size_t remain_size = size;
     rt_size_t req_size;
-    rt_align(4) uint8_t buffer[SECTOR_SIZE];
+    rt_align(4) rt_uint8_t buffer[SECTOR_SIZE];
 
     while (remain_size)
     {
@@ -79,7 +79,7 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
     return size;
 }
@@ -93,7 +93,7 @@ static int init(void)
     }
     rt_device_open(sd_dev, RT_DEVICE_OFLAG_RDWR);
     struct dev_sdmmc *dev_sdmmc = (struct dev_sdmmc *)sd_dev->user_data;
-    sd_card.len = (size_t)dev_sdmmc->geometry.bytes_per_sector * dev_sdmmc->geometry.sector_count;
+    sd_card.len = (rt_size_t)dev_sdmmc->geometry.bytes_per_sector * dev_sdmmc->geometry.sector_count;
     sd_card.blk_size = dev_sdmmc->geometry.bytes_per_sector;
 
     return 0;

+ 12 - 12
bsp/hc32/ev_hc32f448_lqfp80/board/ports/fal/fal_flash_sfud_port.c

@@ -21,9 +21,9 @@
 #endif
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static sfud_flash_t sfud_dev = NULL;
 struct fal_flash_dev ext_nor_flash0 =
@@ -51,19 +51,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, ext_nor_flash0.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, ext_nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -72,10 +72,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, ext_nor_flash0.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 12 - 12
bsp/hc32/ev_hc32f460_lqfp100_v2/board/ports/fal/fal_flash_sfud_port.c

@@ -20,9 +20,9 @@
 #endif
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static sfud_flash_t sfud_dev = NULL;
 struct fal_flash_dev ext_nor_flash0 =
@@ -50,19 +50,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, ext_nor_flash0.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, ext_nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -71,10 +71,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, ext_nor_flash0.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 12 - 12
bsp/hc32/ev_hc32f4a0_lqfp176/board/ports/fal/fal_flash_sfud_port.c

@@ -20,9 +20,9 @@
 #endif
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static sfud_flash_t sfud_dev = NULL;
 struct fal_flash_dev ext_nor_flash0 =
@@ -50,19 +50,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, ext_nor_flash0.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, ext_nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -71,10 +71,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, ext_nor_flash0.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 12 - 12
bsp/hc32/lckfb-hc32f4a0-lqfp100/board/ports/fal/fal_flash_sfud_port.c

@@ -20,9 +20,9 @@
 #endif
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static sfud_flash_t sfud_dev = NULL;
 struct fal_flash_dev ext_nor_flash0 =
@@ -50,19 +50,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, ext_nor_flash0.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, ext_nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -71,10 +71,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, ext_nor_flash0.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 12 - 12
bsp/hc32/platform/fal/fal_flash_sfud_nor.c

@@ -25,9 +25,9 @@
 
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 
 static sfud_flash_t sfud_dev = NULL;
@@ -57,19 +57,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, ext_nor_flash0.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, ext_nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -78,10 +78,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, ext_nor_flash0.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 25 - 25
bsp/hpmicro/hpm5300evk/board/fal_flash_port.c

@@ -42,9 +42,9 @@
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -85,9 +85,9 @@ FAL_RAMFUNC static int init(void)
     {
         s_flashcfg.device_info.clk_freq_for_non_read_cmd = 0U;
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -104,12 +104,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -126,7 +126,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -151,21 +151,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -214,17 +214,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 25 - 25
bsp/hpmicro/hpm5301evklite/board/fal_flash_port.c

@@ -42,9 +42,9 @@
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -85,9 +85,9 @@ FAL_RAMFUNC static int init(void)
     {
         s_flashcfg.device_info.clk_freq_for_non_read_cmd = 0U;
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -104,12 +104,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -126,7 +126,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -151,21 +151,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -214,17 +214,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 25 - 25
bsp/hpmicro/hpm6200evk/board/fal_flash_port.c

@@ -42,9 +42,9 @@
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -85,9 +85,9 @@ FAL_RAMFUNC static int init(void)
     {
         s_flashcfg.device_info.clk_freq_for_non_read_cmd = 0U;
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -104,12 +104,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -126,7 +126,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -151,21 +151,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -214,17 +214,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 25 - 25
bsp/hpmicro/hpm6300evk/board/fal_flash_port.c

@@ -42,9 +42,9 @@
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -85,9 +85,9 @@ FAL_RAMFUNC static int init(void)
     {
         s_flashcfg.device_info.clk_freq_for_non_read_cmd = 0U;
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -104,12 +104,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -126,7 +126,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -151,21 +151,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -214,17 +214,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 25 - 25
bsp/hpmicro/hpm6750evk/board/fal_flash_port.c

@@ -56,9 +56,9 @@ static rt_base_t s_interrupt_level;
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -98,9 +98,9 @@ FAL_RAMFUNC static int init(void)
     else
     {
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -117,12 +117,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -139,7 +139,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -164,21 +164,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -227,17 +227,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 25 - 25
bsp/hpmicro/hpm6750evk2/board/fal_flash_port.c

@@ -57,9 +57,9 @@ static rt_base_t s_interrupt_level;
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -99,9 +99,9 @@ FAL_RAMFUNC static int init(void)
     else
     {
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -118,12 +118,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -140,7 +140,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -165,21 +165,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -228,17 +228,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 25 - 25
bsp/hpmicro/hpm6750evkmini/board/fal_flash_port.c

@@ -57,9 +57,9 @@ static rt_base_t s_interrupt_level;
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -99,9 +99,9 @@ FAL_RAMFUNC static int init(void)
     else
     {
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -118,12 +118,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -140,7 +140,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -165,21 +165,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -228,17 +228,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 25 - 25
bsp/hpmicro/hpm6800evk/board/fal_flash_port.c

@@ -57,9 +57,9 @@ static rt_base_t s_interrupt_level;
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -99,9 +99,9 @@ FAL_RAMFUNC static int init(void)
     else
     {
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -118,12 +118,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -140,7 +140,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -165,21 +165,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -228,17 +228,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 25 - 25
bsp/hpmicro/hpm6e00evk/board/fal_flash_port.c

@@ -57,9 +57,9 @@ static rt_base_t s_interrupt_level;
  ***************************************************************************************************/
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static xpi_nor_config_t s_flashcfg;
 
@@ -99,9 +99,9 @@ FAL_RAMFUNC static int init(void)
     else
     {
         /* update the flash chip information */
-        uint32_t sector_size;
+        rt_uint32_t sector_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
-        uint32_t flash_size;
+        rt_uint32_t flash_size;
         rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_total_size, &flash_size);
         nor_flash0.blk_size = sector_size;
         nor_flash0.len = flash_size;
@@ -118,12 +118,12 @@ FAL_RAMFUNC static int init(void)
  * @param size Size of data to be read
  * @return actual read bytes
  */
-FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
+FAL_RAMFUNC static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t flash_addr = nor_flash0.addr + offset;
-    uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
-    uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
-    uint32_t aligned_size = aligned_end - aligned_start;
+    rt_uint32_t flash_addr = nor_flash0.addr + offset;
+    rt_uint32_t aligned_start = HPM_L1C_CACHELINE_ALIGN_DOWN(flash_addr);
+    rt_uint32_t aligned_end = HPM_L1C_CACHELINE_ALIGN_UP(flash_addr + size);
+    rt_uint32_t aligned_size = aligned_end - aligned_start;
     rt_base_t level = rt_hw_interrupt_disable();
     l1c_dc_invalidate(aligned_start, aligned_size);
     rt_hw_interrupt_enable(level);
@@ -140,7 +140,7 @@ FAL_RAMFUNC static int read(long offset, uint8_t *buf, size_t size)
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *buf, size_t size)
+FAL_RAMFUNC static int write_unaligned_page_data(long offset, const rt_uint32_t *buf, rt_size_t size)
 {
     hpm_stat_t status;
 
@@ -165,21 +165,21 @@ FAL_RAMFUNC static int write_unaligned_page_data(long offset, const uint32_t *bu
  * @param size Size of data to be written
  * @return actual size of written data or error code
  */
-FAL_RAMFUNC static int write(long offset, const uint8_t *buf, size_t size)
+FAL_RAMFUNC static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t *src = NULL;
-    uint32_t buf_32[64];
-    uint32_t write_size;
-    size_t remaining_size = size;
+    rt_uint32_t *src = NULL;
+    rt_uint32_t buf_32[64];
+    rt_uint32_t write_size;
+    rt_size_t remaining_size = size;
     int ret = (int)size;
 
-    uint32_t page_size;
+    rt_uint32_t page_size;
     rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_page_size, &page_size);
-    uint32_t offset_in_page = offset % page_size;
+    rt_uint32_t offset_in_page = offset % page_size;
     if (offset_in_page != 0)
     {
-        uint32_t write_size_in_page = page_size - offset_in_page;
-        uint32_t write_page_size = MIN(write_size_in_page, size);
+        rt_uint32_t write_size_in_page = page_size - offset_in_page;
+        rt_uint32_t write_page_size = MIN(write_size_in_page, size);
         (void) rt_memcpy(buf_32, buf, write_page_size);
         write_size = write_unaligned_page_data(offset, buf_32, write_page_size);
         if (write_size < 0)
@@ -228,17 +228,17 @@ write_quit:
  * @ret RT_EOK Erase operation is successful
  * @retval -RT_ERROR Erase operation failed
  */
-FAL_RAMFUNC static int erase(long offset, size_t size)
+FAL_RAMFUNC static int erase(long offset, rt_size_t size)
 {
-    uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
+    rt_uint32_t aligned_size = (size + nor_flash0.blk_size - 1U) & ~(nor_flash0.blk_size - 1U);
     hpm_stat_t status;
     int ret = (int)size;
 
-    uint32_t block_size;
-    uint32_t sector_size;
+    rt_uint32_t block_size;
+    rt_uint32_t sector_size;
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_sector_size, &sector_size);
     (void) rom_xpi_nor_get_property(BOARD_APP_XPI_NOR_XPI_BASE, &s_flashcfg, xpi_nor_property_block_size, &block_size);
-    uint32_t erase_unit;
+    rt_uint32_t erase_unit;
     while (aligned_size > 0)
     {
         FAL_ENTER_CRITICAL();

+ 9 - 9
bsp/nrf5x/libraries/drivers/drv_qspi_flash.c

@@ -35,8 +35,8 @@ static void configure_memory()
 #define QSPI_STD_CMD_RSTEN  0x66
 #define QSPI_STD_CMD_RST    0x99
 
-    uint8_t temporary = 0x40;
-    uint32_t err_code;
+    rt_uint8_t temporary = 0x40;
+    rt_uint32_t err_code;
     nrf_qspi_cinstr_conf_t cinstr_cfg =
     {
         .opcode    = QSPI_STD_CMD_RSTEN,
@@ -75,7 +75,7 @@ static void configure_memory()
 }
 static int init(void)
 {
-    uint32_t err_code;
+    rt_uint32_t err_code;
     nrfx_qspi_config_t config = NRFX_QSPI_DEFAULT_CONFIG(BSP_QSPI_SCK_PIN, BSP_QSPI_CSN_PIN,
                                                          BSP_QSPI_IO0_PIN, BSP_QSPI_IO1_PIN, BSP_QSPI_IO2_PIN, BSP_QSPI_IO3_PIN);
 
@@ -89,9 +89,9 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t err_code;
+    rt_uint32_t err_code;
     m_finished = false;
     err_code = nrfx_qspi_read(buf, size, offset);
     WAIT_FOR_PERIPH();
@@ -106,9 +106,9 @@ static int read(long offset, uint8_t *buf, size_t size)
     }
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t err_code;
+    rt_uint32_t err_code;
     m_finished = false;
     err_code = nrfx_qspi_write(buf, size, offset);
     WAIT_FOR_PERIPH();
@@ -123,9 +123,9 @@ static int write(long offset, const uint8_t *buf, size_t size)
     }
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    uint32_t err_code;
+    rt_uint32_t err_code;
     m_finished = false;
     err_code = nrfx_qspi_erase(NRF_QSPI_ERASE_LEN_64KB, offset);
     WAIT_FOR_PERIPH();

+ 6 - 6
bsp/nxp/lpc/lpc55sxx/lpc55s69_nxp_evk/board/ports/easyflash/ef_fal_port.c

@@ -36,7 +36,7 @@ static const struct fal_partition *part = NULL;
  *
  * @return result
  */
-EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
+EfErrCode ef_port_init(ef_env const **default_env, rt_size_t *default_env_size) {
     EfErrCode result = EF_NO_ERR;
 
     *default_env = default_env_set;
@@ -60,10 +60,10 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
  *
  * @return result
  */
-EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
+EfErrCode ef_port_read(rt_uint32_t addr, rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    fal_partition_read(part, addr, (uint8_t *)buf, size);
+    fal_partition_read(part, addr, (rt_uint8_t *)buf, size);
 
     return result;
 }
@@ -78,7 +78,7 @@ EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_erase(uint32_t addr, size_t size) {
+EfErrCode ef_port_erase(rt_uint32_t addr, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
     /* make sure the start address is a multiple of FLASH_ERASE_MIN_SIZE */
@@ -102,10 +102,10 @@ EfErrCode ef_port_erase(uint32_t addr, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
+EfErrCode ef_port_write(rt_uint32_t addr, const rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    if (fal_partition_write(part, addr, (uint8_t *)buf, size) < 0)
+    if (fal_partition_write(part, addr, (rt_uint8_t *)buf, size) < 0)
     {
         result = EF_WRITE_ERR;
     }

+ 2 - 2
bsp/nxp/lpc/lpc55sxx/lpc55s69_nxp_evk/board/ports/fal/fal_sample.c

@@ -26,7 +26,7 @@ static int fal_test(const char *partiton_name)
 {
     int ret;
     int i, j, len;
-    uint8_t buf[BUF_SIZE];
+    rt_uint8_t buf[BUF_SIZE];
     const struct fal_flash_dev *flash_dev = RT_NULL;
     const struct fal_partition *partition = RT_NULL;
 
@@ -241,7 +241,7 @@ static void easyflash_sample(void)
     /* easyflash init */
     if(easyflash_init() == EF_NO_ERR)
     {
-        uint32_t i_boot_times = NULL;
+        rt_uint32_t i_boot_times = NULL;
         char *c_old_boot_times, c_new_boot_times[11] = {0};
 
         /* get the boot count number from Env */

+ 12 - 12
bsp/stm32/stm32f407-atk-explorer/board/ports/fal/fal_spi_flash_sfud_port.c

@@ -16,9 +16,9 @@
 #endif
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static sfud_flash_t sfud_dev = NULL;
 struct fal_flash_dev w25q128 =
@@ -46,19 +46,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, w25q128.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, w25q128.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -67,10 +67,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, w25q128.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 6 - 6
bsp/stm32/stm32f407-lckfb-skystar/board/ports/ef_fal_port.c

@@ -57,7 +57,7 @@ static const struct fal_partition *part = NULL;
  *
  * @return result
  */
-EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
+EfErrCode ef_port_init(ef_env const **default_env, rt_size_t *default_env_size) {
     EfErrCode result = EF_NO_ERR;
 
     *default_env = default_env_set;
@@ -81,10 +81,10 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
  *
  * @return result
  */
-EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
+EfErrCode ef_port_read(rt_uint32_t addr, rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    fal_partition_read(part, addr, (uint8_t *)buf, size);
+    fal_partition_read(part, addr, (rt_uint8_t *)buf, size);
 
     return result;
 }
@@ -99,7 +99,7 @@ EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_erase(uint32_t addr, size_t size) {
+EfErrCode ef_port_erase(rt_uint32_t addr, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
     /* make sure the start address is a multiple of FLASH_ERASE_MIN_SIZE */
@@ -123,10 +123,10 @@ EfErrCode ef_port_erase(uint32_t addr, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
+EfErrCode ef_port_write(rt_uint32_t addr, const rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    if (fal_partition_write(part, addr, (uint8_t *)buf, size) < 0)
+    if (fal_partition_write(part, addr, (rt_uint8_t *)buf, size) < 0)
     {
         result = EF_WRITE_ERR;
     }

+ 12 - 12
bsp/stm32/stm32f407-lckfb-skystar/board/ports/fal/fal_spi_flash_sfud_port.c

@@ -16,9 +16,9 @@
 #endif
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static sfud_flash_t sfud_dev = NULL;
 struct fal_flash_dev w25q128 =
@@ -46,19 +46,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, w25q128.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, w25q128.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -67,10 +67,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, w25q128.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 6 - 6
bsp/stm32/stm32f407-rt-spark/board/ports/ef_fal_port.c

@@ -57,7 +57,7 @@ static const struct fal_partition *part = NULL;
  *
  * @return result
  */
-EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
+EfErrCode ef_port_init(ef_env const **default_env, rt_size_t *default_env_size) {
     EfErrCode result = EF_NO_ERR;
 
     *default_env = default_env_set;
@@ -81,10 +81,10 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
  *
  * @return result
  */
-EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
+EfErrCode ef_port_read(rt_uint32_t addr, rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    fal_partition_read(part, addr, (uint8_t *)buf, size);
+    fal_partition_read(part, addr, (rt_uint8_t *)buf, size);
 
     return result;
 }
@@ -99,7 +99,7 @@ EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_erase(uint32_t addr, size_t size) {
+EfErrCode ef_port_erase(rt_uint32_t addr, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
     /* make sure the start address is a multiple of FLASH_ERASE_MIN_SIZE */
@@ -123,10 +123,10 @@ EfErrCode ef_port_erase(uint32_t addr, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
+EfErrCode ef_port_write(rt_uint32_t addr, const rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    if (fal_partition_write(part, addr, (uint8_t *)buf, size) < 0)
+    if (fal_partition_write(part, addr, (rt_uint8_t *)buf, size) < 0)
     {
         result = EF_WRITE_ERR;
     }

+ 12 - 12
bsp/stm32/stm32f407-rt-spark/board/ports/fal/fal_spi_flash_sfud_port.c

@@ -16,9 +16,9 @@
 #endif
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static sfud_flash_t sfud_dev = NULL;
 struct fal_flash_dev w25q64 =
@@ -46,19 +46,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, w25q64.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, w25q64.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -67,10 +67,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, w25q64.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 6 - 6
bsp/stm32/stm32h750-artpi/board/port/ef_fal_port.c

@@ -55,7 +55,7 @@ static const struct fal_partition *part = NULL;
  *
  * @return result
  */
-EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
+EfErrCode ef_port_init(ef_env const **default_env, rt_size_t *default_env_size) {
     EfErrCode result = EF_NO_ERR;
 
     *default_env = default_env_set;
@@ -79,10 +79,10 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
  *
  * @return result
  */
-EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
+EfErrCode ef_port_read(rt_uint32_t addr, rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    fal_partition_read(part, addr, (uint8_t *)buf, size);
+    fal_partition_read(part, addr, (rt_uint8_t *)buf, size);
 
     return result;
 }
@@ -97,7 +97,7 @@ EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_erase(uint32_t addr, size_t size) {
+EfErrCode ef_port_erase(rt_uint32_t addr, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
     /* make sure the start address is a multiple of FLASH_ERASE_MIN_SIZE */
@@ -121,10 +121,10 @@ EfErrCode ef_port_erase(uint32_t addr, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
+EfErrCode ef_port_write(rt_uint32_t addr, const rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    if (fal_partition_write(part, addr, (uint8_t *)buf, size) < 0)
+    if (fal_partition_write(part, addr, (rt_uint8_t *)buf, size) < 0)
     {
         result = EF_WRITE_ERR;
     }

+ 12 - 12
bsp/stm32/stm32h750-weact-ministm32h7xx/board/port/drv_qspi_flash.c

@@ -35,9 +35,9 @@
 static sfud_flash_t sfud_dev = NULL;
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 struct fal_flash_dev nor_flash1 =
 {
@@ -73,19 +73,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, nor_flash1.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, nor_flash1.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -94,10 +94,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, nor_flash1.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 6 - 6
bsp/stm32/stm32l475-atk-pandora/board/ports/easyflash/ef_fal_port.c

@@ -37,7 +37,7 @@ static const struct fal_partition *part = NULL;
  *
  * @return result
  */
-EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
+EfErrCode ef_port_init(ef_env const **default_env, rt_size_t *default_env_size) {
     EfErrCode result = EF_NO_ERR;
 
     *default_env = default_env_set;
@@ -61,10 +61,10 @@ EfErrCode ef_port_init(ef_env const **default_env, size_t *default_env_size) {
  *
  * @return result
  */
-EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
+EfErrCode ef_port_read(rt_uint32_t addr, rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    fal_partition_read(part, addr, (uint8_t *)buf, size);
+    fal_partition_read(part, addr, (rt_uint8_t *)buf, size);
 
     return result;
 }
@@ -79,7 +79,7 @@ EfErrCode ef_port_read(uint32_t addr, uint32_t *buf, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_erase(uint32_t addr, size_t size) {
+EfErrCode ef_port_erase(rt_uint32_t addr, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
     /* make sure the start address is a multiple of FLASH_ERASE_MIN_SIZE */
@@ -103,10 +103,10 @@ EfErrCode ef_port_erase(uint32_t addr, size_t size) {
  *
  * @return result
  */
-EfErrCode ef_port_write(uint32_t addr, const uint32_t *buf, size_t size) {
+EfErrCode ef_port_write(rt_uint32_t addr, const rt_uint32_t *buf, rt_size_t size) {
     EfErrCode result = EF_NO_ERR;
 
-    if (fal_partition_write(part, addr, (uint8_t *)buf, size) < 0)
+    if (fal_partition_write(part, addr, (rt_uint8_t *)buf, size) < 0)
     {
         result = EF_WRITE_ERR;
     }

+ 3 - 3
bsp/stm32/stm32l475-atk-pandora/board/ports/fal/fal_flash_sfud_port.c

@@ -29,14 +29,14 @@ static int fal_sfud_init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
     sfud_read(&sfud_norflash0, nor_flash0.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
     if (sfud_write(&sfud_norflash0, nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
     {
@@ -46,7 +46,7 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
     if (sfud_erase(&sfud_norflash0, nor_flash0.addr + offset, size) != SFUD_SUCCESS)
     {

+ 12 - 12
bsp/yichip/yc3122-pos/drivers/ports/fal_flash_yc3122_port.c

@@ -13,10 +13,10 @@
 #include "yc_qspi.h"
 #include "rtdbg.h"
 
-#define FLASH_START_ADRESS ((uint32_t)0x1000000)
-#define FLASH_SIZE ((uint32_t)4 * 1024 * 1024)
-#define FLASH_BLOCK_SIZE ((uint32_t)512)
-#define FLASH_END_ADDRESS ((uint32_t)(FLASH_START_ADRESS + FLASH_SIZE))
+#define FLASH_START_ADRESS ((rt_uint32_t)0x1000000)
+#define FLASH_SIZE ((rt_uint32_t)4 * 1024 * 1024)
+#define FLASH_BLOCK_SIZE ((rt_uint32_t)512)
+#define FLASH_END_ADDRESS ((rt_uint32_t)(FLASH_START_ADRESS + FLASH_SIZE))
 #define FLASH_PAGE_NBPERBANK 256
 #define FLASH_BANK_NUMBER 2
 #define FLASH_PAGE_SIZE 256
@@ -26,9 +26,9 @@
 #else
     #define YC3122_FLASH_DEBUG(...)
 #endif
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t addr = yc3122_onchip_flash.addr + offset;
+    rt_uint32_t addr = yc3122_onchip_flash.addr + offset;
 
     if ((addr + size) > FLASH_END_ADDRESS)
     {
@@ -40,9 +40,9 @@ static int read(long offset, uint8_t *buf, size_t size)
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    uint32_t addr = yc3122_onchip_flash.addr + offset;
+    rt_uint32_t addr = yc3122_onchip_flash.addr + offset;
 
     if ((addr + size) > FLASH_END_ADDRESS)
     {
@@ -54,14 +54,14 @@ static int write(long offset, const uint8_t *buf, size_t size)
         return -1;
     }
     YC3122_FLASH_DEBUG("w_ addr:0x%x,size:0x%x\n", addr, size);
-    qspi_flash_write(addr, (uint8_t *)buf, size);
+    qspi_flash_write(addr, (rt_uint8_t *)buf, size);
 
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    uint32_t addr = yc3122_onchip_flash.addr + offset;
+    rt_uint32_t addr = yc3122_onchip_flash.addr + offset;
     if ((addr + size) > FLASH_END_ADDRESS || addr % 0x100 != 0)
     {
         YC3122_FLASH_DEBUG("ERROR: erase outrange flash size! addr is (0x%p)\n", (void *)(addr + size));
@@ -72,7 +72,7 @@ static int erase(long offset, size_t size)
     {
         YC3122_FLASH_DEBUG("ERROR: erase addr is not page alignment\n");
     }
-    for (uint32_t i = 0; i < size; i += 256)
+    for (rt_uint32_t i = 0; i < size; i += 256)
         qspi_flash_pageerase(addr + i);
     return size;
 }

+ 3 - 7
components/fal/Kconfig

@@ -5,14 +5,10 @@ menuconfig RT_USING_FAL
     default n
 
 if RT_USING_FAL
-    config FAL_DEBUG_CONFIG
+    config FAL_USING_DEBUG
         bool "Enable debug log output"
-        default y
-
-    config FAL_DEBUG
-       int
-       default 1    if FAL_DEBUG_CONFIG
-       default 0
+        default y if RT_USING_DEBUG
+        default n
 
     config FAL_PART_HAS_TABLE_CFG
         bool "FAL partition table config has defined on 'fal_cfg.h'"

+ 5 - 5
components/fal/docs/fal_api.md

@@ -25,7 +25,7 @@ const struct fal_partition *fal_partition_find(const char *name)
 ## 获取分区表
 
 ```C
-const struct fal_partition *fal_get_partition_table(size_t *len)
+const struct fal_partition *fal_get_partition_table(rt_size_t *len)
 ```
 
 | 参数    | 描述                      |
@@ -38,7 +38,7 @@ const struct fal_partition *fal_get_partition_table(size_t *len)
 FAL 初始化时会自动装载默认分区表。使用该设置将临时修改分区表,重启后会 **丢失** 该设置
 
 ```C
-void fal_set_partition_table_temp(struct fal_partition *table, size_t len)
+void fal_set_partition_table_temp(struct fal_partition *table, rt_size_t len)
 ```
 
 | 参数    | 描述                      |
@@ -49,7 +49,7 @@ void fal_set_partition_table_temp(struct fal_partition *table, size_t len)
 ## 从分区读取数据
 
 ```C
-int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t *buf, size_t size)
+int fal_partition_read(const struct fal_partition *part, rt_uint32_t addr, rt_uint8_t *buf, rt_size_t size)
 ```
 
 | 参数    | 描述                      |
@@ -63,7 +63,7 @@ int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t
 ## 往分区写入数据
 
 ```C
-int fal_partition_write(const struct fal_partition *part, uint32_t addr, const uint8_t *buf, size_t size)
+int fal_partition_write(const struct fal_partition *part, rt_uint32_t addr, const rt_uint8_t *buf, rt_size_t size)
 ```
 
 | 参数    | 描述                      |
@@ -77,7 +77,7 @@ int fal_partition_write(const struct fal_partition *part, uint32_t addr, const u
 ## 擦除分区数据
 
 ```C
-int fal_partition_erase(const struct fal_partition *part, uint32_t addr, size_t size)
+int fal_partition_erase(const struct fal_partition *part, rt_uint32_t addr, rt_size_t size)
 ```
 
 | 参数    | 描述                      |

+ 5 - 5
components/fal/docs/fal_api_en.md

@@ -25,7 +25,7 @@ const struct fal_partition *fal_partition_find(const char *name)
 ## Get the partition table
 
 ```C
-const struct fal_partition *fal_get_partition_table(size_t *len)
+const struct fal_partition *fal_get_partition_table(rt_size_t *len)
 ```
 
 | Parameters | Description |
@@ -38,7 +38,7 @@ const struct fal_partition *fal_get_partition_table(size_t *len)
 The default partition table will be automatically loaded when FAL is initialized. Using this setting will temporarily modify the partition table and will **lost** this setting after restarting
 
 ```C
-void fal_set_partition_table_temp(struct fal_partition *table, size_t len)
+void fal_set_partition_table_temp(struct fal_partition *table, rt_size_t len)
 ```
 
 | Parameters | Description |
@@ -49,7 +49,7 @@ void fal_set_partition_table_temp(struct fal_partition *table, size_t len)
 ## Read data from partition
 
 ```C
-int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t *buf, size_t size)
+int fal_partition_read(const struct fal_partition *part, rt_uint32_t addr, rt_uint8_t *buf, rt_size_t size)
 ```
 
 | Parameters | Description |
@@ -63,7 +63,7 @@ int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t
 ## Write data to partition
 
 ```C
-int fal_partition_write(const struct fal_partition *part, uint32_t addr, const uint8_t *buf, size_t size)
+int fal_partition_write(const struct fal_partition *part, rt_uint32_t addr, const rt_uint8_t *buf, rt_size_t size)
 ```
 
 | Parameters | Description |
@@ -77,7 +77,7 @@ int fal_partition_write(const struct fal_partition *part, uint32_t addr, const u
 ## Erase partition data
 
 ```C
-int fal_partition_erase(const struct fal_partition *part, uint32_t addr, size_t size)
+int fal_partition_erase(const struct fal_partition *part, rt_uint32_t addr, rt_size_t size)
 ```
 
 | Parameters | Description |

+ 5 - 5
components/fal/inc/fal.h

@@ -56,7 +56,7 @@ const struct fal_partition *fal_partition_find(const char *name);
  *
  * @return partition table
  */
-const struct fal_partition *fal_get_partition_table(size_t *len);
+const struct fal_partition *fal_get_partition_table(rt_size_t *len);
 
 /**
  * set partition table temporarily
@@ -65,7 +65,7 @@ const struct fal_partition *fal_get_partition_table(size_t *len);
  * @param table partition table
  * @param len partition table length
  */
-void fal_set_partition_table_temp(struct fal_partition *table, size_t len);
+void fal_set_partition_table_temp(struct fal_partition *table, rt_size_t len);
 
 /**
  * read data from partition
@@ -78,7 +78,7 @@ void fal_set_partition_table_temp(struct fal_partition *table, size_t len);
  * @return >= 0: successful read data size
  *           -1: error
  */
-int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t *buf, size_t size);
+int fal_partition_read(const struct fal_partition *part, rt_uint32_t addr, rt_uint8_t *buf, rt_size_t size);
 
 /**
  * write data to partition
@@ -91,7 +91,7 @@ int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t
  * @return >= 0: successful write data size
  *           -1: error
  */
-int fal_partition_write(const struct fal_partition *part, uint32_t addr, const uint8_t *buf, size_t size);
+int fal_partition_write(const struct fal_partition *part, rt_uint32_t addr, const rt_uint8_t *buf, rt_size_t size);
 
 /**
  * erase partition data
@@ -103,7 +103,7 @@ int fal_partition_write(const struct fal_partition *part, uint32_t addr, const u
  * @return >= 0: successful erased data size
  *           -1: error
  */
-int fal_partition_erase(const struct fal_partition *part, uint32_t addr, size_t size);
+int fal_partition_erase(const struct fal_partition *part, rt_uint32_t addr, rt_size_t size);
 
 /**
  * erase partition all data

+ 12 - 67
components/fal/inc/fal_def.h

@@ -11,63 +11,8 @@
 #ifndef _FAL_DEF_H_
 #define _FAL_DEF_H_
 
-#include <stdint.h>
-#include <stdio.h>
 #include <rtthread.h>
 
-#define FAL_PRINTF      rt_kprintf
-#define FAL_MALLOC      rt_malloc
-#define FAL_CALLOC      rt_calloc
-#define FAL_REALLOC     rt_realloc
-#define FAL_FREE        rt_free
-
-#ifndef FAL_DEBUG
-#define FAL_DEBUG                      0
-#endif
-
-#if FAL_DEBUG
-#ifdef assert
-#undef assert
-#endif
-#define assert(EXPR)                                                           \
-if (!(EXPR))                                                                   \
-{                                                                              \
-    FAL_PRINTF("(%s) has assert failed at %s.\n", #EXPR, __FUNCTION__);        \
-    while (1);                                                                 \
-}
-
-/* debug level log */
-#ifdef  log_d
-#undef  log_d
-#endif
-#define log_d(...)                     FAL_PRINTF("[D/FAL] (%s:%d) ", __FUNCTION__, __LINE__);           FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\n")
-
-#else
-
-#ifdef assert
-#undef assert
-#endif
-#define assert(EXPR)                   ((void)0);
-
-/* debug level log */
-#ifdef  log_d
-#undef  log_d
-#endif
-#define log_d(...)
-#endif /* FAL_DEBUG */
-
-/* error level log */
-#ifdef  log_e
-#undef  log_e
-#endif
-#define log_e(...)                     FAL_PRINTF("\033[31;22m[E/FAL] (%s:%d) ", __FUNCTION__, __LINE__);FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\033[0m\n")
-
-/* info level log */
-#ifdef  log_i
-#undef  log_i
-#endif
-#define log_i(...)                     FAL_PRINTF("\033[32;22m[I/FAL] ");                                FAL_PRINTF(__VA_ARGS__);FAL_PRINTF("\033[0m\n")
-
 /* FAL flash and partition device name max length */
 #ifndef FAL_DEV_NAME_MAX
 #define FAL_DEV_NAME_MAX 24
@@ -79,8 +24,8 @@ if (!(EXPR))                                                                   \
 
 struct flash_blk
 {
-    size_t size;
-    size_t count;
+    rt_size_t size;
+    rt_size_t count;
 };
 
 struct fal_flash_dev
@@ -88,23 +33,23 @@ struct fal_flash_dev
     char name[FAL_DEV_NAME_MAX];
 
     /* flash device start address and len  */
-    uint32_t addr;
-    size_t len;
+    rt_uint32_t addr;
+    rt_size_t len;
     /* the block size in the flash for erase minimum granularity */
-    size_t blk_size;
+    rt_size_t blk_size;
 
     struct
     {
         int (*init)(void);
-        int (*read)(long offset, uint8_t *buf, size_t size);
-        int (*write)(long offset, const uint8_t *buf, size_t size);
-        int (*erase)(long offset, size_t size);
+        int (*read)(long offset, rt_uint8_t *buf, rt_size_t size);
+        int (*write)(long offset, const rt_uint8_t *buf, rt_size_t size);
+        int (*erase)(long offset, rt_size_t size);
     } ops;
 
     /* write minimum granularity, unit: bit.
        1(nor flash)/ 8(stm32f2/f4)/ 32(stm32f1)/ 64(stm32l4)
        0 will not take effect. */
-    size_t write_gran;
+    rt_size_t write_gran;
     struct flash_blk blocks[FAL_DEV_BLK_MAX];
 };
 typedef struct fal_flash_dev *fal_flash_dev_t;
@@ -114,7 +59,7 @@ typedef struct fal_flash_dev *fal_flash_dev_t;
  */
 struct fal_partition
 {
-    uint32_t magic_word;
+    rt_uint32_t magic_word;
 
     /* partition name */
     char name[FAL_DEV_NAME_MAX];
@@ -123,9 +68,9 @@ struct fal_partition
 
     /* partition offset address on flash device */
     long offset;
-    size_t len;
+    rt_size_t len;
 
-    uint32_t reserved;
+    rt_uint32_t reserved;
 };
 typedef struct fal_partition *fal_partition_t;
 

+ 3 - 3
components/fal/samples/porting/README.md

@@ -12,7 +12,7 @@
 
 - `static int init(void)`:**可选** 的初始化操作
 
-- `static int read(long offset, uint8_t *buf, size_t size)`:读取操作
+- `static int read(long offset, rt_uint8_t *buf, rt_size_t size)`:读取操作
 
 |参数                                    |描述|
 |:-----                                  |:----|
@@ -21,7 +21,7 @@
 |size                                    |待读取数据的大小|
 |return                                  |返回实际读取的数据大小|
 
-- `static int write(long offset, const uint8_t *buf, size_t size)` :写入操作
+- `static int write(long offset, const rt_uint8_t *buf, rt_size_t size)` :写入操作
 
 | 参数   | 描述                      |
 | :----- | :------------------------ |
@@ -30,7 +30,7 @@
 | size   | 待写入数据的大小          |
 | return | 返回实际写入的数据大小    |
 
-- `static int erase(long offset, size_t size)` :擦除操作
+- `static int erase(long offset, rt_size_t size)` :擦除操作
 
 | 参数   | 描述                      |
 | :----- | :------------------------ |

+ 12 - 12
components/fal/samples/porting/fal_flash_sfud_port.c

@@ -21,9 +21,9 @@
 #endif
 
 static int init(void);
-static int read(long offset, uint8_t *buf, size_t size);
-static int write(long offset, const uint8_t *buf, size_t size);
-static int erase(long offset, size_t size);
+static int read(long offset, rt_uint8_t *buf, rt_size_t size);
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size);
+static int erase(long offset, rt_size_t size);
 
 static sfud_flash_t sfud_dev = NULL;
 struct fal_flash_dev nor_flash0 =
@@ -60,19 +60,19 @@ static int init(void)
     return 0;
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     sfud_read(sfud_dev, nor_flash0.addr + offset, size, buf);
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_write(sfud_dev, nor_flash0.addr + offset, size, buf) != SFUD_SUCCESS)
     {
         return -1;
@@ -81,10 +81,10 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
-    assert(sfud_dev);
-    assert(sfud_dev->init_ok);
+    RT_ASSERT(sfud_dev);
+    RT_ASSERT(sfud_dev->init_ok);
     if (sfud_erase(sfud_dev, nor_flash0.addr + offset, size) != SFUD_SUCCESS)
     {
         return -1;

+ 29 - 29
components/fal/samples/porting/fal_flash_stm32f2_port.c

@@ -13,18 +13,18 @@
 #include <stm32f2xx.h>
 
 /* base address of the flash sectors */
-#define ADDR_FLASH_SECTOR_0      ((uint32_t)0x08000000) /* Base address of Sector 0, 16 K bytes   */
-#define ADDR_FLASH_SECTOR_1      ((uint32_t)0x08004000) /* Base address of Sector 1, 16 K bytes   */
-#define ADDR_FLASH_SECTOR_2      ((uint32_t)0x08008000) /* Base address of Sector 2, 16 K bytes   */
-#define ADDR_FLASH_SECTOR_3      ((uint32_t)0x0800C000) /* Base address of Sector 3, 16 K bytes   */
-#define ADDR_FLASH_SECTOR_4      ((uint32_t)0x08010000) /* Base address of Sector 4, 64 K bytes   */
-#define ADDR_FLASH_SECTOR_5      ((uint32_t)0x08020000) /* Base address of Sector 5, 128 K bytes  */
-#define ADDR_FLASH_SECTOR_6      ((uint32_t)0x08040000) /* Base address of Sector 6, 128 K bytes  */
-#define ADDR_FLASH_SECTOR_7      ((uint32_t)0x08060000) /* Base address of Sector 7, 128 K bytes  */
-#define ADDR_FLASH_SECTOR_8      ((uint32_t)0x08080000) /* Base address of Sector 8, 128 K bytes  */
-#define ADDR_FLASH_SECTOR_9      ((uint32_t)0x080A0000) /* Base address of Sector 9, 128 K bytes  */
-#define ADDR_FLASH_SECTOR_10     ((uint32_t)0x080C0000) /* Base address of Sector 10, 128 K bytes */
-#define ADDR_FLASH_SECTOR_11     ((uint32_t)0x080E0000) /* Base address of Sector 11, 128 K bytes */
+#define ADDR_FLASH_SECTOR_0      ((rt_uint32_t)0x08000000) /* Base address of Sector 0, 16 K bytes   */
+#define ADDR_FLASH_SECTOR_1      ((rt_uint32_t)0x08004000) /* Base address of Sector 1, 16 K bytes   */
+#define ADDR_FLASH_SECTOR_2      ((rt_uint32_t)0x08008000) /* Base address of Sector 2, 16 K bytes   */
+#define ADDR_FLASH_SECTOR_3      ((rt_uint32_t)0x0800C000) /* Base address of Sector 3, 16 K bytes   */
+#define ADDR_FLASH_SECTOR_4      ((rt_uint32_t)0x08010000) /* Base address of Sector 4, 64 K bytes   */
+#define ADDR_FLASH_SECTOR_5      ((rt_uint32_t)0x08020000) /* Base address of Sector 5, 128 K bytes  */
+#define ADDR_FLASH_SECTOR_6      ((rt_uint32_t)0x08040000) /* Base address of Sector 6, 128 K bytes  */
+#define ADDR_FLASH_SECTOR_7      ((rt_uint32_t)0x08060000) /* Base address of Sector 7, 128 K bytes  */
+#define ADDR_FLASH_SECTOR_8      ((rt_uint32_t)0x08080000) /* Base address of Sector 8, 128 K bytes  */
+#define ADDR_FLASH_SECTOR_9      ((rt_uint32_t)0x080A0000) /* Base address of Sector 9, 128 K bytes  */
+#define ADDR_FLASH_SECTOR_10     ((rt_uint32_t)0x080C0000) /* Base address of Sector 10, 128 K bytes */
+#define ADDR_FLASH_SECTOR_11     ((rt_uint32_t)0x080E0000) /* Base address of Sector 11, 128 K bytes */
 
 /**
  * Get the sector of a given address
@@ -33,9 +33,9 @@
  *
  * @return The sector of a given address
  */
-static uint32_t stm32_get_sector(uint32_t address)
+static rt_uint32_t stm32_get_sector(rt_uint32_t address)
 {
-    uint32_t sector = 0;
+    rt_uint32_t sector = 0;
 
     if ((address < ADDR_FLASH_SECTOR_1) && (address >= ADDR_FLASH_SECTOR_0))
     {
@@ -96,8 +96,8 @@ static uint32_t stm32_get_sector(uint32_t address)
  *
  * @return sector size
  */
-static uint32_t stm32_get_sector_size(uint32_t sector) {
-    assert(IS_FLASH_SECTOR(sector));
+static rt_uint32_t stm32_get_sector_size(rt_uint32_t sector) {
+    RT_ASSERT(IS_FLASH_SECTOR(sector));
 
     switch (sector) {
     case FLASH_Sector_0: return 16 * 1024;
@@ -120,23 +120,23 @@ static int init(void)
     /* do nothing now */
 }
 
-static int read(long offset, uint8_t *buf, size_t size)
+static int read(long offset, rt_uint8_t *buf, rt_size_t size)
 {
-    size_t i;
-    uint32_t addr = stm32f2_onchip_flash.addr + offset;
+    rt_size_t i;
+    rt_uint32_t addr = stm32f2_onchip_flash.addr + offset;
     for (i = 0; i < size; i++, addr++, buf++)
     {
-        *buf = *(uint8_t *) addr;
+        *buf = *(rt_uint8_t *) addr;
     }
 
     return size;
 }
 
-static int write(long offset, const uint8_t *buf, size_t size)
+static int write(long offset, const rt_uint8_t *buf, rt_size_t size)
 {
-    size_t i;
-    uint32_t read_data;
-    uint32_t addr = stm32f2_onchip_flash.addr + offset;
+    rt_size_t i;
+    rt_uint32_t read_data;
+    rt_uint32_t addr = stm32f2_onchip_flash.addr + offset;
 
     FLASH_Unlock();
     FLASH_ClearFlag(
@@ -146,7 +146,7 @@ static int write(long offset, const uint8_t *buf, size_t size)
     {
         /* write data */
         FLASH_ProgramByte(addr, *buf);
-        read_data = *(uint8_t *) addr;
+        read_data = *(rt_uint8_t *) addr;
         /* check data */
         if (read_data != *buf)
         {
@@ -158,12 +158,12 @@ static int write(long offset, const uint8_t *buf, size_t size)
     return size;
 }
 
-static int erase(long offset, size_t size)
+static int erase(long offset, rt_size_t size)
 {
     FLASH_Status flash_status;
-    size_t erased_size = 0;
-    uint32_t cur_erase_sector;
-    uint32_t addr = stm32f2_onchip_flash.addr + offset;
+    rt_size_t erased_size = 0;
+    rt_uint32_t cur_erase_sector;
+    rt_uint32_t addr = stm32f2_onchip_flash.addr + offset;
 
     /* start erase */
     FLASH_Unlock();

+ 12 - 3
components/fal/src/fal.c

@@ -9,8 +9,17 @@
  */
 
 #include <fal.h>
+#include <rtdevice.h>
 
-static uint8_t init_ok = 0;
+#define DBG_TAG "FAL"
+#ifdef FAL_USING_DEBUG
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif
+#include <rtdbg.h>
+
+static rt_uint8_t init_ok = 0;
 
 /**
  * FAL (Flash Abstraction Layer) initialization.
@@ -40,12 +49,12 @@ __exit:
     if ((result > 0) && (!init_ok))
     {
         init_ok = 1;
-        log_i("RT-Thread Flash Abstraction Layer initialize success.");
+        LOG_I("RT-Thread Flash Abstraction Layer initialize success.");
     }
     else if(result <= 0)
     {
         init_ok = 0;
-        log_e("RT-Thread Flash Abstraction Layer initialize failed.");
+        LOG_E("RT-Thread Flash Abstraction Layer initialize failed.");
     }
 
     return result;

+ 21 - 13
components/fal/src/fal_flash.c

@@ -11,14 +11,22 @@
 #include <fal.h>
 #include <string.h>
 
+#define DBG_TAG "FAL"
+#ifdef FAL_USING_DEBUG
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif
+#include <rtdbg.h>
+
 /* flash device table, must defined by user */
 #if !defined(FAL_FLASH_DEV_TABLE)
 #error "You must defined flash device table (FAL_FLASH_DEV_TABLE) on 'fal_cfg.h'"
 #endif
 
 static const struct fal_flash_dev * const device_table[] = FAL_FLASH_DEV_TABLE;
-static const size_t device_table_len = sizeof(device_table) / sizeof(device_table[0]);
-static uint8_t init_ok = 0;
+static const rt_size_t device_table_len = sizeof(device_table) / sizeof(device_table[0]);
+static rt_uint8_t init_ok = 0;
 
 /**
  * Initialize all flash device on FAL flash table
@@ -27,7 +35,7 @@ static uint8_t init_ok = 0;
  */
 int fal_flash_init(void)
 {
-    size_t i, j, offset;
+    rt_size_t i, j, offset;
 
     if (init_ok)
     {
@@ -36,33 +44,33 @@ int fal_flash_init(void)
 
     for (i = 0; i < device_table_len; i++)
     {
-        assert(device_table[i]->ops.read);
-        assert(device_table[i]->ops.write);
-        assert(device_table[i]->ops.erase);
+        RT_ASSERT(device_table[i]->ops.read);
+        RT_ASSERT(device_table[i]->ops.write);
+        RT_ASSERT(device_table[i]->ops.erase);
         /* init flash device on flash table */
         if (device_table[i]->ops.init)
         {
             device_table[i]->ops.init();
         }
-        log_d("Flash device | %*.*s | addr: 0x%08lx | len: 0x%08x | blk_size: 0x%08x |initialized finish.",
+        LOG_D("Flash device | %*.*s | addr: 0x%08lx | len: 0x%08x | blk_size: 0x%08x |initialized finish.",
                 FAL_DEV_NAME_MAX, FAL_DEV_NAME_MAX, device_table[i]->name, device_table[i]->addr, device_table[i]->len,
                 device_table[i]->blk_size);
         offset = 0;
         for (j = 0; j < FAL_DEV_BLK_MAX; j ++)
         {
             const struct flash_blk *blk = &device_table[i]->blocks[j];
-            size_t blk_len = blk->count * blk->size;
+            rt_size_t blk_len = blk->count * blk->size;
             if (blk->count == 0 || blk->size == 0)
                 break;
 
             if(offset > device_table[i]->len)
             {
-                log_i("Flash device %*.*s: add block failed, offset %d > len %d.",
+                LOG_I("Flash device %*.*s: add block failed, offset %d > len %d.",
                 FAL_DEV_NAME_MAX, FAL_DEV_NAME_MAX, device_table[i]->name, device_table[i]->addr, offset, device_table[i]->len);
                 break;
             }
 
-            log_d("                  blk%2d | addr: 0x%08lx | len: 0x%08x | blk_size: 0x%08x |initialized finish.",
+            LOG_D("                  blk%2d | addr: 0x%08lx | len: 0x%08x | blk_size: 0x%08x |initialized finish.",
                     j, device_table[i]->addr + offset, blk_len, blk->size);
             offset += blk_len;
         }
@@ -82,10 +90,10 @@ int fal_flash_init(void)
  */
 const struct fal_flash_dev *fal_flash_device_find(const char *name)
 {
-    assert(init_ok);
-    assert(name);
+    RT_ASSERT(init_ok);
+    RT_ASSERT(name);
 
-    size_t i;
+    rt_size_t i;
 
     for (i = 0; i < device_table_len; i++)
     {

+ 67 - 59
components/fal/src/fal_partition.c

@@ -10,7 +10,15 @@
 
 #include <fal.h>
 #include <string.h>
-#include <stdlib.h>
+
+#define DBG_TAG "FAL"
+#ifdef FAL_USING_DEBUG
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif
+#include <rtdbg.h>
+
 
 /* partition magic word */
 #define FAL_PART_MAGIC_WORD         0x45503130
@@ -55,8 +63,8 @@ static struct fal_partition *partition_table = NULL;
 static struct part_flash_info *part_flash_cache = NULL;
 #endif /* FAL_PART_HAS_TABLE_CFG */
 
-static uint8_t init_ok = 0;
-static size_t partition_table_len = 0;
+static rt_uint8_t init_ok = 0;
+static rt_size_t partition_table_len = 0;
 
 /**
  * print the partition table
@@ -64,7 +72,7 @@ static size_t partition_table_len = 0;
 void fal_show_part_table(void)
 {
     char *item1 = "name", *item2 = "flash_dev";
-    size_t i, part_name_max = strlen(item1), flash_dev_name_max = strlen(item2);
+    rt_size_t i, part_name_max = strlen(item1), flash_dev_name_max = strlen(item2);
     const struct fal_partition *part;
 
     if (partition_table_len)
@@ -82,10 +90,10 @@ void fal_show_part_table(void)
             }
         }
     }
-    log_i("==================== FAL partition table ====================");
-    log_i("| %-*.*s | %-*.*s |   offset   |    length  |", part_name_max, FAL_DEV_NAME_MAX, item1, flash_dev_name_max,
+    LOG_I("==================== FAL partition table ====================");
+    LOG_I("| %-*.*s | %-*.*s |   offset   |    length  |", part_name_max, FAL_DEV_NAME_MAX, item1, flash_dev_name_max,
             FAL_DEV_NAME_MAX, item2);
-    log_i("-------------------------------------------------------------");
+    LOG_I("-------------------------------------------------------------");
     for (i = 0; i < partition_table_len; i++)
     {
 
@@ -95,26 +103,26 @@ void fal_show_part_table(void)
         part = &partition_table[partition_table_len - i - 1];
 #endif
 
-        log_i("| %-*.*s | %-*.*s | 0x%08lx | 0x%08x |", part_name_max, FAL_DEV_NAME_MAX, part->name, flash_dev_name_max,
+        LOG_I("| %-*.*s | %-*.*s | 0x%08lx | 0x%08x |", part_name_max, FAL_DEV_NAME_MAX, part->name, flash_dev_name_max,
                 FAL_DEV_NAME_MAX, part->flash_name, part->offset, part->len);
     }
-    log_i("=============================================================");
+    LOG_I("=============================================================");
 }
 
-static int check_and_update_part_cache(const struct fal_partition *table, size_t len)
+static int check_and_update_part_cache(const struct fal_partition *table, rt_size_t len)
 {
     const struct fal_flash_dev *flash_dev = NULL;
-    size_t i;
+    rt_size_t i;
 
 #ifndef FAL_PART_HAS_TABLE_CFG
     if (part_flash_cache)
     {
-        FAL_FREE(part_flash_cache);
+        rt_free(part_flash_cache);
     }
-    part_flash_cache = FAL_MALLOC(len * sizeof(struct part_flash_info));
+    part_flash_cache = rt_malloc(len * sizeof(struct part_flash_info));
     if (part_flash_cache == NULL)
     {
-        log_e("Initialize failed! No memory for partition table cache");
+        LOG_E("Initialize failed! No memory for partition table cache");
         return -2;
     }
 #endif
@@ -124,13 +132,13 @@ static int check_and_update_part_cache(const struct fal_partition *table, size_t
         flash_dev = fal_flash_device_find(table[i].flash_name);
         if (flash_dev == NULL)
         {
-            log_d("Warning: Do NOT found the flash device(%s).", table[i].flash_name);
+            LOG_D("Warning: Do NOT found the flash device(%s).", table[i].flash_name);
             continue;
         }
 
         if (table[i].offset >= (long)flash_dev->len)
         {
-            log_e("Initialize failed! Partition(%s) offset address(%ld) out of flash bound(<%d).",
+            LOG_E("Initialize failed! Partition(%s) offset address(%ld) out of flash bound(<%d).",
                     table[i].name, table[i].offset, flash_dev->len);
             partition_table_len = 0;
 
@@ -162,38 +170,38 @@ int fal_partition_init(void)
 #else
     /* load partition table from the end address FAL_PART_TABLE_END_OFFSET, error return 0 */
     long part_table_offset = FAL_PART_TABLE_END_OFFSET;
-    size_t table_num = 0, table_item_size = 0;
-    uint8_t part_table_find_ok = 0;
-    uint32_t read_magic_word;
+    rt_size_t table_num = 0, table_item_size = 0;
+    rt_uint8_t part_table_find_ok = 0;
+    rt_uint32_t read_magic_word;
     fal_partition_t new_part = NULL;
-    size_t i;
+    rt_size_t i;
     const struct fal_flash_dev *flash_dev = NULL;
 
     flash_dev = fal_flash_device_find(FAL_PART_TABLE_FLASH_DEV_NAME);
     if (flash_dev == NULL)
     {
-        log_e("Initialize failed! Flash device (%s) NOT found.", FAL_PART_TABLE_FLASH_DEV_NAME);
+        LOG_E("Initialize failed! Flash device (%s) NOT found.", FAL_PART_TABLE_FLASH_DEV_NAME);
         goto _exit;
     }
 
     /* check partition table offset address */
     if (part_table_offset < 0 || part_table_offset >= (long) flash_dev->len)
     {
-        log_e("Setting partition table end offset address(%ld) out of flash bound(<%d).", part_table_offset, flash_dev->len);
+        LOG_E("Setting partition table end offset address(%ld) out of flash bound(<%d).", part_table_offset, flash_dev->len);
         goto _exit;
     }
 
     table_item_size = sizeof(struct fal_partition);
-    new_part = (fal_partition_t)FAL_MALLOC(table_item_size);
+    new_part = (fal_partition_t)rt_malloc(table_item_size);
     if (new_part == NULL)
     {
-        log_e("Initialize failed! No memory for table buffer.");
+        LOG_E("Initialize failed! No memory for table buffer.");
         goto _exit;
     }
 
     /* find partition table location */
     {
-        uint8_t read_buf[64];
+        rt_uint8_t read_buf[64];
 
         part_table_offset -= sizeof(read_buf);
         while (part_table_offset >= 0)
@@ -208,7 +216,7 @@ int fal_partition_init(void)
                     {
                         part_table_find_ok = 1;
                         part_table_offset += i;
-                        log_d("Find the partition table on '%s' offset @0x%08lx.", FAL_PART_TABLE_FLASH_DEV_NAME,
+                        LOG_D("Find the partition table on '%s' offset @0x%08lx.", FAL_PART_TABLE_FLASH_DEV_NAME,
                                 part_table_offset);
                         break;
                     }
@@ -249,10 +257,10 @@ int fal_partition_init(void)
     while (part_table_find_ok)
     {
         memset(new_part, 0x00, table_num);
-        if (flash_dev->ops.read(part_table_offset - table_item_size * (table_num), (uint8_t *) new_part,
+        if (flash_dev->ops.read(part_table_offset - table_item_size * (table_num), (rt_uint8_t *) new_part,
                 table_item_size) < 0)
         {
-            log_e("Initialize failed! Flash device (%s) read error!", flash_dev->name);
+            LOG_E("Initialize failed! Flash device (%s) read error!", flash_dev->name);
             table_num = 0;
             break;
         }
@@ -262,10 +270,10 @@ int fal_partition_init(void)
             break;
         }
 
-        partition_table = (fal_partition_t) FAL_REALLOC(partition_table, table_item_size * (table_num + 1));
+        partition_table = (fal_partition_t) rt_realloc(partition_table, table_item_size * (table_num + 1));
         if (partition_table == NULL)
         {
-            log_e("Initialize failed! No memory for partition table");
+            LOG_E("Initialize failed! No memory for partition table");
             table_num = 0;
             break;
         }
@@ -277,7 +285,7 @@ int fal_partition_init(void)
 
     if (table_num == 0)
     {
-        log_e("Partition table NOT found on flash: %s (len: %d) from offset: 0x%08x.", FAL_PART_TABLE_FLASH_DEV_NAME,
+        LOG_E("Partition table NOT found on flash: %s (len: %d) from offset: 0x%08x.", FAL_PART_TABLE_FLASH_DEV_NAME,
                 FAL_DEV_NAME_MAX, FAL_PART_TABLE_END_OFFSET);
         goto _exit;
     }
@@ -297,14 +305,14 @@ int fal_partition_init(void)
 
 _exit:
 
-#if FAL_DEBUG
+#ifdef FAL_USING_DEBUG
     fal_show_part_table();
-#endif
+#endif /* FAL_USING_DEBUG */
 
 #ifndef FAL_PART_HAS_TABLE_CFG
     if (new_part)
     {
-        FAL_FREE(new_part);
+        rt_free(new_part);
     }
 #endif /* !FAL_PART_HAS_TABLE_CFG */
 
@@ -324,7 +332,7 @@ const struct fal_partition *fal_partition_find(const char *name)
     if (!init_ok)
         return NULL;
 
-    size_t i;
+    rt_size_t i;
 
     for (i = 0; i < partition_table_len; i++)
     {
@@ -339,8 +347,8 @@ const struct fal_partition *fal_partition_find(const char *name)
 
 static const struct fal_flash_dev *flash_device_find_by_part(const struct fal_partition *part)
 {
-    assert(part >= partition_table);
-    assert(part <= &partition_table[partition_table_len - 1]);
+    RT_ASSERT(part >= partition_table);
+    RT_ASSERT(part <= &partition_table[partition_table_len - 1]);
 
     return part_flash_cache[part - partition_table].flash_dev;
 }
@@ -352,9 +360,9 @@ static const struct fal_flash_dev *flash_device_find_by_part(const struct fal_pa
  *
  * @return partition table
  */
-const struct fal_partition *fal_get_partition_table(size_t *len)
+const struct fal_partition *fal_get_partition_table(rt_size_t *len)
 {
-    assert(len);
+    RT_ASSERT(len);
 
     if (!init_ok)
         return NULL;
@@ -371,13 +379,13 @@ const struct fal_partition *fal_get_partition_table(size_t *len)
  * @param table partition table
  * @param len partition table length
  */
-void fal_set_partition_table_temp(struct fal_partition *table, size_t len)
+void fal_set_partition_table_temp(struct fal_partition *table, rt_size_t len)
 {
-    assert(table);
+    RT_ASSERT(table);
 
     if (!init_ok)
     {
-        log_e("FAL NOT initialized");
+        LOG_E("FAL NOT initialized");
         return;
     }
 
@@ -398,31 +406,31 @@ void fal_set_partition_table_temp(struct fal_partition *table, size_t len)
  * @return >= 0: successful read data size
  *           -1: error
  */
-int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t *buf, size_t size)
+int fal_partition_read(const struct fal_partition *part, rt_uint32_t addr, rt_uint8_t *buf, rt_size_t size)
 {
     int ret = 0;
     const struct fal_flash_dev *flash_dev = NULL;
 
-    assert(part);
-    assert(buf);
+    RT_ASSERT(part);
+    RT_ASSERT(buf);
 
     if (addr + size > part->len)
     {
-        log_e("Partition read error! Partition(%s) address(0x%08x) out of bound(0x%08x).", part->name, addr + size, part->len);
+        LOG_E("Partition read error! Partition(%s) address(0x%08x) out of bound(0x%08x).", part->name, addr + size, part->len);
         return -1;
     }
 
     flash_dev = flash_device_find_by_part(part);
     if (flash_dev == NULL)
     {
-        log_e("Partition read error! Don't found flash device(%s) of the partition(%s).", part->flash_name, part->name);
+        LOG_E("Partition read error! Don't found flash device(%s) of the partition(%s).", part->flash_name, part->name);
         return -1;
     }
 
     ret = flash_dev->ops.read(part->offset + addr, buf, size);
     if (ret < 0)
     {
-        log_e("Partition read error! Flash device(%s) read error!", part->flash_name);
+        LOG_E("Partition read error! Flash device(%s) read error!", part->flash_name);
     }
 
     return ret;
@@ -439,31 +447,31 @@ int fal_partition_read(const struct fal_partition *part, uint32_t addr, uint8_t
  * @return >= 0: successful write data size
  *           -1: error
  */
-int fal_partition_write(const struct fal_partition *part, uint32_t addr, const uint8_t *buf, size_t size)
+int fal_partition_write(const struct fal_partition *part, rt_uint32_t addr, const rt_uint8_t *buf, rt_size_t size)
 {
     int ret = 0;
     const struct fal_flash_dev *flash_dev = NULL;
 
-    assert(part);
-    assert(buf);
+    RT_ASSERT(part);
+    RT_ASSERT(buf);
 
     if (addr + size > part->len)
     {
-        log_e("Partition write error! Partition address out of bound.");
+        LOG_E("Partition write error! Partition address out of bound.");
         return -1;
     }
 
     flash_dev = flash_device_find_by_part(part);
     if (flash_dev == NULL)
     {
-        log_e("Partition write error!  Don't found flash device(%s) of the partition(%s).", part->flash_name, part->name);
+        LOG_E("Partition write error!  Don't found flash device(%s) of the partition(%s).", part->flash_name, part->name);
         return -1;
     }
 
     ret = flash_dev->ops.write(part->offset + addr, buf, size);
     if (ret < 0)
     {
-        log_e("Partition write error! Flash device(%s) write error!", part->flash_name);
+        LOG_E("Partition write error! Flash device(%s) write error!", part->flash_name);
     }
 
     return ret;
@@ -479,30 +487,30 @@ int fal_partition_write(const struct fal_partition *part, uint32_t addr, const u
  * @return >= 0: successful erased data size
  *           -1: error
  */
-int fal_partition_erase(const struct fal_partition *part, uint32_t addr, size_t size)
+int fal_partition_erase(const struct fal_partition *part, rt_uint32_t addr, rt_size_t size)
 {
     int ret = 0;
     const struct fal_flash_dev *flash_dev = NULL;
 
-    assert(part);
+    RT_ASSERT(part);
 
     if (addr + size > part->len)
     {
-        log_e("Partition erase error! Partition address out of bound.");
+        LOG_E("Partition erase error! Partition address out of bound.");
         return -1;
     }
 
     flash_dev = flash_device_find_by_part(part);
     if (flash_dev == NULL)
     {
-        log_e("Partition erase error! Don't found flash device(%s) of the partition(%s).", part->flash_name, part->name);
+        LOG_E("Partition erase error! Don't found flash device(%s) of the partition(%s).", part->flash_name, part->name);
         return -1;
     }
 
     ret = flash_dev->ops.erase(part->offset + addr, size);
     if (ret < 0)
     {
-        log_e("Partition erase error! Flash device(%s) erase error!", part->flash_name);
+        LOG_E("Partition erase error! Flash device(%s) erase error!", part->flash_name);
     }
 
     return ret;

+ 43 - 40
components/fal/src/fal_rtt.c

@@ -10,12 +10,16 @@
  */
 
 #include <fal.h>
-
-#ifdef RT_VER_NUM
-#include <rtthread.h>
 #include <rtdevice.h>
-#include <string.h>
-#include <stdlib.h>
+
+#define DBG_TAG "FAL"
+#ifdef FAL_USING_DEBUG
+#define DBG_LVL DBG_LOG
+#else
+#define DBG_LVL DBG_WARNING
+#endif
+#include <rtdbg.h>
+
 
 /* ========================== block device ======================== */
 struct fal_blk_device
@@ -34,7 +38,7 @@ static rt_err_t blk_dev_control(rt_device_t dev, rt_uint8_t cmd, void *args)
 {
     struct fal_blk_device *part = (struct fal_blk_device*) dev;
 
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     if (cmd == RT_DEVICE_CTRL_BLK_GETGEOME)
     {
@@ -80,7 +84,7 @@ static rt_ssize_t blk_dev_read(rt_device_t dev, rt_off_t pos, void* buffer, rt_s
     int ret = 0;
     struct fal_blk_device *part = (struct fal_blk_device*) dev;
 
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     ret = fal_partition_read(part->fal_part, pos * part->geometry.block_size, buffer, size * part->geometry.block_size);
 
@@ -104,7 +108,7 @@ static rt_ssize_t blk_dev_write(rt_device_t dev, rt_off_t pos, const void* buffe
     rt_size_t phy_size;
 
     part = (struct fal_blk_device*) dev;
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     /* change the block device's logic address to physical address */
     phy_pos = pos * part->geometry.bytes_per_sector;
@@ -157,13 +161,13 @@ struct rt_device *fal_blk_device_create(const char *parition_name)
 
     if (!fal_part)
     {
-        log_e("Error: the partition name (%s) is not found.", parition_name);
+        LOG_E("Error: the partition name (%s) is not found.", parition_name);
         return NULL;
     }
 
     if ((fal_flash = fal_flash_device_find(fal_part->flash_name)) == NULL)
     {
-        log_e("Error: the flash device name (%s) is not found.", fal_part->flash_name);
+        LOG_E("Error: the flash device name (%s) is not found.", fal_part->flash_name);
         return NULL;
     }
 
@@ -192,12 +196,12 @@ struct rt_device *fal_blk_device_create(const char *parition_name)
         /* no private */
         blk_dev->parent.user_data = RT_NULL;
 
-        log_i("The FAL block device (%s) created successfully", fal_part->name);
+        LOG_I("The FAL block device (%s) created successfully", fal_part->name);
         rt_device_register(RT_DEVICE(blk_dev), fal_part->name, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_STANDALONE);
     }
     else
     {
-        log_e("Error: no memory for create FAL block device");
+        LOG_E("Error: no memory for create FAL block device");
     }
 
     return RT_DEVICE(blk_dev);
@@ -217,7 +221,7 @@ static rt_ssize_t mtd_nor_dev_read(struct rt_mtd_nor_device* device, rt_off_t of
     int ret = 0;
     struct fal_mtd_nor_device *part = (struct fal_mtd_nor_device*) device;
 
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     ret = fal_partition_read(part->fal_part, offset, data, length);
 
@@ -239,7 +243,7 @@ static rt_ssize_t mtd_nor_dev_write(struct rt_mtd_nor_device* device, rt_off_t o
     struct fal_mtd_nor_device *part;
 
     part = (struct fal_mtd_nor_device*) device;
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     ret = fal_partition_write(part->fal_part, offset, data, length);
 
@@ -261,7 +265,7 @@ static rt_err_t mtd_nor_dev_erase(struct rt_mtd_nor_device* device, rt_off_t off
     struct fal_mtd_nor_device *part;
 
     part = (struct fal_mtd_nor_device*) device;
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     ret = fal_partition_erase(part->fal_part, offset, length);
 
@@ -299,13 +303,13 @@ struct rt_device *fal_mtd_nor_device_create(const char *parition_name)
 
     if (!fal_part)
     {
-        log_e("Error: the partition name (%s) is not found.", parition_name);
+        LOG_E("Error: the partition name (%s) is not found.", parition_name);
         return NULL;
     }
 
     if ((fal_flash = fal_flash_device_find(fal_part->flash_name)) == NULL)
     {
-        log_e("Error: the flash device name (%s) is not found.", fal_part->flash_name);
+        LOG_E("Error: the flash device name (%s) is not found.", fal_part->flash_name);
         return NULL;
     }
 
@@ -321,12 +325,12 @@ struct rt_device *fal_mtd_nor_device_create(const char *parition_name)
         /* set ops */
         mtd_nor_dev->parent.ops = &_ops;
 
-        log_i("The FAL MTD NOR device (%s) created successfully", fal_part->name);
+        LOG_I("The FAL MTD NOR device (%s) created successfully", fal_part->name);
         rt_mtd_nor_register_device(fal_part->name, &mtd_nor_dev->parent);
     }
     else
     {
-        log_e("Error: no memory for create FAL MTD NOR device");
+        LOG_E("Error: no memory for create FAL MTD NOR device");
     }
 
     return RT_DEVICE(&mtd_nor_dev->parent);
@@ -348,7 +352,7 @@ static rt_ssize_t char_dev_read(rt_device_t dev, rt_off_t pos, void *buffer, rt_
     int ret = 0;
     struct fal_char_device *part = (struct fal_char_device *) dev;
 
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     if (pos + size > part->fal_part->len)
         size = part->fal_part->len - pos;
@@ -367,7 +371,7 @@ static rt_ssize_t char_dev_write(rt_device_t dev, rt_off_t pos, const void *buff
     struct fal_char_device *part;
 
     part = (struct fal_char_device *) dev;
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     if (pos == 0)
     {
@@ -410,7 +414,7 @@ static int char_dev_fopen(struct dfs_file *fd)
 {
     struct fal_char_device *part = (struct fal_char_device *) fd->vnode->data;
 
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     switch (fd->flags & O_ACCMODE)
     {
@@ -429,12 +433,12 @@ static int char_dev_fopen(struct dfs_file *fd)
     return RT_EOK;
 }
 
-static int char_dev_fread(struct dfs_file *fd, void *buf, size_t count)
+static int char_dev_fread(struct dfs_file *fd, void *buf, rt_size_t count)
 {
     int ret = 0;
     struct fal_char_device *part = (struct fal_char_device *) fd->vnode->data;
 
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     if (DFS_FILE_POS(fd) + count > part->fal_part->len)
         count = part->fal_part->len - DFS_FILE_POS(fd);
@@ -449,12 +453,12 @@ static int char_dev_fread(struct dfs_file *fd, void *buf, size_t count)
     return ret;
 }
 
-static int char_dev_fwrite(struct dfs_file *fd, const void *buf, size_t count)
+static int char_dev_fwrite(struct dfs_file *fd, const void *buf, rt_size_t count)
 {
     int ret = 0;
     struct fal_char_device *part = (struct fal_char_device *) fd->vnode->data;
 
-    assert(part != RT_NULL);
+    RT_ASSERT(part != RT_NULL);
 
     if (DFS_FILE_POS(fd) + count > part->fal_part->len)
         count = part->fal_part->len - DFS_FILE_POS(fd);
@@ -498,13 +502,13 @@ struct rt_device *fal_char_device_create(const char *parition_name)
 
     if (!fal_part)
     {
-        log_e("Error: the partition name (%s) is not found.", parition_name);
+        LOG_E("Error: the partition name (%s) is not found.", parition_name);
         return NULL;
     }
 
     if ((fal_flash_device_find(fal_part->flash_name)) == NULL)
     {
-        log_e("Error: the flash device name (%s) is not found.", fal_part->flash_name);
+        LOG_E("Error: the flash device name (%s) is not found.", fal_part->flash_name);
         return NULL;
     }
 
@@ -530,7 +534,7 @@ struct rt_device *fal_char_device_create(const char *parition_name)
 #endif
 
         rt_device_register(RT_DEVICE(char_dev), fal_part->name, RT_DEVICE_FLAG_RDWR);
-        log_i("The FAL char device (%s) created successfully", fal_part->name);
+        LOG_I("The FAL char device (%s) created successfully", fal_part->name);
 
 #ifdef RT_USING_POSIX_DEVIO
         /* set fops */
@@ -540,7 +544,7 @@ struct rt_device *fal_char_device_create(const char *parition_name)
     }
     else
     {
-        log_e("Error: no memory for create FAL char device");
+        LOG_E("Error: no memory for create FAL char device");
     }
 
     return RT_DEVICE(char_dev);
@@ -551,7 +555,7 @@ struct rt_device *fal_char_device_create(const char *parition_name)
 #include <finsh.h>
 extern int fal_init_check(void);
 
-static void fal(uint8_t argc, char **argv) {
+static void fal(rt_uint8_t argc, char **argv) {
 
 #define __is_print(ch)                ((unsigned int)((ch) - ' ') < 127u - ' ')
 #define HEXDUMP_WIDTH                 16
@@ -564,7 +568,7 @@ static void fal(uint8_t argc, char **argv) {
     int result = 0;
     static const struct fal_flash_dev *flash_dev = NULL;
     static const struct fal_partition *part_dev = NULL;
-    size_t i = 0, j = 0;
+    rt_size_t i = 0, j = 0;
 
     const char* help_info[] =
     {
@@ -593,7 +597,7 @@ static void fal(uint8_t argc, char **argv) {
     else
     {
         const char *operator = argv[1];
-        uint32_t addr, size;
+        rt_uint32_t addr, size;
 
         if (!strcmp(operator, "probe"))
         {
@@ -651,7 +655,7 @@ static void fal(uint8_t argc, char **argv) {
                 {
                     addr = strtol(argv[2], NULL, 0);
                     size = strtol(argv[3], NULL, 0);
-                    uint8_t *data = rt_malloc(size);
+                    rt_uint8_t *data = rt_malloc(size);
                     if (data)
                     {
                         if (flash_dev)
@@ -713,7 +717,7 @@ static void fal(uint8_t argc, char **argv) {
                 {
                     addr = strtol(argv[2], NULL, 0);
                     size = argc - 3;
-                    uint8_t *data = rt_malloc(size);
+                    rt_uint8_t *data = rt_malloc(size);
                     if (data)
                     {
                         for (i = 0; i < size; i++)
@@ -784,9 +788,9 @@ static void fal(uint8_t argc, char **argv) {
                     return;
                 }
                 /* full chip benchmark test */
-                uint32_t start_time, time_cast;
-                size_t write_size = strtol(argv[2], NULL, 0), read_size = strtol(argv[2], NULL, 0), cur_op_size;
-                uint8_t *write_data = (uint8_t *)rt_malloc(write_size), *read_data = (uint8_t *)rt_malloc(read_size);
+                rt_uint32_t start_time, time_cast;
+                rt_size_t write_size = strtol(argv[2], NULL, 0), read_size = strtol(argv[2], NULL, 0), cur_op_size;
+                rt_uint8_t *write_data = (rt_uint8_t *)rt_malloc(write_size), *read_data = (rt_uint8_t *)rt_malloc(read_size);
 
                 if (write_data && read_data)
                 {
@@ -880,7 +884,7 @@ static void fal(uint8_t argc, char **argv) {
                             result = fal_partition_read(part_dev, i, read_data, cur_op_size);
                         }
                         /* data check */
-                        for (size_t index = 0; index < cur_op_size; index ++)
+                        for (rt_size_t index = 0; index < cur_op_size; index ++)
                         {
                             if (write_data[index] != read_data[index])
                             {
@@ -936,4 +940,3 @@ static void fal(uint8_t argc, char **argv) {
 MSH_CMD_EXPORT(fal, FAL (Flash Abstraction Layer) operate.);
 
 #endif /* defined(RT_USING_FINSH) && defined(FINSH_USING_MSH) */
-#endif /* RT_VER_NUM */