<?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>BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/123213/bmi270-accelerometer-device-is-ready-when-debugging-but-not-when-just-flashing-on-a-custom-board</link><description>I am using a custom board with a nrf5340 chip on it with vs code and sdk/toolchain of 2.9.1 and the bmi270 sample. I am getting and issue with my bmi270 accelerometer when I run, but it succeeds when I step through to debug. Here is the log when it fails</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 13 Aug 2025 11:19:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/123213/bmi270-accelerometer-device-is-ready-when-debugging-but-not-when-just-flashing-on-a-custom-board" /><item><title>RE: BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/thread/545506?ContentTypeID=1</link><pubDate>Wed, 13 Aug 2025 11:19:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23cb3efe-74c4-48ba-9de0-22ec55fa5482</guid><dc:creator>lcj</dc:creator><description>&lt;p&gt;That didn&amp;#39;t work. Seems to keep restarting over and over again when trying to switch between 1V8 and 3V0.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried with all kinds of variations of wait time between the vregh call&amp;nbsp; (which does nothing the 2nd time btw, so it should not be a problem) and the accelerometer initialization, even so much as 1 minute.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/thread/543964?ContentTypeID=1</link><pubDate>Tue, 29 Jul 2025 13:35:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3535370f-4cc4-4a87-b631-1dca70d49b3e</guid><dc:creator>lcj</dc:creator><description>&lt;p&gt;Ok. All of that is way over my head. It seems like there should be a way to control the timing of initialization. I guess checking with the code you provided will prove if the theory you have is correct or not. It seems like changing the VREGH every time is a little extreme, but I can test it out.&lt;/p&gt;
&lt;p&gt;There is no&amp;nbsp;&lt;code&gt;UICR_VREGHVOUT_VREGHVOUT_0V0&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;These are the options:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* Bits 2..0 : VREGH regulator output voltage. */
#define UICR_VREGHVOUT_VREGHVOUT_Pos (0UL) /*!&amp;lt; Position of VREGHVOUT field. */
#define UICR_VREGHVOUT_VREGHVOUT_Msk (0x7UL &amp;lt;&amp;lt; UICR_VREGHVOUT_VREGHVOUT_Pos) /*!&amp;lt; Bit mask of VREGHVOUT field. */
#define UICR_VREGHVOUT_VREGHVOUT_1V8 (0x0UL) /*!&amp;lt; 1.8 V */
#define UICR_VREGHVOUT_VREGHVOUT_2V1 (0x1UL) /*!&amp;lt; 2.1 V */
#define UICR_VREGHVOUT_VREGHVOUT_2V4 (0x2UL) /*!&amp;lt; 2.4 V */
#define UICR_VREGHVOUT_VREGHVOUT_2V7 (0x3UL) /*!&amp;lt; 2.7 V */
#define UICR_VREGHVOUT_VREGHVOUT_3V0 (0x4UL) /*!&amp;lt; 3.0 V */
#define UICR_VREGHVOUT_VREGHVOUT_3V3 (0x5UL) /*!&amp;lt; 3.3 V */
#define UICR_VREGHVOUT_VREGHVOUT_DEFAULT (0x7UL) /*!&amp;lt; Default voltage: 1.8 V */&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/thread/543938?ContentTypeID=1</link><pubDate>Tue, 29 Jul 2025 12:15:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f26d749f-7daa-4f5d-8ab8-0ef0dfa09dd0</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;because somehow debugger is changing the timings of the initialization inserting delays which happen to luckily working in the right way to stretch out time between rail goes to 3v and the driver probing the chip.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/thread/543912?ContentTypeID=1</link><pubDate>Tue, 29 Jul 2025 10:48:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2f2e2bb-f8e9-406f-b47b-e94386c088c5</guid><dc:creator>lcj</dc:creator><description>&lt;p&gt;But why does it work when I step through the debugger using my segger after it has already been set to 3V?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/thread/543873?ContentTypeID=1</link><pubDate>Tue, 29 Jul 2025 07:58:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a49a2ff0-345a-459b-aa1f-dda583e62c6a</guid><dc:creator>alicejess889</dc:creator><description>&lt;p&gt;It makes perfect sense that if the power manager only actively switches the rail when there&amp;#39;s a change in voltage, then simply requesting the same 3V it&amp;#39;s already providing wouldn&amp;#39;t trigger a true &amp;quot;power-on&amp;quot; cycle for the BMI270. The sensor&amp;nbsp;&lt;span data-sheets-root="1"&gt;&lt;a class="in-cell-link" href="https://melonsandboxgame.github.io/" rel="noopener noreferrer" target="_blank"&gt;melon sandbox&lt;/a&gt;&lt;/span&gt; effectively never sees that fresh power transition it needs for a proper reset and initialization.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/thread/543861?ContentTypeID=1</link><pubDate>Tue, 29 Jul 2025 07:34:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a40b116f-241c-48e7-9893-2e3f9394283d</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I think what is happening is that this little “power manager” only actually switches the rail when it goes from one voltage to another. The very first time you ask it to turn on 3 V, it does the job. But after that, asking for 3 V again does nothing because it’s already sitting at 3 V, even though the BMI270 never saw that fresh power-on. So when you stick a &lt;code&gt;k_sleep()&lt;/code&gt; right inside &lt;code&gt;bmi270_init()&lt;/code&gt;, it works. By then you’ve effectively powered the sensor and given it time to wake up. But your &lt;code&gt;SYS_INIT(..., POST_KERNEL)&lt;/code&gt; trick didn’t help, because you had already set the rail to 3 V and never toggled it a second time before the driver started.&lt;/p&gt;
&lt;p&gt;Easy workaround is to pulse the rail off and on again in the very early stages of SYS_INIT so that every boot actually transitions power.&lt;/p&gt;
&lt;p&gt;Do something like this&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static int set_voltage_early(const struct device *unused)
{
    ARG_UNUSED(unused);

    LOG_DBG(&amp;quot;Power-cycling BMI270 rail&amp;quot;);
    change_gpio_voltage(UICR_VREGHVOUT_VREGHVOUT_0V0);
    k_sleep(K_MSEC(5));

    change_gpio_voltage(UICR_VREGHVOUT_VREGHVOUT_3V0);
    k_sleep(K_MSEC(10));

    return 0;
}
SYS_INIT(set_voltage_early, PRE_KERNEL_1, 0);
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/thread/543596?ContentTypeID=1</link><pubDate>Fri, 25 Jul 2025 10:57:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba31651c-8ffc-4423-b974-8c4077b9591e</guid><dc:creator>lcj</dc:creator><description>&lt;p&gt;No luck:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; [00:00:00.740,661] &amp;lt;err&amp;gt; voltage: setup: -134
00&amp;gt; *** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ***
00&amp;gt; *** Using Zephyr OS v3.7.99-ca954a6216c9 ***
00&amp;gt; [00:00:00.741,485] &amp;lt;dbg&amp;gt; app: main: Starting BMI270 sensor example, test number 1
00&amp;gt; [00:00:00.741,516] &amp;lt;inf&amp;gt; voltage_mgr: change_gpio_voltage: REGOUT = 0xfffffffc
00&amp;gt; [00:00:00.741,516] &amp;lt;inf&amp;gt; voltage_mgr: change_gpio_voltage: target voltage is 4
00&amp;gt; [00:00:00.741,516] &amp;lt;dbg&amp;gt; app: main: Waiting 60 seconds for voltage to stabilize
00&amp;gt; [00:01:00.741,638] &amp;lt;err&amp;gt; app: Device bmi270@68 is not ready&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;and:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; [00:00:00.742,095] &amp;lt;err&amp;gt; voltage: setup: -134
00&amp;gt; *** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ***
00&amp;gt; *** Using Zephyr OS v3.7.99-ca954a6216c9 ***
00&amp;gt; [00:00:00.742,919] &amp;lt;dbg&amp;gt; app: main: Starting BMI270 sensor example, test number 1
00&amp;gt; [00:00:00.742,950] &amp;lt;inf&amp;gt; voltage_mgr: change_gpio_voltage: REGOUT = 0xfffffffc
00&amp;gt; [00:00:00.742,950] &amp;lt;inf&amp;gt; voltage_mgr: change_gpio_voltage: target voltage is 4
00&amp;gt; [00:00:00.742,950] &amp;lt;dbg&amp;gt; app: main: Waiting 120 seconds for voltage to stabilize
00&amp;gt; [00:02:00.743,072] &amp;lt;err&amp;gt; app: Device bmi270@68 is not ready&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; [00:00:00.733,551] &amp;lt;err&amp;gt; voltage: setup: -134
00&amp;gt; *** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ***
00&amp;gt; *** Using Zephyr OS v3.7.99-ca954a6216c9 ***
00&amp;gt; [00:00:00.734,375] &amp;lt;dbg&amp;gt; app: main: Starting BMI270 sensor example, test number 1
00&amp;gt; [00:00:00.734,405] &amp;lt;inf&amp;gt; voltage_mgr: change_gpio_voltage: REGOUT = 0xfffffffc
00&amp;gt; [00:00:00.734,405] &amp;lt;inf&amp;gt; voltage_mgr: change_gpio_voltage: target voltage is 4
00&amp;gt; [00:00:00.734,405] &amp;lt;dbg&amp;gt; app: main: Waiting 300 seconds for voltage to stabilize
00&amp;gt; [00:05:00.734,527] &amp;lt;err&amp;gt; app: Device bmi270@68 is not ready&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;change_gpio_voltage only does it the first time if it&amp;#39;s not at the right setting.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&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;However when I put&amp;nbsp;&lt;code&gt;k_sleep(K_SECONDS(2));&lt;/code&gt; in it works:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;static int bmi270_init(const struct device *dev)
{
	int ret;
	struct bmi270_data *data = dev-&amp;gt;data;
	uint8_t chip_id;
	uint8_t soft_reset_cmd;
	uint8_t init_ctrl;
	uint8_t msg;
	uint8_t tries;
	uint8_t adv_pwr_save;
k_sleep(K_SECONDS(2));
	ret = bmi270_bus_check(dev);
	if (ret &amp;lt; 0) {
		LOG_ERR(&amp;quot;Could not initialize bus&amp;quot;);
		return ret;
	}
	
	...
}&lt;/pre&gt;&lt;br /&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;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Obviously, that&amp;#39;s not a solution, but I hope it helps determine the problem and solution. Is there any way to delay the init?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve even tried this:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;static int set_volttage_early(void)
{
	int sleep_time = 2; // seconds
	LOG_DBG(&amp;quot;Setting GPIO voltage early in boot process&amp;quot;);
    int rt = change_gpio_voltage(UICR_VREGHVOUT_VREGHVOUT_3V0);
	LOG_DBG(&amp;quot;sleeping for %d seconds&amp;quot;, sleep_time);
	k_sleep(K_SECONDS(sleep_time));
	return rt;
}

