<?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>Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82067/writing-reading-data-to-external-flash-on-the-nrf9160dk</link><description>Hello Nordic! I have connected a sensor to the DK via SPI. It outputs a lot of data, a lot... for 1 second of data I get 4096 entries. Each entry is 10 bytes in length. 
 I want to store 20 seconds of sensor data on the flash memory, that is a total of</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 13 Dec 2021 15:53:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82067/writing-reading-data-to-external-flash-on-the-nrf9160dk" /><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/343252?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 15:53:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d345e40a-0b6f-4254-8eb5-c60f2fef4a39</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Yes, building for the &amp;quot;nrf9160dk_nrf9160_ns&amp;quot; board. Using the sample with the correct board setup I still get the same errors I posted above. Are you able to run the sample without any mods on nrf9160dk? If that&amp;#39;s the case I might need to do a reset. Thanks again, appreciate it.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit: The reset helped, I must have written something goofy somewhere. Thanks H&amp;aring;kon, you the man. I&amp;#39;ll buy you a beer if you ever come to Gothenburg.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/343247?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 15:16:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b02c1197-8211-4bad-93ab-74618d05ac31</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The &amp;quot;compatible&amp;quot; member shall be inherited from the board itself, ie. this line:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts#L197"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common.dts#L197&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which board are you configuring for? It should be the &amp;quot;nrf9160dk_nrf9160_ns&amp;quot; board.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;PS: remember to delete any ancient build folders, especially when&amp;nbsp;editing static partition layout.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/343209?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 14:05:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d8fca0a-314b-4e2e-8e5a-3e20ed3bcf1c</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Thanks H&amp;aring;kon, I tried the sample but having trouble with the SPI-bus. &amp;quot;Node should only occur on the spi bus&amp;quot;, I&amp;#39;m guessing that occurs because the sample you sent does not have a&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;compatible = &amp;quot;nordic,nrf-spim&amp;quot;;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;If I do include that, I instead get these errors:&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1040x46/__key/communityserver-discussions-components-files/4/3288.Untitled.png" /&gt;&lt;br /&gt;&lt;br /&gt;Thank you for all the help, you are my Gandalf in Moria.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/343143?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 12:13:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e59e02fd-623f-4c4f-8c18-c829b140a604</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a modified littlefs sample, with nrf9160dk ext flash support:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ncs1_5F00_7_5F00_nrf9160dk_5F00_ext_5F00_flash_5F00_littlefs.zip"&gt;devzone.nordicsemi.com/.../ncs1_5F00_7_5F00_nrf9160dk_5F00_ext_5F00_flash_5F00_littlefs.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/342976?ContentTypeID=1</link><pubDate>Fri, 10 Dec 2021 15:43:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71f13416-0c87-478a-9566-f1e15a01ef66</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Seems like the namespace littlefs_storage is not accepted when I try to build the project. I get this:&lt;br /&gt;&lt;br /&gt;&amp;#39;PM_littlefs_storage_ID&amp;#39; undeclared here (not in a function); did you mean &amp;#39;littlefs_storage&amp;#39;?&lt;br /&gt;&lt;br /&gt;I&amp;#39;m trying to use the example from Zephyr&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* Matches LFS_NAME_MAX */
#define MAX_PATH_LEN 255

#define PARTITION_NODE DT_NODELABEL(mx25r6435f)

#if DT_NODE_EXISTS(PARTITION_NODE)
FS_FSTAB_DECLARE_ENTRY(PARTITION_NODE);
#else  /* PARTITION_NODE */
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
static struct fs_mount_t lfs_storage_mnt = {
	.type = FS_LITTLEFS,
	.fs_data = &amp;amp;storage,
	.storage_dev = (void *)FLASH_AREA_ID(storage),
	.mnt_point = &amp;quot;/lfs&amp;quot;,
};
#endif /* PARTITION_NODE */

