<?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>Use of SD Card with SPI+EasyDMA and BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/122281/use-of-sd-card-with-spi-easydma-and-ble</link><description>Hi there, 
 My nRF5340 application requires the use of SD card with DMA and BLE transmission. Howerver, as soon as I turn on the device, I get the following errors: 
 
 A few internet searches and ChatGPT conversations have revealed that the clocking</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Jun 2025 11:15:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/122281/use-of-sd-card-with-spi-easydma-and-ble" /><item><title>RE: Use of SD Card with SPI+EasyDMA and BLE</title><link>https://devzone.nordicsemi.com/thread/539369?ContentTypeID=1</link><pubDate>Mon, 16 Jun 2025 11:15:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:08b2e993-1881-4353-9682-2fdf3b6ccf54</guid><dc:creator>umer</dc:creator><description>&lt;p&gt;You are a life saver!&lt;/p&gt;
&lt;p&gt;Yes, I confirm that P1.00 and P1.01 were being forwarded automatically for use with the networking core. I was able to have BLE run successfully after disabling gpio forwarding:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;gpio_fwd {
    status = &amp;quot;disabled&amp;quot;;
};&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of SD Card with SPI+EasyDMA and BLE</title><link>https://devzone.nordicsemi.com/thread/539309?ContentTypeID=1</link><pubDate>Mon, 16 Jun 2025 06:57:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04cfab86-f775-4e36-bdf9-3cbeb0ed6edd</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;Check the final zephyr.dts in build/zephyr folder.&lt;/p&gt;
&lt;p&gt;P1.00 and P1.01 are forwarded by default for NR5430 DK boards (look for &amp;quot;gpio_fwd&amp;quot; or &amp;quot;nrf-gpio-forwarder&amp;quot; entry).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of SD Card with SPI+EasyDMA and BLE</title><link>https://devzone.nordicsemi.com/thread/539286?ContentTypeID=1</link><pubDate>Sun, 15 Jun 2025 17:38:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32dcf670-cefc-4b39-85ca-7a42b6d8a234</guid><dc:creator>umer</dc:creator><description>&lt;p&gt;Thanks again for the reply.&lt;/p&gt;
&lt;p&gt;I am not really assigning any pins to the network core--not deliberately anyways. Here is my overlay file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/*
 * Copyright (c) 2021 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */
 &amp;amp;clock {
	
	status = &amp;quot;okay&amp;quot;;
};


&amp;amp;pinctrl {
	

	i2s0_default_alt: i2s0_default_alt {
		group1 {
			psels = &amp;lt;NRF_PSEL(I2S_SCK_M, 0, 26)&amp;gt;,
				&amp;lt;NRF_PSEL(I2S_LRCK_M, 0, 6)&amp;gt;,  // MODIFIED from 0.07 since that is taken by CS pin
				&amp;lt;NRF_PSEL(I2S_SDOUT, 1, 13)&amp;gt;,
				&amp;lt;NRF_PSEL(I2S_SDIN, 0, 25)&amp;gt;;
		};
	};
};


&amp;amp;clock {
	hfclkaudio-frequency = &amp;lt;11289600&amp;gt;;
};

i2s_rxtx: &amp;amp;i2s0 {
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;i2s0_default_alt&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;;
	clock-source = &amp;quot;ACLK&amp;quot;;
};




&amp;amp;spi1 {
    compatible = &amp;quot;nordic,nrf-spim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;spi1_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;spi1_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
	cs-gpios = &amp;lt;&amp;amp;gpio0 7 GPIO_ACTIVE_LOW&amp;gt;; //CS for SD
	

    sdhc0: sdhc@0 {
        compatible = &amp;quot;zephyr,sdhc-spi-slot&amp;quot;;
        reg = &amp;lt;0&amp;gt;;
        status = &amp;quot;okay&amp;quot;;
        label = &amp;quot;SDHC0&amp;quot;;
        spi-max-frequency = &amp;lt;24000000&amp;gt;;
		mmc {
			compatible = &amp;quot;zephyr,sdmmc-disk&amp;quot;;
			status = &amp;quot;okay&amp;quot;;
		};
    };
};

