FATFS - disk initalization fail

Hi there,

I am running the nRF FATFS example code on my Laird BL645 dev board which executes with no issues, i.e; it creates nordic.txt and writes the test string to it. However, when i create a new project with all the relevant includes disk initialise fails, even when using the main.c file from the example project (with adjusted pin definitions).

After debugging the program I can confirm the following:

in "nrfx_prs.c" - nrfx_prs_aquired() returns NRFX_SUCCESS

in "nrfx_spim.c" - nrfx_spim_init() returns NRFX_SUCCESS (note: p_cb->state = NRFX_DRV_STATE_INITIALISED)

in "nrf_drv_spi.c" - nrf_drv_spi_init() returns nrf_spi_init() (which returns 0x00)

in "nrf_spim.c" - spim_xfer() returns NRFX_SUCCESS

in "nrf_drv_spi.h" - nrf_drv_spi_transfer() returns nrfx_spi_xfer() (which returns NRFX_SUCCESS)

in "app_sdcard.c" - app_sdc_init() returns NRF_SUCCESS

in "diskio_blkdev.c" - if statement on line 123:

if (m_drives[drv].last_result == NRF_BLOCK_DEV_RESULT_SUCCESS){
    m_drives[drv].state &= ~STA_NOINIT;
}

is not executed therefore, disk_initialise() returns 0x01 as such Disk_state == 1 and triggers failure.

for (uint32_t retries = 3; retries && Disk_state; --retries){
	Disk_state = disk_initialize(0);
 }
    
if (Disk_state){
	NRF_LOG_INFO("Disk initialization failed. DSTATUS: %d", Disk_state);
}

looking at the error codes, 0x01 indicates a r/w fail however, inspecting the mosi and miso lines with an oscilloscope indicates no issues.

my project settings are:

 

IDE-Version:
µVision V5.38.0.0
Copyright (C) 2022 ARM Ltd and ARM Germany GmbH. All rights reserved.

Tool Version Numbers:
Toolchain:          MDK-Lite  Version: 5.38.0.0
Toolchain Path:     C:\Keil_community\Keil_v5\ARM\ARM_Compiler_5.06u7\Bin
C Compiler:         Armcc.exe           V5.06 update 7 (build 960)
Assembler:          Armasm.exe          V5.06 update 7 (build 960)
Linker/Locator:     ArmLink.exe         V5.06 update 7 (build 960)
Library Manager:    ArmAr.exe           V5.06 update 7 (build 960)
Hex Converter:      FromElf.exe         V5.06 update 7 (build 960)
CPU DLL:            SARMCM3.DLL         V5.38.0.0
Dialog DLL:         TCM.DLL             V1.56.4.0
Target DLL:         Segger\JL2CM3.dll   V2.99.42.0
Dialog DLL:         TCM.DLL             V1.56.4.0

preprocessor symbols: BOARD_PCA10056 BSP_DEFINES_ONLY CONFIG_GPIO_AS_PINRESET FLOAT_ABI_HARD NRF52840_XXAA __HEAP_SIZE=8192 __STACK_SIZE=8192

also all miso lines ae configured as pullnone.

any thoughts or advice would be greatly appreciated!

Andy

Related