void memtest(void)
{
	struct fs_mount_t *mp =
#if DT_NODE_EXISTS(PARTITION_NODE)
		&amp;amp;FS_FSTAB_ENTRY(PARTITION_NODE)
#else
		&amp;amp;lfs_storage_mnt
#endif
		;
	unsigned int id = (uintptr_t)mp-&amp;gt;storage_dev;
	char fname[MAX_PATH_LEN];
	struct fs_statvfs sbuf;
	const struct flash_area *pfa;
	int rc;

	snprintf(fname, sizeof(fname), &amp;quot;%s/boot_count&amp;quot;, mp-&amp;gt;mnt_point);

	rc = flash_area_open(id, &amp;amp;pfa);
	if (rc &amp;lt; 0)
	{
		printk(&amp;quot;FAIL: unable to find flash area %u: %d\n&amp;quot;,
			   id, rc);
		return;
	}

	printk(&amp;quot;Area %u at 0x%x on %s for %u bytes\n&amp;quot;,
		   id, (unsigned int)pfa-&amp;gt;fa_off, pfa-&amp;gt;fa_dev_name,
		   (unsigned int)pfa-&amp;gt;fa_size);

	/* Optional wipe flash contents */
	if (IS_ENABLED(CONFIG_APP_WIPE_STORAGE))
	{
		printk(&amp;quot;Erasing flash area ... &amp;quot;);
		rc = flash_area_erase(pfa, 0, pfa-&amp;gt;fa_size);
		printk(&amp;quot;%d\n&amp;quot;, rc);
	}

	flash_area_close(pfa);

	/* Do not mount if auto-mount has been enabled */
#if !DT_NODE_EXISTS(PARTITION_NODE) || \
	!(FSTAB_ENTRY_DT_MOUNT_FLAGS(PARTITION_NODE) &amp;amp; FS_MOUNT_FLAG_AUTOMOUNT)
	rc = fs_mount(mp);
	if (rc &amp;lt; 0)
	{
		printk(&amp;quot;FAIL: mount id %u at %s: %d\n&amp;quot;,
			   (unsigned int)mp-&amp;gt;storage_dev, mp-&amp;gt;mnt_point,
			   rc);
		return;
	}
	printk(&amp;quot;%s mount: %d\n&amp;quot;, mp-&amp;gt;mnt_point, rc);
#else
	printk(&amp;quot;%s automounted\n&amp;quot;, mp-&amp;gt;mnt_point);
#endif

	rc = fs_statvfs(mp-&amp;gt;mnt_point, &amp;amp;sbuf);
	if (rc &amp;lt; 0)
	{
		printk(&amp;quot;FAIL: statvfs: %d\n&amp;quot;, rc);
		goto out;
	}

	printk(&amp;quot;%s: bsize = %lu ; frsize = %lu ;&amp;quot;
		   &amp;quot; blocks = %lu ; bfree = %lu\n&amp;quot;,
		   mp-&amp;gt;mnt_point,
		   sbuf.f_bsize, sbuf.f_frsize,
		   sbuf.f_blocks, sbuf.f_bfree);

	struct fs_dirent dirent;

	rc = fs_stat(fname, &amp;amp;dirent);
	printk(&amp;quot;%s stat: %d\n&amp;quot;, fname, rc);
	if (rc &amp;gt;= 0)
	{
		printk(&amp;quot;\tfn &amp;#39;%s&amp;#39; siz %u\n&amp;quot;, dirent.name, dirent.size);
	}

	struct fs_file_t file;

	fs_file_t_init(&amp;amp;file);

	rc = fs_open(&amp;amp;file, fname, FS_O_CREATE | FS_O_RDWR);
	if (rc &amp;lt; 0)
	{
		printk(&amp;quot;FAIL: open %s: %d\n&amp;quot;, fname, rc);
		goto out;
	}

	uint32_t boot_count = 0;

	if (rc &amp;gt;= 0)
	{
		rc = fs_read(&amp;amp;file, &amp;amp;boot_count, sizeof(boot_count));
		printk(&amp;quot;%s read count %u: %d\n&amp;quot;, fname, boot_count, rc);
		rc = fs_seek(&amp;amp;file, 0, FS_SEEK_SET);
		printk(&amp;quot;%s seek start: %d\n&amp;quot;, fname, rc);
	}

	boot_count += 1;
	rc = fs_write(&amp;amp;file, &amp;amp;boot_count, sizeof(boot_count));
	printk(&amp;quot;%s write new boot count %u: %d\n&amp;quot;, fname,
		   boot_count, rc);

	rc = fs_close(&amp;amp;file);
	printk(&amp;quot;%s close: %d\n&amp;quot;, fname, rc);

	struct fs_dir_t dir;

	fs_dir_t_init(&amp;amp;dir);

	rc = fs_opendir(&amp;amp;dir, mp-&amp;gt;mnt_point);
	printk(&amp;quot;%s opendir: %d\n&amp;quot;, mp-&amp;gt;mnt_point, rc);

	while (rc &amp;gt;= 0)
	{
		struct fs_dirent ent = {0};

		rc = fs_readdir(&amp;amp;dir, &amp;amp;ent);
		if (rc &amp;lt; 0)
		{
			break;
		}
		if (ent.name[0] == 0)
		{
			printk(&amp;quot;End of files\n&amp;quot;);
			break;
		}
		printk(&amp;quot;  %c %u %s\n&amp;quot;,
			   (ent.type == FS_DIR_ENTRY_FILE) ? &amp;#39;F&amp;#39; : &amp;#39;D&amp;#39;,
			   ent.size,
			   ent.name);
	}

	(void)fs_closedir(&amp;amp;dir);

out:
	rc = fs_unmount(mp);
	printk(&amp;quot;%s unmount: %d\n&amp;quot;, mp-&amp;gt;mnt_point, rc);
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&amp;Ouml;nsker deg en nydelig helg!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/342957?ContentTypeID=1</link><pubDate>Fri, 10 Dec 2021 14:29:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4adb93c6-bce7-4bd6-89d5-e159610121a1</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi nWre!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]Hi again Håkon! Hoppas allt är bra med dig![/quote]
&lt;p&gt;All good here, thanks! Hope you had a wonderful trip!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]I&amp;#39;ve flashed the sequence you linked earlier with the prog/debug-switch on nrf52:[/quote][quote user="nWre"]I&amp;#39;ve also added the SPI-code that you linked:[/quote]
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The &amp;quot;board-control&amp;quot; is setting a pin on the nRF52840 on the DK to route the ext-flash to the nRF91, while the next is a direct setting of which nRF9160 GPIO on the is connected to the /CS pin on the external-flash itself.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;They should match the hardware layout of the nRF9160-DK, which they do by default.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]Now that this config is done, should I be able to use say, LittleFS to write to the external memory by pointing it towards the MX25R64 in the device tree? Is there any other config I should do?[/quote]
&lt;p&gt;Define it in your pm_static.yml, here from addr offset 0, size 256kB in region &amp;quot;external_flash&amp;quot;:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;littlefs_storage:
  address: 0x0
  device: MX25R64
  end_address: 0x40000
  region: external_flash
  size: 0x40000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Remember to re-generate your build after altering the pm_static.yml!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/342911?ContentTypeID=1</link><pubDate>Fri, 10 Dec 2021 12:41:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc6aec2c-7ca4-45ea-9409-0b21026cfb65</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Hi again H&amp;aring;kon! Hoppas allt &amp;auml;r bra med dig!&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve flashed the sequence you linked earlier with the prog/debug-switch on nrf52:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;/ {
        board-control {
                external_flash_pins_routing: switch-ext-mem-ctrl {
                        compatible = &amp;quot;nordic,nrf9160dk-optional-routing&amp;quot;;
                        control-gpios = &amp;lt;&amp;amp;gpio0 19 GPIO_ACTIVE_HIGH&amp;gt;;
                        status = &amp;quot;okay&amp;quot;;
                };
        };
};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt; I&amp;#39;ve also added the SPI-code that you linked:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi3 {
	status = &amp;quot;okay&amp;quot;;
	sck-pin = &amp;lt;13&amp;gt;;
	mosi-pin = &amp;lt;11&amp;gt;;
	miso-pin = &amp;lt;12&amp;gt;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 25 GPIO_ACTIVE_LOW&amp;gt;;
	mx25r64: mx25r6435f@0 {
		compatible = &amp;quot;jedec,spi-nor&amp;quot;;
		reg = &amp;lt;0&amp;gt;;
		spi-max-frequency = &amp;lt;8000000&amp;gt;;
		label = &amp;quot;MX25R64&amp;quot;;
		jedec-id = [c2 28 17];
		sfdp-bfp = [
			e5 20 f1 ff  ff ff ff 03  44 eb 08 6b  08 3b 04 bb
			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
			10 d8 00 ff  23 72 f5 00  82 ed 04 cc  44 83 68 44
			30 b0 30 b0  f7 c4 d5 5c  00 be 29 ff  f0 d0 ff ff
		];
		size = &amp;lt;67108864&amp;gt;;
		has-dpd;
		t-enter-dpd = &amp;lt;10000&amp;gt;;
		t-exit-dpd = &amp;lt;35000&amp;gt;;
	};
};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Should the CS-GPIOS match? Now that this config is done, should I be able to use say, LittleFS to write to the external memory by pointing it towards the MX25R64 in the device tree? Is there any other config I should do?&lt;br /&gt;&lt;br /&gt;Kind regards&lt;br /&gt;nWre&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/341909?ContentTypeID=1</link><pubDate>Fri, 03 Dec 2021 14:05:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11945d1c-d4f5-4c17-8a0a-b33ba8624799</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]It is a rare treat for us to get snow down here and even though the entire community and infrastructure shuts down, I really enjoy it. I miss living in the north.[/quote]
&lt;p&gt;Snow is wonderful, I agree. It brightens the day during these darker winter days.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]Ontopic: Yes, I realized that too, so I&amp;#39;ve written my own drivers by studying the datasheet of the respective component. They are included in my main.c-file. The compatible part is really just a copy paste of the adxl362 and doesn&amp;#39;t contain any functionality. The drivers are working flawlessly for 2 of the 3 sensors. I am yet to figure out what causes problem with the third one. I handle the cs-pins manually, putting them high or low before reads/write. On these sensors, a high cs pin blocks data. So reading from 1 sensor, keeping the other two cs pins high, should only give me data stream from that sensor, however, there is a strange interference when doing this. Sorry for rambling, I understand this is impossible for you to help with.[/quote]
&lt;p&gt;I&amp;#39;d recommend using a logic analyzer (saleae or similar if you have available) to decode the SPI traffic (MOSI, MISO, CLK, CSN) to see if there&amp;#39;s anything out-of-the-ordinary.&lt;/p&gt;
&lt;p&gt;If there&amp;#39;s a interference, you could try other GPIOs to see if there might be a hardware related issue on specific GPIOs (soldering or similar?).&lt;/p&gt;
[quote user="nWre"]Off to spend the weekend in the woods in a tent, with a stove and multiple beers.&lt;br /&gt;Take care Håkon, I&amp;#39;ll return with more rambling questions about writing to external memory in a bit[/quote]
&lt;p&gt;Take care, hope you have a wonderful weekend!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/341846?ContentTypeID=1</link><pubDate>Fri, 03 Dec 2021 11:23:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71f5bb0e-e63a-4ded-b9e1-eb9acec4a927</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;It is a rare treat for us to get snow down here and even though the entire community and infrastructure shuts down, I really enjoy it. I miss living in the north. &lt;br /&gt;&lt;br /&gt;Ontopic: Yes, I realized that too, so I&amp;#39;ve written my own drivers by studying the datasheet of the respective component. They are included in my main.c-file. The compatible part is really just a copy paste of the adxl362 and doesn&amp;#39;t contain any functionality. The drivers are working flawlessly for 2 of the 3 sensors. I am yet to figure out what causes problem with the third one. I handle the cs-pins manually, putting them high or low before reads/write. On these sensors, a high cs pin blocks data. So reading from 1 sensor, keeping the other two cs pins high, should only give me data stream from that sensor, however, there is a strange interference when doing this. Sorry for rambling, I understand this is impossible for you to help with.&lt;br /&gt;&lt;br /&gt;Off to spend the weekend in the woods in a tent, with a stove and multiple beers.&lt;br /&gt;Take care H&amp;aring;kon, I&amp;#39;ll return with more rambling questions about writing to external memory in a bit&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/341798?ContentTypeID=1</link><pubDate>Fri, 03 Dec 2021 08:40:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e478e6b-1d61-4802-b9f7-577b1c397b56</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote user="nWre"]Snowy, gothenburgian regards![/quote]
&lt;p&gt;Close to 15 below, and around 20 cm of snow here as well!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]Edit: It appears as though I am not the solderer I thought I was. The interference came from shoddy soldering. I would still like to know the answer to the device binding question though, as of now, it works with getting the spi binding for all three sensors.[/quote]
&lt;p&gt;Glad to hear that you found the root cause of the hardware-wise connections.&lt;/p&gt;
&lt;p&gt;I have some bad news for you. The sensors that you configure for are not compatible with any sources (note: dts &amp;quot;compatible = &amp;quot;vendor,component&amp;quot;&amp;quot; maps to source files, which are then included in your project):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/main/dts/bindings/sensor"&gt;https://github.com/nrfconnect/sdk-zephyr/tree/main/dts/bindings/sensor&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;adxl345, 362 and 372 are supported by zephyr. I&amp;#39;m not sure that your sensors are compatible 1-to-1 with those drivers, so you might have to interface them manually, using the spi driver directly. Here&amp;#39;s a sample a colleague of mine wrote:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/sigurdnev/ncs-playground/tree/master/samples/spi_test"&gt;https://github.com/sigurdnev/ncs-playground/tree/master/samples/spi_test&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Snowy regards from Trondheim,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/341715?ContentTypeID=1</link><pubDate>Thu, 02 Dec 2021 13:49:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de0e7689-755c-44ca-9ffc-2e1713cf4e83</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Hi! I have it setup like this in an overlay file:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;spi3 {
	compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	sck-pin = &amp;lt;19&amp;gt;;
	mosi-pin = &amp;lt;18&amp;gt;; 
	miso-pin = &amp;lt;17&amp;gt;; 
	cs-gpios = &amp;lt;&amp;amp;gpio0 23 0&amp;gt;,&amp;lt;&amp;amp;gpio0 22 0&amp;gt;,&amp;lt;&amp;amp;gpio0 21 0&amp;gt;; 
	clock-frequency = &amp;lt;10000000&amp;gt;;
	label = &amp;quot;SENSORARRAY&amp;quot;;
	sensor8: sensor8@0 {
		compatible = &amp;quot;adi,adxl355&amp;quot;;
		status = &amp;quot;okay&amp;quot;;
		label = &amp;quot;sensor8&amp;quot;;
		spi-max-frequency = &amp;lt;10000000&amp;gt;;
		reg = &amp;lt;0&amp;gt;;
	};

	sensor40: sensor40@1 {
		compatible = &amp;quot;adi,adxl357&amp;quot;;
		status = &amp;quot;okay&amp;quot;;
		label = &amp;quot;sensor40&amp;quot;;
		spi-max-frequency = &amp;lt;10000000&amp;gt;;
		reg = &amp;lt;1&amp;gt;;
	};
	sensor200: sensor200@2 {
		compatible = &amp;quot;adi,adxl375&amp;quot;;
		status = &amp;quot;okay&amp;quot;;
		label = &amp;quot;sensor200&amp;quot;;
		spi-max-frequency = &amp;lt;10000000&amp;gt;;
		reg = &amp;lt;2&amp;gt;;
	};
};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I can communicate with the sensors but they do interfere with each other even when their corresponding cs-pin is set to high(blocking). I don&amp;#39;t really understand why but one question I have about this is if &lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;spi_dev = device_get_binding(&amp;quot;SENSORARRAY&amp;quot;);&lt;/pre&gt;&lt;br /&gt;Instead should be separated by child nodes, like this&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;spi_dev8 = device_get_binding(&amp;quot;sensor8&amp;quot;);
spi_dev40 = device_get_binding(&amp;quot;sensor40&amp;quot;);
spi_dev200 = device_get_binding(&amp;quot;sensor200&amp;quot;);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve tried this all day but couldn&amp;#39;t get any other value from this but null. I&amp;#39;ve tried aliases, node_label, node_path but nothing. Maybe I&amp;#39;m misunderstanding this and that the master is the dev, not the slaves.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m using the same MISO,MOSI and SCLK lines for all three. They also share 3V-input and GRND. Apart from this they have different CS-pins. I&amp;#39;ve tried them one by one and they&amp;#39;re all working, however when I connect more than one sensor, there is interference. &lt;br /&gt;&lt;br /&gt;I hope you can clear some of this up for me, I&amp;#39;ll keep banging my head against your fine hardware in the meantime ;)&lt;br /&gt;&lt;br /&gt;Snowy, gothenburgian regards!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Edit: It appears as though I am not the solderer I thought I was. The interference came from shoddy soldering. I would still like to know the answer to the device binding question though, as of now, it works with getting the spi binding for all three sensors.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/341492?ContentTypeID=1</link><pubDate>Wed, 01 Dec 2021 12:05:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fcb5f13a-ffbc-4ce2-89f4-734ffc9de19e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]I&amp;#39;m already using SPI3 for a sensor, can I just add an arbitrary number to the SPI interface? Like SPI4?[/quote]
&lt;p&gt;No, do not do that. This will then point the hardware to a non-existing SPI instance. nRF9160 has from 0 to 3:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf9160/spim.html?cp=2_0_0_5_12_5#topic"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf9160/spim.html?cp=2_0_0_5_12_5#topic&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you want to setup more than one sensor, you should do it similar to how it is done on the thingy91:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/boards/arm/thingy91_nrf9160/thingy91_nrf9160_common.dts#L128-L151"&gt;https://github.com/nrfconnect/sdk-nrf/blob/main/boards/arm/thingy91_nrf9160/thingy91_nrf9160_common.dts#L128-L151&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]Are there any examples writing to the external flash? I&amp;#39;d like to create numerous .bin or .hex files which I then send via LTE to server, once acknowledged that they are recieved, I want to free up that memory for other sensor data.[/quote]
&lt;p&gt;Once you have setup the external flash area, you can address it directly to the flash-backend that you&amp;#39;re using (NVS, littlefs or which ever you chose). The logic you require needs to be added manually in your application.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/341047?ContentTypeID=1</link><pubDate>Mon, 29 Nov 2021 11:18:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:439eea86-e3ed-44a1-b984-545019669f2d</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Hi! Thanks H&amp;aring;kon! I&amp;#39;m already using SPI3 for a sensor, can I just add an arbitrary number to the SPI interface? Like SPI4? Are there any examples writing to the external flash? I&amp;#39;d like to create numerous .bin or .hex files which I then send via LTE to server, once acknowledged that they are recieved, I want to free up that memory for other sensor data. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/340915?ContentTypeID=1</link><pubDate>Fri, 26 Nov 2021 13:16:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1787f50-89f8-4c31-ac50-323deb307ddd</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]After creating the pm_static.yml I need to include it in CMakeLists.txt, correct?[/quote]
&lt;p&gt;No, just place it in the root of your project folder.&lt;/p&gt;
[quote user="nWre"]If so, how? I tried creating an overlayfile and using that instead of the nrf9160dk_nrf9160_common.dts and targeting it in my CMakeLists but it wasnt included, thus I resorted to writing it in the nrf9160dk_nrf9160_common.dts file instead.[/quote]
&lt;p&gt;Usually you want to do this with the board file, so that each sub-project is supplied with the same configuration.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When you&amp;#39;re creating an overlay that you want to be included in multiple projects (ie. non-secure application, secure application, and mcuboot), you have to specify this for each project.&lt;/p&gt;
&lt;p&gt;You can do this by placing your $(BOARD).overlay file in these two folder structures:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/v1.7.1/tests/modules/mcuboot/external_flash/boards"&gt;https://github.com/nrfconnect/sdk-nrf/tree/v1.7.1/tests/modules/mcuboot/external_flash/boards&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/tree/v1.7.1/tests/modules/mcuboot/external_flash/child_image/mcuboot/boards"&gt;https://github.com/nrfconnect/sdk-nrf/tree/v1.7.1/tests/modules/mcuboot/external_flash/child_image/mcuboot/boards&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="nWre"]Are there any sample code of reading and writing? I do not know the syntax. As it is SPI, I&amp;#39;m guessing the CS-pin needs to be sit high/low during reading/writing, is this correct?[/quote]
&lt;p&gt;The overlay for your spi-flash (including the peripheral itself) will look something like this (depending on spi-nor flash you&amp;#39;ve chosen, gpios used etc):&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/main/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi#L42-L65"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/main/boards/arm/nrf9160dk_nrf9160/nrf9160dk_nrf9160_common_0_14_0.dtsi#L42-L65&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/340788?ContentTypeID=1</link><pubDate>Thu, 25 Nov 2021 15:50:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f714e76a-d52b-470d-8ea8-353e21e205ac</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Hi H&amp;aring;kon! &lt;br /&gt;&lt;br /&gt;I wrote the code from your link in to nrf9160dk_nrf9160_common.dts and it compiles.&lt;br /&gt;&lt;br /&gt;After creating the pm_static.yml I need to include it in CMakeLists.txt, correct? If so, how? I tried creating an overlayfile and using that instead of the nrf9160dk_nrf9160_common.dts and targeting it in my CMakeLists but it wasnt included, thus I resorted to writing it in the nrf9160dk_nrf9160_common.dts file instead.&lt;br /&gt;&lt;br /&gt;Are there any sample code of reading and writing? I do not know the syntax. As it is SPI, I&amp;#39;m guessing the CS-pin needs to be sit high/low during reading/writing, is this correct?&lt;br /&gt;&lt;br /&gt;Thanks for your patience with my very newbie questions &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Thanks for all your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/340773?ContentTypeID=1</link><pubDate>Thu, 25 Nov 2021 14:42:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52cb19b1-9056-41ec-b425-d768a64e4a01</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Since you mention using the nRF9160DK&amp;#39;s external flash, it is important that you switch in the lines for the external flash. That is done by re-programming the board controller, with the sequence explained here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/80836/extend-flash-size-of-nrf9160---single-slot-application/335345#335345"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/80836/extend-flash-size-of-nrf9160---single-slot-application/335345#335345&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;create the file my_project/pm_static.yml, which holds something like this (alter sizes to your needs):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;settings_storage:
  address: 0x0
  region: external_flash
  size: 0x40000&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/340752?ContentTypeID=1</link><pubDate>Thu, 25 Nov 2021 13:37:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2f25aae-f3b9-46ad-899a-7c53ef0516bd</guid><dc:creator>Sebastiaan Merckx</dc:creator><description>[quote userid="110024" url="~/f/nordic-q-a/82067/writing-reading-data-to-external-flash-on-the-nrf9160dk/340749#340749"]I&amp;#39;m thinking http communication but that is mostly because it&amp;#39;s the one I know and have used, does it make much of a difference?[/quote]
&lt;p&gt;That&amp;#39;s a very broad question :). Communication protocols are often fundamentally different with respect to speed, reliability, transfer size, security, ease of use, ...&lt;/p&gt;
&lt;p&gt;HTTP might be fine for now, you could extend it to HTTPS for improved security in the future. Coap might also be worth looking into, if your cloud platform supports it directly - I have unfortunately never used it yet since we typically interact with AWS which does not support coap.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/340749?ContentTypeID=1</link><pubDate>Thu, 25 Nov 2021 13:26:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68cecb7b-1dce-43e0-bb18-29d677c23f61</guid><dc:creator>nWre</dc:creator><description>&lt;p&gt;Hi Sebastiaan! Thank you for answering, truly appreciate it! I was to understand that the nRF9160DK has a 64 Mb external flash memory described here:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf91_dk%2FUG%2Fnrf91_DK%2Fexternal_memory.html"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fug_nrf91_dk%2FUG%2Fnrf91_DK%2Fexternal_memory.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This is indeed done via SPI. &lt;br /&gt;&lt;br /&gt;I&amp;#39;m thinking http communication but that is mostly because it&amp;#39;s the one I know and have used, does it make much of a difference?&lt;br /&gt;&lt;br /&gt;That&amp;#39;s a clever solution for getting the data, I will look into that solution.&lt;br /&gt;&lt;br /&gt;Many thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Writing/reading data to external flash on the nRF9160DK</title><link>https://devzone.nordicsemi.com/thread/340655?ContentTypeID=1</link><pubDate>Thu, 25 Nov 2021 08:23:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d1b402d-122b-4bd0-83a6-05047a7b5da0</guid><dc:creator>Sebastiaan Merckx</dc:creator><description>&lt;p&gt;* write to flash: some elements to take into account. Since your program is also stored in flash, you need to make sure it never gets overwritten. There is already a &amp;quot;storage&amp;quot; partition in the flash by default on NRF9160 (if I am correct): check the device tree, and you will find the storage_partition:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; storage_partition: partition@fa000 {&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;label = &amp;quot;storage&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;reg = &amp;lt; 0xfa000 0x6000 &amp;gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;};&lt;/p&gt;
&lt;p&gt;You could adapt the size via an overlay, but evidently it all still needs to fit in the 1MB flash. In fact, this storage partition is used for non-volatile-storage (NVS) of which I guess you can find some examples. But you&amp;#39;ll not use it in that way.You&amp;#39;ll probably need following configs: CONFIG_FLASH=y, CONFIG_FLASH_PAGE_LAYOUT=y, CONFIG_MPU_ALLOW_FLASH_WRITE=y&lt;/p&gt;
&lt;p&gt;If you need 0.8 MB of data, it might be best to go for an external flash device with SPI access.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;* chunk size: that strongly depends on the communication protocol that you would use to upload the data (coap, http, mqtt, ...?).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;* Maybe with the NRF programmer it&amp;#39;s possible to download a partition of the flash. I&amp;#39;ve never done that but it might be possible. If that is not supported, you can always implement a functionality to transmit your binary data over the UART and write a python script that listens on the VCOM port, reassembles all the data and stores it in a file. You could initiate this transfer by e.g. clicking on a button, or by implementing a 2-way communication protocol between the python script and your NRF (so it can be triggered on command from your python script).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>