<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Generate storage partition during build</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/114268/generate-storage-partition-during-build</link><description>Hi All, HW: nrf52840dk SW: ncs-v2.6.1 Issue: I&amp;#39;d like to be able to create a directory in my project say `/storage_part` place some files in, and during the build process have it generate a pre-built storage partition that contains my files in it that</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Sep 2024 15:16:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/114268/generate-storage-partition-during-build" /><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/501019?ContentTypeID=1</link><pubDate>Tue, 03 Sep 2024 15:16:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17a22f9d-b776-4f18-924f-731f09ed3bfb</guid><dc:creator>waderq21</dc:creator><description>&lt;p&gt;That did it, thanks for your help Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500449?ContentTypeID=1</link><pubDate>Thu, 29 Aug 2024 14:17:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57c51382-82c0-49e4-8b79-327fc8c0b75a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry, I was certain that I built the project with SDK v2.6.1, but I see now that I actually built it with SDK v2.7.0. When building with SDK v2.7.0, please make sure you use the pre-release version of the VS code extension:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1724939810226v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;This is needed to work with sysbuild (&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/releases_and_maturity/migration/migration_sysbuild.html"&gt;Migrating from multi-image builds to sysbuild&lt;/a&gt;) and the new HW model (&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/releases_and_maturity/migration/migration_hwmv2.html"&gt;igrating to the current hardware model&lt;/a&gt;). From the release notes:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1724939978344v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Build&amp;nbsp;configuration:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1724940051179v3.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Note: Sysbuild is enabled by default if you use West to install a new SDK, but not if you update your existing SDK with git checkout and west update. Therefore, you may want to explicitly enable it in the project configuration as shown above. (&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/app_dev/config_and_build/config_and_build_system.html#sysbuild_enabled_by_default"&gt;Sysbuild enabled by default&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;The partition manager gets enabled by default, which is why the storage partition got assigned a different starting address (0xfa000 vs 0xf8000).&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an updated version of the project:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/littlefs_5F00_2.7.0.zip"&gt;devzone.nordicsemi.com/.../littlefs_5F00_2.7.0.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This version includes the custom cmake commands to create the littlefs filesystem image. The generated littlefs_image.hex can be found in&amp;nbsp;build/littlefs_2.7.0. I did not manage to find a way to automatically merge it with the zephyr.hex, so it still needs to be programmed separately.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500297?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 19:52:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca6bb44d-cb0e-4b94-a3ac-313618cd1999</guid><dc:creator>waderq21</dc:creator><description>&lt;p&gt;Edit: Sorry never mind, accidently used the wrong hex file got to excited, v2.7.0 not working for me either&lt;br /&gt;&lt;br /&gt;To be as explicit as possible I removed the VSCode extension from the equation.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I took your zip file, and on nvs-v2.7.0 ( As this will setup littlefs version to 2.8, disk version 2.1 )&lt;br /&gt;&lt;br /&gt;I&amp;#39;m running the following&lt;br /&gt;&lt;br /&gt;west build --build-dir build/ --pristine --board nrf52840dk_nrf52840&lt;br /&gt;&lt;br /&gt;If I flash this on my board ignoring attempting to flash the littlefs partition on it yet. I get this output:&lt;br /&gt;&lt;br /&gt;Area 3 at 0xf8000 on flash-controller@4001e000 for 32768 bytes&lt;br /&gt;&lt;br /&gt;This from as far as I can tell is the only difference I can tell, tho even so it should be fine long as I account for it I would expect.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;My full steps:&lt;br /&gt;&lt;br /&gt;1)&amp;nbsp;&lt;span&gt;west build --build-dir build/ --pristine --board nrf52840dk_nrf52840&lt;/span&gt;&lt;br /&gt;2) mklittlefs -c textfiles -p 4096 -s 32768 lfs_part.bin&lt;br /&gt;3)&amp;nbsp;/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-objcopy -I binary -O ihex --change-addresses 0xf8000 lfs_part.bin lfs_part.hex&lt;br /&gt;&lt;br /&gt;Here I&amp;#39;ve tried two ways&lt;br /&gt;4a) west flash&lt;br /&gt;4a.1) nrfjprog --program lfs_part.hex --sectorerase --verify -r&lt;br /&gt;-----&lt;br /&gt;4b)&amp;nbsp;python3 /opt/nordic/ncs/v2.6.1/zephyr/scripts/build/mergehex.py -o merged.hex lfs_part.hex build/zephyr/merged.hex&lt;br /&gt;4b.1)&amp;nbsp;nrfjprog --program merged.hex --sectorerase --verify -r&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500292?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 19:33:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1f2533d-8f0d-4341-82ff-95a3e00473fa</guid><dc:creator>waderq21</dc:creator><description>&lt;p&gt;Ah I missed it but there&amp;#39;s another slight difference here:&lt;br /&gt;&lt;br /&gt;Mine:&lt;br /&gt;&lt;br /&gt;I: LittleFS version 2.5, disk version 2.0&lt;br /&gt;&lt;br /&gt;Yours:&lt;br /&gt;&lt;br /&gt;I: LittleFS version 2.8, disk version 2.1&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500286?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 19:01:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6465cbe8-3ca9-40d4-b4be-f83ab3f87a0d</guid><dc:creator>waderq21</dc:creator><description>&lt;p&gt;Yeah that hex works, I see the hello.txt print out.&lt;br /&gt;&lt;br /&gt;One thing I see different is when I build for nrf52840dk_52840 with the default prf.conf&lt;br /&gt;&lt;br /&gt;My default storage partition is 0xf8000 -&amp;gt; 0x100000 instead of 0xfa000.&lt;br /&gt;&lt;br /&gt;I tried building it for that&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;mklittlefs -c textfiles -p 4096 -s 32768 lfs_part.bin
/opt/nordic/ncs/toolchains/20d68df7e5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-objcopy -I binary -O ihex --change-addresses 0xf8000 lfs_part.bin lfs_part.hex
python3 /opt/nordic/ncs/v2.6.1/zephyr/scripts/build/mergehex.py -o merged.hex lfs_part.hex build/zephyr/zephyr.hex&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;But no luck,&lt;br /&gt;&lt;br /&gt;I also tried building it for 0xfa000&lt;br /&gt;&lt;br /&gt;But same as well.&lt;br /&gt;&lt;br /&gt;Are you building on v2.6.1?&lt;br /&gt;&lt;br /&gt;Side note as well I don&amp;#39;t know if it matters but I&amp;#39;m building with the VSCode extension&lt;br /&gt;&lt;br /&gt;Best Regards,&lt;br /&gt;Wade&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500283?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 18:47:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3209396c-347c-4bf1-b2f2-f6b57abd28cd</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Strange. I&amp;#39;m testing with the nRF52840 DK as the build target and using the default storage partition. This is the log I get:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Using Zephyr OS v3.6.99-100befc70c74 ***
Sample program to r/w files on littlefs
Area 1 at 0xfa000 on flash-controller@4001e000 for 24576 bytes
I: LittleFS version 2.8, disk version 2.1
I: FS at flash-controller@4001e000:0xfa000 is 6 0x1000-byte blocks with 512 cycle
I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
/lfs mount: 0
/lfs: bsize = 16 ; frsize = 4096 ; blocks = 6 ; bfree = 3

