{"id":24196,"date":"2021-11-28T20:58:03","date_gmt":"2021-11-28T11:58:03","guid":{"rendered":"https:\/\/www.souichi.club\/?p=24196"},"modified":"2022-03-19T17:17:41","modified_gmt":"2022-03-19T08:17:41","slug":"spiffs","status":"publish","type":"post","link":"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/","title":{"rendered":"Try to read and write files from a sketch using SPIFFS on ESP32"},"content":{"rendered":"<ul class=\"bogo-language-switcher list-view\"><li class=\"en-US en current first\"><span class=\"bogoflags bogoflags-us\"><\/span> <span class=\"bogo-language-name\"><a rel=\"alternate\" hreflang=\"en-US\" href=\"https:\/\/www.souichi.club\/en\/wp-json\/wp\/v2\/posts\/24196\/\" title=\"English\" class=\"current\" aria-current=\"page\">English<\/a><\/span><\/li>\n<li class=\"ja last\"><span class=\"bogoflags bogoflags-jp\"><\/span> <span class=\"bogo-language-name\"><a rel=\"alternate\" hreflang=\"ja\" href=\"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts\/24196\/\" title=\"Japanese\">\u65e5\u672c\u8a9e<\/a><\/span><\/li>\n<\/ul>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_79_2 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-69dbf7ced274a\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #454e5c;color:#454e5c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #454e5c;color:#454e5c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-69dbf7ced274a\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#SPIFFS\" >SPIFFS<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Environment\" >Environment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Install_the_uploader\" >Install the uploader<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Download\" >Download<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Unzip_the_file\" >Unzip the file<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Check_the_Arduino_IDE_environment\" >Check the Arduino IDE environment<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#tools\" >tools<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Check\" >Check<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Partition_Scheme\" >Partition Scheme<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Uploading\" >Uploading<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Prepare_the_files\" >Prepare the files<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#upload\" >upload<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Skecth\" >Skecth<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Loading\" >Loading<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-15\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Execution_Results\" >Execution Results<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-16\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Delete\" >Delete<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-17\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Write\" >Write<\/a><ul class='ez-toc-list-level-4' ><li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-18\" href=\"https:\/\/www.souichi.club\/en\/m5stack\/spiffs\/#Execution_Result\" >Execution Result<\/a><\/li><\/ul><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"SPIFFS\"><\/span>SPIFFS<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>There was a time when I wanted to save a configuration file on ESP32-WROOM-32 and load it from a sketch program.<\/p>\n\n\n\n<p>This article describes how I tried to use SPIFFS (SPI Flash File System).<\/p>\n\n\n\n<p>The saved file is stored in the user area of the ESP32 flash memory.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Environment\"><\/span>Environment<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The following environment was tested.<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-regular\">\n<table class=\"r_table01\">\n<tbody>\n<tr>\n<td class=\"r_td30\">\n<p>OS<\/p>\n<\/td>\n<td>\n<p>Windows 10 Home\uff0864 Bit\uff09<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Arduino IDE<\/p>\n<\/td>\n<td>\n<p>1.8.13<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td>\n<p>Module<\/p>\n<\/td>\n<td>\n<p>ESP32-WROOM-32<\/p>\n<p>ESP32 with Wi-Fi and Bluetooth in one module<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Install_the_uploader\"><\/span>Install the uploader<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Install the uploader in the Arduino IDE.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Download\"><\/span>Download<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p><a href=\"https:\/\/github.com\/me-no-dev\/arduino-esp32fs-plugin\" target=\"_blank\" rel=\"noreferrer noopener\">Go to this site<\/a>, scroll down, and click &#8220;releases page&#8221; under Download the tool archive from releases page.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-01.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-01.png?resize=768%2C359&#038;ssl=1\" alt=\"Download the spiffs uploader\" class=\"wp-image-24159\" width=\"768\" height=\"359\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-01.png?resize=1024%2C478&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-01.png?resize=300%2C140&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-01.png?resize=768%2C359&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-01.png?resize=1536%2C718&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-01.png?w=1862&amp;ssl=1 1862w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<p>Download ESP32FS-1.0.zip.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-02.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-02.png?resize=768%2C374&#038;ssl=1\" alt=\"Download ESP32FS-1.0.zip\" class=\"wp-image-24160\" width=\"768\" height=\"374\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-02.png?resize=1024%2C498&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-02.png?resize=300%2C146&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-02.png?resize=768%2C374&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-02.png?resize=1536%2C747&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-02.png?w=1862&amp;ssl=1 1862w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Unzip_the_file\"><\/span>Unzip the file<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When you unzip the downloaded file, you will see the following folder structure.<\/p>\n\n\n<pre><code class=\"lang-shell\">\u251c\u2500ESP32FS-1.0\n\u2502  \u2502      \n\u2502  \u251c\u2500ESP32FS\n\u2502  \u2502  \u2502\n\u2502  \u2502  \u251c\u2500\u2500tool\n\u2502  \u2502  \u2502  esp32fs.jar\n\u2502  \u2502  \u2502<\/code><\/pre>\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-01.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-01.png?resize=768%2C439&#038;ssl=1\" alt=\"unzipping\" class=\"wp-image-24202\" width=\"768\" height=\"439\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-01.png?resize=1024%2C585&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-01.png?resize=300%2C172&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-01.png?resize=768%2C439&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-01.png?resize=1536%2C878&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-01.png?w=1714&amp;ssl=1 1714w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Check_the_Arduino_IDE_environment\"><\/span>Check the Arduino IDE environment<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Start the Arduino IDE and check the sketchbook location.<\/p>\n\n\n\n<p>Select File &gt; Preferences.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-02.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-02.png?resize=768%2C491&#038;ssl=1\" alt=\"Preferences\" class=\"wp-image-24204\" width=\"768\" height=\"491\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-02.png?resize=1024%2C654&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-02.png?resize=300%2C191&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-02.png?resize=768%2C490&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-02.png?w=1341&amp;ssl=1 1341w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<p>Check the sketchbook location.<\/p>\n\n\n\n<p>The default location is C:\u00a5Users\u00a5Username\u00a5Documents\u00a5Arduino.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-03.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-03.png?resize=602%2C403&#038;ssl=1\" alt=\"Sketchbook Location\" class=\"wp-image-24205\" width=\"602\" height=\"403\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-03.png?w=802&amp;ssl=1 802w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-03.png?resize=300%2C201&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-03.png?resize=768%2C514&amp;ssl=1 768w\" sizes=\"auto, (max-width: 602px) 100vw, 602px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"tools\"><\/span>tools<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Create a &#8220;tools&#8221; folder under the above folder, and copy the folder and files under ESP32FS that you unzipped.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-04.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-04.png?resize=768%2C439&#038;ssl=1\" alt=\"folder copy\" class=\"wp-image-24206\" width=\"768\" height=\"439\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-04.png?resize=1024%2C585&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-04.png?resize=300%2C172&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-04.png?resize=768%2C439&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-04.png?resize=1536%2C878&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-04.png?w=1714&amp;ssl=1 1714w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Check\"><\/span>Check<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>After exiting the Arduino IDE and starting it up, I found that &#8220;ESP32 Sketch Data Upload&#8221; was added to the Tools menu.<\/p>\n\n\n\n<p>Use this menu to write the file to the flash memory of ESP32.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-05.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-05.png?resize=768%2C490&#038;ssl=1\" alt=\"ESP32 Sketch Data Upload\" class=\"wp-image-24209\" width=\"768\" height=\"490\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-05.png?resize=1024%2C653&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-05.png?resize=300%2C191&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-05.png?resize=768%2C490&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-05.png?w=1340&amp;ssl=1 1340w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Partition_Scheme\"><\/span>Partition Scheme<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>Select a Partition Scheme that has SPIFFS.<\/p>\n\n\n\n<p>When I selected a Partition Scheme without SPIFFS (e.g. Default 4MB with ffat (1.2MB APP\/1.5MB FATTS)) and tried to Upload, I got &#8220;SPIFFS Error: partition size could not be found! SPIFFS Error: partition size could not be found!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-07.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-07.png?resize=768%2C488&#038;ssl=1\" alt=\"Partition Scheme\" class=\"wp-image-24218\" width=\"768\" height=\"488\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-07.png?resize=1024%2C651&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-07.png?resize=300%2C191&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-07.png?resize=768%2C488&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-07.png?w=1341&amp;ssl=1 1341w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Uploading\"><\/span>Uploading<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Upload the file manually and try to read it from the sketch.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Prepare_the_files\"><\/span>Prepare the files<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>I created a &#8220;data&#8221; folder under the folder where the sketch is saved and put the file I want to copy (config.ini).<\/p>\n\n\n\n<p>The name of the &#8220;data&#8221; folder seems to be &#8220;predetermined&#8221;.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-06.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-06.png?resize=768%2C439&#038;ssl=1\" alt=\"created config.ini\" class=\"wp-image-24210\" width=\"768\" height=\"439\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-06.png?resize=1024%2C585&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-06.png?resize=300%2C172&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-06.png?resize=768%2C439&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-06.png?resize=1536%2C878&amp;ssl=1 1536w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-06.png?w=1714&amp;ssl=1 1714w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<p>config.ini<\/p>\n\n\n<pre><code class=\"lang-shell\">client_id=SKSPI0001\nflg1=1\nflg2=0\nflg3=0<\/code><\/pre>\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"upload\"><\/span>upload<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>When I selected Tools &gt; ESP32 Sketch Data Upload, the message &#8220;SPIFFS image Uploaded&#8221; appeared and the config.ini file under the data folder was written to ESP32.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-08.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-08.png?resize=768%2C491&#038;ssl=1\" alt=\"SPIFFS Image Uploaded\" class=\"wp-image-24219\" width=\"768\" height=\"491\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-08.png?resize=1024%2C655&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-08.png?resize=300%2C192&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-08.png?resize=768%2C491&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-08.png?w=1341&amp;ssl=1 1341w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<p>The message is as follows.<\/p>\n\n\n\n<p>It turns out that config.sys, desktop.ini (a file created automatically by Windows to store desktop display information), and spiffs.spiffs.bin files under the data folder have been written.<\/p>\n\n\n<pre><code class=\"lang-shell\">[SPIFFS] data   : D:\\GoogleDriveD\\M2B\\Program\\ArduinoProgram\\spiffsen\\data\n[SPIFFS] start  : 2686976\n[SPIFFS] size   : 1472\n[SPIFFS] page   : 256\n[SPIFFS] block  : 4096\n\/config.ini\n\/desktop.ini\n[SPIFFS] upload : C:\\Users\\UserName\\AppData\\Local\\Temp\\arduino_build_197820\/spiffsen.spiffs.bin\n[SPIFFS] address: 2686976\n[SPIFFS] port   : COM7\n[SPIFFS] speed  : 115200\n[SPIFFS] mode   : dio\n[SPIFFS] freq   : 80m\n\nesptool.py v3.0-dev\nSerial port COM7\nConnecting....\nChip is ESP32-D0WDQ6 (revision 1)\nFeatures: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None\nCrystal is 40MHz\nMAC: f0:08:d1:d2:7b:20\nUploading stub...\nRunning stub...\nStub running...\nConfiguring flash size...\nAuto-detected Flash size: 4MB\nCompressed 1507328 bytes to 3025...\nWriting at 0x00290000... (100 %)\nWrote 1507328 bytes (3025 compressed) at 0x00290000 in 0.3 seconds (effective 42913.3 kbit\/s)...\nHash of data verified.\n\nLeaving...\nHard resetting via RTS pin...<\/code><\/pre>\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Skecth\"><\/span>Skecth<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Loading\"><\/span>Loading<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A sketch that reads and displays the config.ini file under the data folder.<\/p>\n\n\n\n<p>spiffs.ino<\/p>\n\n\n<pre class=\"line-numbers\"><code class=\"lang-cpp\">\/*\n * SPIFFS Test Scketch\n *  \n *\/\n#include \"SPIFFS.h\"\n\nvoid setup() {\n    Serial.begin(115200);\n    SPIFFS.begin();\n    File fr = SPIFFS.open(\"\/config.ini\", \"r\");\n    while(fr.available()){\n        String readStr = fr.readStringUntil('\\n'); \/\/ Read one line\n        Serial.println(readStr);\n    }\n    fr.close();\n}\n\nvoid loop() {\n}<\/code><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Execution_Results\"><\/span>Execution Results<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p><br>The execution result of the serial monitor is as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-09.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-09.png?resize=768%2C314&#038;ssl=1\" alt=\"Serial Monitor\" class=\"wp-image-24225\" width=\"768\" height=\"314\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-09.png?resize=1024%2C419&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-09.png?resize=300%2C123&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-09.png?resize=768%2C314&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-09.png?w=1131&amp;ssl=1 1131w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Delete\"><\/span>Delete<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A sketch to remove unnecessary desktop.ini that was uploaded along with the manual upload.<\/p>\n\n\n<pre class=\"line-numbers\"><code class=\"lang-cpp\">\/*\n * SPIFFS Test Scketch\n *  \n *\/\n#include \"FS.h\"\n#include \"SPIFFS.h\"\n\nvoid setup() {\n    Serial.begin(115200);\n    SPIFFS.begin();\n    fs::FS fs = SPIFFS;\n    fs.remove(\"\/desktop.ini\");\n}\n\nvoid loop() {\n}<\/code><\/pre>\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Write\"><\/span>Write<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>A sketch that writes and rereads a file.<\/p>\n\n\n<pre class=\"line-numbers\"><code class=\"lang-cpp\">\/*\n * SPIFFS Test Scketch\n *  \n *\/\n#include \"SPIFFS.h\"\n\nvoid setup() {\n    Serial.begin(115200);\n    SPIFFS.begin();\n    File fr = SPIFFS.open(\"\/config2.ini\", \"w\"); \/\/ Write Mode\n    fr.println(\"confing2 test line1\");\n    fr.println(\"confing2 test line2\");\n    fr.close();\n    \n    File frr = SPIFFS.open(\"\/config2.ini\", \"r\"); \/\/ Read Mode\n    while(frr.available()){\n        String readStr = frr.readStringUntil('\\n');\n        Serial.println(readStr);\n    }\n    frr.close();\n}\n\nvoid loop() {\n}<\/code><\/pre>\n\n\n<h4 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Execution_Result\"><\/span>Execution Result<span class=\"ez-toc-section-end\"><\/span><\/h4>\n\n\n\n<p>The two lines that have been written are displayed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a class=\"r_image\" href=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-11.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-11.png?resize=768%2C314&#038;ssl=1\" alt=\"File Write Sketch Execution Result\" class=\"wp-image-24231\" width=\"768\" height=\"314\" srcset=\"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-11.png?resize=1024%2C419&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-11.png?resize=300%2C123&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-11.png?resize=768%2C314&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-en-11.png?w=1131&amp;ssl=1 1131w\" sizes=\"auto, (max-width: 768px) 100vw, 768px\" \/><\/a><\/figure>\n\n\n\n<p>This concludes this article.<\/p>\n\n\n<div class=\"postscript_balloon\">Finally.<\/div>\n\n\n<p>I hope this article will be useful to someone somewhere.<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>There was a time when I wanted to save a file on ESP32-WROOM-32 and load it from a sketch program. I found out that SPIFFS can be used.<\/p>\n","protected":false},"author":5,"featured_media":24195,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"en_US","_original_post":"https:\/\/www.souichi.club\/?p=24153","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[238],"tags":[],"class_list":["post-24196","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-m5stack","en-US"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.souichi.club\/wp-content\/uploads\/spiffs-15.jpg?fit=1920%2C1458&ssl=1","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts\/24196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/comments?post=24196"}],"version-history":[{"count":15,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts\/24196\/revisions"}],"predecessor-version":[{"id":24241,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/posts\/24196\/revisions\/24241"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/media\/24195"}],"wp:attachment":[{"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/media?parent=24196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/categories?post=24196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.souichi.club\/wp-json\/wp\/v2\/tags?post=24196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}