<?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>Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64403/migrating-optiga-trust-i2c-pal-from-nrf_drv_-to-nrfx_twim-causes-nrf_pwr_mgmt_run-to-not-return</link><description>I am currently testing Optiga Trust X using an NRF52 DK. I am using armgcc as my toolchain. 
 The example provided by the nRF5 SDK v17.0.0 is a great starting point and I was able to fully test the Optiga functionalities. 
 
 Now, I am integrating the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 15 Oct 2020 10:08:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64403/migrating-optiga-trust-i2c-pal-from-nrf_drv_-to-nrfx_twim-causes-nrf_pwr_mgmt_run-to-not-return" /><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/275028?ContentTypeID=1</link><pubDate>Thu, 15 Oct 2020 10:08:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3aaa8527-b8cf-424b-a75c-f9a06ff805ab</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Hi Einar,&lt;br /&gt;&lt;br /&gt;Thank you for looking into this and confirming that the approach to uninit all the Optiga related resources is indeed ok.&lt;br /&gt;&lt;br /&gt;Also appreciate the explanation on the nrf_crypto. It confirms that I&amp;#39;ve build a good understand of it after the initial post.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;All is clear now, thank you for the time.&lt;br /&gt;&lt;br /&gt;Best regards,&amp;nbsp;&lt;br /&gt;Pedro&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/274208?ContentTypeID=1</link><pubDate>Mon, 12 Oct 2020 07:55:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fbeaeb4-9abb-4a52-9e5a-426fd99a646d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Pedro Martins"]Either way, to release the hardware peripherals being used to communicate with Optiga, this problem can be solved by rewriting&amp;nbsp;this function as:[/quote]