Listing dir /lfs ...
[FILE] boot_count (size = 1)
[FILE] hello.txt (size = 0)
[FILE] pattern.bin (size = 547)
/lfs/boot_count read count:1 (bytes: 1)
/lfs/boot_count write new boot count 2: [wr:1]
------ FILE: /lfs/pattern.bin ------
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And here is the hex file:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/merged_5F00_ltfs.hex"&gt;devzone.nordicsemi.com/.../merged_5F00_ltfs.hex&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Please try programming the hex file above as well.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500280?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 18:26:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d854984-209f-4205-8c86-d9607af8cc57</guid><dc:creator>waderq21</dc:creator><description>&lt;p&gt;Hrm yeah I&amp;#39;m seeing the same thing still on it&amp;#39;s initial boot&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;Area 3 at 0xf8000 on flash-controller@4001e000 for 32768 bytes
I: LittleFS version 2.5, disk version 2.0
I: FS at flash-controller@4001e000:0xf8000 is 8 0x1000-byte blocks with 512 cycle
I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
E: WEST_TOPDIR/modules/fs/littlefs/lfs.c:1234: Corrupted dir pair at {0x1, 0x0}
W: can&amp;#39;t mount (LFS -84); formatting&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I just built it plain board target: nrf52840dk_52840 and prj.conf, Are you just using the standard default storage partition that&amp;#39;s in internal?&lt;br /&gt;&lt;br /&gt;Then flashed it, and then flashed the littlefs.hex,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I tried merging them as well but no luck.&lt;br /&gt;&lt;br /&gt;Best Regards,&lt;br /&gt;Wade&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500276?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 17:52:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b42ae9f6-2534-4038-b0f6-659901746e8a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi Wade,&lt;/p&gt;
&lt;p&gt;I only verified that I was able to mount the partition and that it found the file I added (based on log output). I did not make any changes to the sample code. Attached below is the project I used. Could you please try that just to see if we get the same result?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/6675.littlefs.zip"&gt;devzone.nordicsemi.com/.../6675.littlefs.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500274?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 17:42:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dbde3b3-42a1-4ca0-834f-34cbc973b34d</guid><dc:creator>waderq21</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;br /&gt;&lt;br /&gt;Thanks for the reply,&lt;br /&gt;&lt;br /&gt;I tried making the changes you suggested but still unfortunately littlefs doesn&amp;#39;t mount cleanly onto it.&lt;br /&gt;&lt;br /&gt;For clarity I&amp;#39;m using the littlefs sample from the zephyr side, v3.5.99, slightly modified to put the storage partition into interal.&lt;br /&gt;&lt;br /&gt;The changes I made from my post before is to define the littlefs partition in a pm_static.yml&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;app:
  address: 0x0
  end_address: 0xfa000
  region: flash_primary
  size: 0xfa000
