Closed Hoel closed 6 years ago
I decided to add the HAL includes directly in device.h
#ifndef MBED_DEVICE_H
#define MBED_DEVICE_H
//=======================================
#define DEVICE_ID_LENGTH 24
#include "stm32l4xx_hal_rng.h"
#include "stm32l4xx_hal_dma.h"
#include "stm32l4xx_hal_adc.h"
#include "stm32l4xx_hal_dac.h"
#include "stm32l4xx_hal_spi.h"
#include "stm32l4xx_hal_i2c.h"
#include "objects.h"
/* WORKAROUND waiting for mbed-os issue 4408 to be addressed */
#include "stm32l4xx_ll_usart.h"
#endif
It now compiles up to 83%
$ sudo mbed compile -m L4680_L451 -t GCC_ARM
[mbed] Auto-installing missing Python modules...
[Warning] @,: Compiler version mismatch: Have 4.8.4; expected version >= 6.0.0 and < 7.0.0
Building project mbed-os-example-blinky (L4680_L451, GCC_ARM)
Scan: mbed-os-example-blinky
Scan: env
Compile [ 0.7%]: AnalogIn.cpp
....
Compile [ 83.0%]: PeripheralPins.c
[Error] PeripheralPins.c@51,54: 'GPIO_NOPULL' undeclared here (not in a function)
[Error] PinNamesTypes.h@98,33: invalid operands to binary & (have 'const struct PinMap *' and 'int')
then few thousand lines of errors are thrown, full log is include below built_log.txt
EDIT: Now reaching 96% after adding
to device.h and PeripheralPins.c
Scan: env
Compile [ 96.6%]: system_clock.c
[Error] system_clock.c@373,5: unknown type name 'RCC_ClkInitTypeDef'
[Error] system_clock.c@374,5: unknown type name 'RCC_OscInitTypeDef'
There is definitely something wrong
now reaching 98.2% after adding more includes to system_clock.c
Scan: env
Compile [ 98.2%]: pinmap.c
[Error] pin_device.h@47,14: 'GPIO_PULLUP' undeclared (first use in this function)
[Error] pin_device.h@50,14: 'GPIO_PULLDOWN' undeclared (first use in this function
Compile [ 96.2%]: mbed_wait_api_rtos.cpp
[Warning] MbedCRC.h@36,32: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
[Warning] mbed_wait_api_rtos.cpp@45,41: 'static osStatus rtos::Thread::wait(uint32_t)' is deprecated (declared at ./mbed-os/rtos/Thread.h:442): Static methods only affecting current thread cause confusion. Replaced by ThisThread::sleep_for. [since mbed-os-5.10] [-Wdeprecated-declarations]
Compile [ 96.3%]: stm32l4xx_hal_uart_ex.c
[Error] stm32l4xx_hal_uart_ex.c@490,27: 'USART_CR3_UCESM' undeclared (first use in this function)
[Error] stm32l4xx_hal_uart_ex.c@539,29: 'USART_CR3_UCESM' undeclared (first use in this function)
[ERROR] ./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c: In function 'HAL_UARTEx_EnableClockStopMode':
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c:490:27: error: 'USART_CR3_UCESM' undeclared (first use in this function)
huart->Instance->CR3 |= USART_CR3_UCESM;
^
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c:490:27: note: each undeclared identifier is reported only once for each function it appears in
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c: In function 'HAL_UARTEx_DisableClockStopMode':
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c:539:29: error: 'USART_CR3_UCESM' undeclared (first use in this function)
huart->Instance->CR3 &= ~(USART_CR3_UCESM);
Hopefully the last error, related to USART_CR3_UCESM, however this is internal HAL files and by experience it is preferable not to mess with HAL files because when an error occurs here it is the sign of a more major issue. @bcostm ST team, please check my custom target folder and help with this issue.
you are not using the HAL drinvers, they are not enabled in stm32l4xx.h:
#if !defined (USE_HAL_DRIVER)
/**
* @brief Comment the line below if you will not use the peripherals drivers.
In this case, these drivers will not be included and the application code will
be based on direct access to peripherals registers
*/
#define USE_HAL_DRIVER
#endif /* USE_HAL_DRIVER */
then it will compile until system_clock.c, it looks like there are some modifications neccessary.
The missing USART define looks like a HAL problem, check the other stm32l4xxxx.h files, there is a MBED fix:
/* MBED */
#define USART_CR3_UCESM_Pos (23U)
#define USART_CR3_UCESM_Msk (0x1U << USART_CR3_UCESM_Pos) /*!< 0x00800000 */
#define USART_CR3_UCESM USART_CR3_UCESM_Msk /*!< Clock Enable in Stop mode */
/* MBED */
Internal Jira reference: https://jira.arm.com/browse/MBOCUSTRIA-132
remaining:
typedef enum {
UART_1 = (int)USART1_BASE,
UART_2 = (int)USART2_BASE,
UART_3 = (int)USART3_BASE,
UART_4 = (int)UART4_BASE,
LPUART_1 = (int)LPUART1_BASE
} UARTName;
Happy testing :)
@JojoS62 Thanks
you are not using the HAL drinvers, they are not enabled in stm32l4xx.h:
#if !defined (USE_HAL_DRIVER) /** * @brief Comment the line below if you will not use the peripherals drivers. In this case, these drivers will not be included and the application code will be based on direct access to peripherals registers */ #define USE_HAL_DRIVER #endif /* USE_HAL_DRIVER */
So i should define USE_HAL_DRIVER? i am confused because i checked that earlier, on an existing nucleo target and did not find USE_HAL_DRIVER defined. Where should it be defined, directly in the HAL file?
remaining:
.\mbed-os\targets\TARGET_STM\TARGET_STM32L4\TARGET_STM32L451xE\device\us_ticker_data.h is missing PeripheralNames.h contains a double definition for UART4, try typedef enum { UART_1 = (int)USART1_BASE, UART_2 = (int)USART2_BASE, UART_3 = (int)USART3_BASE, UART_4 = (int)UART4_BASE, LPUART_1 = (int)LPUART1_BASE } UARTName;
OK nice, i will try that, thanks a bunch, i hope it will compile now, thats always a fight to get this working.
So i should define USE_HAL_DRIVER?
I just compared to the other targets, all other have this #define uncommented in the stm32f4xx.h, like my code snippet.
Ohh, i didnt even realized the define in the conditional statement was actaully commented in my STM32L4xx.h that should explain why i had to includes all these HAL stuffs everywhere. Looks like i am close to successful compilation now. Thanks a lot for spotting this.
EDIT: Made the changes, sadly it doesnt compile. for clarity i removed most of the duplicates entries on same peripheral :
Scan: mbed-os-example-blinky
Scan: env
Compile [ 55.4%]: AnalogIn.cpp
[Error] stm32l4xx_hal_rcc_ex.h@2331,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_rcc.h@4546,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_dma.h@136,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_dfsdm.h@534,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_adc.h@375,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_adc_ex.h@1318,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_adc.h@1697,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_can_legacy.h@232,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_comp.h@120,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_crc.h@130,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_crc_ex.h@145,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_crc.h@323,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_dac.h@84,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_dac_ex.h@222,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_dac.h@479,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_firewall.h@342,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_flash.h@142,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_flash_ex.h@87,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_flash_ramfunc.h@85,20: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_flash.h@781,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_i2c.h@214,21: expected identifier before '*' token
[Error] stm32l4xx_hal_i2c.h@214,101: ISO C++ forbids declaration of 'HAL_StatusTypeDef' with no type [-fpermissive]
[Error] stm32l4xx_hal_i2c.h@214,101: 'HAL_StatusTypeDef' declared as function returning a function
[Error] stm32l4xx_hal_i2c.h@220,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_i2c_ex.h@117,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_i2c.h@527,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_iwdg.h@155,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_lptim.h@161,7: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_opamp.h@142,3: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_opamp_ex.h@83,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_pwr_ex.h@821,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_qspi.h@122,8: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_rng.h@94,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_rtc.h@187,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_rtc_ex.h@898,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_rtc.h@654,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_sai.h@260,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_ll_sdmmc.h@1141,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_sd.h@142,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_smbus.h@163,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_spi.h@160,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_spi_ex.h@68,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_tim.h@342,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_tim_ex.h@341,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_tim.h@1815,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_tsc.h@130,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_uart.h@289,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_usart.h@194,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_irda.h@211,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_smartcard.h@281,3: 'HAL_LockTypeDef' does not name a type
[Error] stm32l4xx_hal_smartcard_ex.h@460,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal_wwdg.h@248,1: 'HAL_StatusTypeDef' does not name a type
[Error] stm32l4xx_hal.h@580,1: 'HAL_StatusTypeDef' does not name a type
i removed my includes from device.h, now it compiles again but stall to the same point as before (USART_CR3_UCESM), i initally overlooked the second part of your answer, now trying to add the fix mentioned.
/* MBED */ #define USART_CR3_UCESM_Pos (23U) #define USART_CR3_UCESM_Msk (0x1U << USART_CR3_UCESM_Pos) /*!< 0x00800000 */ #define USART_CR3_UCESM USART_CR3_UCESM_Msk /*!< Clock Enable in Stop mode */ /* MBED */
Compile [ 95.3%]: stm32l4xx_hal_uart_ex.c
[Error] stm32l4xx_hal_uart_ex.c@490,27: 'USART_CR3_UCESM' undeclared (first use in this function)
[Error] stm32l4xx_hal_uart_ex.c@539,29: 'USART_CR3_UCESM' undeclared (first use in this function)
[ERROR] ./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c: In function 'HAL_UARTEx_EnableClockStopMode':
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c:490:27: error: 'USART_CR3_UCESM' undeclared (first use in this function)
huart->Instance->CR3 |= USART_CR3_UCESM;
^
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c:490:27: note: each undeclared identifier is reported only once for each function it appears in
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c: In function 'HAL_UARTEx_DisableClockStopMode':
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/device/stm32l4xx_hal_uart_ex.c:539:29: error: 'USART_CR3_UCESM' undeclared (first use in this function)
huart->Instance->CR3 &= ~(USART_CR3_UCESM);
right, adding the register definition to STM32L4xx.h did the trick for UART_CR3_UCESM, now i have a last error on TIM5 in us_ticker_data.h since there is no TIM5 on this target (i scavanged the file from another nucleo target) hopefully it is just a matter of changing the TIM number
Compile [ 99.9%]: us_ticker.c
[Error] us_ticker_data.h@27,22: 'TIM5' undeclared (first use in this function)
[Warning] us_ticker.c@157,5: implicit declaration of function '__HAL_RCC_TIM5_CLK_ENABLE' [-Wimplicit-function-declaration]
[Warning] us_ticker.c@160,5: implicit declaration of function '__HAL_RCC_TIM5_FORCE_RESET' [-Wimplicit-function-declaration]
[Warning] us_ticker.c@161,5: implicit declaration of function '__HAL_RCC_TIM5_RELEASE_RESET' [-Wimplicit-function-declaration]
[Error] us_ticker_data.h@27,22: 'TIM5' undeclared (first use in this function)
[Error] us_ticker_data.h@28,22: 'TIM5_IRQn' undeclared (first use in this function)
[Error] us_ticker_data.h@27,22: 'TIM5' undeclared (first use in this function)
[Error] us_ticker_data.h@27,22: 'TIM5' undeclared (first use in this function)
[Error] us_ticker_data.h@27,22: 'TIM5' undeclared (first use in this function)
[Warning] us_ticker.c@215,1: control reaches end of non-void function [-Wreturn-type]
[ERROR] In file included from ./mbed-os/targets/TARGET_STM/us_ticker.c:19:0:
./mbed-os/targets/TARGET_STM/us_ticker.c: In function 'timer_irq_handler':
./mbed-os/targets/TARGET_STM/TARGET_STM32L4/TARGET_STM32L451xE/device/us_ticker_data.h:27:22: error: 'TIM5' undeclared (first use in this function)
#define TIM_MST TIM5
After fixing us_ticker_data.h, it finally compiles, now time to mess with the SW4STM32 project export / generation.
$ sudo mbed compile -m L4680_L451 -t GCC_ARM
Password:
[mbed] Auto-installing missing Python modules...
[Warning] @,: Compiler version mismatch: Have 4.8.4; expected version >= 6.0.0 and < 7.0.0
Building project mbed-os-example-blinky (L4680_L451, GCC_ARM)
Scan: mbed-os-example-blinky
Scan: env
Compile [100.0%]: us_ticker.c
Link: mbed-os-example-blinky
Elf2Bin: mbed-os-example-blinky
| Module | .text | .data | .bss |
|------------------|---------------|-------------|-------------|
| [fill] | 53(+53) | 4(+4) | 7(+7) |
| [lib]/c.a | 24524(+24524) | 2204(+2204) | 56(+56) |
| [lib]/gcc.a | 3792(+3792) | 0(+0) | 0(+0) |
| [lib]/m.a | 80(+80) | 0(+0) | 0(+0) |
| [lib]/misc | 112(+112) | 16(+16) | 28(+28) |
| main.o | 68(+68) | 4(+4) | 28(+28) |
| mbed-os/drivers | 216(+216) | 4(+4) | 100(+100) |
| mbed-os/hal | 1807(+1807) | 4(+4) | 68(+68) |
| mbed-os/platform | 3184(+3184) | 260(+260) | 197(+197) |
| mbed-os/rtos | 3485(+3485) | 164(+164) | 4336(+4336) |
| mbed-os/targets | 8115(+8115) | 4(+4) | 832(+832) |
| Subtotals | 45436(+45436) | 2664(+2664) | 5652(+5652) |
Total Static RAM memory (data + bss): 8316(+8316) bytes
Total Flash memory (text + data): 48100(+48100) bytes
Image: ./BUILD/L4680_L451/GCC_ARM/mbed-os-example-blinky.bin
Hello, I already ported various custom targets with succes in the past (STM32F103CBT6, STM32F303CCT6, STM32L151C8T6, STM32L462CEU6), i now have to port our latest target STM32L451CEU6, unfortunately it fails completely, despite few hours of search i cannot get it to compile.
Here is what has been done:
TARGET_STM32L451xE.zip
targets.json.zip
mbed_rtx.h.zip
Unfortunately it refuses to compile past 0.4%, there is apparently something wrong with the includes system since the compiler doesnt see base HAL peripherals (SPI, I2C, ADC, DAC) handles:
Is there another dictionary somewhere i should add my target to get includes system working? I have no idea what the problem is, the other custom targets have no problem.
If ST team could have a check and help to make this custom target work, it would be much appreaciated, at this point i have no idea what to try next.