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

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

Postby sntnjrg » Sat Aug 03, 2019 1:40 pm

Hi,

I'm learning how to use the SDC driver. I have a STM32L4R5ZI-NUCLEO144 board and I created a project from the RT-STM32L4R5ZI-NUCLEO144 project. Then, I took the following steps:

    1. Put TRUE the HAL_USE_SDC macro (halconf.h).
    2. Study the code from the main.c file of the STM32F4xx/SDC test (supplied by ChibiOS).

Based on this, I wrote the following code in the main() function:

Code: Select all

  static uint8_t sd_scratchpad[512]; /* Working area for driver */
  static sdcbusmode_t bus_width = SDC_MODE_4BIT; /* Bus width */
  static const SDCConfig sdccfg = { /*  SDIO configuration. */
    sd_scratchpad,
    bus_width
  };
  sdcObjectInit(&SDCD1);
  sdcStart(&SDCD1, &sdccfg); /* Initializes the SDIO drivers. */


But, when compiling, the following error occurs:

Code: Select all

In file included from ../../chibios191/os/hal/include/hal.h:147:0,
                 from ../../chibios191/os/hal/src/hal_st.c:25:
../../chibios191/os/hal/include/hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory
 #include "hal_sdc_lld.h"
          ^~~~~~~~~~~~~~~
compilation terminated.
In file included from ../../chibios191/os/hal/include/hal.h:147:0,
                 from ../../chibios191/os/hal/src/hal.c:25:
../../chibios191/os/hal/include/hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory
 #include "hal_sdc_lld.h"
          ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [../../chibios191/os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk:178: build/obj/hal.o] Error 1
make: *** Waiting for unfinished jobs....
make: *** [../../chibios191/os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk:178: build/obj/hal_st.o] Error 1
In file included from ../../chibios191/os/hal/include/hal.h:147:0,
                 from ../../chibios191/os/hal/src/hal_buffers.c:41:
../../chibios191/os/hal/include/hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory
 #include "hal_sdc_lld.h"
          ^~~~~~~~~~~~~~~
compilation terminated.
make: *** [../../chibios191/os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk:178: build/obj/hal_buffers.o] Error 1
In file included from ../../chibios191/os/hal/include/hal.h:147:0,
                 from ../../chibios191/os/hal/src/hal_queues.c:40:
../../chibios191/os/hal/include/hal_sdc.h:136:10: fatal error: hal_sdc_lld.h: No such file or directory
 #include "hal_sdc_lld.h"
          ^~~~~~~~~~~~~~~
compilation terminated.


I have observed that in the STM32F4xx/SDC test, in the file "mcuconf.h ", there is a section for the SDC driver that does not exist in the RT-STM32L4R5ZI-NUCLEO144 project. This is the section that appears in the STM32F4xx/SDC test:

Code: Select all

/*
 * SDC driver system settings.
 */
#define STM32_SDC_SDIO_DMA_PRIORITY         3
#define STM32_SDC_SDIO_IRQ_PRIORITY         9
#define STM32_SDC_WRITE_TIMEOUT_MS          1000
#define STM32_SDC_READ_TIMEOUT_MS           1000
#define STM32_SDC_CLOCK_ACTIVATION_DELAY    10
#define STM32_SDC_SDIO_UNALIGNED_SUPPORT    TRUE
#define STM32_SDC_SDIO_DMA_STREAM           STM32_DMA_STREAM_ID(2, 3)


When I read the STM32L4R5ZI-NUCLEO144 card documentation, I have noticed that it has a SD/SDIO/MMC interface and I can use the MMC over SPI driver without problems.

What am I doing wrong? How can I solve this problem?

Thank you.

User avatar
Giovanni
Site Admin
Posts: 12749
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 696 times
Been thanked: 573 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 » Sat Aug 03, 2019 1:46 pm

Hi,

SDMMC is not tested with the L4+ so the makefile does not include it.

If you want to give it a try add it to the /os/hal/ports/STM32/STM32L4xx+/platform.mk taking the missing line from the platform.mk of the normal L4.

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 » Sat Aug 03, 2019 2:33 pm

I have done the following:

I have added the following line to the /os/hal/ports/STM32/STM32L4xx+/platform.mk file:

Code: Select all

