khoih-prog / EthernetWebServer_STM32

This is simple yet complete WebServer library for STM32 boards running built-in Ethernet LAN8742A (Nucleo-144, Discovery), ENC28J60 or W5x00 Ethernet shields. The functions are similar and compatible to ESP8266/ESP32 WebServer libraries to make life much easier to port sketches from ESP8266/ESP32. Ethernet_Generic library is used as default for W5x00. Now W5x00 can use any custom hardware / software SPI
MIT License
88 stars 21 forks source link

EthernetWebServer_STM32 build broken on STM32F103C8T6 #8

Closed dm5xx closed 2 years ago

dm5xx commented 2 years ago

Describe the bug

Its impossible to build because of build is broken. Build log is full of errors like

.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:80:15: error: 'ETH_DMADescTypeDef' does not name a type 80 | ALIGN_BEGIN ETH_DMADescTypeDef DMARxDscrTab[ETH_RXBUFNB] ALIGN_END;/ Ethernet Rx MA Descriptor / | ^~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:85:15: error: 'ETH_DMADescTypeDef' does not name a type 85 | ALIGN_BEGIN ETH_DMADescTypeDef DMATxDscrTab[ETH_TXBUFNB] ALIGN_END;/ Ethernet Tx DMA Descriptor /

Looking into ehternetif.cpp => Its almost completly red

Steps to Reproduce

Set up Visual Code as described, use this ini and build.

[platformio] default_envs = STM32

[env] upload_speed = 921600

lib_compat_mode = strict lib_ldf_mode = chain+ ;lib_ldf_mode = deep+

lib_deps = stm32duino/STM32duino LwIP@~2.1.2 stm32duino/STM32Ethernet@~1.3.0 khoih-prog/Functional-Vlpp@~1.0.2 khoih-prog/Ethernet_Generic@~2.2.0 uipethernet/UIPEthernet@~2.0.11 jandrassy/EthernetENC@~2.0.2

[env:STM32] platform = ststm32 framework = arduino board = bluepill_f103c8

Expected behavior

Build should be possible and all is running fine again :)

Actual behavior

Its dead jim.

Debug and AT-command log (if applicable)

