{"id":343595,"date":"2023-01-06T21:01:32","date_gmt":"2023-01-06T21:01:32","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=343595"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=343595","title":{"rendered":"<span>FlashFS \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u0445 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u0435\u0441\u0442\u044c <strong>\u0447\u0438\u0441\u043b\u043e<\/strong> <strong>\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/strong> \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b\u043e\u043a \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435 \u0441\u0431\u0440\u043e\u0441\u043e\u043c \u043f\u0438\u0442\u0430\u043d\u0438\u044f. \u0412\u0441\u0435 \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u043e-\u0441\u0432\u043e\u0435\u043c\u0443: StoreFS, FlashFS, \u042d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0430\u044f Key-Value Map(\u0430), HashMap(\u043a\u0430), NVS \u0438 \u043f\u0440\u043e\u0447\u0435\u0435.  <\/p>\n<p><strong>FlashFS<\/strong> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0443\u043c\u043d\u044b\u0445 \u043d\u0430\u0432\u043e\u0440\u043e\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c \u0442\u0438\u043f\u0430 \u0431\u0435\u0441\u043f\u0440\u043e\u0432\u043e\u0434\u043d\u044b\u0445 \u0442\u0440\u0430\u043d\u0441\u0438\u0432\u0435\u0440\u043e\u0432, \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0448\u0430\u0433\u043e\u0432\u044b\u0445 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u043e\u043c\u0435\u0442\u0440\u0430 \u0438 \u0442\u043f. \u041d\u0430\u043b\u0438\u0447\u0438\u0435 FlashFS \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a <strong>\u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c<\/strong> <strong>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e<\/strong> <strong>\u0441\u0431\u043e\u0440\u043e\u043a<\/strong> \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e <strong>\u0434\u043e<\/strong> <strong>\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/strong> \u0443\u0436\u0435 \u0432 Run-Time(\u0435).  \u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0432 UART Shell \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0440\u0443\u043a\u0430\u043c\u0438 \u0432 TeraTerm\/Putty \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043e FlashFS \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c(reset(\u043d\u0443\u0442\u044c)) \u0433\u0430\u0434\u0436\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. Easy. \u0418 \u043d\u0435 \u043d\u0430\u0434\u043e \u0432\u0430\u0440\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c FlashFS.  FlashFs \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e <strong>on-chip<\/strong> NorFlash? <\/p>\n<p>1&#8212;\u042d\u0442\u043e \u0434\u0435\u0448\u0435\u0432\u043e. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u043f\u0430\u0440\u0430 \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446(\u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432) Flash(\u0430). \u0417\u0430 \u043d\u0435\u0451 &#171;\u0443\u0436\u0435 \u0437\u0430\u043f\u043b\u0430\u0447\u0435\u043d\u043e&#187; \u043f\u0440\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u041d\u0435\u0442 \u043d\u0443\u0436\u0434\u044b \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 off-chip SPI-NorFlash \u0447\u0438\u043f\u044b \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0433\u0430\u0431\u0430\u0440\u0438\u0442\u044b, \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u043a\u0443, \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.  FlashFS \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442 \u0441\u0430\u043c\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 STM32 \u043f\u0435\u0440\u0432\u044b\u0435 4 \u0441\u0435\u043a\u0442\u043e\u0440\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e <strong>16kByte, <\/strong>\u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e 128kByte. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0441 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u043c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b  \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0441\u0435\u043a\u0442\u043e\u0440\u0430\u0445 \u043f\u043e 16kByte  FlashFS(c\u044b) \u0441 \u043f\u043b\u0430\u0432\u043d\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c. <\/p>\n<p>2&#8212;On-chip FS <strong>\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435<\/strong> \u0447\u0435\u043c off-chip FS, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u0446\u0435\u043f\u0438\u0442\u044c\u0441\u044f \u043a SPI \u0438\u043b\u0438 SDIO \u043f\u0440\u043e\u0432\u043e\u0434\u0430\u043c \u043d\u0430 PCB \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u043c \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c \u0437\u0430 500 \u0440\u0443\u0431\u043b\u0435\u0439.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0443 <strong>Nor-Flash<\/strong> \u043f\u0430\u043c\u044f\u0442\u0438 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0421\u0442\u0438\u0440\u0430\u0442\u044c \u0435\u0451 (\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c 0xFF(\u043a\u0430\u043c\u0438)) \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e <strong>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438<\/strong> \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442 (\u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e 4kByte, 8kByte, 16kByte, 64kByte, 128kByte). \u041e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u0442\u044b 1 \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432 0. \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 <strong>\u043d\u0435\u043b\u044c\u0437\u044f<\/strong> <strong>\u0434\u043e \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c<\/strong> \u0443\u0436\u0435 \u0441\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0435 \u0431\u0438\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0431\u0430\u0439\u0442\u0435 0x55. \u042d\u0442\u043e \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u0448\u0430\u0440\u0438\u043a\u043e\u0432\u043e\u0439 \u0440\u0443\u0447\u043a\u043e\u0439 \u043f\u043e \u0431\u0443\u043c\u0430\u0433\u0435. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043d\u0435 \u0441\u043e\u0442\u0440\u0435\u0448\u044c \u043b\u0430\u0441\u0442\u0438\u043a\u043e\u043c. \u0415\u0441\u0442\u044c \u0441\u043c\u044b\u0441\u043b \u0438\u0441\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043b\u0438\u0441\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0440\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 On-Chip Nor-Flash \u043f\u0430\u043c\u044f\u0442\u044c\u044e. <\/p>\n<pre><code class=\"cpp\">#ifndef FLASH_DRV_H #define FLASH_DRV_H  #include &lt;stdbool.h> #include &lt;stdint.h>  #include \"flash_const.h\"  #ifndef HAS_FLASH #error \"Add HAS_FLASH\" #endif  #ifndef HAS_MCU #error \"Add HAS_MCU\" #endif  #ifdef HAS_FLASH_WRITE bool flash_wr(uint32_t addr, uint8_t* array, uint32_t array_len); bool flash_wr4(uint32_t flash_addr, uint32_t* wr_array, uint32_t byte_size); bool flash_errase(uint32_t addr, uint32_t len); bool flash_erase_pages(uint8_t page_start, uint8_t page_end); #endif  bool Addr2SectorSize(uint32_t addr, uint32_t *sector, uint32_t *sec_size); bool flash_read(uint32_t in_flash_addr, uint8_t* rx_array, uint32_t array_len); bool flash_init(void); bool flash_scan(uint8_t* base, uint32_t size, float* usage_pec, uint32_t* spare, uint32_t* busy); bool is_errased(uint32_t addr, uint32_t size); bool is_flash_spare(uint32_t flash_addr, uint32_t size); bool is_flash_addr(uint32_t flash_addr);  #endif \/* FLASH_DRV_H *\/  <\/code><\/pre>\n<p>\u041d\u0430\u043c \u0436\u0435, \u043b\u044e\u0434\u044f\u043c, \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 <strong>\u043f\u043e<\/strong> <strong>\u043a\u043b\u044e\u0447\u0443<\/strong>. \u042d\u0442\u043e \u043a\u0430\u043a \u0432 \u0442\u0435\u0430\u0442\u0440\u0435. \u0414\u0430\u0435\u0448\u044c \u043d\u043e\u043c\u0435\u0440\u043e\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u0441\u0432\u043e\u0439 \u0442\u0440\u0435\u043d\u0447. \u0418\u043b\u0438 \u043a\u0430\u043a \u0432 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0435. \u0414\u0430\u0435\u0448\u044c \u0438\u043c\u044f, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430.<\/p>\n<p>\u041d\u0443\u0436\u0435\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 <strong>\u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0434\u0430\u0432\u0430\u043b \u0442\u0430\u043a\u043e\u0439 API \u0438 \u0434\u0435\u043b\u0430\u043b \u0431\u044b \u0432\u0441\u044e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u0441\u044b\u0440\u043e\u0439 Flash \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u0430\u0435\u0448\u044c \u0447\u0438\u0441\u043b\u043e \u0438 \u043c\u0430\u0441\u0441\u0438\u0432, \u041c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0434\u0435\u043b\u044e \u0434\u0430\u0435\u0448\u044c \u0447\u0438\u0441\u043b\u043e, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u043c\u0430\u0441\u0441\u0438\u0432.  <\/p>\n<p>\u042d\u0442\u043e \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u043e\u043c. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0435\u0440\u0435\u0442\u044c \u043b\u0430\u0441\u0442\u0438\u043a\u043e\u043c \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u043d \u0434\u0440\u0443\u0433\u043e\u0435. \u0423\u0434\u043e\u0431\u043d\u043e? \u041e\u0447\u0435\u043d\u044c. <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 <strong>\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/strong> \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 embedded on-chip \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c <strong>FlashFS<\/strong>.<\/p>\n<p>1\u2013<strong>\u0420\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Nor-Flash \u043f\u0430\u043c\u044f\u0442\u0438 (endurance optimization)<\/p>\n<p>2\u2013<strong>\u0417\u0430\u0448\u0438\u0442\u0430<\/strong> \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e\u0433\u043e <strong>\u043f\u0440\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f<\/strong> <strong>\u043f\u0438\u0442\u0430\u043d\u0438\u044f <\/strong>(power off tolerance). <\/p>\n<p>3\u2013<strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430<\/strong> \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u0435\u0447\u0435\u043c\u0443 \u0431\u044b\u043b\u043e \u043b\u043e\u043c\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p>4&#8212;\u0424\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e <strong>\u0438\u043c\u0435\u043d\u0438<\/strong><\/p>\n<p>5&#8212;\u0424\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d <strong>\u0431\u044b\u0441\u0442\u0440\u043e<\/strong> <strong>\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f<\/strong><\/p>\n<p>6&#8212;\u0424\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d <strong>\u0431\u044b\u0441\u0442\u0440\u043e<\/strong> <strong>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f<\/strong><\/p>\n<p>7&#8212;\u0424\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d <strong>\u0431\u044b\u0441\u0442\u0440\u043e<\/strong> <strong>\u0441\u0442\u0438\u0440\u0430\u0442\u044c\u0441\u044f<\/strong><\/p>\n<p>8&#8212;<strong>\u041a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u044c<\/strong> \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c FlashFS. \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0441 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <strong>File<\/strong>?<\/p>\n<p><strong>File<\/strong> \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c RAM, ROM (Flash), FRAM, EEPROM, SD \u043a\u0430\u0440\u0442\u044b. \u0427\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439? \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043a \u044d\u0442\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e. \u041f\u0443\u0441\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 16-\u0431\u0438\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u0422\u0430\u043a \u043f\u0440\u043e\u0449\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432, \u0442\u043e \u0440\u044f\u0434\u043e\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0434\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 <strong>\u0434\u043b\u0438\u043d\u0443<\/strong> \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 FlashFs.<\/p>\n<pre><code class=\"cpp\">struct xFlashFsFileHeader_t {     uint16_t id;     uint16_t nid; \/* bit inverted id*\/     uint16_t length;     uint8_t crc8;   \/*only for payload*\/ } __attribute__((packed)); \/*to save flash memory*\/ typedef struct xFlashFsFileHeader_t FlashFsFileHeader_t;<\/code><\/pre>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f Flash FS<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 ID, \u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u042d\u0442\u0438\u043c \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u044f. \u0412\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0444\u0430\u0439\u043b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u043e\u0441\u043d\u0430\u0449\u0435\u043d 8\u043c\u0438 \u0431\u0438\u0442\u043d\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0427\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u0430, \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u0430 \u0438\u0437 ID(\u0448\u043d\u0438\u043a\u043e\u0432). \u042d\u0442\u043e FileID \u0438 \u0435\u0433\u043e \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043f\u0438\u044f.  \u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 ID? \u042d\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f CRC \u044d\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430. \u0411\u044b\u043b\u043e \u0431\u044b \u0440\u0430\u0441\u0442\u043e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c CRC \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0444\u0430\u0439\u043b \u0442\u0443\u0442 \u0438\u043b\u0438 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 CRC \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0442\u0435\u043c \u043e\u0442\u0441\u0443\u043f\u0430\u043c, \u0433\u0434\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u0430\u044f \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u0430.<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0444\u043b\u0435\u0448\u044c \u043f\u0430\u043c\u044f\u0442\u0438. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c? \u041d\u0430\u0434\u043e \u043e\u0442\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438 \u043f\u0435\u0440\u0435\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u0451 \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0432\u0435\u0436\u0438\u0435 \u0444\u0430\u0439\u043b\u044b. <\/p>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <strong>\u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435<\/strong> \u0432\u0435\u0440\u0441\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432. \u0421\u0442\u0430\u0440\u044b\u0435 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0438 \u0436\u0434\u0443\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435\u0439. \u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0438\u0445 \u043e\u0442\u0447\u0438\u0441\u0442\u044f\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435\u0439 NorFlash.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0cb\/6db\/ced\/0cb6dbced3b47226382d96f018735b1c.png\" width=\"727\" height=\"598\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0cb\/6db\/ced\/0cb6dbced3b47226382d96f018735b1c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0443\u0436\u043d\u0430 \u0435\u0449\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0430\u043c\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 &#171;B&#187; \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f, \u0442\u043e background \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 toggle flash page, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0447\u0438c\u0442\u0438\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 &#171;A&#187;. \u0412\u0437\u044f\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0441\u0432\u0435\u0436\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b &#171;B&#187; \u0438 \u043f\u0435\u0440\u0435\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 &#171;A&#187;. <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c API \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043d\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/p>\n<pre><code class=\"cpp\"> #ifndef NOR_FLASH_H #define NOR_FLASH_H  #include &lt;stdbool.h> #include &lt;stdint.h>  #include \"flash_drv.h\" #include \"flash_fs_config.h\" #include \"flash_fs_types.h\"  #ifndef HAS_FLASH #error \"+ HAS_FLASH\" #endif  #ifndef HAS_NVS #error \"+ HAS_NVS\" #endif  #ifndef HAS_FLASH_FS #error \"+ HAS_FLASH_FS\" #endif  #ifndef HAS_CRC8 #error \"+HAS_CRC8\" #endif  #ifdef HAS_FLASH_FS_WRITE bool flash_fs_format(void); bool flash_fs_erase(void); bool flash_fs_invalidate(uint16_t data_id); bool flash_fs_set(uint16_t data_id, uint8_t* new_file, uint16_t new_file_len); bool flash_fs_maintain(void); bool flash_fs_turn_page(void); #endif  bool flash_fs_is_active(uint8_t page_num); bool flash_fs_init(void); bool flash_fs_proc(void); bool flash_fs_get(uint16_t data_id, uint8_t* value, uint16_t max_value_len, uint16_t* value_len); bool flash_fs_get_active_page(uint32_t* flash_fs_page_start, uint32_t* flash_fs_page_len); bool flash_fs_get_address(uint16_t data_id, uint8_t** value_address, uint16_t* value_len); bool is_flash_fs_addr(uint32_t addr); uint32_t flash_fs_get_page_size(uint8_t page_num); uint32_t flash_fs_get_page_base_addr(uint8_t page_num); uint32_t flash_fs_cnt_files(uint32_t start_page_addr, uint32_t page_len, uint32_t* spare_cnt); uint32_t flash_fs_get_remaining_space(void); uint8_t addr2page_num(uint32_t flash_fs_page_start);  #endif \/* MEMORY_MANAGER_NOR_FLASH_H *\/ <\/code><\/pre>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f FlashFs \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0430\u043a<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/7d3\/288\/bc4\/7d3288bc472f800d2dd61957c3d9f255.png\" width=\"1202\" height=\"381\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/7d3\/288\/bc4\/7d3288bc472f800d2dd61957c3d9f255.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043b\u0438 \u0442\u0430\u043a <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4a8\/081\/7fc\/4a80817fc5605934a238c30795699c2a.png\" width=\"2011\" height=\"883\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4a8\/081\/7fc\/4a80817fc5605934a238c30795699c2a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b (\u0440\u0438\u0441 2). \u042d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u0430, \u0440\u0430\u0437\u043c\u0435\u0440, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430, ID(\u0448\u043d\u0438\u043a)<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ad0\/2fe\/ad3\/ad02fead34e79a66bf5b84ba73b1f224.png\" alt=\"\u0440\u0438\u0441 2\" title=\"\u0440\u0438\u0441 2\" width=\"865\" height=\"490\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ad0\/2fe\/ad3\/ad02fead34e79a66bf5b84ba73b1f224.png\"\/><figcaption>\u0440\u0438\u0441 2<\/figcaption><\/figure>\n<p>\u0421 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c. \u041d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u044b\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e\u0436\u0435 \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c-\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e. \u0414\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0438\u043c\u0431\u043b\u043e\u0432 (hex \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432). \u041d\u0430\u0434\u043e \u043a\u0430\u043a-\u0442\u043e <strong>\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/strong> \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0438 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u0438\u043c \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <strong>Param.<\/strong><\/p>\n<p>\u041f\u043e\u0432\u0435\u0440\u0445 Flash Fs \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438. \u042f \u0435\u0433\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b (Param). \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u0442\u0430\u043a. \u0414\u0430\u0435\u0448\u044c ID \u0444\u0430\u0439\u043b\u0430 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 (hex \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0434\u043b\u0438\u043d\u043d\u043e\u0439), \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <strong>param<\/strong><\/p>\n<pre><code class=\"cpp\">#ifndef PARAM_DRV_H #define PARAM_DRV_H  #include &lt;stdbool.h> #include &lt;stdint.h>  #include \"param_types.h\"  #ifndef HAS_PARAM #error \"+HAS_PARAM\" #endif \/*HAS_PARAM*\/  bool param_init(void); bool param_proc(void);  #ifdef HAS_PARAM_SET bool param_set(Id_t id, uint8_t* in_data); #endif \/*HAS_PARAM_SET*\/  bool param_get(Id_t id, uint8_t* out_data); ParamType_t param_get_type(Id_t id); uint16_t param_get_real_len(Id_t id) ; uint16_t param_get_len(Id_t param_id); uint16_t param_get_type_len(ParamType_t type_id); uint32_t param_get_cnt(void);  #endif \/* PARAM_DRV_H  *\/ <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u0423\u0441\u043f\u0435\u0445. <\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3bd\/93d\/030\/3bd93d03008fd95277e02e5035036f36.png\" width=\"459\" height=\"232\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3bd\/93d\/030\/3bd93d03008fd95277e02e5035036f36.png\"\/><figcaption><\/figcaption><\/figure>\n<p><strong>\u0412\u044b\u0432\u043e\u0434<\/strong><\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0441\u0442\u0440\u043e\u044f\u0442\u0441\u044f \u0438\u0437 <strong>\u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438,<\/strong> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u043f\u043e\u0432\u0435\u0440\u0445 \u0434\u0440\u0443\u0433\u043e\u0433\u043e. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u044f\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u043e\u0433\u043e (\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u043f\u0440\u043e\u0448\u0438\u0432\u043e\u043a). \u041d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 on-\u0441hip NorFlash. \u041c\u043e\u0436\u043d\u043e \u0438 \u043d\u0430 off-chip NorFlash \u0438\u043b\u0438 EEPROM.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u0432 \u0441\u0432\u043e\u0438 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0421 \u0441 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u0442\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043b\u0438\u0447\u043a\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0442\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\"><strong>\u0410\u043a\u0440\u043e\u043d\u0438\u043c<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">FS<\/p>\n<\/td>\n<td>\n<p align=\"left\">file system<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">SPI<\/p>\n<\/td>\n<td>\n<p align=\"left\"> Serial Peripheral Interface<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">ID<\/p>\n<\/td>\n<td>\n<p align=\"left\">Identifier<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">NVIC<\/p>\n<\/td>\n<td>\n<p align=\"left\">Nested Vectored Interrupt Controller<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">CRC<\/p>\n<\/td>\n<td>\n<p align=\"left\">Cyclic redundancy check<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">NVS<\/p>\n<\/td>\n<td>\n<p align=\"left\">Non-Volatile Storage<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">API <\/p>\n<\/td>\n<td>\n<p align=\"left\">Application Programming Interface<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p><strong>Links<\/strong><\/p>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/584156\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/post\/584156\/<\/a><br \/><a href=\"https:\/\/habr.com\/ru\/post\/483280\/\" rel=\"noopener noreferrer nofollow\">https:\/\/habr.com\/ru\/post\/483280\/<\/a><\/p>\n<p><a href=\"https:\/\/www.allaboutcircuits.com\/technical-articles\/microfat-a-file-system-for-micro-controllers\/\" rel=\"noopener noreferrer nofollow\">https:\/\/www.allaboutcircuits.com\/technical-articles\/microfat-a-file-system-for-micro-controllers\/<\/a><br \/><a href=\"https:\/\/bestofcpp.com\/repo\/matt001k-STORfs\" rel=\"noopener noreferrer nofollow\">https:\/\/bestofcpp.com\/repo\/matt001k-STORfs<\/a><\/p>\n<p><a href=\"https:\/\/itnan.ru\/post.php?c=1&amp;p=573244\" rel=\"noopener noreferrer nofollow\">https:\/\/itnan.ru\/post.php?c=1&amp;p=573244<\/a><\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <\/p>\n<div class=\"tm-article-poll\">\n<div class=\"tm-notice tm-article-poll__notice tm-notice_positive\"><!----> <\/p>\n<div class=\"tm-notice__inner\"><!----> <\/p>\n<div class=\"tm-notice__content\"><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/post\/706972\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__header\">\u0412\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u0432 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u044d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0443\u044e Key-Value Map(\u043a\u0443)?<\/div>\n<div class=\"tm-article-poll__answers\">\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             46.15%           <\/span> <span class=\"tm-article-poll__answer-label\">\u0434\u0430<\/span> <span class=\"tm-article-poll__answer-votes\">             6           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:46.15%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">             53.85%           <\/span> <span class=\"tm-article-poll__answer-label\">\u043d\u0435\u0442<\/span> <span class=\"tm-article-poll__answer-votes\">             7           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width:53.85%;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__stats\">        \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 13 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.          \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 4 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.      <\/div>\n<\/div>\n<div class=\"tm-article-poll\">\n<div class=\"tm-notice tm-article-poll__notice tm-notice_positive\"><!----> <\/p>\n<div class=\"tm-notice__inner\"><!----> <\/p>\n<div class=\"tm-notice__content\"><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/post\/706972\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__header\">\u0412\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 FlashFS On-chip?<\/div>\n<div class=\"tm-article-poll__answers\">\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">             57.14%           <\/span> <span class=\"tm-article-poll__answer-label\">\u0434\u0430<\/span> <span class=\"tm-article-poll__answer-votes\">             8           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width:57.14%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             42.86%           <\/span> <span class=\"tm-article-poll__answer-label\">\u043d\u0435\u0442<\/span> <span class=\"tm-article-poll__answer-votes\">             6           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:42.86%;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__stats\">        \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 14 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.          \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 4 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.      <\/div>\n<\/div>\n<div class=\"tm-article-poll\">\n<div class=\"tm-notice tm-article-poll__notice tm-notice_positive\"><!----> <\/p>\n<div class=\"tm-notice__inner\"><!----> <\/p>\n<div class=\"tm-notice__content\"><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/post\/706972\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__header\">\u0412\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 FlashFS off-chip?<\/div>\n<div class=\"tm-article-poll__answers\">\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             42.86%           <\/span> <span class=\"tm-article-poll__answer-label\">\u0434\u0430<\/span> <span class=\"tm-article-poll__answer-votes\">             6           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:42.86%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">             57.14%           <\/span> <span class=\"tm-article-poll__answer-label\">\u043d\u0435\u0442<\/span> <span class=\"tm-article-poll__answer-votes\">             8           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width:57.14%;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__stats\">        \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 14 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.          \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 4 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.      <\/div>\n<\/div>\n<div class=\"tm-article-poll\">\n<div class=\"tm-notice tm-article-poll__notice tm-notice_positive\"><!----> <\/p>\n<div class=\"tm-notice__inner\"><!----> <\/p>\n<div class=\"tm-notice__content\"><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/post\/706972\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__header\">\u0412\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438c\u044c \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c\u0438 FatFS?<\/div>\n<div class=\"tm-article-poll__answers\">\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             46.15%           <\/span> <span class=\"tm-article-poll__answer-label\">\u0434\u0430<\/span> <span class=\"tm-article-poll__answer-votes\">             6           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:46.15%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">             53.85%           <\/span> <span class=\"tm-article-poll__answer-label\">\u043d\u0435\u0442<\/span> <span class=\"tm-article-poll__answer-votes\">             7           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width:53.85%;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__stats\">        \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 13 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.          \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u043b\u0438\u0441\u044c 5 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439.      <\/div>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/706972\/\"> https:\/\/habr.com\/ru\/post\/706972\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u0430 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430\u0445 \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0435 \u0435\u0441\u0442\u044c <strong>\u0447\u0438\u0441\u043b\u043e<\/strong> <strong>\u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435<\/strong> \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b\u043e\u043a \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435 \u0441\u0431\u0440\u043e\u0441\u043e\u043c \u043f\u0438\u0442\u0430\u043d\u0438\u044f. \u0412\u0441\u0435 \u044d\u0442\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043f\u043e-\u0441\u0432\u043e\u0435\u043c\u0443: StoreFS, FlashFS, \u042d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0430\u044f Key-Value Map(\u0430), HashMap(\u043a\u0430), NVS \u0438 \u043f\u0440\u043e\u0447\u0435\u0435.  <\/p>\n<p><strong>FlashFS<\/strong> \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0439 \u0443\u043c\u043d\u044b\u0445 \u043d\u0430\u0432\u043e\u0440\u043e\u0447\u0435\u043d\u043d\u044b\u0445 \u043c\u0438\u043a\u0440\u043e\u0441\u0445\u0435\u043c \u0442\u0438\u043f\u0430 \u0431\u0435\u0441\u043f\u0440\u043e\u0432\u043e\u0434\u043d\u044b\u0445 \u0442\u0440\u0430\u043d\u0441\u0438\u0432\u0435\u0440\u043e\u0432, \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432 \u0448\u0430\u0433\u043e\u0432\u044b\u0445 \u0434\u0432\u0438\u0433\u0430\u0442\u0435\u043b\u0435\u0439, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043e\u0434\u043e\u043c\u0435\u0442\u0440\u0430 \u0438 \u0442\u043f. \u041d\u0430\u043b\u0438\u0447\u0438\u0435 FlashFS \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a <strong>\u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c<\/strong> <strong>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e<\/strong> <strong>\u0441\u0431\u043e\u0440\u043e\u043a<\/strong> \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e <strong>\u0434\u043e<\/strong> <strong>\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/strong> \u0443\u0436\u0435 \u0432 Run-Time(\u0435).  \u0411\u0443\u043a\u0432\u0430\u043b\u044c\u043d\u043e \u043e\u0442\u043a\u0440\u044b\u0432 UART Shell \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u044f\u043c\u043e \u0440\u0443\u043a\u0430\u043c\u0438 \u0432 TeraTerm\/Putty \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u043e FlashFS \u043a\u043e\u043d\u0444\u0438\u0433\u0438 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c(reset(\u043d\u0443\u0442\u044c)) \u0433\u0430\u0434\u0436\u0435\u0442, \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0432\u044b\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438\u0441\u044c \u0432 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. Easy. \u0418 \u043d\u0435 \u043d\u0430\u0434\u043e \u0432\u0430\u0440\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0441 \u043a\u0430\u043a\u0438\u043c\u0438-\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430\u043c\u0438, \u043a\u043e\u0433\u0434\u0430 \u0435\u0441\u0442\u044c FlashFS.  FlashFs \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443.<\/p>\n<p>\u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e <strong>on-chip<\/strong> NorFlash? <\/p>\n<p>1&#8212;\u042d\u0442\u043e \u0434\u0435\u0448\u0435\u0432\u043e. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u043a\u0430\u0442\u044b\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0435\u0449\u0451 \u043f\u0430\u0440\u0430 \u043f\u0443\u0441\u0442\u044b\u0445 \u0441\u0442\u0440\u0430\u043d\u0438\u0446(\u0441\u0435\u043a\u0442\u043e\u0440\u043e\u0432) Flash(\u0430). \u0417\u0430 \u043d\u0435\u0451 &#171;\u0443\u0436\u0435 \u0437\u0430\u043f\u043b\u0430\u0447\u0435\u043d\u043e&#187; \u043f\u0440\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0435 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u0430. \u041d\u0435\u0442 \u043d\u0443\u0436\u0434\u044b \u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 off-chip SPI-NorFlash \u0447\u0438\u043f\u044b \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0433\u0430\u0431\u0430\u0440\u0438\u0442\u044b, \u0441\u0442\u043e\u0438\u043c\u043e\u0441\u0442\u044c, \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u0441\u0442\u0438\u043a\u0443, \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442\u044c \u043d\u0430\u0434\u0435\u0436\u043d\u043e\u0441\u0442\u044c, \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430.  FlashFS \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e\u0442 \u0441\u0430\u043c\u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0438 \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0432 STM32 \u043f\u0435\u0440\u0432\u044b\u0435 4 \u0441\u0435\u043a\u0442\u043e\u0440\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u043f\u043e <strong>16kByte, <\/strong>\u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e 128kByte. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u043e, \u0441 \u0440\u0430\u0441\u0447\u0435\u0442\u043e\u043c \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e\u0431\u044b  \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0430 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0445 \u0441\u0435\u043a\u0442\u043e\u0440\u0430\u0445 \u043f\u043e 16kByte  FlashFS(c\u044b) \u0441 \u043f\u043b\u0430\u0432\u043d\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u0443\u0435\u043c\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c. <\/p>\n<p>2&#8212;On-chip FS <strong>\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0435\u0435<\/strong> \u0447\u0435\u043c off-chip FS, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u0446\u0435\u043f\u0438\u0442\u044c\u0441\u044f \u043a SPI \u0438\u043b\u0438 SDIO \u043f\u0440\u043e\u0432\u043e\u0434\u0430\u043c \u043d\u0430 PCB \u0438 \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431\u044b\u043a\u043d\u043e\u0432\u0435\u043d\u043d\u044b\u043c \u043a\u0438\u0442\u0430\u0439\u0441\u043a\u0438\u043c \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c \u0437\u0430 500 \u0440\u0443\u0431\u043b\u0435\u0439.<\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0443 <strong>Nor-Flash<\/strong> \u043f\u0430\u043c\u044f\u0442\u0438 \u0435\u0441\u0442\u044c \u043e\u0434\u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430. \u0421\u0442\u0438\u0440\u0430\u0442\u044c \u0435\u0451 (\u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c 0xFF(\u043a\u0430\u043c\u0438)) \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e <strong>\u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430\u043c\u0438<\/strong> \u043f\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043a\u0438\u043b\u043e\u0431\u0430\u0439\u0442 (\u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e 4kByte, 8kByte, 16kByte, 64kByte, 128kByte). \u041e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0431\u0438\u0442\u044b 1 \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432 0. \u0418\u043d\u043e\u0433\u0434\u0430 \u0434\u0430\u0436\u0435 <strong>\u043d\u0435\u043b\u044c\u0437\u044f<\/strong> <strong>\u0434\u043e \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c<\/strong> \u0443\u0436\u0435 \u0441\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u044b\u0435 \u0431\u0438\u0442\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 \u0431\u0430\u0439\u0442\u0435 0x55. \u042d\u0442\u043e \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u0448\u0430\u0440\u0438\u043a\u043e\u0432\u043e\u0439 \u0440\u0443\u0447\u043a\u043e\u0439 \u043f\u043e \u0431\u0443\u043c\u0430\u0433\u0435. \u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0435 \u043d\u0435 \u0441\u043e\u0442\u0440\u0435\u0448\u044c \u043b\u0430\u0441\u0442\u0438\u043a\u043e\u043c. \u0415\u0441\u0442\u044c \u0441\u043c\u044b\u0441\u043b \u0438\u0441\u043f\u0438\u0441\u0430\u0442\u044c \u0432\u0435\u0441\u044c \u043b\u0438\u0441\u0442, \u0430 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0440\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0438 \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c.<\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 API \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 On-Chip Nor-Flash \u043f\u0430\u043c\u044f\u0442\u044c\u044e. <\/p>\n<pre><code class=\"cpp\">#ifndef FLASH_DRV_H #define FLASH_DRV_H  #include &lt;stdbool.h> #include &lt;stdint.h>  #include \"flash_const.h\"  #ifndef HAS_FLASH #error \"Add HAS_FLASH\" #endif  #ifndef HAS_MCU #error \"Add HAS_MCU\" #endif  #ifdef HAS_FLASH_WRITE bool flash_wr(uint32_t addr, uint8_t* array, uint32_t array_len); bool flash_wr4(uint32_t flash_addr, uint32_t* wr_array, uint32_t byte_size); bool flash_errase(uint32_t addr, uint32_t len); bool flash_erase_pages(uint8_t page_start, uint8_t page_end); #endif  bool Addr2SectorSize(uint32_t addr, uint32_t *sector, uint32_t *sec_size); bool flash_read(uint32_t in_flash_addr, uint8_t* rx_array, uint32_t array_len); bool flash_init(void); bool flash_scan(uint8_t* base, uint32_t size, float* usage_pec, uint32_t* spare, uint32_t* busy); bool is_errased(uint32_t addr, uint32_t size); bool is_flash_spare(uint32_t flash_addr, uint32_t size); bool is_flash_addr(uint32_t flash_addr);  #endif \/* FLASH_DRV_H *\/  <\/code><\/pre>\n<p>\u041d\u0430\u043c \u0436\u0435, \u043b\u044e\u0434\u044f\u043c, \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 <strong>\u043f\u043e<\/strong> <strong>\u043a\u043b\u044e\u0447\u0443<\/strong>. \u042d\u0442\u043e \u043a\u0430\u043a \u0432 \u0442\u0435\u0430\u0442\u0440\u0435. \u0414\u0430\u0435\u0448\u044c \u043d\u043e\u043c\u0435\u0440\u043e\u043a, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u0441\u0432\u043e\u0439 \u0442\u0440\u0435\u043d\u0447. \u0418\u043b\u0438 \u043a\u0430\u043a \u0432 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u043d\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u043d\u043e\u0439 \u043a\u043d\u0438\u0436\u043a\u0435. \u0414\u0430\u0435\u0448\u044c \u0438\u043c\u044f, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u043d\u043e\u043c\u0435\u0440 \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430.<\/p>\n<p>\u041d\u0443\u0436\u0435\u043d \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 <strong>\u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b \u0434\u0430\u0432\u0430\u043b \u0442\u0430\u043a\u043e\u0439 API \u0438 \u0434\u0435\u043b\u0430\u043b \u0431\u044b \u0432\u0441\u044e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u043e\u0434 \u043a\u0430\u043f\u043e\u0442\u043e\u043c \u0441 \u043c\u0430\u0441\u0441\u0438\u0432\u0430\u043c\u0438 \u0441\u044b\u0440\u043e\u0439 Flash \u043f\u0430\u043c\u044f\u0442\u0438. \u0414\u0430\u0435\u0448\u044c \u0447\u0438\u0441\u043b\u043e \u0438 \u043c\u0430\u0441\u0441\u0438\u0432, \u041c\u0430\u0441\u0441\u0438\u0432 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0427\u0435\u0440\u0435\u0437 \u043d\u0435\u0434\u0435\u043b\u044e \u0434\u0430\u0435\u0448\u044c \u0447\u0438\u0441\u043b\u043e, \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u043c\u0430\u0441\u0441\u0438\u0432.  <\/p>\n<p>\u042d\u0442\u043e \u043a\u0430\u043a \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u0430\u0440\u0430\u043d\u0434\u0430\u0448\u043e\u043c. \u041c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438 \u043c\u043e\u0436\u043d\u043e \u0441\u0442\u0435\u0440\u0435\u0442\u044c \u043b\u0430\u0441\u0442\u0438\u043a\u043e\u043c \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u043d \u0434\u0440\u0443\u0433\u043e\u0435. \u0423\u0434\u043e\u0431\u043d\u043e? \u041e\u0447\u0435\u043d\u044c. <\/p>\n<p>\u041f\u043e\u043f\u0440\u043e\u0431\u0443\u044e \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0438\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 <strong>\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f<\/strong> \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 embedded on-chip \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c <strong>FlashFS<\/strong>.<\/p>\n<p>1\u2013<strong>\u0420\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u0435<\/strong> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 Nor-Flash \u043f\u0430\u043c\u044f\u0442\u0438 (endurance optimization)<\/p>\n<p>2\u2013<strong>\u0417\u0430\u0448\u0438\u0442\u0430<\/strong> \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u0432\u043d\u0435\u0437\u0430\u043f\u043d\u043e\u0433\u043e <strong>\u043f\u0440\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f<\/strong> <strong>\u043f\u0438\u0442\u0430\u043d\u0438\u044f <\/strong>(power off tolerance). <\/p>\n<p>3\u2013<strong>\u041f\u0440\u043e\u0441\u0442\u043e\u0442\u0430<\/strong> \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u0435\u0447\u0435\u043c\u0443 \u0431\u044b\u043b\u043e \u043b\u043e\u043c\u0430\u0442\u044c\u0441\u044f. <\/p>\n<p>4&#8212;\u0424\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0441\u0442\u0440\u043e \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043f\u043e <strong>\u0438\u043c\u0435\u043d\u0438<\/strong><\/p>\n<p>5&#8212;\u0424\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d <strong>\u0431\u044b\u0441\u0442\u0440\u043e<\/strong> <strong>\u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f<\/strong><\/p>\n<p>6&#8212;\u0424\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d <strong>\u0431\u044b\u0441\u0442\u0440\u043e<\/strong> <strong>\u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c\u0441\u044f<\/strong><\/p>\n<p>7&#8212;\u0424\u0430\u0439\u043b \u0434\u043e\u043b\u0436\u0435\u043d <strong>\u0431\u044b\u0441\u0442\u0440\u043e<\/strong> <strong>\u0441\u0442\u0438\u0440\u0430\u0442\u044c\u0441\u044f<\/strong><\/p>\n<p>8&#8212;<strong>\u041a\u043e\u043c\u043f\u0430\u043a\u0442\u043d\u043e\u0441\u0442\u044c<\/strong> \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u044d\u0442\u043e\u0442 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c FlashFS. \u0427\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043a\u043e\u0434\u0430, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u0444\u0430\u0439\u043b\u043e\u0432.<\/p>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0441 \u0442\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u0435\u0439. \u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <strong>File<\/strong>?<\/p>\n<p><strong>File<\/strong> \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442\u043e\u0432 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0430\u043c\u044f\u0442\u0438 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0441\u0442\u0443\u043f\u0430\u0442\u044c RAM, ROM (Flash), FRAM, EEPROM, SD \u043a\u0430\u0440\u0442\u044b. \u0427\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439? \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043a \u044d\u0442\u0438\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e. \u041f\u0443\u0441\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0442\u0443\u0440\u0430\u043b\u044c\u043d\u043e\u0435 16-\u0431\u0438\u0442\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e. \u0422\u0430\u043a \u043f\u0440\u043e\u0449\u0435. \u0422\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432, \u0442\u043e \u0440\u044f\u0434\u043e\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0442\u0430\u043a\u0436\u0435 \u043d\u0430\u0434\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438 <strong>\u0434\u043b\u0438\u043d\u0443<\/strong> \u044d\u0442\u043e\u0433\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u0430. \u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 FlashFs.<\/p>\n<pre><code class=\"cpp\">struct xFlashFsFileHeader_t {     uint16_t id;     uint16_t nid; \/* bit inverted id*\/     uint16_t length;     uint8_t crc8;   \/*only for payload*\/ } __attribute__((packed)); \/*to save flash memory*\/ typedef struct xFlashFsFileHeader_t FlashFsFileHeader_t;<\/code><\/pre>\n<p><strong>\u041e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f Flash FS<\/strong><\/p>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0441 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438 ID, \u0442\u043e \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u042d\u0442\u0438\u043c \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u0437\u0430\u0449\u0438\u0442\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442 \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u043f\u0438\u0442\u0430\u043d\u0438\u044f. \u0412\u0441\u0435\u0433\u0434\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u0444\u0430\u0439\u043b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0444\u0430\u0439\u043b \u043e\u0441\u043d\u0430\u0449\u0435\u043d 8\u043c\u0438 \u0431\u0438\u0442\u043d\u043e\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u043e\u0439 \u0441\u0443\u043c\u043c\u043e\u0439. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u044b\u044f\u0432\u043b\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u043b\u0443\u0447\u0430\u0439\u043d\u044b\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438. \u0427\u0442\u043e\u0431\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0443\u044e \u0441\u0443\u043c\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u0430, \u0435\u0441\u0442\u044c \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u0430 \u0438\u0437 ID(\u0448\u043d\u0438\u043a\u043e\u0432). \u042d\u0442\u043e FileID \u0438 \u0435\u0433\u043e \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u043a\u043e\u043f\u0438\u044f.  \u0417\u0430\u0447\u0435\u043c \u043d\u0443\u0436\u0435\u043d \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 ID? \u042d\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u043a\u043e\u0440\u0438\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c \u0447\u0442\u043e \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f CRC \u044d\u0442\u043e \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430. \u0411\u044b\u043b\u043e \u0431\u044b \u0440\u0430\u0441\u0442\u043e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c CRC \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043e\u0442\u0441\u0442\u0443\u043f\u0430, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u0444\u0430\u0439\u043b \u0442\u0443\u0442 \u0438\u043b\u0438 \u043d\u0435\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0440\u0430\u0441\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442 CRC \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0442\u0435\u043c \u043e\u0442\u0441\u0443\u043f\u0430\u043c, \u0433\u0434\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u0430\u044f \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u0430.<\/p>\n<p>\u0418 \u0432\u043e\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u043b\u0430\u0441\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 \u0444\u043b\u0435\u0448\u044c \u043f\u0430\u043c\u044f\u0442\u0438. \u0427\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c? \u041d\u0430\u0434\u043e \u043e\u0442\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0432\u0442\u043e\u0440\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 \u0438 \u043f\u0435\u0440\u0435\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u0451 \u043f\u043e\u043f\u0430\u0440\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0430\u043c\u044b\u0435 \u0441\u0432\u0435\u0436\u0438\u0435 \u0444\u0430\u0439\u043b\u044b. <\/p>\n<p>\u041f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b \u043f\u0435\u0440\u0435\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e <strong>\u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435<\/strong> \u0432\u0435\u0440\u0441\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432. \u0421\u0442\u0430\u0440\u044b\u0435 \u043e\u0441\u0442\u0430\u044e\u0442\u0441\u044f \u0438 \u0436\u0434\u0443\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435\u0439. \u041f\u0440\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u0438\u0445 \u043e\u0442\u0447\u0438\u0441\u0442\u044f\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0432\u0441\u0435\u0439 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0435\u0439 NorFlash.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041f\u043e\u043c\u0438\u043c\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0447\u0442\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043f\u0438\u0441\u0438 \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0443\u0436\u043d\u0430 \u0435\u0449\u0435 \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043a\u0430\u043a \u0440\u0430\u0437 \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0441\u0430\u043c\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u041a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0430 &#171;B&#187; \u043f\u0435\u0440\u0435\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f, \u0442\u043e background \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0443 toggle flash page, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u0442\u0447\u0438c\u0442\u0438\u0442\u044c \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 &#171;A&#187;. \u0412\u0437\u044f\u0442\u044c \u0441\u0430\u043c\u044b\u0435 \u0441\u0432\u0435\u0436\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0438\u0437 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b &#171;B&#187; \u0438 \u043f\u0435\u0440\u0435\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 &#171;A&#187;. <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c API \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043d\u043e\u0439 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b<\/p>\n<pre><code class=\"cpp\"> #ifndef NOR_FLASH_H #define NOR_FLASH_H  #include &lt;stdbool.h> #include &lt;stdint.h>  #include \"flash_drv.h\" #include \"flash_fs_config.h\" #include \"flash_fs_types.h\"  #ifndef HAS_FLASH #error \"+ HAS_FLASH\" #endif  #ifndef HAS_NVS #error \"+ HAS_NVS\" #endif  #ifndef HAS_FLASH_FS #error \"+ HAS_FLASH_FS\" #endif  #ifndef HAS_CRC8 #error \"+HAS_CRC8\" #endif  #ifdef HAS_FLASH_FS_WRITE bool flash_fs_format(void); bool flash_fs_erase(void); bool flash_fs_invalidate(uint16_t data_id); bool flash_fs_set(uint16_t data_id, uint8_t* new_file, uint16_t new_file_len); bool flash_fs_maintain(void); bool flash_fs_turn_page(void); #endif  bool flash_fs_is_active(uint8_t page_num); bool flash_fs_init(void); bool flash_fs_proc(void); bool flash_fs_get(uint16_t data_id, uint8_t* value, uint16_t max_value_len, uint16_t* value_len); bool flash_fs_get_active_page(uint32_t* flash_fs_page_start, uint32_t* flash_fs_page_len); bool flash_fs_get_address(uint16_t data_id, uint8_t** value_address, uint16_t* value_len); bool is_flash_fs_addr(uint32_t addr); uint32_t flash_fs_get_page_size(uint8_t page_num); uint32_t flash_fs_get_page_base_addr(uint8_t page_num); uint32_t flash_fs_cnt_files(uint32_t start_page_addr, uint32_t page_len, uint32_t* spare_cnt); uint32_t flash_fs_get_remaining_space(void); uint8_t addr2page_num(uint32_t flash_fs_page_start);  #endif \/* MEMORY_MANAGER_NOR_FLASH_H *\/ <\/code><\/pre>\n<p>\u0417\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f FlashFs \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0430\u043a<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043b\u0438 \u0442\u0430\u043a <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b (\u0440\u0438\u0441 2). \u042d\u0442\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435, \u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u0430, \u0440\u0430\u0437\u043c\u0435\u0440, \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u043d\u0443\u0442\u0440\u0438, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c\u043d\u0430\u044f \u0441\u0443\u043c\u043c\u0430, ID(\u0448\u043d\u0438\u043a)<\/p>\n<figure class=\"full-width\"><figcaption>\u0440\u0438\u0441 2<\/figcaption><\/figure>\n<p>\u0421 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043b\u0438\u0441\u044c. \u041d\u043e \u0447\u0438\u0442\u0430\u0442\u044c \u0441\u044b\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0442\u043e\u0436\u0435 \u043a\u0430\u043a-\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c-\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e. \u0414\u043b\u044f \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u0430 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043d\u0438\u043c\u0431\u043b\u043e\u0432 (hex \u0440\u0430\u0437\u0440\u044f\u0434\u043e\u0432). \u041d\u0430\u0434\u043e \u043a\u0430\u043a-\u0442\u043e <strong>\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c<\/strong> \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0438\u0437\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0438 \u0442\u0438\u043f\u044b \u0434\u0430\u043d\u043d\u044b\u0445. \u042d\u0442\u0438\u043c \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <strong>Param.<\/strong><\/p>\n<p>\u041f\u043e\u0432\u0435\u0440\u0445 Flash Fs \u0434\u043e\u043b\u0436\u0435\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0443\u0440\u043e\u0432\u0435\u043d\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438. \u042f \u0435\u0433\u043e \u043d\u0430\u0437\u044b\u0432\u0430\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b (Param). \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u043d \u0442\u0430\u043a. \u0414\u0430\u0435\u0448\u044c ID \u0444\u0430\u0439\u043b\u0430 \u0438 \u0434\u0430\u043d\u043d\u044b\u0435 (hex \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u0434\u043b\u0438\u043d\u043d\u043e\u0439), \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0448\u044c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0435\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435. <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u043c\u043e\u0433\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u043e\u0442\u043e\u0442\u0438\u043f\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0434\u043b\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 <strong>param<\/strong><\/p>\n<pre><code class=\"cpp\">#ifndef PARAM_DRV_H #define PARAM_DRV_H  #include &lt;stdbool.h> #include &lt;stdint.h>  #include \"param_types.h\"  #ifndef HAS_PARAM #error \"+HAS_PARAM\" #endif \/*HAS_PARAM*\/  bool param_init(void); bool param_proc(void);  #ifdef HAS_PARAM_SET bool param_set(Id_t id, uint8_t* in_data); #endif \/*HAS_PARAM_SET*\/  bool param_get(Id_t id, uint8_t* out_data); ParamType_t param_get_type(Id_t id); uint16_t param_get_real_len(Id_t id) ; uint16_t param_get_len(Id_t param_id); uint16_t param_get_type_len(ParamType_t type_id); uint32_t param_get_cnt(void);  #endif \/* PARAM_DRV_H  *\/ <\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0441 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f. \u0423\u0441\u043f\u0435\u0445. <\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p><strong>\u0412\u044b\u0432\u043e\u0434<\/strong><\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0434\u043b\u044f \u043c\u0438\u043a\u0440\u043e\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u0441\u0442\u0440\u043e\u044f\u0442\u0441\u044f \u0438\u0437 <strong>\u0443\u0440\u043e\u0432\u043d\u0435\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438,<\/strong> \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u043f\u043e\u0432\u0435\u0440\u0445 \u0434\u0440\u0443\u0433\u043e\u0433\u043e. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0435 \u043a\u0430\u043a \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u043d\u0435\u0440\u0433\u043e\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u0443\u044e \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u044f\u043a\u043e\u0433\u043e \u0440\u0430\u0437\u043d\u043e\u0433\u043e (\u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043a, \u043f\u0440\u043e\u0448\u0438\u0432\u043e\u043a). \u041d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u043d\u0430 on-\u0441hip NorFlash. \u041c\u043e\u0436\u043d\u043e \u0438 \u043d\u0430 off-chip NorFlash \u0438\u043b\u0438 EEPROM.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0439\u0442\u0435 \u0432 \u0441\u0432\u043e\u0438 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b. \u0412 \u044d\u0442\u043e\u043c \u043d\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e\u0433\u043e.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u044b \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0444\u0430\u0439\u043b\u043e\u0432\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 \u0421 \u0441 \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438, \u0442\u043e \u043f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043b\u0438\u0447\u043a\u0443.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c, \u0447\u0442\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c, \u0442\u043e <\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-343595","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=343595"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/343595\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=343595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=343595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=343595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}