include $(CHIBIOS)/os/hal/ports/STM32/LLD/SDMMCv1/driver.mk


but when I compile I get this error:

Code: Select all

In file included from ../../chibios191/os/hal/include/hal_sdc.h:136:0,
                 from ../../chibios191/os/hal/include/hal.h:147,
                 from ../../chibios191/os/hal/src/hal_st.c:25:
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.h:168:2: error: #error "SDC driver activated but no SDMMC peripheral assigned"
 #error "SDC driver activated but no SDMMC peripheral assigned"
  ^~~~~


In the mcuconf.h file, I added the following:

Code: Select all

/*
 * SDC driver system settings.
 */
#define STM32_SDC_USE_SDMMC1                TRUE


but when I compile I get this error:

Code: Select all

In file included from ../../chibios191/os/hal/include/hal_sdc.h:136:0,
                 from ../../chibios191/os/hal/include/hal.h:147,
                 from ../../chibios191/os/hal/src/hal_st.c:25:
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.h:150:2: error: #error "STM32_SDC_SDMMCx_DMA_MSK not defined in registry"
 #error "STM32_SDC_SDMMCx_DMA_MSK not defined in registry"
  ^~~~~


In the /os/hal/ports/STM32/STM32L4xx/stm32_registry. file I have observed the following:

Code: Select all

/* SDMMC attributes.*/
#define STM32_HAS_SDMMC1                    TRUE
#define STM32_SDMMC1_HANDLER                Vector104
#define STM32_SDMMC1_NUMBER                 49
#define STM32_SDC_SDMMC1_DMA_MSK            (STM32_DMA_STREAM_ID_MSK(2, 4) |\
                                             STM32_DMA_STREAM_ID_MSK(2, 5))
#define STM32_SDC_SDMMC1_DMA_CHN            0x00077000


Do I have to add the last two lines?

Thanks for the help.

User avatar
Giovanni
Site Admin
Posts: 12749
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 696 times
Been thanked: 573 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 » Sat Aug 03, 2019 2:45 pm

Those DMA-related lines are not required, you are right.

All the changes you made are correct but this reminds me that the SDMMCv1 needs an upgrade because L4+ has DMAMUX...

Other drivers have already been updated to support DMAMUX but this is missing SDMMCv1, you could look at SPIv2 for an example, it is not complex but not trivial.

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 Aug 05, 2019 12:12 pm

Hi Giovanni,

Without implementing DMAMUX, is it possible to use the driver as it is?

When I compile I get errors. To fix them, I've been adding entries to the mcuconf.h file.

Code: Select all

/*
 * SDC driver system settings.
 */
#define STM32_SDC_USE_SDMMC1                TRUE
#define STM32_SDC_SDMMC1_DMA_MSK            (STM32_DMA_STREAM_ID_MSK(2, 4) |\
                                             STM32_DMA_STREAM_ID_MSK(2, 5))
#define STM32_SDC_SDMMC1_DMA_CHN            0x00077000
#define STM32_SDC_SDMMC1_DMA_STREAM         STM32_DMA_STREAM_ID(2, 4)


With these entries, I get the following error:

Code: Select all