Compiling .pio\build\STM32\lib3c6\STM32Ethernet\utility\stm32_eth.cpp.o .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:80:15: error: 'ETH_DMADescTypeDef' does not name a type 80 | ALIGN_BEGIN ETH_DMADescTypeDef DMARxDscrTab[ETH_RXBUFNB] ALIGN_END;/ Ethernet Rx MA Descriptor / | ^~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:85:15: error: 'ETH_DMADescTypeDef' does not name a type 85 | ALIGN_BEGIN ETH_DMADescTypeDef DMATxDscrTab[ETH_TXBUFNB] ALIGN_END;/ Ethernet Tx DMA Descriptor / | ^~~~~~ In file included from C:\Users\matrixxx.platformio\packages\framework-arduinoststm32\system\STM32F1xx/stm32f1xx_hal_conf.h:13, from C:\Users\matrixxx.platformio\packages\framework-arduinoststm32\system\Drivers\STM32F1xx_HAL_Driver\Inc/stm32f1xx_hal.h:30, from C:\Users\matrixxx.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32F1xx\Include/stm32f1xx.h:255, from C:\Users\matrixxx.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:28, from .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:48: C:\Users\matrixxx.platformio\packages\framework-arduinoststm32\system\STM32F1xx/stm32f1xx_hal_conf_default.h:187:40: error: 'ETH_MAX_PACKET_SIZE' was not declared in this scope 187 | #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE / buffer size for receive / | ^~~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:90:44: note: in expansion of macro 'ETH_RX_BUF_SIZE' 90 | ALIGN_BEGIN uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE] ALIGN_END; / Ethernet Receive Buffer / | ^~~~~~~ C:\Users\matrixxx.platformio\packages\framework-arduinoststm32\system\STM32F1xx/stm32f1xx_hal_conf_default.h:188:40: error: 'ETH_MAX_PACKET_SIZE' was not declared in this scope 188 | #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE / buffer size for transmit / | ^~~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:95:44: note: in expansion of macro 'ETH_TX_BUF_SIZE' 95 | ALIGN_BEGIN uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE] ALIGN_END; / Ethernet Transmit Buffer / | ^~~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:97:8: error: 'ETH_HandleTypeDef' does not name a type; did you mean 'RTC_HandleTypeDef'? 97 | static ETH_HandleTypeDef EthHandle; | ^~~~~ | RTC_HandleTypeDef .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:116:22: error: variable or field 'HAL_ETH_MspInit' declared void
116 | void HAL_ETH_MspInit(ETH_HandleTypeDef heth) | ^~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:116:22: error: 'ETH_HandleTypeDef' was not declared in this scope; did you mean 'RTC_HandleTypeDef'? 116 | void HAL_ETH_MspInit(ETH_HandleTypeDef heth) | ^~~~~ | RTC_HandleTypeDef .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:116:41: error: 'heth' was not declared in this scope 116 | void HAL_ETH_MspInit(ETH_HandleTypeDef heth) | ^~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\stm32_eth.cpp:67:4: warning: #warning "Default timer used to call ethernet scheduler at regular interval: TIM14" [-Wcpp] 67 | #warning "Default timer used to call ethernet scheduler at regular interval: TIM14" | ^~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp: In function 'void low_level_init(netif)': .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:168:3: error: 'EthHandle' was not declared in this scope 168 | EthHandle.Instance = ETH; | ^~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:168:24: error: 'ETH' was not declared in this scope 168 | EthHandle.Instance = ETH; | ^~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:170:36: error: 'ETH_AUTONEGOTIATION_ENABLE' was not declared in this scope 170 | EthHandle.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE; | ^~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:171:26: error: 'ETH_SPEED_100M' was not declared in this scope 171 | EthHandle.Init.Speed = ETH_SPEED_100M; | ^~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:172:31: error: 'ETH_MODE_FULLDUPLEX' was not declared in this scope 172 | EthHandle.Init.DuplexMode = ETH_MODE_FULLDUPLEX; | ^~~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:174:35: error: 'ETH_MEDIA_INTERFACE_RMII' was not declared in this scope 174 | EthHandle.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII; | ^~~~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:181:27: error: 'ETH_RXPOLLING_MODE' was not declared in this scope
181 | EthHandle.Init.RxMode = ETH_RXPOLLING_MODE; | ^~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:183:33: error: 'ETH_CHECKSUM_BY_HARDWARE' was not declared in this scope; did you mean 'CHECKSUM_BY_HARDWARE'? 183 | EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE; | ^~~~~~~~ | CHECKSUM_BY_HARDWARE .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:184:31: error: 'LAN8742A_PHY_ADDRESS' was not declared in this scope
184 | EthHandle.Init.PhyAddress = LAN8742A_PHY_ADDRESS; | ^~~~~~~~ .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:187:7: error: 'HAL_ETH_Init' was not declared in this scope; did you mean 'HAL_RTC_Init'? 187 | if (HAL_ETH_Init(&EthHandle) == HAL_OK) { | ^~~~ | HAL_RTC_Init .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:193:41: error: 'DMATxDscrTab' was not declared in this scope Compiling .pio\build\STM32\src\main.cpp.o 193 | HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB); | ^~~~~Compiling .pio\build\STM32\libc4e\STM32duino LwIP\api\api_lib.c.o


