STM32F7_LXI_Device
STM32F7_LXI_Device copied to clipboard
(wip) LAN Instrument standard implemented on a STM32f7 Nucleo board using Ethernet / LwIP / SCPI / FreeRTOS
STM32F7_LXI_Device
STM32 based LXI Device using Ethernet, LwIP, httpd, SCPI
stm32f746zg(Nucleo)- STM32CubeIDE
Working
- ✅ DHCP IP Address Management
- MCU continues to run even without active Ethernet connection
- MCU connects to Network when pluged in via Ethernet
- ✅ http web interface
- ✅ has switches to turn on/off configurations
- ✅ uses CGI/SSI
- ⚠️ mandatory
/lxi/identification.xmlis present (but not detected by the LXI tool)
- ✅ custom physical MAC address from within firmware
- ✅ unique EUI48 address is read from EEPROM
- ✅ EEPROM to save/load user settings (IP, DHCP config ...)
- ✅ Settings allow to enable/disable DHCP + AutoIP or manual settings (IP/Netmask/Gateway)
Sources
- How to make Ethernet and lwIP working on STM32
- Tutorial HTTPd web-server on STM32 with SSI
- STM32F7 LwIP_TCP_Echo_Server
- STM32H7 LwIP_UDP_Echo_Server
- SCPI parser Library
- List of LXI Ports & Protocols
- UDP/Portmap Identification Broadcast example packet: liblxi
- Correct SSI API application: ssi_example.c
Tools
- official LXI Discovery Tool
- This sends out a
UDP/RPC/Portmapbroadcast with theGETPORTcommand - the LXI device must reply to this broadcast in
rcp_server.c - Then the tool requests the
http://<host>/lxi/identification.xmlfrom the device
- This sends out a
- lxi-tools
- This sends out a
UDP/RPC/Portmapbroadcast with theGETPORTcommand - according to wireshark, the device does not reply --> how does it work then?
- The tool will attempt to connect to the device via VXI-11 and
*IRQ?the name
- This sends out a
- Wireshark
Todo
| ❌ | 🔄 | ⚠️ | ✅ |
|---|---|---|---|
| Todo | WIP | Debug (broken) | Done (working) |
Todo Critical
- ⚠️ [Bug] stops at: queue.c:1429 configASSERT(pxQueue->uxItemSize == 0)
- https://community.st.com/s/question/0D50X0000BJ1iquSQB/bug-in-cubemx-ide-lwip-freertos-on-nucleo-f429zi
- 🔄 [Feature] make dynamic version of
/lxi/identification.xmlwith appropriate SSI implementation- https://www.nongnu.org/lwip/2_0_x/group__httpd.html
- (?) reverse changes in
httpd.cbecause SSI can be controlled by makefsdata - (?) since the xml file contains
<!--comments-->the LXI Discovery tool does not recognize the device anymore - ⚠️ LXI Identification still unclear, lxi-tools vs. LXI Identification Tool do not behave the same
- Assertion "sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty" failed at line 190 in ../Middlewares/Third_Party/LwIP/src/core/timeouts.c
Todo Whishlist
- ❌ [Feature] function to check web connection status
- or callback handlers when connected / disconnected
- ❌ [reliability] Add further
ASSERT()statements throughout the code (e.g. for SSI) - ❌ [refactor] author/licence/description header for each file
- 🔄 [refactor] cleanup spaghetti code of global variables, introduce hierarchy of config headers
- ❌ [refactor] implement clear MVC structure for SCPI commands
- ❌ [Feature] add hislip compatibility
- ❌ [refactor] refactor/rename scpi_server.c to tcp/ip (does this have a name? VXI?)
- ❌ [reliability] use MUTEX for UART ringbuffer?
- ❌ [reliability] implement a memory monitor (FreeRTOS?) to check on heap/stack/RAM usage
- ❌ [refactor] use SCPI_Result**** API as return throughout scpi User Code
- ❌ [Feature] enable https within lwip
- ❌ [Feature] enable web login
- probably not supported by LwIP, requires form post and session creation using a cookie in the post header
- password is stored on EEPROM
- redesign of web interface is required
Documentation
- exclude from build:
fs_data.cfs_data_custom.c
Helper Libraries
-
lwip/ip4_addr.hparse and verify IPv4 addresses (documentation) -
scpi/parser.hparse and extract parameters from ascii (documentation)
Features
- Webinterface (http / port 80)
- http://192.168.1.179/
- http://192.168.1.179/lxi/identification
File Structure
Core/Src and Core/Inc
scpi-def.c- SCPI commands definition
- SCPI command callback functions
- command parsing, argument preprocessing + sanitization
stm32f7xx_it.c- USART Interrupt for UART SCPI
http_cgi_app.c- CGI + SSI implementation for the httpd Webserver
- SSI works for both the Website and the
identification.xml
rpc_server.c- implements the Sun-RPC Protocol based on UDP (more specifically the
Portmapprotocol) - When a UDP Broadcast (IP address:
xxx.xxx.xxx.255) is received, the LXI device must answer correctly
- implements the Sun-RPC Protocol based on UDP (more specifically the
Tools/fs
- Filesystem for the Webserver
- use any program
makefsdata(perl, C, ...) to convert the file System to a C source filefs_data_custom.c fs_data_custom.cmust be copied to./Middlewares/Third_Party/LwIP/src/apps/httpafter re-generation
LWIP/App
lwip.c- initialization with DHCP
- initialization with manual IP
LWIP/Target
-
LWIP/Target/ethernetif.ccontains some User Code to set the PHY/MAC address -
eeprom_24aa.hcontains macros to store and retreive data (e.g. manual IP config) in EEPROM
Webserver
SSI CGI
#define LWIP_HTTPD_MAX_TAG_NAME_LEN 8
#define LWIP_HTTPD_MAX_TAG_INSERT_LEN 192