../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c: In function 'sdc_lld_prepare_read_bytes':
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:154:24: error: 'SDMMC_DCTRL_DMAEN' undeclared (first use in this function); did you mean 'SDMMC_DCTRL_DTEN'?
                        SDMMC_DCTRL_DMAEN |
                        ^~~~~~~~~~~~~~~~~
                        SDMMC_DCTRL_DTEN
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:154:24: note: each undeclared identifier is reported only once for each function it appears in
In file included from ../../chibios191/os/hal/ports/STM32/STM32L4xx+/hal_lld.h:2395:0,
                 from ../../chibios191/os/hal/include/hal.h:118,
                 from ../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:27:
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c: In function 'sdc_lld_start':
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:718:43: error: 'RCC_APB2ENR_SDMMC1EN' undeclared (first use in this function); did you mean 'RCC_AHB2ENR_SDMMC1EN'?
 #define rccEnableSDMMC1(lp) rccEnableAPB2(RCC_APB2ENR_SDMMC1EN, lp)
                                           ^
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:148:20: note: in definition of macro 'rccEnableAPB2'
   RCC->APB2ENR |= (mask);                                                   \
                    ^~~~
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:457:7: note: in expansion of macro 'rccEnableSDMMC1'
       rccEnableSDMMC1(true);
       ^~~~~~~~~~~~~~~
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c: In function 'sdc_lld_stop':
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:725:43: error: 'RCC_APB2ENR_SDMMC1EN' undeclared (first use in this function); did you mean 'RCC_AHB2ENR_SDMMC1EN'?
 #define rccDisableSDMMC1() rccDisableAPB2(RCC_APB2ENR_SDMMC1EN)
                                           ^
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:164:21: note: in definition of macro 'rccDisableAPB2'
   RCC->APB2ENR &= ~(mask);                                                  \
                     ^~~~
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:512:7: note: in expansion of macro 'rccDisableSDMMC1'
       rccDisableSDMMC1();
       ^~~~~~~~~~~~~~~~
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c: In function 'sdc_lld_start_clk':
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:536:25: error: 'SDMMC_CLKCR_CLKEN' undeclared (first use in this function); did you mean 'SDMMC_CLKCR_CLKDIV'?
   sdcp->sdmmc->CLKCR |= SDMMC_CLKCR_CLKEN;
                         ^~~~~~~~~~~~~~~~~
                         SDMMC_CLKCR_CLKDIV
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c: In function 'sdc_lld_read_aligned':
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:825:24: error: 'SDMMC_DCTRL_DMAEN' undeclared (first use in this function); did you mean 'SDMMC_DCTRL_DTEN'?
                        SDMMC_DCTRL_DMAEN |
                        ^~~~~~~~~~~~~~~~~
                        SDMMC_DCTRL_DTEN
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c: In function 'sdc_lld_write_aligned':
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:889:24: error: 'SDMMC_DCTRL_DMAEN' undeclared (first use in this function); did you mean 'SDMMC_DCTRL_DTEN'?
                        SDMMC_DCTRL_DMAEN |
                        ^~~~~~~~~~~~~~~~~
                        SDMMC_DCTRL_DTEN


I have noticed that these definitions are usually inside the directory os/common/ext/ST/ but in the os/common/ext/ST/STM32L4xx/stm32l4r5xx.h file it is not defined.

Cheers.

User avatar
Giovanni
Site Admin
Posts: 12749
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 696 times
Been thanked: 573 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 » Mon Aug 05, 2019 12:15 pm

This means that there are other differences in SDMMC registers and those bits are no more defined or have a different name.

When this happens usually a new driver is required even if there aren't huge differences, SDMMCv2 for example. You may duplicate the driver and make changes in the copy.

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 Aug 05, 2019 1:58 pm

I have done the following:

1. I created the copy in the /os/hal/ports/STM32/LLD/SDMMCv12 folder.
2. I have commented on the lines where the SDMMC_DCTRL_DMAEN definition appears.
3. I have commented on line 536(sdc_lld_start_clk function): sdcp->sdmmc->CLKCR |= SDMMC_CLKCR_CLKEN;

When compiling I get the following error:

Code: Select all

Compiling hal_sdc_lld.c
In file included from ../../chibios191/os/hal/ports/STM32/STM32L4xx+/hal_lld.h:2395:0,
                 from ../../chibios191/os/hal/include/hal.h:118,
                 from ../../chibios191/os/hal/ports/STM32/LLD/SDMMCv12/hal_sdc_lld.c:27:
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv12/hal_sdc_lld.c: In function 'sdc_lld_start':
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:718:43: error: 'RCC_APB2ENR_SDMMC1EN' undeclared (first use in this function); did you mean 'RCC_AHB2ENR_SDMMC1EN'?
 #define rccEnableSDMMC1(lp) rccEnableAPB2(RCC_APB2ENR_SDMMC1EN, lp)
                                           ^
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:148:20: note: in definition of macro 'rccEnableAPB2'
   RCC->APB2ENR |= (mask);                                                   \
                    ^~~~
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv12/hal_sdc_lld.c:457:7: note: in expansion of macro 'rccEnableSDMMC1'
       rccEnableSDMMC1(true);
       ^~~~~~~~~~~~~~~
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:718:43: note: each undeclared identifier is reported only once for each function it appears in
 #define rccEnableSDMMC1(lp) rccEnableAPB2(RCC_APB2ENR_SDMMC1EN, lp)
                                           ^
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:148:20: note: in definition of macro 'rccEnableAPB2'
   RCC->APB2ENR |= (mask);                                                   \
                    ^~~~
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv12/hal_sdc_lld.c:457:7: note: in expansion of macro 'rccEnableSDMMC1'
       rccEnableSDMMC1(true);
       ^~~~~~~~~~~~~~~
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv12/hal_sdc_lld.c: In function 'sdc_lld_stop':
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:725:43: error: 'RCC_APB2ENR_SDMMC1EN' undeclared (first use in this function); did you mean 'RCC_AHB2ENR_SDMMC1EN'?
 #define rccDisableSDMMC1() rccDisableAPB2(RCC_APB2ENR_SDMMC1EN)
                                           ^
