STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Report here problems in any of ChibiOS components. This forum is NOT for support.
sntnjrg
Posts: 52
Joined: Mon Jul 22, 2019 2:19 pm
Has thanked: 15 times
Been thanked: 2 times

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby sntnjrg » Thu Aug 08, 2019 10:31 am

Hi Giovanni,

I have made the following changes:

The rccEnableSDMMC1 and rccDisableSDMMC1 macros use the RCC_APB2ENR_SDMMC1EN macro. The SDMMC1EN bit is in RCC_AHB2ENR register. I changed RCC_APB2ENR_SDMMC1EN macro by RCC_AHB2ENR_SDMMC1EN.

The SDMMC_DCTRL_DMAEN macro was changed by SDMMC_IDMACTRLR_IDMAEN macro

When executing the program, the sdcConnect() function is locked in this loop:

Code: Select all

void sdc_lld_send_cmd_none(SDCDriver *sdcp, uint8_t cmd, uint32_t arg) {

  sdcp->sdmmc->ARG = arg;
  sdcp->sdmmc->CMD = (uint32_t)cmd | SDMMC_CMD_CPSMEN;
  while ((sdcp->sdmmc->STA & SDMMC_STA_CMDSENT) == 0)
    ;
  sdcp->sdmmc->ICR = SDMMC_ICR_CMDSENTC;
}


I don't know how to solve the problem. Does the ChibiOS development team plan to update this driver shortly?

Cheers.

User avatar
Giovanni
Site Admin
Posts: 12747
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 694 times
Been thanked: 572 times
Contact:

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby Giovanni » Thu Aug 08, 2019 10:37 am

Have you programmed GPIOs correctly for SDMMC use in your board files?

Code: Select all

Does the ChibiOS development team plan to update this driver shortly?


Not shortly.

Giovanni

sntnjrg
Posts: 52
Joined: Mon Jul 22, 2019 2:19 pm
Has thanked: 15 times
Been thanked: 2 times

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby sntnjrg » Thu Feb 06, 2020 7:54 pm

Hi,

According to the manual, I have configured the ports as follows:

Code: Select all

palSetPadMode(GPIOC, 8, PAL_MODE_ALTERNATE(12)|PAL_STM32_OSPEED_HIGH);
palSetPadMode(GPIOC, 9,  PAL_MODE_ALTERNATE(12)|PAL_STM32_OSPEED_HIGH);
palSetPadMode(GPIOC, 10, PAL_MODE_ALTERNATE(12)|PAL_STM32_OSPEED_HIGH);
palSetPadMode(GPIOC, 11, PAL_MODE_ALTERNATE(12)|PAL_STM32_OSPEED_HIGH);
palSetPadMode(GPIOC, 12, PAL_MODE_ALTERNATE(12)|PAL_STM32_OSPEED_HIGH);
palSetPadMode(GPIOD, 2,  PAL_MODE_ALTERNATE(12)|PAL_STM32_OSPEED_HIGH);


When you try to connect you are blocked indefinitely in the sdc_lld_send_cmd_none() function.

I have noticed that in the master branch (in the GitHub repository) there is a new version of the driver. Is it compatible with the STM32L4R5ZI-NUCLEO144 card? Could it be used?

Cheers.

User avatar
Giovanni
Site Admin
Posts: 12747
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 694 times
Been thanked: 572 times
Contact:

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby Giovanni » Thu Feb 06, 2020 8:57 pm

Hi,

There is an updated driver on trunk, I tested it on a STM32L4R9AI-Discovery, the demo is STM32-SDMMC-FATFS.

Giovanni

sntnjrg
Posts: 52
Joined: Mon Jul 22, 2019 2:19 pm
Has thanked: 15 times
Been thanked: 2 times

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby sntnjrg » Tue Feb 11, 2020 2:40 pm

Hi Giovanni,

I cloned the master branch from GitHub. From the RT-STM32L4R5ZI-NUCLEO144 project, I've created a new project. Then, I copied the code of STM32-SDMMC-FATFS in the new project. When I run, I obtain the following panic message: SV#10

