zhaoxingyu12 opened a new pull request, #18225:
URL: https://github.com/apache/nuttx/pull/18225

   *Note: Please adhere to [Contributing 
Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).*
   
   ## Summary
   
   mtdconfig/nvs: some optimizations to the nvs module
   
   1. Commit 0b397a3: fix the issue of compilation failure when using the 
tasking compiler
   the tasking compiler reports the error: expression must be constant
   in line 510
   2. Commit 196c950: when deleting a non-existent KV, it is considered 
successful
   3. Commit f47e622: Enhancing the robustness of NVS, traversing ATE in a 
sector should maintain a growing trend, as data is written from low addresses 
to high addresses in a sector
   4. Commit c789eec:Add data CRC verification to ensure the accuracy of data
   5. Commit 2d1b6bf:Use a fixed stack size to prevent the risk of stack 
overflow
   6. Commit 997f329:fix -Werror=unused-variable
   7. Commit 3b9093a:Clear key value and corresponding ate when data is invalid
   8. Commit 5d394d1:Clear key value and corresponding ate when key is invalid
   9. Commit b1bd6f6:When there is no valid data in a sector, the action of 
erasing this sector is moved from startup to gc, reducing startup time
   
   
   ## Impact
   
   key-value read/write function
   
   ## Testing
   
   testcases
   `
   int print_list(void)
   {
   int fd = open("/dev/nvs", O_RDONLY);
   
   uint8_t buf[255];
   struct config_data_s data;
   int ret;
   
   data.configdata = buf;
   data.len = 255;
   ret = ioctl(fd, CFGDIOC_FIRSTCONFIG, &data);
   if (ret < 0)
       return ret;
   #ifdef CONFIG_MTD_CONFIG_NAMED
   syslog(0, "######## key=%s, value=%s", data.name, data.configdata);
   #else
   syslog(0, "######## id=%d, instance=%d, value=%s", data.id, data.instance, 
data.configdata);
   #endif
   
   while (1) {
       data.configdata = buf;
       data.len = 255;
       ret = ioctl(fd, CFGDIOC_NEXTCONFIG, &data);
       if (ret < 0) {
           ret = -errno;
   
           /* ENOENT is expected when there are no more entries */
   
           if (ret == -ENOENT)
               ret = 0;
   
           break;
       }
   #ifdef CONFIG_MTD_CONFIG_NAMED
   syslog(0, "######## key=%s, value=%s", data.name, data.configdata);
   #else
   syslog(0, "######## id=%d, instance=%d, value=%s", data.id, data.instance, 
data.configdata);
   #endif
   }
   
   close(fd);
   return ret;
   }
   
   void test(void)
   {
   uint64_t filling_id = 0;
   struct config_data_s data;
   int ret;
   
   int fd = open("/dev/nvs", O_RDWR);
   while (1)
     {
     
     uint8_t wr_buf[50] = {0};
     uint8_t wr_buf1[50] = {0};
     snprintf(wr_buf, sizeof(wr_buf), "v----------------------------%llx", 
filling_id);
   #ifdef CONFIG_MTD_CONFIG_NAMED
   char rd_buf[10] = {0};
   
     snprintf(rd_buf, sizeof(rd_buf), "k%llx", filling_id);  
     strlcpy(data.name, rd_buf, sizeof(data.name));
   #else
   data.id = (uint16_t)filling_id;
   data.instance = (int)filling_id + 1;
   #endif
   data.configdata = wr_buf;
   data.len = sizeof(wr_buf);
   ret = ioctl(fd, CFGDIOC_SETCONFIG, &data);
   
      if (ret != 0)
        {
          return;
        }
   
     data.configdata = wr_buf1;
     ret = ioctl(fd, CFGDIOC_GETCONFIG, &data);
   
      if (ret < 0)
        {
          assert(0);
        }
   
      if (memcmp(wr_buf, wr_buf1, sizeof(wr_buf)) != 0)
        {
          assert(0);
        }
   
      filling_id++;
     }
   close(fd);
   }
   
   int main(int argc, FAR char *argv[])
   {
   test();
   print_list();
   return 0;
   }
   `
   
   test result
   [ 3.724800] [core0] ######## key=k28, value=v----------------------------28
   [ 3.725400] [core0] ######## key=k27, value=v----------------------------27
   [ 3.726000] [core0] ######## key=k26, value=v----------------------------26
   [ 3.726600] [core0] ######## key=k25, value=v----------------------------25
   [ 3.727100] [core0] ######## key=k24, value=v----------------------------24
   [ 3.727700] [core0] ######## key=k23, value=v----------------------------23
   [ 3.728300] [core0] ######## key=k22, value=v----------------------------22
   [ 3.728800] [core0] ######## key=k21, value=v----------------------------21
   [ 3.729400] [core0] ######## key=k20, value=v----------------------------20
   [ 3.729900] [core0] ######## key=k1f, value=v----------------------------1f
   [ 3.730500] [core0] ######## key=k1e, value=v----------------------------1e
   [ 3.731200] [core0] ######## key=k1d, value=v----------------------------1d
   [ 3.731800] [core0] ######## key=k1c, value=v----------------------------1c
   [ 3.732500] [core0] ######## key=k1b, value=v----------------------------1b
   [ 3.733100] [core0] ######## key=k1a, value=v----------------------------1a
   [ 3.733700] [core0] ######## key=k19, value=v----------------------------19
   [ 3.734300] [core0] ######## key=k18, value=v----------------------------18
   [ 3.734800] [core0] ######## key=k17, value=v----------------------------17
   [ 3.735400] [core0] ######## key=k16, value=v----------------------------16
   [ 3.736100] [core0] ######## key=k15, value=v----------------------------15
   [ 3.736700] [core0] ######## key=k14, value=v----------------------------14
   [ 3.737300] [core0] ######## key=k13, value=v----------------------------13
   [ 3.737700] [core0] ######## key=k12, value=v----------------------------12
   [ 3.738200] [core0] ######## key=k11, value=v----------------------------11
   [ 3.738700] [core0] ######## key=k10, value=v----------------------------10
   [ 3.739100] [core0] ######## key=kf, value=v----------------------------f
   [ 3.739600] [core0] ######## key=ke, value=v----------------------------e
   [ 3.740100] [core0] ######## key=kd, value=v----------------------------d
   [ 3.740600] [core0] ######## key=kc, value=v----------------------------c
   [ 3.741100] [core0] ######## key=kb, value=v----------------------------b
   [ 3.741700] [core0] ######## key=ka, value=v----------------------------a
   [ 3.742100] [core0] ######## key=k9, value=v----------------------------9
   [ 3.742600] [core0] ######## key=k8, value=v----------------------------8
   [ 3.743100] [core0] ######## key=k7, value=v----------------------------7
   [ 3.743500] [core0] ######## key=k6, value=v----------------------------6
   [ 3.744000] [core0] ######## key=k5, value=v----------------------------5
   [ 3.744500] [core0] ######## key=k4, value=v----------------------------4
   [ 3.744900] [core0] ######## key=k3, value=v----------------------------3
   [ 3.745400] [core0] ######## key=k2, value=v----------------------------2
   [ 3.746000] [core0] ######## key=k1, value=v----------------------------1
   [ 3.747300] [core0] ######## key=k0, value=v----------------------------0
   [ 3.748300] [core0] ######## key=k29, value=v----------------------------29
   [ 3.748700] [core0] ######## key=k2a, value=v----------------------------2a
   [ 3.749300] [core0] ######## key=k2b, value=v----------------------------2b
   [ 3.749800] [core0] ######## key=k2c, value=v----------------------------2c
   [ 3.750300] [core0] ######## key=k2d, value=v----------------------------2d
   [ 3.751000] [core0] ######## key=k2e, value=v----------------------------2e
   [ 3.751600] [core0] ######## key=k2f, value=v----------------------------2f
   [ 3.752200] [core0] ######## key=k30, value=v----------------------------30
   [ 3.752700] [core0] ######## key=k31, value=v----------------------------31
   [ 3.753300] [core0] ######## key=k32, value=v----------------------------32
   [ 3.753800] [core0] ######## key=k33, value=v----------------------------33
   [ 3.754300] [core0] ######## key=k34, value=v----------------------------34
   [ 3.754900] [core0] ######## key=k35, value=v----------------------------35
   [ 3.755400] [core0] ######## key=k36, value=v----------------------------36
   [ 3.756100] [core0] ######## key=k37, value=v----------------------------37
   [ 3.756600] [core0] ######## key=k38, value=v----------------------------38
   [ 3.757200] [core0] ######## key=k39, value=v----------------------------39
   [ 3.757700] [core0] ######## key=k3a, value=v----------------------------3a
   [ 3.758200] [core0] ######## key=k3b, value=v----------------------------3b
   [ 3.758800] [core0] ######## key=k3c, value=v----------------------------3c
   [ 3.759300] [core0] ######## key=k3d, value=v----------------------------3d
   [ 3.759800] [core0] ######## key=k3e, value=v----------------------------3e
   [ 3.760300] [core0] ######## key=k3f, value=v----------------------------3f
   [ 3.761100] [core0] ######## key=k40, value=v----------------------------40
   [ 3.761700] [core0] ######## key=k41, value=v----------------------------41
   [ 3.762200] [core0] ######## key=k42, value=v----------------------------42
   [ 3.762700] [core0] ######## key=k43, value=v----------------------------43
   [ 3.763200] [core0] ######## key=k44, value=v----------------------------44
   [ 3.763800] [core0] ######## key=k45, value=v----------------------------45
   [ 3.764300] [core0] ######## key=k46, value=v----------------------------46
   [ 3.764800] [core0] ######## key=k47, value=v----------------------------47
   [ 3.765400] [core0] ######## key=k48, value=v----------------------------48
   [ 3.766000] [core0] ######## key=k49, value=v----------------------------49
   [ 3.766600] [core0] ######## key=k4a, value=v----------------------------4a
   [ 3.767100] [core0] ######## key=k4b, value=v----------------------------4b
   [ 3.767600] [core0] ######## key=k4c, value=v----------------------------4c
   [ 3.768200] [core0] ######## key=k4d, value=v----------------------------4d
   [ 3.768800] [core0] ######## key=k4e, value=v----------------------------4e
   [ 3.769300] [core0] ######## key=k4f, value=v----------------------------4f
   [ 3.769900] [core0] ######## key=k50, value=v----------------------------50
   [ 3.771100] [core0] ######## key=k51, value=v----------------------------51


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to