&amp;amp;pinctrl {
	spi1_default: spi1_default {
		
		group1 {
			psels = &amp;lt;NRF_PSEL(SPIM_SCK, 1, 0)&amp;gt;,
						&amp;lt;NRF_PSEL(SPIM_MOSI, 1, 1)&amp;gt;,
						&amp;lt;NRF_PSEL(SPIM_MISO, 0, 10)&amp;gt;;
		};
	};

	spi1_sleep: spi1_sleep {
		group1 {
			// psels = &amp;lt;NRF_PSEL(SPIM_SCK, 0, 8)&amp;gt;,
			// 			&amp;lt;NRF_PSEL(SPIM_MOSI, 0, 9)&amp;gt;,
			// 			&amp;lt;NRF_PSEL(SPIM_MISO, 0, 10)&amp;gt;;
				// low-power-enable;
					psels = &amp;lt;NRF_PSEL(SPIM_SCK, 1, 0)&amp;gt;,
						&amp;lt;NRF_PSEL(SPIM_MOSI, 1, 1)&amp;gt;,
						&amp;lt;NRF_PSEL(SPIM_MISO, 0, 10)&amp;gt;;
				low-power-enable;
		};
	};
};

&amp;amp;gpio1 {
    status = &amp;quot;okay&amp;quot;;
};
/ {
    aliases {
        button5 = &amp;amp;button5;
        button6 = &amp;amp;button6;
        button7 = &amp;amp;button7;
        button8 = &amp;amp;button8;
    };
};

/ {
    buttons {
        compatible = &amp;quot;gpio-keys&amp;quot;;

        button5: button_5 {
            gpios = &amp;lt;&amp;amp;gpio1 6 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
            label = &amp;quot;Button 5&amp;quot;;
        };
        button6: button_6 {
            gpios = &amp;lt;&amp;amp;gpio1 7 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
            label = &amp;quot;Button 6&amp;quot;;
        };
        button7: button_7 {
            gpios = &amp;lt;&amp;amp;gpio1 8 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
            label = &amp;quot;POWER Button&amp;quot;;
        };
        button8: button_8 {
            gpios = &amp;lt;&amp;amp;gpio1 9 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)&amp;gt;;
            label = &amp;quot;Button 7&amp;quot;;
        };
    };
};
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here is the application code--reading from an SD card:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
#include &amp;lt;zephyr/kernel.h&amp;gt;
#include &amp;lt;zephyr/device.h&amp;gt;
#include &amp;lt;zephyr/drivers/spi.h&amp;gt;
#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;
#include &amp;lt;zephyr/sys/printk.h&amp;gt;

#include &amp;lt;zephyr/fs/fs.h&amp;gt;
#include &amp;lt;zephyr/storage/disk_access.h&amp;gt;
#include &amp;lt;ff.h&amp;gt;
#include &amp;lt;zephyr/logging/log.h&amp;gt;
#include &amp;quot;SD_card.h&amp;quot;
#define SPI_DEVICE_NODE DT_NODELABEL(spi1)

void button_pressed(const struct device *dev, struct gpio_callback *cb, uint32_t pins);

//////////////////
K_FIFO_DEFINE(i2s_block_fifo);
bool opened_file = false;
bool mounted_card = false;

bool recoding_init = false;

LOG_MODULE_REGISTER(Main, LOG_LEVEL_INF);

// Define memory structures

K_SEM_DEFINE(enable_recording, 0, 1);
K_SEM_DEFINE(data_ready, 0, 1);



/* SD Card Reading Operations*/

// once initiatied, the SD card is repeatedly read from and the data read is displayed on the UART terminal

void sd_reading(void) {
        LOG_INF(&amp;quot;SD Card Reading Function\n&amp;quot;);
    
        k_sem_take(&amp;amp;data_ready, K_FOREVER);
        if (sd_file_open() != 0) {
            LOG_ERR(&amp;quot;Failed to open file\n&amp;quot;);
            return;
        } else {
            opened_file = true;
            LOG_INF(&amp;quot;File Opened Successfully\n&amp;quot;);
        }
        // List all the files in the SD card

        
        while (1) {
            LOG_INF(&amp;quot;Reading from SD card...\n&amp;quot;);
            // Call the function to read from the SD card
            if (sd_file_read_line() != 0) {
                LOG_ERR(&amp;quot;Failed to read from SD card&amp;quot;);
                break;
            }
            
            k_sleep(K_MSEC(10)); // Sleep for 10 milli second before next read
        }
        
}