.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:193:56: error: 'Tx_Buff' was not declared in this scope
  193 |   HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
      |                                                        ^~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:193:3: error: 'HAL_ETH_DMATxDescListInit' was not declared in this scope
  193 |   HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:196:41: error: 'DMARxDscrTab' was not declared in this scope
  196 |   HAL_ETH_DMARxDescListInit(&EthHandle, DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
      |                                         ^~~~~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:196:56: error: 'Rx_Buff' was not declared in this scope
  196 |   HAL_ETH_DMARxDescListInit(&EthHandle, DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
      |                                                        ^~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\stm32_eth.cpp: In function 'void TIM_scheduler_Config()':
.pio\libdeps\STM32\STM32Ethernet\src\utility\stm32_eth.cpp:66:35: error: 'TIM14' was not declared in this scope; did you mean 'TIM1'?
   66 |   #define DEFAULT_ETHERNET_TIMER  TIM14
      |                                   ^~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\stm32_eth.cpp:184:30: note: in expansion of macro 'DEFAULT_ETHERNET_TIMER'
  184 |   EthTim = new HardwareTimer(DEFAULT_ETHERNET_TIMER);
      |                              ^~~~~~~~~~~~~~~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:196:3: error: 'HAL_ETH_DMARxDescListInit' was not declared in this scope
  196 |   HAL_ETH_DMARxDescListInit(&EthHandle, DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:217:3: error: 'HAL_ETH_Start' was not declared in this scope; did you 
mean 'HAL_ADC_Start'?
  217 |   HAL_ETH_Start(&EthHandle);
      |   ^~~~~~~~~~~~~
      |   HAL_ADC_Start
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:223:39: error: 'PHY_IMR' was not declared in this scope; did you mean 
'PHY_MISR'?
  223 |   HAL_ETH_ReadPHYRegister(&EthHandle, PHY_IMR, &regvalue);
      |                                       ^~~~~~~
      |                                       PHY_MISR
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:223:3: error: 'HAL_ETH_ReadPHYRegister' was not declared in this scope  223 |   HAL_ETH_ReadPHYRegister(&EthHandle, PHY_IMR, &regvalue);
      |   ^~~~~~~~~~~~~~~~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:225:15: error: 'PHY_ISFR_INT4' was not declared in this scope
  225 |   regvalue |= PHY_ISFR_INT4;
      |               ^~~~~~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:228:3: error: 'HAL_ETH_WritePHYRegister' was not declared in this scope
  228 |   HAL_ETH_WritePHYRegister(&EthHandle, PHY_IMR, regvalue);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~
*** [.pio\build\STM32\lib3c6\STM32Ethernet\utility\stm32_eth.cpp.o] Error 1
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp: In function 'err_t low_level_output(netif*, pbuf*)':
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:254:33: error: 'EthHandle' was not declared in this scope
  254 |   uint8_t *buffer = (uint8_t *)(EthHandle.TxDesc->Buffer1Addr);
      |                                 ^~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:255:8: error: 'ETH_DMADescTypeDef' does not name a type
  255 |   __IO ETH_DMADescTypeDef *DmaTxDesc;
      |        ^~~~~~~~~~~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:263:3: error: 'DmaTxDesc' was not declared in this scope
  263 |   DmaTxDesc = EthHandle.TxDesc;
      |   ^~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:269:30: error: 'ETH_DMATXDESC_OWN' was not declared in this scope     
  269 |     if ((DmaTxDesc->Status & ETH_DMATXDESC_OWN) != (uint32_t)RESET) {
      |                              ^~~~~~~~~~~~~~~~~
In file included from C:\Users\matrixxx\.platformio\packages\framework-arduinoststm32\system\STM32F1xx/stm32f1xx_hal_conf.h:13,   
                 from C:\Users\matrixxx\.platformio\packages\framework-arduinoststm32\system\Drivers\STM32F1xx_HAL_Driver\Inc/stm32f1xx_hal.h:30,
                 from C:\Users\matrixxx\.platformio\packages\framework-arduinoststm32\system\Drivers\CMSIS\Device\ST\STM32F1xx\Include/stm32f1xx.h:255,
                 from C:\Users\matrixxx\.platformio\packages\framework-arduinoststm32\cores\arduino\stm32/stm32_def.h:28,
                 from .pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:48:
C:\Users\matrixxx\.platformio\packages\framework-arduinoststm32\system\STM32F1xx/stm32f1xx_hal_conf_default.h:188:40: error: 'ETH_MAX_PACKET_SIZE' was not declared in this scope
  188 | #define ETH_TX_BUF_SIZE                ETH_MAX_PACKET_SIZE /* buffer size for transmit              */
      |                                        ^~~~~~~~~~~~~~~~~~~
.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:279:47: note: in expansion of macro 'ETH_TX_BUF_SIZE'
  279 |     while ((byteslefttocopy + bufferoffset) > ETH_TX_BUF_SIZE) {
      |                                               ^~~~~~~~~~~~~~~
In file included from src\main.cpp:22:
src\defines.h:64:4: warning: #warning Using W5x00 & Ethernet_Generic lib [-Wcpp]
   64 |   #warning Using W5x00 & Ethernet_Generic lib
      |    ^~~~~~~
src\defines.h:89:12: fatal error: SPI.h: No such file or directory

### Information

Visual Code newest.

Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/bluepill_f103c8.html
PLATFORM: ST STM32 (15.0.0) > BluePill F103C8
HARDWARE: STM32F103C8T6 72MHz, 20KB RAM, 64KB Flash
DEBUG: Current (stlink) External (blackmagic, cmsis-dap, jlink, stlink)
PACKAGES: 
 - framework-arduinoststm32 @ 4.20100.211028 (2.1.0) 
 - framework-cmsis @ 2.50700.210515 (5.7.0) 
 - toolchain-gccarmnoneeabi @ 1.90201.191206 (9.2.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain+, Compatibility ~ strict
Found 19 compatible libraries
Scanning dependencies...
Dependency Graph
|-- STM32duino LwIP @ 2.1.2
|   |-- STM32Ethernet @ 1.3.0
|-- STM32Ethernet @ 1.3.0
|-- Functional-Vlpp @ 1.0.2
|-- Ethernet_Generic @ 2.2.0
|-- UIPEthernet @ 2.0.12
|-- EthernetENC @ 2.0.3
|-- EthernetWebServer_STM32 @ 1.5.0
|   |-- STM32duino LwIP @ 2.1.2
|   |   |-- STM32Ethernet @ 1.3.0
|   |-- STM32Ethernet @ 1.3.0
|   |-- Functional-Vlpp @ 1.0.2
|   |-- Ethernet_Generic @ 2.2.0

### Additional context

Maybe same problem because of this: https://community.st.com/s/question/0D53W00001RKeRZSA1/stm32f4-hal-eth-broken

Hi Khoih! Thanks for all your hard work! Hope you can help here too :) Mike.
khoih-prog commented 2 years ago

Hi @dm5xx

Thanks for your interest in the library.

I just test compile the example HelloServer on F103C8 and still OK using Arduino IDE.

Selection_045

I suggest you try to use Arduino IDE first. Then move on to PIO when everything is OK.

PIO is still not mature enough for complex use cases, and requires much more knowledge / skills to manually modify the settings.

Post for help in PIO Forum if you still have problem.

I'm closing the issue now, because I just compiled and OK here.

khoih-prog commented 2 years ago

.pio\libdeps\STM32\STM32Ethernet\src\utility\ethernetif.cpp:184:31: error: 'LAN8742A_PHY_ADDRESS' was not declared in this scope 184 | EthHandle.Init.PhyAddress = LAN8742A_PHY_ADDRESS;

Another note is that LAN8742A can be only used for some STM32F7 (Nucleo-144 F767ZI, etc.), , etc. as built-in Ethernet. Now you can only use W5x00 or ENC28J60 for STM31F1, F4.

STM32F1, F4, etc. can't use LAN8742A yet.

Even support to LAN8720 and STM32F4 recently was broken with new STM32 core v2.3.0. I'm not interested in finding out why and had to drop the support to LAN8720 ;={{

If necessary, use the STM32 core v2.2.0 or STM32 core v2.1.0 for LAN8720

Be sure to use in your code before includion of EthernetWebServer_STM32

#define USE_BUILTIN_ETHERNET    false
...
#include <EthernetWebServer_STM32.h>