../../chibios191/os/hal/ports/STM32/STM32L4xx+/stm32_rcc.h:164:21: note: in definition of macro 'rccDisableAPB2'
   RCC->APB2ENR &= ~(mask);                                                  \
                     ^~~~
../../chibios191/os/hal/ports/STM32/LLD/SDMMCv12/hal_sdc_lld.c:512:7: note: in expansion of macro 'rccDisableSDMMC1'
       rccDisableSDMMC1();
       ^~~~~~~~~~~~~~~~
make: *** [../../chibios191/os/common/startup/ARMCMx/compilers/GCC/mk/rules.mk:178: build/obj/hal_sdc_lld.o] Error 1


If I comment on macros, the project compiles.

At this moment, I am lost. My knowledge of chibios is not extensive. Where can I get more information on this subject?

Cheers.

User avatar
Giovanni
Site Admin
Posts: 12749
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 696 times
Been thanked: 573 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 » Mon Aug 05, 2019 2:01 pm

Those RCC macros are used to enable/disable clocks on the various peripherals, you need to add macros for SDMMC into strm32_rcc.h, just follow the pattern.

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 Aug 05, 2019 3:28 pm

Hi Giovanni,

The code compiles when you add these lines to the stm32l4r5xx.h file:

Code: Select all

#define RCC_APB2ENR_SDMMC1EN_Pos            (10U)
#define RCC_APB2ENR_SDMMC1EN_Msk            (0x1U << RCC_APB2ENR_SDMMC1EN_Pos) /*!< 0x00000400 */
#define RCC_APB2ENR_SDMMC1EN                   RCC_APB2ENR_SDMMC1EN_Msk


I just have to follow the correlation, isn't I?

Code: Select all

/********************  Bit definition for RCC_APB2ENR register  ***************/
#define RCC_APB2ENR_SYSCFGEN_Pos             (0U)
#define RCC_APB2ENR_SYSCFGEN_Msk             (0x1U << RCC_APB2ENR_SYSCFGEN_Pos) /*!< 0x00000001 */
#define RCC_APB2ENR_SYSCFGEN                 RCC_APB2ENR_SYSCFGEN_Msk
#define RCC_APB2ENR_FWEN_Pos                 (7U)
#define RCC_APB2ENR_FWEN_Msk                 (0x1U << RCC_APB2ENR_FWEN_Pos)    /*!< 0x00000080 */
#define RCC_APB2ENR_FWEN                     RCC_APB2ENR_FWEN_Msk

#define RCC_APB2ENR_SDMMC1EN_Pos            (10U)
#define RCC_APB2ENR_SDMMC1EN_Msk            (0x1U << RCC_APB2ENR_SDMMC1EN_Pos) /*!< 0x00000400 */
#define RCC_APB2ENR_SDMMC1EN                RCC_APB2ENR_SDMMC1EN_Msk

#define RCC_APB2ENR_TIM1EN_Pos               (11U)
#define RCC_APB2ENR_TIM1EN_Msk               (0x1U << RCC_APB2ENR_TIM1EN_Pos)  /*!< 0x00000800 */
#define RCC_APB2ENR_TIM1EN                   RCC_APB2ENR_TIM1EN_Msk


Cheers.

User avatar
Giovanni
Site Admin
Posts: 12749
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 696 times
Been thanked: 573 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 » Mon Aug 05, 2019 3:42 pm

Hi,

If those lines are not in the STM32 header file then you should verify if those bits exist at all in that register, probably have been removed or moved into other registers.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 3 guests