SYS_INIT(set_volttage_early, POST_KERNEL, 1); &lt;/pre&gt;&lt;br /&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;But it doesn&amp;#39;t work (I put debug statements in the init to show order):&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;00&amp;gt; [00:00:00.719,299] &amp;lt;dbg&amp;gt; app: set_volttage_early: Setting GPIO voltage early in boot process
00&amp;gt; [00:00:00.719,299] &amp;lt;inf&amp;gt; voltage_mgr: change_gpio_voltage: REGOUT = 0xfffffffc
00&amp;gt; [00:00:00.719,329] &amp;lt;inf&amp;gt; voltage_mgr: change_gpio_voltage: target voltage is 4
00&amp;gt; [00:00:00.719,329] &amp;lt;inf&amp;gt; voltage_mgr: Target voltage already set. No action needed.
00&amp;gt; [00:00:00.719,329] &amp;lt;dbg&amp;gt; app: set_volttage_early: sleeping for 2 seconds
00&amp;gt; [00:00:02.719,696] &amp;lt;err&amp;gt; voltage: setup: -134
00&amp;gt; [00:00:02.719,726] &amp;lt;dbg&amp;gt; bmi270: bmi270_init: Initializing BMI270 sensor
00&amp;gt; *** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ***
00&amp;gt; *** Using Zephyr OS v3.7.99-ca954a6216c9 ***
00&amp;gt; [00:00:02.720,520] &amp;lt;dbg&amp;gt; app: main: Starting BMI270 sensor example, test number 2
00&amp;gt; [00:00:02.720,550] &amp;lt;dbg&amp;gt; app: main: Waiting 1 seconds for voltage to stabilize
00&amp;gt; [00:00:03.720,642] &amp;lt;err&amp;gt; app: Device bmi270@68 is not ready&lt;/pre&gt;&lt;br /&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;Seems strange I can delay before the init, but it only works in the init.&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: BMI270 Accelerometer device is ready when debugging but not when just flashing on a custom board</title><link>https://devzone.nordicsemi.com/thread/543442?ContentTypeID=1</link><pubDate>Thu, 24 Jul 2025 08:43:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ac6eaa49-957b-4e72-b75a-c7a46c7add10</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;It seems to me that the issue on your custom board the BMI270 driver runs immediately after reset, but the new 3 V rail isn’t stable yet. In a debugger session the halt gives enough time for the LDO to settle, but in a normal boot the sensor probe races ahead and fails.&lt;/p&gt;
&lt;p&gt;Can you try to add some delay about 50msafter&amp;nbsp;change_gpio_voltage and before&amp;nbsp;DEVICE_DT_GET_ONE so that it can give the sensor some time to initialize. It is very possible that the debugger which inserts extra clock cycles to halt the PC for debugging inserts enough delay to let the sensor initialize properly. Please try and let me know if this works.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>