&lt;p&gt;I do not see any problems with your approach. By adding a call to&amp;nbsp;optiga_comms_close() in&amp;nbsp;optiga_backend_uninit() you uninit the TWI manager and driver when calling nrf_crypto_uninit(), and that&amp;nbsp;will be initialized again if you call&amp;nbsp;nrf_crypto_init() at a later stage. I have added an internal feature request for this.&lt;/p&gt;
[quote user="Pedro Martins"]Since my knowledge of the nrf_crypto is limited, I am not sure if anything needs to be unitialized. At least, Optiga&amp;#39;s backend should be removed from the list of available backends, no? Can you please advice?[/quote]
&lt;p&gt;This is not how nrf_crypto is designed. You select backends in sdk_config.h, and the preprocessor verifies that there is maximum one backend for each specific algorithm. And when you call nrf_crypto_init() all backend are enabled and stay enabled until you call nrf_crypto_uninit().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/268089?ContentTypeID=1</link><pubDate>Fri, 04 Sep 2020 13:21:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3e37a1c-d33d-4b52-ae50-15cd4313d504</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Of course,&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;! &lt;br /&gt;I am also waiting for the crypto expert answer on the topic.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/267527?ContentTypeID=1</link><pubDate>Wed, 02 Sep 2020 06:37:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc307177-0e19-45bf-af5c-32071290c762</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Martin,&lt;/p&gt;
&lt;p&gt;I understand that you have solved the issue with the solution you proposed. It seems a sensible solution, however, i would like to get the expert to give his blessings to this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/267503?ContentTypeID=1</link><pubDate>Tue, 01 Sep 2020 17:25:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a758bf2-dd18-4f72-9e08-225636169688</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Dear&amp;nbsp; &lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for getting back to this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To clarify, I solved myTWI module issues using the solution&amp;nbsp;I proposed above.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I was just hoping that someone from your side could clarify if my approach is enough&amp;nbsp;to uninit the nrf_crypto module. Also, I would like to understand why the SDK had a comment saying&amp;nbsp;&lt;em&gt;Function to uninitialize OPTIGA backend - currently no implementation is required.&lt;/em&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/266701?ContentTypeID=1</link><pubDate>Thu, 27 Aug 2020 10:47:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56092156-3b28-4671-8218-3035c5d4f056</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Martin,&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Thanks for waiting so patiently, unfortunately, the expert of crypto is still unable to look at this at the moment, i will come back to you as soon as i get new info. sorry for the delays.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/264783?ContentTypeID=1</link><pubDate>Mon, 17 Aug 2020 08:35:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72cca498-7a79-418c-9f7e-3685745fcf12</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;My apologies for the delay in&amp;nbsp;answering&amp;nbsp;you.&lt;/p&gt;
&lt;p&gt;Thank you for the update.&amp;nbsp;Looking forward for the&amp;nbsp;crypto expert view on this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/264176?ContentTypeID=1</link><pubDate>Wed, 12 Aug 2020 08:02:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39e2db3a-dd23-4ced-af74-1723edf37b44</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
&lt;p&gt;Got a response that&amp;nbsp;&lt;span style="font-family:inherit;"&gt;the crypto expert will most likely look into this next week. We need to wait until then. Thanks for your patience.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/263671?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2020 15:36:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b4b632b-87bb-476e-86b2-6fcbbf45c17c</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Thank you for the help&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I look forward for the details.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/263519?ContentTypeID=1</link><pubDate>Fri, 07 Aug 2020 06:28:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:554ce65b-729a-4a29-996d-620b1717e21c</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thanks for sharing your thoughts Martin,&lt;/p&gt;
&lt;p&gt;I have asked the crypto expert to share some thoughts on this. The suggestions to uniinit function looks sensible to me. I will come back to you when i have some feedback from the crypto expert.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/263190?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 11:00:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0478a024-0c75-4e2a-948d-e375bc70b10a</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;The workaround works fine, but I shouldn&amp;#39;t need one. I decided to invest more time and further investigate the problem.&lt;/p&gt;
&lt;p&gt;Doing a complete trace of the function calls, one can see that&amp;nbsp;when calling nrf_crypto_init(), the call stack is:&lt;/p&gt;
&lt;p&gt;nrf_crypto_init()&lt;br /&gt;- optiga_backend_init()&lt;br /&gt;--&amp;nbsp;optiga_init()&lt;br /&gt;---&amp;nbsp;pal_gpio_init();&lt;br /&gt;--- pal_os_event_init();&lt;br /&gt;--- optiga_util_open_application(&amp;amp;optiga_comms);&lt;br /&gt;---- optiga_comms_open()&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When calling nrf_crypto_deinit(), the call stack is only:&lt;/p&gt;
&lt;p&gt;nrf_crypto_deinit()&lt;br /&gt;&lt;span&gt;- optiga_backend_uninit()&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;because&amp;nbsp;the&amp;nbsp;contents&amp;nbsp;of optiga_backend_uninit() are:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/** @internal @brief Function to uninitialize OPTIGA backend - currently no implementation is required.
 */
