<?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>MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/91021/mcuboot-adding-custom-serial-flash-driver-as-secondary-partition</link><description>We use spi flash with custom driver and goal is to set it to act as secondary partition for MCUBoot. 
 The question is how to adapt driver to be accepted by MCUBoot, maybe there is an example on how driver should look like? 
 As far as I understand Nordic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 31 Aug 2022 13:15:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/91021/mcuboot-adding-custom-serial-flash-driver-as-secondary-partition" /><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/384151?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 13:15:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dae67fe-fb81-4c78-9201-86396daed27d</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;By the way, I will be gone until next Monday, so I won&amp;#39;t be able to answer until then.&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/384150?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 13:14:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19a50994-1903-4c48-bc30-3e19ff58b5cc</guid><dc:creator>Simon</dc:creator><description>[quote user="mesh777"]Where to put/how to reference at25xe081.yaml in the module? At the moment I have same problem as before that dts property is not found.[/quote]
&lt;p&gt;Did it not work putting it in the board folder like I suggested earlier?&lt;/p&gt;
&lt;p&gt;You can also try setting it like this:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.0.2/samples/nrf9160/lwm2m_client/dts/bindings/pwm-buzzer.yaml"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.0.2/samples/nrf9160/lwm2m_client/dts/bindings/pwm-buzzer.yaml&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
[quote user="mesh777"]How to include files to the module from the project?[/quote]
&lt;p&gt;Let&amp;#39;s say that you&amp;#39;re including&amp;nbsp;drivers/spi.h, like it&amp;#39;s done in the spi_nor.c driver&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/flash/spi_nor.c#L14"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/flash/spi_nor.c#L14&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Then you need to make sure that the application that is using your module (&lt;a href="https://github.com/nrfconnect/sdk-mcuboot/tree/v1.9.99-ncs1/boot/zephyr"&gt;mcuboot application&lt;/a&gt; in your case) has set CONFIG_SPI=y. This can be done by setting&amp;nbsp;CONFIG_SPI in&lt;span&gt;&amp;nbsp;&amp;lt;ncs&amp;gt;/bootloader/mcuboot/boot/zephyr/prj.conf (or through the main application using&amp;nbsp;&lt;/span&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/89146/how-to-overlay-b0n-config-in-cmake"&gt;the approaches in this ticket&lt;/a&gt;&lt;span&gt;).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It might be smart to do something like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/flash/Kconfig.nor#L6-L9"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/flash/Kconfig.nor#L6-L9&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Make it select or make it depend on the necessary dependencies. So in the above case, and error will be thrown if CONFIG_SPI is not enabled.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;For the out of tree driver example, it has defined a new Kconfig here:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/Kconfig#L4"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/Kconfig#L4&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can do the same four your out of tree driver, and call it &amp;quot;config SPI_FLASH_AT25&amp;quot; for example. Then you can modfiy the Kconfig file and make it depend on SPI, like below for example&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;menuconfig SPI_FLASH_AT25
    bool &amp;quot;AT25 family flash driver&amp;quot;
    select &amp;lt;something&amp;gt;
    .
    .
    depends on SPI
    help
        text text text&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s probably smart to do something like this as well:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/CMakeLists.txt#L3"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/CMakeLists.txt#L3&lt;/a&gt;. So you&amp;#39;re forced to set CONFIG_SPI_FLASH_AT25 in&amp;nbsp;&lt;span&gt;&amp;lt;ncs&amp;gt;/bootloader/mcuboot/boot/zephyr/prj.conf&amp;nbsp;(or through the main application using&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/89146/how-to-overlay-b0n-config-in-cmake"&gt;the approaches in this ticket&lt;/a&gt;) in order to use the spi flash driver.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/384049?ContentTypeID=1</link><pubDate>Wed, 31 Aug 2022 07:36:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6737f587-6fc0-47cc-869a-250b461eb50d</guid><dc:creator>mesh777</dc:creator><description>&lt;p&gt;Thanks a lot&amp;nbsp;for detailed information. I managed to make that driver is found and init function is called.&lt;/p&gt;
&lt;p&gt;I have&amp;nbsp;some more questions:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Where to put/how to reference at25xe081.yaml in the module? At the moment I have same problem as before that dts property is not found.&lt;/p&gt;
&lt;p&gt;How to include files to the module from the project? I have shared files between module and application (driver itself is used by application and the wrapper&amp;nbsp;inside the module). So module has to find source file and header files which&amp;nbsp;belong to project tree.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383961?ContentTypeID=1</link><pubDate>Tue, 30 Aug 2022 14:20:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0cbe6bc-3118-4565-b617-3f867090ab88</guid><dc:creator>Simon</dc:creator><description>[quote user="mesh777"]I need to make it out-of-tree anyway, could you please check how to proceed with that.[/quote]
&lt;p&gt;I talked to the developer of the out-of-tree-driver examples and got some hints on how to go about this.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First, add your custom SPI flash driver like done in the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/application_development/out_of_tree_driver"&gt;out_of_tree_driver example&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Remove the header file in&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr"&gt;https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Use #include&lt;span&gt; &lt;/span&gt;&lt;span&gt;&amp;lt;drivers/flash.h&amp;gt; in your&amp;nbsp;driver and implement all the functions needed from flash.h&amp;quot;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Instead of &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/CMakeLists.txt#L7"&gt;zephyr_library()&lt;/a&gt;, use zephyr_library_amend(), like done in &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.0.2/drivers/serial/CMakeLists.txt#L7"&gt;lpuart&lt;/a&gt;&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;Read about the zephyr_library amend future in &lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/19980"&gt;PR 19980&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Put your driver/CMakeList.txt into the file structure &amp;lt;zephyr_module_oot&amp;gt;/drivers/flash, like explained &lt;a href="https://github.com/zephyrproject-rtos/zephyr/pull/19980#:~:text=The%20amend%20function,entropy%2FCMakeLists.txt"&gt;here&lt;/a&gt;.
&lt;ul&gt;
&lt;li&gt;For example, the file structure for the module in the out-of-tree-driver example is &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr"&gt;&amp;lt;zephyr_module_oot&amp;gt;/zephyr&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Set CONFIG_&lt;span&gt;FLASH_NRF_FORCE_ALT=y in &amp;lt;ncs&amp;gt;/bootloader/mcuboot/boot/zephyr/prj.conf (or through the main application using &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/89146/how-to-overlay-b0n-config-in-cmake"&gt;the approaches in this ticket&lt;/a&gt;)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Make sure your custom flash driver is visible to mcuboot. For example if you have made an if statement like &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/samples/application_development/out_of_tree_driver/hello_world_module/zephyr/CMakeLists.txt#L3"&gt;this&lt;/a&gt;&amp;nbsp;then you need to make sure&amp;nbsp;CONFIG_HELLO_WORLD_DRIVER=y in mcuboot.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;span&gt;Also, the developer I talked to said that it may be simpler to just maintan a fork of NCS/nrf that has just that driver, instead of making it out-of-tree.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383935?ContentTypeID=1</link><pubDate>Tue, 30 Aug 2022 13:09:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abc68eea-d34c-49cd-a908-bee80399f2a8</guid><dc:creator>Simon</dc:creator><description>[quote user="mesh777"]I need to make it out-of-tree anyway, could you please check how to proceed with that.[/quote]
&lt;p&gt;Yes, of course I can look into that. I&amp;#39;ll do it tomorrow.&lt;/p&gt;
&lt;p&gt;However, I think it is smart to try to resolve one issue at the time. So I would recommend this approach:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Add your driver in-tree and make sure it works&lt;/li&gt;
&lt;li&gt;Add your fully working driver out-of-tree&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383928?ContentTypeID=1</link><pubDate>Tue, 30 Aug 2022 13:02:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a2af4a0-adca-48a2-b88c-f04fa8639973</guid><dc:creator>mesh777</dc:creator><description>&lt;p&gt;This is my own static function which resides in the driver.&lt;/p&gt;
&lt;p&gt;I need to make it out-of-tree anyway, could you please check how to proceed with that.&lt;/p&gt;
&lt;p&gt;Thank you again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383910?ContentTypeID=1</link><pubDate>Tue, 30 Aug 2022 12:29:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c398bed-c775-45f1-972b-f690b2b54daa</guid><dc:creator>Simon</dc:creator><description>[quote user="mesh777"]However init function is not called. In driver file the following macro is added at the end of file:[/quote]
&lt;p&gt;If your custom init function is not called, maybe it is because the custom driver file is not seen by the build system and added to the executable? Have you modified the CMakeLists.txt to include the source file? Like done for spi_nor.c for example here:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/drivers/flash/CMakeLists.txt#L6"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v2.7.0-ncs1/drivers/flash/CMakeLists.txt#L6&lt;/a&gt;&amp;nbsp;(try adding your driver in-tree first, just to make sure it works). You can check that the source file is included by looking in&amp;nbsp;/&amp;lt;sample&amp;gt;/build/&lt;strong&gt;mcuboot&lt;/strong&gt;/zephyr/drivers/flash/CMakeFiles/drivers__flash.dir I think (or just open build folder in vscode, click ctrl+P and search for the source (.c) file).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Again, I do think the spi_nor.c driver might support the&amp;nbsp;&lt;span&gt;at25x, at least it&amp;#39;s worth checking out.&lt;/span&gt;&lt;/p&gt;
[quote user="mesh777"]And&amp;nbsp;spi_flash_init is not called. What I am still missing?[/quote]
&lt;p&gt;Where did you find this function? I search through the whole NCS v1.8.0 (based on earlier logs, it seems like you&amp;#39;re using this version).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383877?ContentTypeID=1</link><pubDate>Tue, 30 Aug 2022 11:15:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9d24b43-5d28-452c-be4c-709d6a0ea951</guid><dc:creator>mesh777</dc:creator><description>&lt;p&gt;I checked&amp;nbsp;&lt;span&gt;build/&lt;/span&gt;&lt;strong&gt;mcuboot&lt;/strong&gt;&lt;span&gt;/zephyr/zephyr.dts, at25x appears in spi2 node. Also&amp;nbsp;device_get_binding is called with correct label. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However init function is not called. In driver file the following macro is added at the end of file:&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;DEVICE_DT_INST_DEFINE&lt;/span&gt;&lt;span&gt;(0, &amp;amp;&lt;/span&gt;&lt;span&gt;spi_flash_init&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;NULL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;amp;&lt;/span&gt;&lt;span&gt;spi_flash_data_0&lt;/span&gt;&lt;span&gt;, &amp;amp;&lt;/span&gt;&lt;span&gt;spi_flash_config_0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;POST_KERNEL, 80,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;amp;&lt;/span&gt;&lt;span&gt;spi_flash_api&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;And&amp;nbsp;spi_flash_init is not called. What I am still missing?&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383857?ContentTypeID=1</link><pubDate>Tue, 30 Aug 2022 10:26:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:459831b1-d31c-4221-9e70-f8feea03f2eb</guid><dc:creator>Simon</dc:creator><description>[quote user="mesh777"]Now I have problem with&amp;nbsp;device_get_binding, it returns Null for my driver. Although&amp;nbsp;MCUBoot uses the same dts file when building. What else could be possibly wrong?[/quote]
&lt;p&gt;There may be different reasons for the failure of device_get_binding(). I can see in the overlay you provider earlier that label=&amp;quot;AT25XE081&amp;quot;, so maybe you could start by putting a break point in mcuboot when device_get_binding() is called and check that it evaluates to device_get_binding(&amp;quot;AT25XE081&amp;quot;).&lt;/p&gt;
&lt;p&gt;Maybe also check the file build/&lt;strong&gt;mcuboot&lt;/strong&gt;/zephyr/zephyr.dts (notice that this is a different path than build/zephyr/zephyr.dts), and check if you find the at25x node, and that it is enabled. If not, you probably need to enable it following the approaches explained in&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/nrf/ug_multi_image.html#image-specific-variables"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/nrf/ug_multi_image.html#image-specific-variables&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If the init function of you driver fails (the&amp;nbsp;function that is passed into DEVICE_DT_INST_DEFINE, like done &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/flash/spi_nor.c#L1263-L1266"&gt;here&lt;/a&gt;), the call to device_get_binding will also fail.&lt;/p&gt;
&lt;p&gt;In &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/84235/zephyr-nrf5240-dk-lvgl-ssd1306#:~:text=Lastly%20you%20need,dts%23L113-L118"&gt;this reply&lt;/a&gt; I give some detailed explanations about why init function need to be successful for device_get_binding() to succeed, if you&amp;#39;re interested. It may be a bit outdated due to an older NCS version.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383280?ContentTypeID=1</link><pubDate>Thu, 25 Aug 2022 12:28:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9230e640-361b-4a99-bc6e-ad693212076f</guid><dc:creator>mesh777</dc:creator><description>&lt;p&gt;I use VS Code and GDB.&lt;/p&gt;
&lt;p&gt;Can you share working launch.json, as I am not able to manage to reach that breakpoint.&lt;/p&gt;
&lt;p&gt;EDIT: I enabled debugging by unchecking Debug Options in build configuration.&lt;/p&gt;
&lt;p&gt;Now I have problem with&amp;nbsp;device_get_binding, it returns Null for my driver. Although&amp;nbsp;MCUBoot uses the same dts file when building. What else could be possibly wrong?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383252?ContentTypeID=1</link><pubDate>Thu, 25 Aug 2022 11:38:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d98e961-4d95-49a5-b78f-72172e2c20c3</guid><dc:creator>Simon</dc:creator><description>[quote user="mesh777"]Maybe you can also provide a hint on how to debug the bootloader?[/quote]
&lt;p&gt;Ah, yes. Of course. If you debug through VS Code GDB it should be quite straightforward. See the following video:&amp;nbsp;&lt;a href="https://youtu.be/MGsZJpdLtco?list=PLx_tBuQ_KSqEt7NK-H7Lu78lT2OijwIMl&amp;amp;t=30"&gt;https://youtu.be/MGsZJpdLtco?list=PLx_tBuQ_KSqEt7NK-H7Lu78lT2OijwIMl&amp;amp;t=30&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then set a break point in &lt;a href="https://github.com/nrfconnect/sdk-mcuboot/blob/v1.9.99-ncs1/boot/zephyr/main.c#L472"&gt;&amp;lt;ncs location&amp;gt;/bootloader/mcuboot/boot/zephyr/main.c--&amp;gt;main()&lt;/a&gt;&amp;nbsp;and you can start to debug.&lt;/p&gt;
&lt;p&gt;Let me know if you don&amp;#39;t get it to work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383234?ContentTypeID=1</link><pubDate>Thu, 25 Aug 2022 10:46:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f15bc9f1-d5a6-488e-bb99-03632c87303a</guid><dc:creator>mesh777</dc:creator><description>&lt;p&gt;Thank you for information, Simon.&lt;/p&gt;
&lt;p&gt;Maybe you can also provide a hint on how to debug the bootloader?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/383219?ContentTypeID=1</link><pubDate>Thu, 25 Aug 2022 09:51:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8c453ff3-d5b4-4827-9b34-fbaa47de5694</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I just talked to a colleague familiar with this stuff, and asked if&amp;nbsp;&lt;span&gt;at25xe081 was supported by the spi_nor driver. He said as far as he knew, most of the NOR chips should be supported by the spi_nor driver, and most of the commands from the data sheets seems to be generic, so it should not be a problem as far as he knew.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;To get more details, and a more certain answer, try to&amp;nbsp;ask&amp;nbsp;the Zephyr experts on&amp;nbsp;&lt;a href="https://discord.com/invite/Ck7jw53nU2"&gt;Zephyr Discord&lt;/a&gt;, if&amp;nbsp;&lt;span&gt;at25xe081&amp;nbsp;is supported by the spi_nor driver (Maybe add a link to the data sheet).&lt;/span&gt;&lt;span&gt;&amp;nbsp;If that is the case, you may save a lot of time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Simon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/382999?ContentTypeID=1</link><pubDate>Wed, 24 Aug 2022 07:33:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ca7ca78-e1bc-443c-99ef-e195f1dc9263</guid><dc:creator>mesh777</dc:creator><description>&lt;p&gt;Is it possible to run debugger in bootloader (using VS Code) ?&lt;/p&gt;
&lt;p&gt;I managed to build the project, however get the following error from the bootloader:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.7.0-ncs1  ***
00&amp;gt; I: Starting bootloader
00&amp;gt; W: Failed reading sectors; BOOT_MAX_IMG_SECTORS=128 - too small?
00&amp;gt; E: ***** MPU FAULT *****
00&amp;gt; E:   Instruction Access Violation
00&amp;gt; E: r0/a1:  0x00000000  r1/a2:  0x00000000  r2/a3:  0x20000284
00&amp;gt; E: r3/a4:  0x00000020 r12/ip:  0xe6f7fbb5 r14/lr:  0x00000e4f
00&amp;gt; E:  xpsr:  0x61000000
00&amp;gt; E: Faulting instruction address (r15/pc): 0xe6f7fbb4
00&amp;gt; E: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
00&amp;gt; E: Current thread: 0x20000128 (unknown)
00&amp;gt; E: Resetting system&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And this is my pm_static.yml:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;external_flash:
  address: 0x0
  region: external_flash
  size: 0x800000
app:
  address: 0xc200
  end_address: 0x6DC80
  region: flash_primary
  size: 0x61A80
mcuboot:
  address: 0x0
  end_address: 0xc000
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0xc000
mcuboot_pad:
  address: 0xc000
  end_address: 0xc200
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x200
mcuboot_primary:
  address: 0xc000
  end_address: 0x6DC80
  orig_span: &amp;amp;id001
  - mcuboot_pad
  - app
  region: flash_primary
  sharers: 0x1
  size: 0x6DE80
  span: *id001
mcuboot_primary_app:
  address: 0xc200
  end_address: 0x6DC80
  orig_span: &amp;amp;id002
  - app
  region: flash_primary
  size: 0x61A80
  span: *id002
mcuboot_secondary:
  address: 0x0
  device: at25xe081
  end_address: 0x6DE80
  region: external_flash
  size: 0x6DE80
settings_storage:
  address: 0x7e000
  end_address: 0x80000
  placement:
    before:
    - end
  region: flash_primary
  size: 0x2000
sram_primary:
  address: 0x20000000
  end_address: 0x20010000
  region: sram_primary
  size: 0x10000&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/382753?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 16:28:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a731a2e5-af03-4a59-a474-a9c139d7c6d8</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Try adding the binding to&amp;nbsp;your board folder&amp;nbsp;like it&amp;#39;s done here (&amp;lt;board&amp;gt;/dts/bindings):&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/v2.0.2/boards/arm/thingy91_nrf9160/dts/bindings"&gt;https://github.com/nrfconnect/sdk-nrf/tree/v2.0.2/boards/arm/thingy91_nrf9160/dts/bindings&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Regarding adding your driver out-of-tree, I&amp;#39;m not sure if it will work by simply following this approach:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/application_development/out_of_tree_driver"&gt;https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/samples/application_development/out_of_tree_driver&lt;/a&gt;, since your driver should not be used directly, but rather through the flash.h API. The other flash drivers are put in&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/drivers/flash"&gt;https://github.com/nrfconnect/sdk-zephyr/tree/v3.0.99-ncs1/drivers/flash&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll ask internally tomorrow how to go about this.&lt;/p&gt;
&lt;p&gt;I realized that&amp;nbsp;it might be possible that the spi_nor driver actually supports the&amp;nbsp;at25xe081, I&amp;#39;ll look into this as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/382732?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 14:26:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54a3f18a-d508-4c37-80c7-4e93edc38a38</guid><dc:creator>mesh777</dc:creator><description>[quote userid="72692" url="~/f/nordic-q-a/91021/mcuboot-adding-custom-serial-flash-driver-as-secondary-partition/382731"] If this is not preferable, let me know, and I can look into do this out-of-tree.[/quote]
&lt;p&gt;Many thanks for fast response.&lt;/p&gt;
&lt;p&gt;Yes, I think it would be better to have out-of-tree solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/382731?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 14:22:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c96b8a7-336f-45c4-813e-d83be61da7ce</guid><dc:creator>Simon</dc:creator><description>[quote user="mesh777"]&lt;p&gt;And placed it in the same folder of project files, where my_board.dts resides. But still get the same error.&lt;/p&gt;
&lt;p&gt;Also I tried to modify my_board.yaml and added include of the new file, but it did not change anything.&lt;/p&gt;[/quote]
&lt;p&gt;Try placing it in the same folder as jedec,spi-nor.yaml, the folder zephyr/dts/bindings/mtd.&lt;/p&gt;
&lt;p&gt;This section may be useful to learn more about compatible/bindings:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/build/dts/bindings.html"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.2/zephyr/build/dts/bindings.html&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
[quote user="mesh777"]At the end it is important that MCUBoot builds using the new driver and I am not sure where to place files in order to accomplish that. Can these files be part of project or I have to modify SDK folder (that we want to avoid if possible).[/quote]
&lt;p&gt;I&amp;#39;m not sure how to add a dts bindings out of tree. However, adding it directly to Zephyr might not be a bad idea, then you could create a &lt;a href="https://github.com/zephyrproject-rtos/zephyr/pulls"&gt;Pull Request&lt;/a&gt; at the end, making your driver a part of Zephyr upstream (and Nordic Zephyr downstream). If this is not preferable, let me know, and I can look into do this out-of-tree.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/382701?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 13:24:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4177c5c4-d7c2-4f3c-8c24-807c65243c1c</guid><dc:creator>mesh777</dc:creator><description>&lt;p&gt;I created&amp;nbsp;at25xe081.yaml with the following content:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;description: |
  AT25XE081 serial flash.

compatible: &amp;quot;at25xe081&amp;quot;

include: spi-device.yaml

properties:
  size:
    type: int
    required: false
    description: flash capacity in bits&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And placed it in the same folder of project files, where my_board.dts resides. But still get the same error.&lt;/p&gt;
&lt;p&gt;Also I tried to modify my_board.yaml and added include of the new file, but it did not change anything.&lt;/p&gt;
&lt;p&gt;At the end it is important that MCUBoot builds using the new driver and I am not sure where to place files in order to accomplish that. Can these files be part of project or I have to modify SDK folder (that we want to avoid if possible).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/382636?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 10:41:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac689ba8-3789-435f-9051-0e71f4d9206b</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I could not&amp;nbsp;see that&amp;nbsp;at25xe081 is defined in a yaml file, which needs to be done in order to use it in a dts/overlay file.&lt;/p&gt;
&lt;p&gt;For example &amp;quot;jedec,spi-nor&amp;quot;, which is used in&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi#L66"&gt;zephyr/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi&lt;/a&gt;, is defined in the yaml file&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/dts/bindings/mtd/jedec%2Cspi-nor.yaml"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/dts/bindings/mtd/jedec%2Cspi-nor.yaml&lt;/a&gt;&amp;nbsp;+ the included files:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/dts/bindings/mtd/jedec%2Cspi-nor.yaml#L12"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/dts/bindings/mtd/jedec%2Cspi-nor.yaml#L12&lt;/a&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please create new a yaml file for&amp;nbsp;at25xe081.&lt;/p&gt;
&lt;p&gt;If it&amp;#39;s too much work, and too many abstraction layers to add the driver to Zephyr, you could probably add it directly to your application, and&amp;nbsp;maybe add it to Zephyr at a later point.&lt;/p&gt;
&lt;p&gt;You may find these DevZone cases useful:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://devzone.nordicsemi.com/support-private/support/269125#permalink=658068"&gt;https://devzone.nordicsemi.com/support-private/support/269125#permalink=658068&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/66230/how-to-add-new-i2c-based-sensor-device-to-ncs-v1-3-0-zephyr-drivers-sensor/271109"&gt;RE: How to add new i2c based sensor device to ncs\v1.3.0\zephyr\drivers\sensor&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/382569?ContentTypeID=1</link><pubDate>Mon, 22 Aug 2022 07:19:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87394e28-fd39-49f5-8d5c-4624b5c7f79c</guid><dc:creator>mesh777</dc:creator><description>&lt;p&gt;Thank you for clarification, Simon.&lt;/p&gt;
&lt;p&gt;At the moment I am struggling with this error: &amp;quot;zephyr\include\generated\devicetree_unfixed.h:6002:34: error: &amp;#39;DT_N_S_soc_S_spi_40023000_S_at25xe081_0_P_size&amp;#39; undeclared here (not in a function); did you mean &amp;#39;DT_N_S_soc_S_spi_40023000_S_at25xe081_0_P_reg&amp;quot;.&lt;/p&gt;
&lt;p&gt;I added this to my_board.dts file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi2 {
	status = &amp;quot;okay&amp;quot;;
	at25xe081: at25xe081@0 {
		compatible = &amp;quot;at25xe081&amp;quot;;
		reg = &amp;lt;0&amp;gt;;
		label = &amp;quot;AT25XE081&amp;quot;;
		size = &amp;lt;67108864&amp;gt;;
	};
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And in my driver wrapper I added&amp;nbsp;&lt;span&gt;#define&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;DT_DRV_COMPAT&lt;/span&gt;&lt;span&gt; at25xe081. However it seems that size property is not found when I am doing:&amp;nbsp;&lt;/span&gt;&lt;span&gt;flash_size = &lt;/span&gt;&lt;span&gt;DT_INST_PROP&lt;/span&gt;&lt;span&gt;(0, size) / 8. What I am missing here?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MCUBoot: adding custom serial flash driver as secondary partition</title><link>https://devzone.nordicsemi.com/thread/381826?ContentTypeID=1</link><pubDate>Tue, 16 Aug 2022 15:31:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dd75767-d8c4-4f06-98e4-c9108432ee08</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;The nRF91 DK which contains an&amp;nbsp;&lt;span&gt;mx25r64, and it will use the spi nor driver to communicate with it:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi#L66"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi#L66&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/flash/spi_nor.c#L10"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/drivers/flash/spi_nor.c#L10&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As you can see, the spi_nor.c is located inside &lt;em&gt;zephyr/drivers/flash&lt;/em&gt;.&amp;nbsp;&lt;/span&gt;If you do it this way, you will be able to write/read to the spi flash using the &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.0.99-ncs1/include/zephyr/drivers/flash.h"&gt;flash API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;After&amp;nbsp;adding your spi flash driver and adding your flash device to the device tree you can put the secondary partition in your external flash by doing the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Point&amp;nbsp;&lt;span&gt;nordic,pm-ext-flash to your flash device in DTS:&lt;/span&gt;
&lt;ul&gt;
&lt;li&gt;Like done here:&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.0.2/tests/modules/mcuboot/external_flash/boards/thingy53_nrf5340_cpuapp.overlay#L3"&gt;https://github.com/nrfconnect/sdk-nrf/blob/v2.0.2/tests/modules/mcuboot/external_flash/boards/thingy53_nrf5340_cpuapp.overlay#L3&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;In a pm_static.yml/pm.yml file, configure secondary partition to be placed in external flash
&lt;ul&gt;
&lt;li&gt;Set region to external_flash like explained here:&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/nrf/scripts/partition_manager/partition_manager.html#external-flash-memory-partitions"&gt;https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.0.0/nrf/scripts/partition_manager/partition_manager.html#external-flash-memory-partitions&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>