LwIP_HTTP_Server_Netconn_RTOS_OpENer.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. diff --git a/Inc/lwipopts.h b/Inc/lwipopts.h
  2. index ef9dbfa..6a8c593 100644
  3. --- a/Inc/lwipopts.h
  4. +++ b/Inc/lwipopts.h
  5. @@ -56,7 +56,9 @@ a lot of data that needs to be copied, this should be set high. */
  6. /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active
  7. timeouts. */
  8. #define MEMP_NUM_SYS_TIMEOUT 10
  9. -
  10. +/* MEMP_NUM_NETCONN: the number of struct netconns.
  11. + (only needed if you use the sequential API, like api_lib.c) */
  12. +#define MEMP_NUM_NETCONN 12
  13. /* ---------- Pbuf options ---------- */
  14. /* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
  15. @@ -94,6 +96,8 @@ a lot of data that needs to be copied, this should be set high. */
  16. /* ---------- ICMP options ---------- */
  17. #define LWIP_ICMP 1
  18. +/* ---------- IGMP options ---------- */
  19. +#define LWIP_IGMP 1
  20. /* ---------- DHCP options ---------- */
  21. #define LWIP_DHCP 1
  22. @@ -113,6 +117,9 @@ a lot of data that needs to be copied, this should be set high. */
  23. */
  24. #define LWIP_NETIF_LINK_CALLBACK 1
  25. +/* ---------- Netif options ---------- */
  26. +#define LWIP_NETIF_HOSTNAME 1
  27. +
  28. /*
  29. --------------------------------------
  30. ---------- Checksum options ----------
  31. @@ -178,7 +185,11 @@ The STM32F4x7 allows computing and verifying the IP, UDP, TCP and ICMP checksums
  32. /**
  33. * LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
  34. */
  35. -#define LWIP_SOCKET 0
  36. +#define LWIP_SOCKET 1
  37. +/**
  38. + * SO_REUSE==1: Enable SO_REUSEADDR option.
  39. + */
  40. +#define SO_REUSE 1
  41. /*
  42. ------------------------------------
  43. diff --git a/Inc/main.h b/Inc/main.h
  44. index 36ca85f..fb7961c 100644
  45. --- a/Inc/main.h
  46. +++ b/Inc/main.h
  47. @@ -31,7 +31,7 @@
  48. /* Exported types ------------------------------------------------------------*/
  49. /* Exported constants --------------------------------------------------------*/
  50. -#define USE_DHCP /* enable DHCP, if disabled static address is used*/
  51. +//#define USE_DHCP // not used, replaced by LWIP_DHCP
  52. #define USE_LCD
  53. /*Static IP ADDRESS*/
  54. diff --git a/SW4STM32/syscalls.c b/SW4STM32/syscalls.c
  55. index fa8687f..6a84edb 100644
  56. --- a/SW4STM32/syscalls.c
  57. +++ b/SW4STM32/syscalls.c
  58. @@ -15,7 +15,7 @@
  59. #include <reent.h>
  60. #include <unistd.h>
  61. #include <sys/wait.h>
  62. -
  63. +#include <stm32f7xx_hal.h>
  64. #define FreeRTOS
  65. @@ -99,6 +99,15 @@ void _exit (int status)
  66. while (1) {}
  67. }
  68. +#if REDIRECT_PRINTF_TO_SWV_ITM
  69. +__attribute__((weak)) int _write(int file, char *ptr, int len) {
  70. + int DataIdx;
  71. + for (DataIdx = 0; DataIdx < len; DataIdx++) {
  72. + ITM_SendChar(*ptr++);
  73. + }
  74. + return len;
  75. +}
  76. +#else // standard output
  77. int _write(int file, char *ptr, int len)
  78. {
  79. int DataIdx;
  80. @@ -109,6 +118,7 @@ int _write(int file, char *ptr, int len)
  81. }
  82. return len;
  83. }
  84. +#endif // standard output
  85. int _close(int file)
  86. {
  87. diff --git a/Src/app_ethernet.c b/Src/app_ethernet.c
  88. index e3278ac..aab6265 100644
  89. --- a/Src/app_ethernet.c
  90. +++ b/Src/app_ethernet.c
  91. @@ -28,6 +28,9 @@
  92. #include "lcd_log.h"
  93. #endif
  94. +// for OpENer
  95. +#include "opener.h"
  96. +
  97. /* Private typedef -----------------------------------------------------------*/
  98. /* Private define ------------------------------------------------------------*/
  99. /* Private macro -------------------------------------------------------------*/
  100. @@ -55,6 +58,8 @@ void ethernet_link_status_updated(struct netif *netif)
  101. uint8_t iptxt[20];
  102. sprintf((char *)iptxt, "%s", ip4addr_ntoa(netif_ip4_addr(netif)));
  103. LCD_UsrLog ("Static IP address: %s\n", iptxt);
  104. + /* Start Ethernet/IP Stack (OpENer) */
  105. + opener_init(netif);
  106. #else
  107. BSP_LED_On(LED1);
  108. BSP_LED_Off(LED2);
  109. @@ -124,6 +129,8 @@ void DHCP_Thread(void const * argument)
  110. BSP_LED_On(LED1);
  111. BSP_LED_Off(LED2);
  112. #endif
  113. + /* Start Ethernet/IP Stack (OpENer) */
  114. + opener_init(netif);
  115. }
  116. else
  117. {
  118. @@ -148,6 +155,8 @@ void DHCP_Thread(void const * argument)
  119. BSP_LED_On(LED1);
  120. BSP_LED_Off(LED2);
  121. #endif
  122. + /* Start Ethernet/IP Stack (OpENer) */
  123. + opener_init(netif);
  124. }
  125. }
  126. }
  127. diff --git a/Src/main.c b/Src/main.c
  128. index c25dbd0..e3dda6c 100644
  129. --- a/Src/main.c
  130. +++ b/Src/main.c
  131. @@ -71,6 +71,11 @@ int main(void)
  132. /* Configure the system clock to 200 MHz */
  133. SystemClock_Config();
  134. + /* For single step debug, e.g. timers with interrupts need to be stopped in Halt */
  135. + HAL_DBGMCU_EnableDBGStandbyMode();
  136. + HAL_DBGMCU_EnableDBGStopMode();
  137. + __HAL_DBGMCU_FREEZE_TIM6();
  138. +
  139. /* Initialize LCD and LEDs */
  140. BSP_Config();
  141. @@ -139,6 +144,8 @@ static void Netif_Config(void)
  142. /* Registers the default network interface. */
  143. netif_set_default(&gnetif);
  144. + /* Define the hostname, is also used by OpENer */
  145. + netif_set_hostname(&gnetif,"STM32");
  146. ethernet_link_status_updated(&gnetif);
  147. @@ -180,7 +187,7 @@ static void BSP_Config(void)
  148. LCD_LOG_Init();
  149. /* Show Header and Footer texts */
  150. - LCD_LOG_SetHeader((uint8_t *)"Webserver Application Netconn API");
  151. + LCD_LOG_SetHeader((uint8_t *)"Webserver Application Netconn API & OpENer");
  152. LCD_LOG_SetFooter((uint8_t *)"STM32746G-DISCO board");
  153. LCD_UsrLog ((char *)" State: Ethernet Initialization ...\n");