// Main Function
int main(void) {
        LOG_INF(&amp;quot;Starting main thread&amp;quot;);
        
        // LOG_INF(&amp;quot;Assuming a data file with binary data in the SD card, the program will be reading from it and displaying the data on ther UART terminal \n&amp;quot;);

        if (init_button_led() != 0) {
            LOG_ERR(&amp;quot;Failed to initialize button&amp;quot;);
            return -1;
        }

        // initialize the SPI and SD card           

        if (spi_init() != 0) {
            LOG_ERR(&amp;quot;Failed to initialize SPI&amp;quot;);
            return -1;
        }
        
        // List all the files in the SD card

        list_files_on_sd();
        
        sd_reading();


        while (1) {
            k_sleep(K_FOREVER);
        }
        return 0;
    
    }
    &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The application code uses a custom &lt;strong&gt;SD_card.h&lt;/strong&gt; library that successfully carries out read/write operations, that is, until &lt;strong&gt;CONFIG_BT=y&lt;/strong&gt; is assigned in &lt;strong&gt;prj.conf&lt;/strong&gt;. I am not including that here for brevity.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My build configuration is also for the application core not the network core.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Do you see any issues in the way I have written the overlay?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of SD Card with SPI+EasyDMA and BLE</title><link>https://devzone.nordicsemi.com/thread/539282?ContentTypeID=1</link><pubDate>Sun, 15 Jun 2025 16:27:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31869d59-5691-4dbf-bc22-1e3bffcfb90c</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;The example code assigned a few pins to the network core for UART debug output. That might get only pulled in when network core is in use (i.e. CONFIG_BT=yes).&lt;/p&gt;
&lt;p&gt;Pins assigned to the other core cannot be used by the application core at all.&lt;/p&gt;
&lt;p&gt;You can fix this in the dts overlay - just don&amp;#39;t assign pins to the network core.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of SD Card with SPI+EasyDMA and BLE</title><link>https://devzone.nordicsemi.com/thread/539278?ContentTypeID=1</link><pubDate>Sun, 15 Jun 2025 11:00:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8b6f21bb-d9ce-4a04-be17-c55a9cde319f</guid><dc:creator>umer</dc:creator><description>&lt;p&gt;Thanks for your reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But there has to be a link between the two as I have confirmed this point by repeatedly compiling an SD card application.&amp;nbsp;It only does not compile as soon as I enable BLE in the &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;prj.conf&lt;/span&gt; file:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_BT=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;in the &lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;prj.conf&lt;/span&gt; file, the application throws the run time error I provided earlier:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;[00:00:00.594,146] &amp;lt;27&amp;gt;[1;31m&amp;lt;err&amp;gt; spi_nrfx_spim: Timeout waiting for transfer complete&amp;lt;27&amp;gt;[0m&amp;lt;\r&amp;gt;&amp;lt;\n&amp;gt;
[00:00:00.594,604] &amp;lt;27&amp;gt;[1;31m&amp;lt;err&amp;gt; sdhc_spi: Card SCLK init sequence failed&amp;lt;27&amp;gt;[0m&amp;lt;\r&amp;gt;&amp;lt;\n&amp;gt;
[00:00:00.594,635] &amp;lt;27&amp;gt;[1;31m&amp;lt;err&amp;gt; sd: Could not disable card power via SDHC&amp;lt;27&amp;gt;[0m&amp;lt;\r&amp;gt;&amp;lt;\n&amp;gt;
disk_access_init failed. Error code: -5 ()&amp;lt;\r&amp;gt;&amp;lt;\n&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Use of SD Card with SPI+EasyDMA and BLE</title><link>https://devzone.nordicsemi.com/thread/539271?ContentTypeID=1</link><pubDate>Sat, 14 Jun 2025 17:28:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d52d73e-af0f-4d0c-b4b0-1dd7885c9cab</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;ChatGPT is bullshitting you as usual.&lt;/p&gt;
&lt;p&gt;Check your DTS and your pin config. Logic analyser might also be a good idea.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>