The stak is:

Code: Select all

Thread #1 (Suspended : Signal : SIGINT:Interrupt)   
   chSysHalt() at chsys.c:205 0x800a346   
   chDbgCheckClassI() at chdebug.c:236 0x800a346   
   chSchReadyI() at chschd.c:221 0x800a5d6   
   chThdResumeI() at chthreads.c:798 0x800a988   
   osalThreadResumeI() at hal_sdc_lld.c:864 0x800e0a4   
   sdc_lld_serve_interrupt() at hal_sdc_lld.c:870 0x800e0a4   
   Vector104() at stm32_sdmmc1.inc:98 0x800e0a4   
   <signal handler called>() at 0xfffffffd   
   0x55555554


The code is:

Code: Select all

/**
 * @brief   Shared service routine.
 *
 * @param[in] sdcp      pointer to the @p SDCDriver object
 */
void sdc_lld_serve_interrupt(SDCDriver *sdcp) {

  /* Disables the source but the status flags are not reset because the
     read/write functions needs to check them.*/
  sdcp->sdmmc->MASK = 0;

  osalThreadResumeI(&sdcp->thread, MSG_OK);
}


Code: Select all

/*===========================================================================*/
/* Driver interrupt handlers.                                                */
/*===========================================================================*/

#if STM32_SDMMC1_IS_USED|| defined(__DOXYGEN__)
/**
 * @brief   SDMMC1 interrupt handler.
 *
 * @isr
 */
OSAL_IRQ_HANDLER(STM32_SDMMC1_HANDLER) {

  OSAL_IRQ_PROLOGUE();

#if HAL_USE_SDC
#if STM32_SDC_USE_SDMMC1
  sdc_lld_serve_interrupt(&SDCD1);
#endif
#endif

  OSAL_IRQ_EPILOGUE();
}
#endif


Cheers.
Attachments
TEST-SDMMC-FATFS-RT-STM32L4R5ZI-NUCLEO144.zip
A example project for STM32L4R5ZI-NUCLEO144
(24.91 KiB) Downloaded 16 times

sntnjrg
Posts: 52
Joined: Mon Jul 22, 2019 2:19 pm
Has thanked: 15 times
Been thanked: 2 times

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby sntnjrg » Tue Feb 11, 2020 2:56 pm

I have made the following modification and it works for me:

Code: Select all

/**
 * @brief   Shared service routine.
 *
 * @param[in] sdcp      pointer to the @p SDCDriver object
 */
void sdc_lld_serve_interrupt(SDCDriver *sdcp) {

  /* Disables the source but the status flags are not reset because the
     read/write functions needs to check them.*/
  sdcp->sdmmc->MASK = 0;

  osalSysLockFromISR();
  osalThreadResumeI(&sdcp->thread, MSG_OK);
  osalSysUnlockFromISR();
}


Can the SDMMCv2 driver be isolated and used in the stable version of chibios?

User avatar
Giovanni
Site Admin
Posts: 12747
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 694 times
Been thanked: 572 times
Contact:

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby Giovanni » Tue Feb 11, 2020 3:25 pm

Hi,

Moving in bug reports.

Yes, you can back-port the driver if you need it, HAL is 100% open and free source.

Giovanni

sntnjrg
Posts: 52
Joined: Mon Jul 22, 2019 2:19 pm
Has thanked: 15 times
Been thanked: 2 times

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby sntnjrg » Mon Feb 17, 2020 12:08 pm

Hi Giovanni,

I have added the sdiotest part of an example to my project. I have checked that the reading operations are working. However, the same does not apply to write operations.

In the code, when it is executed the following, the thread falls asleep waiting for the writing operation (f_write() function) to be completed.

Code: Select all

  chprintf(chp, "Write some data in it (wait ~1min)... ");
  chThdSleepMilliseconds(100);
  //timemeasurement
  uint32_t cnt = chVTGetSystemTime();
  for (uint32_t i = 0; i < 10000; i++) {
    err = f_write(&FileObject, teststring, sizeof(teststring),
                        (void*)&bytes_written);
    if (err != FR_OK) {
      kernel_panic(chp, fresult_to_str(err));
    }
  }