static ret_code_t optiga_backend_uninit(void)
{
    // Empty implementation
    return NRF_SUCCESS;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As you can see, nothing is being done and the twi_mngr is never&amp;nbsp;being uninitialized.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Since my knowledge of the nrf_crypto is limited, I am not sure if anything needs to be unitialized. At least, Optiga&amp;#39;s backend should be removed from the list of available backends, no? Can you please advice?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Either way, to release the hardware peripherals being used to communicate with Optiga, this problem can be solved by rewriting&amp;nbsp;this function as:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ret_code_t optiga_backend_uninit(void)
{
    if(optiga_comms_close(&amp;amp;optiga_comms) == PAL_STATUS_SUCCESS) {
      return NRF_SUCCESS;
    }
    else {
      return NRF_ERROR_INTERNAL;
    }
    
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/263135?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 08:28:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9280fdff-3c2c-4aae-a6e9-f732ccc49c03</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;[quote user="Pedro Martins"][/quote]&lt;/p&gt;
&lt;p&gt;I solved it by adding:&lt;/p&gt;
&lt;div style="height:30.9091px;width:100%;"&gt;
&lt;div style="bottom:0px;left:41px;right:0px;"&gt;
&lt;div style="height:61.8182px;margin-left:0px;margin-top:0px;width:782px;"&gt;
&lt;div style="padding:0px 4px;"&gt;
&lt;div style="height:15.454545021057129px;"&gt;&lt;span&gt;nrfx_twim_disable&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;m_twi_master&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div style="height:15.454545021057129px;"&gt;&lt;span&gt;nrfx_twim_uninit&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;&amp;amp;&lt;/span&gt;&lt;span&gt;m_twi_master&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style="height:15.4545px;left:4px;top:0px;width:7.07841px;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="bottom:0px;display:none;width:20px;"&gt;
&lt;div style="height:30.9091px;width:20px;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="display:none;height:20px;left:41px;right:0px;"&gt;
&lt;div style="height:20px;width:782px;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="font:inherit;height:auto;left:0px;overflow:hidden;top:0px;white-space:pre;width:auto;"&gt;
&lt;div style="font:inherit;height:auto;left:0px;overflow:visible;top:0px;white-space:pre;width:auto;"&gt;&lt;/div&gt;
&lt;div style="font-family:inherit;font-size:inherit;font-style:inherit;height:auto;left:0px;line-height:inherit;overflow:visible;top:0px;white-space:pre;width:auto;"&gt;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style="overflow:auto;"&gt;
&lt;pre style="display:none;"&gt;nrfx_twim_disable(&amp;amp;m_twi_master);
nrfx_twim_uninit(&amp;amp;m_twi_master);&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;after&amp;nbsp;the nrf_crypto_uninit and&amp;nbsp;before&amp;nbsp;initializing the twim again.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;this is very strange,&amp;nbsp;&lt;span&gt;nrf_twi_mngr_uninit should call&amp;nbsp;&lt;/span&gt;nrf_drv_twi_uninit -&amp;gt;&amp;nbsp;&amp;nbsp;nrfx_twim_uninit which also should disable the twim (nrfx_twim_disable)&lt;/p&gt;
&lt;p&gt;I understand that the preprocessor defines around this glue wrapper between nrx and the legacy driver is making it complicated here. But I am glad that you have a workaround for this. The idea was to create a simple glue layer so that the users using legacy drivers migrate easity to the new changes. But it seems that it can be complicated in some cases to use this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/262856?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2020 16:26:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0d8cb412-560d-40bd-bced-4401001c0ffd</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;[quote userid="90247" url="~/f/nordic-q-a/64403/migrating-optiga-trust-i2c-pal-from-nrf_drv_-to-nrfx_twim-causes-nrf_pwr_mgmt_run-to-not-return/262843"][/quote]&lt;/p&gt;
&lt;p&gt;However, since they require different communication speeds, I am alternatively disabling one and enabling the other to communicate. When I try to enable the second device, I am getting a&amp;nbsp;&lt;span&gt;NRF_ERROR_INVALID_STATE on the TWIM driver initialization.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In the meantime, I was able to fix this problem. Somehow, the&amp;nbsp;nrf_twi_mngr_uninit() was leaving the TWIM peripheral on a INITIALIZED STATE.&amp;nbsp;This function is called byNordics implementation of Optiga Trust X I2C pal_i2c_deinit, which on the code above is called by nrf_crypto_uninit().&lt;/p&gt;
&lt;p&gt;I solved it by adding:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;nrfx_twim_disable(&amp;amp;m_twi_master);
nrfx_twim_uninit(&amp;amp;m_twi_master);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;after&amp;nbsp;the nrf_crypto_uninit and&amp;nbsp;before&amp;nbsp;initializing the twim again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/262843?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2020 15:21:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9cd2154-90d3-4c39-bb12-8901fe3eceb5</guid><dc:creator>martinspedro</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/aryan"&gt;Susheel Nuguru&lt;/a&gt;,&lt;/p&gt;
&lt;p&gt;Thank you for the quick response!&lt;/p&gt;
&lt;p&gt;I apologize for&amp;nbsp;my long answer, but I am trying to be as detailed as possible here to reduce the number of messages exchanged.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/64403/migrating-optiga-trust-i2c-pal-from-nrf_drv_-to-nrfx_twim-causes-nrf_pwr_mgmt_run-to-not-return/262811"]As far as i can see nrf_twi_mngr uses nrf_drv_twi which in turn uses nrfx_twim (if NRF_DRV_TWI_USE_TWIM is defined)&amp;nbsp;[/quote]
&lt;p&gt;Yes, this is true depending on the macros you set.&lt;/p&gt;
&lt;p&gt;But&amp;nbsp;the issue is that you cannot manually set NRF_DRV_TWI_USE_TWIM,&amp;nbsp;as you said above, since the file&amp;nbsp; integration/nrfx/legacy/nrf_drv_twi.h does not check if it&amp;nbsp;has been previously defined elsewhere. Also, the macro expansion performed by the full chain of #includes that allows the integration of legacy nrf_drv_* with nrfx_* is complex, poorly documented and difficult to follow, since macros are defined and undefined across multiple files.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/64403/migrating-optiga-trust-i2c-pal-from-nrf_drv_-to-nrfx_twim-causes-nrf_pwr_mgmt_run-to-not-return/262811"]What errors do you get when you have this. I believe we need to convince the glue layer to use TWOM and make&amp;nbsp;&amp;nbsp;NRF_DRV_TWI_USE_TWIM set to true by satisfying its dependencies.[/quote]
&lt;p&gt;I was getting linking errors on the twi_mngr. I manage it to fix it by trial and error of defining NRFX_TWI_*, TWI_* and NRFX_TWIM_* macros. It is currently building correctly with the macros:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define TWI_ENABLED 1
#define TWI0_ENABLED 1
#define TWI0_USE_EASY_DMA 1
#define NRFX_TWI_ENABLED 1
#define NRFX_TWI0_ENABLED 1
#define NRF_TWI_MNGR_ENABLED 1
#define NRFX_TWIM_ENABLED 1&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="6207" url="~/f/nordic-q-a/64403/migrating-optiga-trust-i2c-pal-from-nrf_drv_-to-nrfx_twim-causes-nrf_pwr_mgmt_run-to-not-return/262811"]Can you please attach the project, so that i can give it a quick try.[/quote]
&lt;p&gt;I cannot do this&amp;nbsp;for the whole project do to privacy concerns, since the project is already in an advanced development state. I can, however, work on providing a minimal working example with only the TWI counterpart. Also,&amp;nbsp;please note that to&amp;nbsp;able to reproduce the error you will need an Optiga Trust X. Please advise if you want me to do this&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Regarding my initial questions:&lt;/p&gt;
[quote userid="90247" url="~/f/nordic-q-a/64403/migrating-optiga-trust-i2c-pal-from-nrf_drv_-to-nrfx_twim-causes-nrf_pwr_mgmt_run-to-not-return"]1. Is not possible to use, on the same application, nrf_drv_ + nrf_twi_mgnr and a nrfx_twim drivers, even if the former controls the TWI0 and the latter the TWIM1, correct?[/quote]
&lt;p&gt;From your answer I conclude that due to the &amp;quot;magic&amp;quot; of the nrfx integration layer, I am, in all cases, using the nrfx_twim, because&amp;nbsp;the nrf_twi_mngr, which uses nrf_drv_twi, is in fact using the nrfx_twim drivers, due to macros defined on the sdk_config.h&lt;/p&gt;
&lt;p&gt;Is my interpretation correct?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="90247" url="~/f/nordic-q-a/64403/migrating-optiga-trust-i2c-pal-from-nrf_drv_-to-nrfx_twim-causes-nrf_pwr_mgmt_run-to-not-return"]2. Why am I getting stuck on the pwr_mgmt_run routine and what can be done to fix it?[/quote]
&lt;p&gt;Regarding this bug, using the macros above I can compile and run the&amp;nbsp;my code&amp;nbsp;with one device using the twim drivers explicitly and another implicit (through nrf_twi_mngr).&lt;/p&gt;
&lt;p&gt;However, since they require different communication speeds, I am alternatively disabling one and enabling the other to communicate. When I try to enable the second device, I am getting a&amp;nbsp;&lt;span&gt;NRF_ERROR_INVALID_STATE on the TWIM driver initialization.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;A code snapshot is provided below. The error is happening on the line&amp;nbsp;&lt;em&gt;err_code = nrfx_twim_init(m_twi_master, &amp;amp;twim_config, twim_handler, NULL).&lt;/em&gt; Am I missing something? Please note that both initialization routines work well independently.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t err_code;

// Optiga Trust X Initialization
err_code = nrfx_clock_init(clock_event_handler);
APP_ERROR_CHECK(err_code);
nrfx_clock_lfclk_start();

// Init nrf_crypto, which initializes the OPTIGA backend, and the OPTIGA host library/stack
err_code = nrf_crypto_init();
DEMO_ERROR_CHECK(err_code);
NRF_LOG_INFO(&amp;quot;Optiga Trust X Init succesfull\r\n&amp;quot;);

optiga_trust_x_test();

err_code = nrf_crypto_uninit();
DEMO_ERROR_CHECK(err_code);
NRF_LOG_INFO(&amp;quot;Optiga Trust X Uninit succesfull\r\n&amp;quot;);


// Intialize second I2C device
#define MASTER_TWI_INST_ID     0       //!&amp;lt; TWI interface used as a master

static const nrfx_twim_t m_twi_master = NRFX_TWIM_INSTANCE(MASTER_TWI_INST_ID);


const nrfx_twim_config_t twim_config = {
   .scl                 = ARDUINO_SCL_PIN,
   .sda                 = ARDUINO_SDA_PIN,
   .frequency           = NRF_TWIM_FREQ_100K*8/10,  // Set to 80 kHz
   .interrupt_priority  = NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY,
   .hold_bus_uninit     = NRFX_TWIM_DEFAULT_CONFIG_HOLD_BUS_UNINIT
};

err_code = nrfx_twim_init(m_twi_master, &amp;amp;twim_config, twim_handler, NULL);
APP_ERROR_CHECK(err_code);

nrfx_twim_enable(m_twi_master);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for your help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Migrating OPTIGA TRUST I2C PAL from nrf_drv_* to nrfx_twim causes nrf_pwr_mgmt_run to not return</title><link>https://devzone.nordicsemi.com/thread/262811?ContentTypeID=1</link><pubDate>Mon, 03 Aug 2020 13:18:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c8ff35c-9295-4666-afd9-adbe09802300</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Martin,&lt;/p&gt;
[quote user=""]As far as I am aware, nrfx_twim cannot coexist with nrf_drv or nrf_twi_mngr, so I started porting the I2C NRF PAL to use only the nrfx_twim[/quote]
&lt;p&gt;As far as i can see nrf_twi_mngr uses nrf_drv_twi which in turn uses nrfx_twim (if NRF_DRV_TWI_USE_TWIM is defined)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user=""]&lt;span style="font-family:inherit;"&gt; I needed to&amp;nbsp;&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;remove&lt;/span&gt;&lt;span style="font-family:inherit;"&gt; my code that uses the nrfx_twim driver. Otherwise the application of the nrfx_glue and legacy porting&amp;nbsp;layer messes up compilation by defining the legacy drivers and undefining the nrfx so much that I cannot get an executable.&lt;/span&gt;[/quote]
&lt;p&gt;What errors do you get when you have this. I believe we need to convince the glue layer to use TWOM and make&amp;nbsp;&amp;nbsp;NRF_DRV_TWI_USE_TWIM set to true by satisfying its dependencies.&lt;/p&gt;
&lt;p&gt;Can you please attach the project, so that i can give it a quick try.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>