littlefs_storage:
  address: 0xfa000
  end_address: 0x100000
  placement:
    align:
      start: 0x1000
    before:
    - end
  region: flash_primary
  size: 0x6000
sram_primary:
  address: 0x20000000
  end_address: 0x20040000
  region: sram_primary
  size: 0x40000
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And I followed your steps of manually creating the partition and adjusting it&amp;#39;s address and flashing it separately. But I still get the error when attempting to mount, (the mounting procedure I havn&amp;#39;t changed from my post earlier)&lt;br /&gt;&lt;br /&gt;Error:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting nRF Connect SDK v3.5.99-ncs1-1 ***
Sample program to r/w files on littlefs
I: LittleFS version 2.5, disk version 2.0
I: FS at flash-controller@4001e000:0xfa000 is 6 0x1000-byte blocks with 512 cycle
I: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
E: WEST_TOPDIR/modules/fs/littlefs/lfs.c:1234: Corrupted dir pair at {0x1, 0x0}
W: can&amp;#39;t mount (LFS -84); formatting
I: /lfs1 mounted
/lfs1 mount: 0
/lfs1: bsize = 16 ; frsize = 4096 ; blocks = 6 ; bfree = 4

Listing dir /lfs1 ...
I: /lfs1 unmounted
/lfs1 unmount: 0&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;How are you mounting the filesystem and validating it?&lt;br /&gt;&lt;br /&gt;Best Regards,&lt;br /&gt;&lt;br /&gt;Wade&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Generate storage partition during build</title><link>https://devzone.nordicsemi.com/thread/500260?ContentTypeID=1</link><pubDate>Wed, 28 Aug 2024 16:24:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78e16017-c05b-462a-8426-c9494983c42e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello Wade,&lt;/p&gt;
&lt;p&gt;Unfortunately, I&amp;#39;m not aware of any existing samples that does this in the SDK. Our sample projects are mostly using the Settings module to manage persistent storage. That said, I think I was able to make it work. I built&amp;nbsp;mklittlefs from the 4.0.0 tag (did not change override any of the default build configurations) and used the littlefs sample from the SDK where the storage partition starts at&amp;nbsp;&lt;span&gt;0xfa000 and is 0x6000 bytes.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Commands I used to generate and program the filesystem image:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;$ mklittlefs -c textfiles/ -p 4096  -s 24576 littlefs.bin
$ arm-zephyr-eabi-objcopy -I binary -O ihex --change-addresses 0xfa000 littlefs.bin littlefs.hex
$ nrfjprog --program littlefs.hex --sectorerase --verify -r&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This was mostly based on the CMake file you posted, but instead of setting the block size, I set the page size to 4096 to match the internal page size of the chip. I&amp;#39;m not sure if the block size paramater applies here since we are using flash. Could this be the reason it didn&amp;#39;t work on your end?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>