In the sdc_lld_wait_transaction_end() function, the sdcp->sdmmc->MASK field is not equal to 0 and the thread is sent to sleep.

Code: Select all

**
 * @brief   Wait end of data transaction and performs finalizations.
 *
 * @param[in] sdcp      pointer to the @p SDCDriver object
 * @param[in] n         number of blocks in transaction
 * @param[in] resp      pointer to the response buffer
 *
 * @return              The operation status.
 * @retval HAL_SUCCESS  operation succeeded.
 * @retval HAL_FAILED   operation failed.
 */
static bool sdc_lld_wait_transaction_end(SDCDriver *sdcp, uint32_t n,
                                         uint32_t *resp) {

  /* Note the mask is checked before going to sleep because the interrupt
     may have occurred before reaching the critical zone.*/
  osalSysLock();
  if (sdcp->sdmmc->MASK != 0)
    osalThreadSuspendS(&sdcp->thread);

  /* Stopping operations.*/
  sdcp->sdmmc->IDMACTRL = 0;
  sdcp->sdmmc->MASK     = 0;
  sdcp->sdmmc->DCTRL    = 0;

  if ((sdcp->sdmmc->STA & SDMMC_STA_DATAEND) == 0) {
    osalSysUnlock();
    return HAL_FAILED;
  }

  /* Clearing status.*/
  sdcp->sdmmc->ICR      = SDMMC_ICR_ALL_FLAGS;
  osalSysUnlock();

  /* Finalize transaction.*/
  if (n > 1)
    return sdc_lld_send_cmd_short_crc(sdcp, MMCSD_CMD_STOP_TRANSMISSION, 0, resp);

  return HAL_SUCCESS;
}


The trace:

Code: Select all

  TEST-SDMMC-FATFS-RT-STM32L4R5ZI-NUCLEO144 (OpenOCD, Flash and Run) [GDB Hardware Debugging]   
   ch.elf   
      Thread #1 (Suspended : Step)   
         sdc_lld_wait_transaction_end() at hal_sdc_lld.c:234 0x8002e1a   
         sdc_lld_write_aligned() at hal_sdc_lld.c:761 0x80034c6   
         sdc_lld_write() at hal_sdc_lld.c:838 0x80035f0   
         sdcWrite() at hal_sdc.c:857 0x8001fa4   
         disk_write() at fatfs_diskio.c:188 0x800a790   
         sync_window() at ff.c:1.050 0x800aad8   
         move_window() at ff.c:1.074 0x800ab4e   
         get_fat() at ff.c:1.181 0x800add4   
         create_chain() at ff.c:1.581 0x800b1c4   
         f_write() at ff.c:3.867 0x800c8d4   
         <...more frames...>   
   arm-none-eabi-gdb (8.3.0.20190703)   


The thread doesn't work again. I couldn't find the problem. I'm attaching the test project.

Cheers.
Attachments
TEST-SDMMC-FATFS-RT-STM32L4R5ZI-NUCLEO144.zip
(28.23 KiB) Downloaded 21 times

User avatar
Giovanni
Site Admin
Posts: 12747
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 694 times
Been thanked: 572 times
Contact:

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby Giovanni » Wed Apr 29, 2020 9:47 am

Bump.

Is this problem still there in latest trunk version?

Giovanni

sntnjrg
Posts: 52
Joined: Mon Jul 22, 2019 2:19 pm
Has thanked: 15 times
Been thanked: 2 times

Re: STM32L4R5ZI-NUCLEO144 and SDC Driver: hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory

Postby sntnjrg » Mon May 04, 2020 12:37 pm

Hi,

I clone the repository from: https://github.com/ChibiOS/ChibiOS.git and I'm on master branch but the file system isn't mounted. The error is:

A hard error occurred in the low level disk I/O layer


The sdcConnect() function is run but not f_mount().

I used the ffconf_template.h template to create the configuration file. Can the error be related to this configuration file?

Cheers.


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests