SlideShare a Scribd company logo
1
2
C/Embedded Base Camp
Connection of GL Embedded Starter Kit to Ethernet
Petro Shevchenko
July 2021
1. STM32F407x Ethernet Interface
2. STM32F407x HAL Ethernet Driver
3. Lightweight TCP/IP Stack
4. TCP Client Example
5. TCP Server Example
6. HTTP Server Demo
7. UDP Server Implementation
Agenda
STM32F407x Ethernet Interface
● GlobalLogic Embedded Starter Kit (GL ESK) is based on the STM32F407G-DISC1 board
produced by STMicroelectronics
● STM32F407VG microcontroller contains an Ethernet MAC (Media Access Control) module
that supports two industry standard interfaces to the external physical layer chip (PHY):
- Media Independent Interface (MII)
- Reduced Media Independent Interface (RMII)
● To connect the STM32F407G-DISC1 board to the KSZ8081RNB PHY, placed on GL ESK,
RMII is used
5
STM32F407VG Ethernet MAC
STM32F407VG Ethernet MAC
● The Ethernet peripheral consists of a MAC 802.3 (media access control) with a dedicated
DMA controller
- The DMA controller interfaces with the Core and memories through the AHB Master
and Slave interfaces
- The AHB Master Interface controls data transfers while the AHB Slave interface
accesses Control and Status registers (CSR) space
● A set of configuration registers permit the user to select the desired mode and features for the
MAC and the DMA controller
STM32F407VG Ethernet MAC
STM32F407VG Ethernet MAC
The Ethernet block diagram contains the following abbreviation :
● PTP IEEE 1588 : Precision Time Protocol is a protocol used to synchronize clocks throughout
a computer network
● PMT : Power Management Technology supports the reception of network wakeup frames and
Magic Packet frames
● MMC : MAC Management Counters maintain a set of registers for gathering statistics on the
received and transmitted frames
Looking at the Ethernet block diagram above, there are two different interfaces between MCU and
an external physical chip :
● MII/RMII to transfer data between MCU and external PHY
● Station Management Interface (SMI) to communicate with external PHY
Station Management Interface (SMI)
● The station management interface allows the application to access any PHY registers
through a 2-wire clock (MDC) and data (MDIO) lines
● The interface supports accessing up to 32 PHYs
● The application can select one of the 32 PHYs and one of the 32 registers within any PHY
and send control data or receive status information
● Only one register in one PHY can be addressed at any given time
There are three types of registers :
● Basic (0 - 1)
● Extended (2 - 14)
● Vendor specific (16 - 31)
Note : For more information about SMI refer to the Reference Manual.
Reduced Media Independent Interface (RMII)
● The reduced media-independent interface specification reduces the pin count between the
microcontroller Ethernet peripheral and the external Ethernet
● According to the IEEE 802.3u standard, an MII contains 16 pins for data and control. The
RMII specification is dedicated to reduce the pin count to 7 pins
● The RMII is instantiated between the MAC and the PHY. This helps to translate the MAC’s
MII into the RMII
The RMII block has the following characteristics :
● It supports 10-Mbit/s and 100-Mbit/s operating rates
● The clock reference must be doubled to 50 MHz
● The same clock reference must be sourced externally to both MAC and external Ethernet
PHY
● It provides independent 2-bit wide (dibit) transmit and receive data paths
Reduced Media Independent Interface (RMII)
Reduced Media Independent Interface (RMII)
Looking at the description of RMII signals, consider each of them in detail :
● TXD[1:0]: transmit data is a bundle of 2 data signals driven synchronously by the MAC
sublayer
● TX_EN: while TX_EN is asserted the transmit data have effect upon the PHY
● RXD[1:0]: reception data is a bundle of 2 data signals driven synchronously by the PHY
● CRSDV: Carrier Sense (CRS) and RX_Data Valid (RX_DV) multiplexed on alternate clock
cycles
● MDC: SMI clock signal
● MDIO: SMI data input/output
● REF_CLK: Continuous 50 MHz reference clock
13
KSZ8081RND PHY
KSZ8081RND PHY
● The KSZ8081RND is a single-supply 10Base-T/100Base-TX Ethernet physical layer
transceiver for transmission and reception of data over standard CAT-5 unshielded twisted
pair (UTP) cable
● The KSZ8081RND takes in the 50MHz RMII reference clock as the power-up default
● The KSZ8081RND is configured optionally to RMII – 25MHz Clock Mode after it is powered up
or hardware reset and software programmed with the following :
- An external 25MHz clock source (oscillator) connected to XI (pin 8)
- Register 1Fh, bit [7] programmed to ‘1’ to select RMII – 25MHz Clock Mode
KSZ8081RNB PHY
KSZ8081RND PHY
KSZ8081RND PHY
● The KSZ8081RND supports PHY addresses 0x0h, 0x3h, 0x4, 0x7
● The PHY Address is latched at the deassertion of reset
○ Pull-up = PHY Address bits [1:0] are both set to 1
○ Pull-down (default) = PHY Address bits [1:0] are both set to 0
● PHY Address bits [4:3] are set to 0x00 by default
● The KSZ8081RND contains 32 registers, the register map is shown below
Note: For information on the formats of internal registers, see the documentation for the KSZ8081RND
KSZ8081RND PHY
19
STM32F407x HAL Ethernet Driver
STM32F407x HAL Ethernet Driver
● The STM32Cube IDE uses STM32CubeMX plug-in to automatically generate initialization
code. The generated source code is based on the HAL driver
● The STM32CubeMX plug-in can automatically generate configurations for two PHYs :
- LAN8742A
- DP83848
● The STM32CubeMX plug-in allows users to configure HAL Ethernet driver. The next pictures
illustrate configuration of HAL Ethernet driver in the STM32Cube IDE through the
STM32CubeMX plug-in
Note: Unfortunately, the KSZ8081RND PHY installed on GL Embedded Starter Kit is not supported by
the STM32CubeMX code generator so the Ethernet driver was replaced with another one, which was created
based on the HAL Ethernet driver. This driver sets up 25MHz clock mode and uses the vendor specific
registers to configure the KSZ8081RND chip
ETH Parameter Settings
ETH Advanced Parameters
ETH GPIO Settings
ETH Driver settings
25
Lightweight TCP/IP (LwIP) Stack
Lightweight TCP/IP Stack features
● LwIP is a free TCP/IP stack developed by Adam Dunkels at the Swedish Institute of
Computer Science (SICS) and licensed under a modified BSD license
● The focus of the LwIP TCP/IP implementation is to reduce RAM usage while keeping a full
scale TCP/IP stack. This makes LwIP suitable for use in embedded systems
● LwIP comes with the following protocols :
- IPv4 and IPv6 (Internet Protocol v4 and v6)
- ICMP (Internet Control Message Protocol) for network maintenance and debugging
- IGMP (Internet Group Management Protocol) for multicast traffic management
- UDP (User Datagram Protocol)
- TCP (Transmission Control Protocol)
- DNS (Domain Name Server)
- SNMP (Simple Network Management Protocol)
- DHCP (Dynamic Host Configuration Protocol)
- PPP (Point to Point Protocol)
- ARP (Address Resolution Protocol)
Lightweight TCP/IP Stack features
LwIP has three application programming interfaces (APIs) :
● Raw API is the native LwIP API. It enables the development of applications using event
callbacks. This API provides the best performance and optimized code size, but adds
some complexity to application development
● Netconn API is a high-level sequential API that requires a real-time operating system
(RTOS). The Netconn API enables multithreaded operations.
● BSD Socket API: Berkeley-like Socket API (developed on top of the Netconn API)
LwIP architecture
● LwIP complies with the TCP/IP model architecture which specifies how data should be
formatted, transmitted, routed and received to provide end-to-end communications
● This model includes four abstraction layers which are used to sort all related protocols
according to the scope of networking involved (see Figure 1).
From lowest to highest, the layers are :
- The link layer contains communication technologies for a single network segment
(link) of a local area network
- The internet layer (IP) connects independent networks, thus establishing
internetworking
- The transport layer handles host-to-host communications
- The application layer contains all protocols for specific data communications services on
a process-to-process level
LwIP architecture
LwIP configuration
● LwIP provides a file named lwipopts.h that allows the user to fully configure the stack and all
its modules. If an option is not defined, a default value defined in opt.h file is used
● The user can choose the modules he needs for his application, so that the code size will be
optimized by compiling only the selected features
example:
#define LWIP_UDP 1 /* Enable UDP */
● LwIP provides a flexible way to manage memory pool sizes and organization. It reserves a
fixed-size static memory area in the data segment
● The following table provides a summary of the main RAM memory options
LwIP memory configuration
LwIP memory option Definition
MEM_SIZE LwIP heap memory size: used for all LwIP dynamic
memory allocations
MEMP_NUM_PBUF Total number of MEM_REF and MEM_ROM pbufs
MEMP_NUM_UDP_PCB Total number of UDP PCB structures
MEMP_NUM_TCP_PCB Total number of TCP PCB structures
MEMP_NUM_TCP_PCB_LISTEN Total number of listening TCP PCBs
MEMP_NUM_TCP_SEG Maximum number of simultaneously queued TCP
segments
LwIP memory configuration
LwIP memory option Definition
PBUF_POOL_SIZE Total number of PBUF_POOL type pbufs
PBUF_POOL_BUFSIZE Size of a PBUF_POOL type pbufs
TCP_MSS TCP maximum segment size
TCP_SND_BUF TCP send buffer space for a connection
TCP_SND_QUEUELEN Maximum number of pbufs in the TCP send queue
TCP_WND Advertised TCP receive window size
LwIP setting in STM32CubeMX
● LwIP stack is used in STM32CubeMX plug-in together with FreeRTOS, which is wrapped by
the CMSIS_OS interface
● The STM32Cube IDE through STM32CubeMX plug-in allows to automatically configure LwIP
stack
- as a result of LwIP settings, the files in the LWIP directory of the project will be modified
- automatically generated ethernetif.c file is used to link the LwIP stack to the STM32F407x
HAL Ethernet driver
● Here is a list of APIs from ethernetif.c file
- low_level_init : calls driver functions to initialize Ethernet
- low_level_output : calls driver functions to send Ethernet packet
- low_level_input : calls driver functions to receive Ethernet packet
- ethernetif_init : initializes the network interface structure (netif) then calls low_level_init
- ethernetif_input : calls low_level_input to receive a packet then push it onto LwIP stack
LwIP General Settings
LwIP Key Options
LwIP Debug
FreeRTOS Config Parameters
38
TCP Client Example
How to use TCP Client Example
● connect GL Embedded Starter Kit to the same local network as your PC is connected to
● open Linux terminal then install and launch Wireshark to capture a connection session
between the board and PC :
$ sudo apt install wireshark -y
$ sudo usermod -a -G wireshark $USER
$ sudo reboot
● open STM32Cube IDE, select default workspace with previously imported tcp_socket_client
project
● select ‘Project->Properties->C/C++Build->Settings->MCU GCC Compiler->Preprocessor’
menu item, then define SERVER=”XXX.XXX.XXX.XXX” with IP address of your PC. Build and
load the firmware
● check if network interface of your board is up by pinging the board. If so, open Linux terminal
and launch the following commands :
$ sudo apt install ncat -y
$ ncat -l 1500 --keep-open --exec /bin/cat
● push the blue button on the board and watch the packets in the Wireshark window
TCP Client Example
TCP Client Example
TCP Client Example
TCP Client Example
TCP Client Example
45
TCP Server Example
How to use TCP Server Example
● connect GL Embedded Starter Kit to the same local network as your PC is connected to
● launch Wireshark to capture a connection session between the board and PC
● open STM32Cube IDE, select default workspace with previously imported tcp_socket_client
project
● select ‘Project->Properties->C/C++Build->Settings->MCU GCC Compiler->Preprocessor’ menu
item, check if USE_TCP_SERVER macros is defined. If not, define USE_TCP_SERVER. Build
and load the firmware
● check if network interface of your board is up by pinging the board. If so, open Linux terminal
and launch the following command then enter some text message to be sent :
$ ncat <IP of the board> 1500
● to read logs from TCP server through USB-UART, define USE_TCP_SERVER_PRINTF=1 in
Core/Inc/main.h. Build and load the firmware
TCP Server Example
TCP Server Example
TCP Server Example
50
HTTP Server Demo
How to use HTTP Server Demo
● connect GL Embedded Starter Kit to the same local network as your PC is connected to
● launch Wireshark to capture a connection session between the board and PC
● open STM32Cube IDE, select default workspace with previously imported tcp_socket_client
project
● select ‘Project->Properties->C/C++Build->Settings->MCU GCC Compiler->Preprocessor’
menu item, check if USE_TCP_SERVER macros is defined. If so, remove
USE_TCP_SERVER. Define USE_HTTP_SERVER, USE_HTTP_SERVER_SOLUTION if
they are not defined. Build and load the firmware
● open your internet browser and enter the IP address of your board. Use form controls to
toggle LEDs
● read humidity from DHT11 by entering ‘<IP of the board>/humidity’ in your internet browser
● read temperature from DHT11 by entering ‘<IP of the board>/temperature’ in your internet
browser
HTTP Server Demo
HTTP Server Demo
HTTP Server Demo
HTTP Server Demo
56
UDP Server Implementation
UDP Server Implementation
● Implement a UDP server, that must be launched in a separate thread of the tcp_socket_client
project
● The UDP server must accept and execute the following commands from the UDP client :
- led<N> on : turn on the LED<N>, where N = 3,4,5,6
- led<N> off : turn off the LED<N>, where N = 3,4,5,6
- led<N> toggle : toggle the LED<N>, where N = 3,4,5,6
- example: led3 toggle
● Use ncat utility as a UDP client :
$ ncat -u <IP of the board> 5678
led3 toggle
● Use Wireshark, output through USB-UART or LCD to debug your application
● Demonstrate how your server works
58
Thank You
Ad

More Related Content

What's hot (20)

TCP/IP(networking)
TCP/IP(networking)TCP/IP(networking)
TCP/IP(networking)
welcometofacebook
 
TCP - Transmission Control Protocol
TCP - Transmission Control ProtocolTCP - Transmission Control Protocol
TCP - Transmission Control Protocol
Peter R. Egli
 
Lesson.7: Configuring IP Routing B
Lesson.7: Configuring IP Routing BLesson.7: Configuring IP Routing B
Lesson.7: Configuring IP Routing B
Mahmmoud Mahdi
 
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
Kruti Niranjan
 
Transport protocols
Transport protocolsTransport protocols
Transport protocols
Online
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
Melvin Cabatuan
 
TCP/IP and UDP protocols
TCP/IP and UDP protocolsTCP/IP and UDP protocols
TCP/IP and UDP protocols
Dawood Faheem Abbasi
 
Transport layer
Transport layerTransport layer
Transport layer
arvind pandey
 
Unit 4 tansport layer in the internat
Unit 4 tansport layer in the internatUnit 4 tansport layer in the internat
Unit 4 tansport layer in the internat
Kritika Purohit
 
10 routing-bgp
10 routing-bgp10 routing-bgp
10 routing-bgp
Olivier Bonaventure
 
Multipath TCP
Multipath TCPMultipath TCP
Multipath TCP
Olivier Bonaventure
 
Tcp udp
Tcp udpTcp udp
Tcp udp
Programmer
 
Transport Layer in Computer Networks (TCP / UDP / SCTP)
Transport Layer in Computer Networks (TCP / UDP / SCTP)Transport Layer in Computer Networks (TCP / UDP / SCTP)
Transport Layer in Computer Networks (TCP / UDP / SCTP)
Hamidreza Bolhasani
 
User Datagram protocol For Msc CS
User Datagram protocol For Msc CSUser Datagram protocol For Msc CS
User Datagram protocol For Msc CS
Thanveen
 
Computer Network Syllabus
Computer Network SyllabusComputer Network Syllabus
Computer Network Syllabus
Meenakshi Paul
 
Multipath TCP as Security Solution
Multipath TCP as Security SolutionMultipath TCP as Security Solution
Multipath TCP as Security Solution
Nishant Pawar
 
Features of tcp (part 2) .68
Features of tcp  (part 2) .68Features of tcp  (part 2) .68
Features of tcp (part 2) .68
myrajendra
 
Chap 10 igmp
Chap 10 igmpChap 10 igmp
Chap 10 igmp
Noctorous Jamal
 
MultiPath TCP - The path to multipath
MultiPath TCP - The path to multipathMultiPath TCP - The path to multipath
MultiPath TCP - The path to multipath
Diogo Mónica
 
Transport Layer Part 1
Transport Layer Part 1Transport Layer Part 1
Transport Layer Part 1
Tutun Juhana
 
TCP - Transmission Control Protocol
TCP - Transmission Control ProtocolTCP - Transmission Control Protocol
TCP - Transmission Control Protocol
Peter R. Egli
 
Lesson.7: Configuring IP Routing B
Lesson.7: Configuring IP Routing BLesson.7: Configuring IP Routing B
Lesson.7: Configuring IP Routing B
Mahmmoud Mahdi
 
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
TCP & UDP ( Transmission Control Protocol and User Datagram Protocol)
Kruti Niranjan
 
Transport protocols
Transport protocolsTransport protocols
Transport protocols
Online
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
Melvin Cabatuan
 
Unit 4 tansport layer in the internat
Unit 4 tansport layer in the internatUnit 4 tansport layer in the internat
Unit 4 tansport layer in the internat
Kritika Purohit
 
Transport Layer in Computer Networks (TCP / UDP / SCTP)
Transport Layer in Computer Networks (TCP / UDP / SCTP)Transport Layer in Computer Networks (TCP / UDP / SCTP)
Transport Layer in Computer Networks (TCP / UDP / SCTP)
Hamidreza Bolhasani
 
User Datagram protocol For Msc CS
User Datagram protocol For Msc CSUser Datagram protocol For Msc CS
User Datagram protocol For Msc CS
Thanveen
 
Computer Network Syllabus
Computer Network SyllabusComputer Network Syllabus
Computer Network Syllabus
Meenakshi Paul
 
Multipath TCP as Security Solution
Multipath TCP as Security SolutionMultipath TCP as Security Solution
Multipath TCP as Security Solution
Nishant Pawar
 
Features of tcp (part 2) .68
Features of tcp  (part 2) .68Features of tcp  (part 2) .68
Features of tcp (part 2) .68
myrajendra
 
MultiPath TCP - The path to multipath
MultiPath TCP - The path to multipathMultiPath TCP - The path to multipath
MultiPath TCP - The path to multipath
Diogo Mónica
 
Transport Layer Part 1
Transport Layer Part 1Transport Layer Part 1
Transport Layer Part 1
Tutun Juhana
 

Similar to Gl embedded starterkit_ethernet (20)

Tft touch screen manufacturers
Tft touch screen manufacturersTft touch screen manufacturers
Tft touch screen manufacturers
KeatonParker2
 
Assignment
AssignmentAssignment
Assignment
Abu Md Choudhury
 
[Application guide] IoT Protocol gateway
[Application guide] IoT Protocol gateway[Application guide] IoT Protocol gateway
[Application guide] IoT Protocol gateway
Seth Xie
 
Webinar: Comunicação TCP/IP segura
Webinar: Comunicação TCP/IP seguraWebinar: Comunicação TCP/IP segura
Webinar: Comunicação TCP/IP segura
Embarcados
 
Nt1310 Unit 5 Algorithm
Nt1310 Unit 5 AlgorithmNt1310 Unit 5 Algorithm
Nt1310 Unit 5 Algorithm
Angie Lee
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03
Premier Farnell
 
Arm usr m,anl
Arm usr m,anlArm usr m,anl
Arm usr m,anl
sam570
 
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
Vivek Venugopal
 
A42060105
A42060105A42060105
A42060105
IJERA Editor
 
Modbus
ModbusModbus
Modbus
Manoj89p
 
Cdot Max ng architecture working models
Cdot Max ng  architecture working modelsCdot Max ng  architecture working models
Cdot Max ng architecture working models
RahmanScholar
 
VJITSk 6713 user manual
VJITSk 6713 user manualVJITSk 6713 user manual
VJITSk 6713 user manual
kot seelam
 
Lecture 5-Embedde.pdf
Lecture 5-Embedde.pdfLecture 5-Embedde.pdf
Lecture 5-Embedde.pdf
BlackHunter13
 
Basic Study on the WT12 Family of Bluetooth Devices
Basic Study on the WT12 Family of Bluetooth DevicesBasic Study on the WT12 Family of Bluetooth Devices
Basic Study on the WT12 Family of Bluetooth Devices
Premier Farnell
 
Bhabha atomic research Centre (BARC)
Bhabha atomic research Centre (BARC)Bhabha atomic research Centre (BARC)
Bhabha atomic research Centre (BARC)
Utkarsh Tiwari
 
Practica 2
Practica 2Practica 2
Practica 2
Bruno Magallanes Noguez
 
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
MeghdeepSingh
 
Overview of LPC213x MCUs
Overview of LPC213x MCUsOverview of LPC213x MCUs
Overview of LPC213x MCUs
Premier Farnell
 
Bm36382385
Bm36382385Bm36382385
Bm36382385
IJERA Editor
 
International Refereed Journal of Engineering and Science (IRJES)
International Refereed Journal of Engineering and Science (IRJES)International Refereed Journal of Engineering and Science (IRJES)
International Refereed Journal of Engineering and Science (IRJES)
irjes
 
Tft touch screen manufacturers
Tft touch screen manufacturersTft touch screen manufacturers
Tft touch screen manufacturers
KeatonParker2
 
[Application guide] IoT Protocol gateway
[Application guide] IoT Protocol gateway[Application guide] IoT Protocol gateway
[Application guide] IoT Protocol gateway
Seth Xie
 
Webinar: Comunicação TCP/IP segura
Webinar: Comunicação TCP/IP seguraWebinar: Comunicação TCP/IP segura
Webinar: Comunicação TCP/IP segura
Embarcados
 
Nt1310 Unit 5 Algorithm
Nt1310 Unit 5 AlgorithmNt1310 Unit 5 Algorithm
Nt1310 Unit 5 Algorithm
Angie Lee
 
An Overview of LPC2101/02/03
An Overview of LPC2101/02/03An Overview of LPC2101/02/03
An Overview of LPC2101/02/03
Premier Farnell
 
Arm usr m,anl
Arm usr m,anlArm usr m,anl
Arm usr m,anl
sam570
 
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
AN INTEGRATED FOUR-PORT DC-DC CONVERTER-CEI0080
Vivek Venugopal
 
Cdot Max ng architecture working models
Cdot Max ng  architecture working modelsCdot Max ng  architecture working models
Cdot Max ng architecture working models
RahmanScholar
 
VJITSk 6713 user manual
VJITSk 6713 user manualVJITSk 6713 user manual
VJITSk 6713 user manual
kot seelam
 
Lecture 5-Embedde.pdf
Lecture 5-Embedde.pdfLecture 5-Embedde.pdf
Lecture 5-Embedde.pdf
BlackHunter13
 
Basic Study on the WT12 Family of Bluetooth Devices
Basic Study on the WT12 Family of Bluetooth DevicesBasic Study on the WT12 Family of Bluetooth Devices
Basic Study on the WT12 Family of Bluetooth Devices
Premier Farnell
 
Bhabha atomic research Centre (BARC)
Bhabha atomic research Centre (BARC)Bhabha atomic research Centre (BARC)
Bhabha atomic research Centre (BARC)
Utkarsh Tiwari
 
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptxINDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
INDUSTRIAL TRAINING REPORT EMBEDDED SYSTEM.pptx
MeghdeepSingh
 
Overview of LPC213x MCUs
Overview of LPC213x MCUsOverview of LPC213x MCUs
Overview of LPC213x MCUs
Premier Farnell
 
International Refereed Journal of Engineering and Science (IRJES)
International Refereed Journal of Engineering and Science (IRJES)International Refereed Journal of Engineering and Science (IRJES)
International Refereed Journal of Engineering and Science (IRJES)
irjes
 
Ad

More from Roman Brovko (20)

Individual task Networking
Individual task NetworkingIndividual task Networking
Individual task Networking
Roman Brovko
 
Networking essentials lect1
Networking essentials lect1Networking essentials lect1
Networking essentials lect1
Roman Brovko
 
Bare metal training_07_spi_flash
Bare metal training_07_spi_flashBare metal training_07_spi_flash
Bare metal training_07_spi_flash
Roman Brovko
 
Bare metal training_06_I2C
Bare metal training_06_I2CBare metal training_06_I2C
Bare metal training_06_I2C
Roman Brovko
 
Glesk worshop
Glesk worshopGlesk worshop
Glesk worshop
Roman Brovko
 
Bare metal training_05_uart
Bare metal training_05_uartBare metal training_05_uart
Bare metal training_05_uart
Roman Brovko
 
Bare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensorBare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensor
Roman Brovko
 
Bare metal training_03_timers_pwm
Bare metal training_03_timers_pwmBare metal training_03_timers_pwm
Bare metal training_03_timers_pwm
Roman Brovko
 
Bare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttonsBare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttons
Roman Brovko
 
Bare metal training_01_hello_world
Bare metal training_01_hello_worldBare metal training_01_hello_world
Bare metal training_01_hello_world
Roman Brovko
 
Bare metal training_00_prerequisites
Bare metal training_00_prerequisitesBare metal training_00_prerequisites
Bare metal training_00_prerequisites
Roman Brovko
 
C language lect_23_advanced
C language lect_23_advancedC language lect_23_advanced
C language lect_23_advanced
Roman Brovko
 
C language lect_22_advanced
C language lect_22_advancedC language lect_22_advanced
C language lect_22_advanced
Roman Brovko
 
C language lect_21_advanced
C language lect_21_advancedC language lect_21_advanced
C language lect_21_advanced
Roman Brovko
 
подготовка рабочего окружения
подготовка рабочего окруженияподготовка рабочего окружения
подготовка рабочего окружения
Roman Brovko
 
C language lect_20_advanced
C language lect_20_advancedC language lect_20_advanced
C language lect_20_advanced
Roman Brovko
 
C language lect_19_basics
C language lect_19_basicsC language lect_19_basics
C language lect_19_basics
Roman Brovko
 
C language lect_18_basics
C language lect_18_basicsC language lect_18_basics
C language lect_18_basics
Roman Brovko
 
C language lect_17_basics
C language lect_17_basicsC language lect_17_basics
C language lect_17_basics
Roman Brovko
 
C language lect_16_basics
C language lect_16_basicsC language lect_16_basics
C language lect_16_basics
Roman Brovko
 
Individual task Networking
Individual task NetworkingIndividual task Networking
Individual task Networking
Roman Brovko
 
Networking essentials lect1
Networking essentials lect1Networking essentials lect1
Networking essentials lect1
Roman Brovko
 
Bare metal training_07_spi_flash
Bare metal training_07_spi_flashBare metal training_07_spi_flash
Bare metal training_07_spi_flash
Roman Brovko
 
Bare metal training_06_I2C
Bare metal training_06_I2CBare metal training_06_I2C
Bare metal training_06_I2C
Roman Brovko
 
Bare metal training_05_uart
Bare metal training_05_uartBare metal training_05_uart
Bare metal training_05_uart
Roman Brovko
 
Bare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensorBare metal training_04_adc_temp_sensor
Bare metal training_04_adc_temp_sensor
Roman Brovko
 
Bare metal training_03_timers_pwm
Bare metal training_03_timers_pwmBare metal training_03_timers_pwm
Bare metal training_03_timers_pwm
Roman Brovko
 
Bare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttonsBare metal training_02_le_ds_and_buttons
Bare metal training_02_le_ds_and_buttons
Roman Brovko
 
Bare metal training_01_hello_world
Bare metal training_01_hello_worldBare metal training_01_hello_world
Bare metal training_01_hello_world
Roman Brovko
 
Bare metal training_00_prerequisites
Bare metal training_00_prerequisitesBare metal training_00_prerequisites
Bare metal training_00_prerequisites
Roman Brovko
 
C language lect_23_advanced
C language lect_23_advancedC language lect_23_advanced
C language lect_23_advanced
Roman Brovko
 
C language lect_22_advanced
C language lect_22_advancedC language lect_22_advanced
C language lect_22_advanced
Roman Brovko
 
C language lect_21_advanced
C language lect_21_advancedC language lect_21_advanced
C language lect_21_advanced
Roman Brovko
 
подготовка рабочего окружения
подготовка рабочего окруженияподготовка рабочего окружения
подготовка рабочего окружения
Roman Brovko
 
C language lect_20_advanced
C language lect_20_advancedC language lect_20_advanced
C language lect_20_advanced
Roman Brovko
 
C language lect_19_basics
C language lect_19_basicsC language lect_19_basics
C language lect_19_basics
Roman Brovko
 
C language lect_18_basics
C language lect_18_basicsC language lect_18_basics
C language lect_18_basics
Roman Brovko
 
C language lect_17_basics
C language lect_17_basicsC language lect_17_basics
C language lect_17_basics
Roman Brovko
 
C language lect_16_basics
C language lect_16_basicsC language lect_16_basics
C language lect_16_basics
Roman Brovko
 
Ad

Recently uploaded (20)

YSPH VMOC Special Report - Measles Outbreak Southwest US 5-14-2025 .pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-14-2025  .pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-14-2025  .pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-14-2025 .pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
ITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQ
SONU HEETSON
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
The History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.pptThe History of Kashmir Lohar Dynasty NEP.ppt
The History of Kashmir Lohar Dynasty NEP.ppt
Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
libbys peer assesment.docx..............
libbys peer assesment.docx..............libbys peer assesment.docx..............
libbys peer assesment.docx..............
19lburrell
 
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdfIPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
IPL QUIZ | THE QUIZ CLUB OF PSGCAS | 2025.pdf
Quiz Club of PSG College of Arts & Science
 
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic SuccessAerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
online college homework help
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-17-2025 .pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 5-17-2025  .pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 5-17-2025  .pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 5-17-2025 .pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit..."Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
"Bridging Cultures Through Holiday Cards: 39 Students Celebrate Global Tradit...
AlionaBujoreanu
 
Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............Peer Assesment- Libby.docx..............
Peer Assesment- Libby.docx..............
19lburrell
 
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdfAntepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Antepartum fetal surveillance---Dr. H.K.Cheema pdf.pdf
Dr H.K. Cheema
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
ITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQITI COPA Question Paper PDF 2017 Theory MCQ
ITI COPA Question Paper PDF 2017 Theory MCQ
SONU HEETSON
 
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales moduleHow To Maximize Sales Performance using Odoo 18 Diverse views in sales module
How To Maximize Sales Performance using Odoo 18 Diverse views in sales module
Celine George
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
libbys peer assesment.docx..............
libbys peer assesment.docx..............libbys peer assesment.docx..............
libbys peer assesment.docx..............
19lburrell
 
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic SuccessAerospace Engineering Homework Help Guide – Expert Support for Academic Success
Aerospace Engineering Homework Help Guide – Expert Support for Academic Success
online college homework help
 
114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf114P_English.pdf
114P_English.pdf114P_English.pdf114P_English.pdf
paulinelee52
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 

Gl embedded starterkit_ethernet

  • 1. 1
  • 2. 2 C/Embedded Base Camp Connection of GL Embedded Starter Kit to Ethernet Petro Shevchenko July 2021
  • 3. 1. STM32F407x Ethernet Interface 2. STM32F407x HAL Ethernet Driver 3. Lightweight TCP/IP Stack 4. TCP Client Example 5. TCP Server Example 6. HTTP Server Demo 7. UDP Server Implementation Agenda
  • 4. STM32F407x Ethernet Interface ● GlobalLogic Embedded Starter Kit (GL ESK) is based on the STM32F407G-DISC1 board produced by STMicroelectronics ● STM32F407VG microcontroller contains an Ethernet MAC (Media Access Control) module that supports two industry standard interfaces to the external physical layer chip (PHY): - Media Independent Interface (MII) - Reduced Media Independent Interface (RMII) ● To connect the STM32F407G-DISC1 board to the KSZ8081RNB PHY, placed on GL ESK, RMII is used
  • 6. STM32F407VG Ethernet MAC ● The Ethernet peripheral consists of a MAC 802.3 (media access control) with a dedicated DMA controller - The DMA controller interfaces with the Core and memories through the AHB Master and Slave interfaces - The AHB Master Interface controls data transfers while the AHB Slave interface accesses Control and Status registers (CSR) space ● A set of configuration registers permit the user to select the desired mode and features for the MAC and the DMA controller
  • 8. STM32F407VG Ethernet MAC The Ethernet block diagram contains the following abbreviation : ● PTP IEEE 1588 : Precision Time Protocol is a protocol used to synchronize clocks throughout a computer network ● PMT : Power Management Technology supports the reception of network wakeup frames and Magic Packet frames ● MMC : MAC Management Counters maintain a set of registers for gathering statistics on the received and transmitted frames Looking at the Ethernet block diagram above, there are two different interfaces between MCU and an external physical chip : ● MII/RMII to transfer data between MCU and external PHY ● Station Management Interface (SMI) to communicate with external PHY
  • 9. Station Management Interface (SMI) ● The station management interface allows the application to access any PHY registers through a 2-wire clock (MDC) and data (MDIO) lines ● The interface supports accessing up to 32 PHYs ● The application can select one of the 32 PHYs and one of the 32 registers within any PHY and send control data or receive status information ● Only one register in one PHY can be addressed at any given time There are three types of registers : ● Basic (0 - 1) ● Extended (2 - 14) ● Vendor specific (16 - 31) Note : For more information about SMI refer to the Reference Manual.
  • 10. Reduced Media Independent Interface (RMII) ● The reduced media-independent interface specification reduces the pin count between the microcontroller Ethernet peripheral and the external Ethernet ● According to the IEEE 802.3u standard, an MII contains 16 pins for data and control. The RMII specification is dedicated to reduce the pin count to 7 pins ● The RMII is instantiated between the MAC and the PHY. This helps to translate the MAC’s MII into the RMII The RMII block has the following characteristics : ● It supports 10-Mbit/s and 100-Mbit/s operating rates ● The clock reference must be doubled to 50 MHz ● The same clock reference must be sourced externally to both MAC and external Ethernet PHY ● It provides independent 2-bit wide (dibit) transmit and receive data paths
  • 11. Reduced Media Independent Interface (RMII)
  • 12. Reduced Media Independent Interface (RMII) Looking at the description of RMII signals, consider each of them in detail : ● TXD[1:0]: transmit data is a bundle of 2 data signals driven synchronously by the MAC sublayer ● TX_EN: while TX_EN is asserted the transmit data have effect upon the PHY ● RXD[1:0]: reception data is a bundle of 2 data signals driven synchronously by the PHY ● CRSDV: Carrier Sense (CRS) and RX_Data Valid (RX_DV) multiplexed on alternate clock cycles ● MDC: SMI clock signal ● MDIO: SMI data input/output ● REF_CLK: Continuous 50 MHz reference clock
  • 14. KSZ8081RND PHY ● The KSZ8081RND is a single-supply 10Base-T/100Base-TX Ethernet physical layer transceiver for transmission and reception of data over standard CAT-5 unshielded twisted pair (UTP) cable ● The KSZ8081RND takes in the 50MHz RMII reference clock as the power-up default ● The KSZ8081RND is configured optionally to RMII – 25MHz Clock Mode after it is powered up or hardware reset and software programmed with the following : - An external 25MHz clock source (oscillator) connected to XI (pin 8) - Register 1Fh, bit [7] programmed to ‘1’ to select RMII – 25MHz Clock Mode
  • 17. KSZ8081RND PHY ● The KSZ8081RND supports PHY addresses 0x0h, 0x3h, 0x4, 0x7 ● The PHY Address is latched at the deassertion of reset ○ Pull-up = PHY Address bits [1:0] are both set to 1 ○ Pull-down (default) = PHY Address bits [1:0] are both set to 0 ● PHY Address bits [4:3] are set to 0x00 by default ● The KSZ8081RND contains 32 registers, the register map is shown below Note: For information on the formats of internal registers, see the documentation for the KSZ8081RND
  • 20. STM32F407x HAL Ethernet Driver ● The STM32Cube IDE uses STM32CubeMX plug-in to automatically generate initialization code. The generated source code is based on the HAL driver ● The STM32CubeMX plug-in can automatically generate configurations for two PHYs : - LAN8742A - DP83848 ● The STM32CubeMX plug-in allows users to configure HAL Ethernet driver. The next pictures illustrate configuration of HAL Ethernet driver in the STM32Cube IDE through the STM32CubeMX plug-in Note: Unfortunately, the KSZ8081RND PHY installed on GL Embedded Starter Kit is not supported by the STM32CubeMX code generator so the Ethernet driver was replaced with another one, which was created based on the HAL Ethernet driver. This driver sets up 25MHz clock mode and uses the vendor specific registers to configure the KSZ8081RND chip
  • 26. Lightweight TCP/IP Stack features ● LwIP is a free TCP/IP stack developed by Adam Dunkels at the Swedish Institute of Computer Science (SICS) and licensed under a modified BSD license ● The focus of the LwIP TCP/IP implementation is to reduce RAM usage while keeping a full scale TCP/IP stack. This makes LwIP suitable for use in embedded systems ● LwIP comes with the following protocols : - IPv4 and IPv6 (Internet Protocol v4 and v6) - ICMP (Internet Control Message Protocol) for network maintenance and debugging - IGMP (Internet Group Management Protocol) for multicast traffic management - UDP (User Datagram Protocol) - TCP (Transmission Control Protocol) - DNS (Domain Name Server) - SNMP (Simple Network Management Protocol) - DHCP (Dynamic Host Configuration Protocol) - PPP (Point to Point Protocol) - ARP (Address Resolution Protocol)
  • 27. Lightweight TCP/IP Stack features LwIP has three application programming interfaces (APIs) : ● Raw API is the native LwIP API. It enables the development of applications using event callbacks. This API provides the best performance and optimized code size, but adds some complexity to application development ● Netconn API is a high-level sequential API that requires a real-time operating system (RTOS). The Netconn API enables multithreaded operations. ● BSD Socket API: Berkeley-like Socket API (developed on top of the Netconn API)
  • 28. LwIP architecture ● LwIP complies with the TCP/IP model architecture which specifies how data should be formatted, transmitted, routed and received to provide end-to-end communications ● This model includes four abstraction layers which are used to sort all related protocols according to the scope of networking involved (see Figure 1). From lowest to highest, the layers are : - The link layer contains communication technologies for a single network segment (link) of a local area network - The internet layer (IP) connects independent networks, thus establishing internetworking - The transport layer handles host-to-host communications - The application layer contains all protocols for specific data communications services on a process-to-process level
  • 30. LwIP configuration ● LwIP provides a file named lwipopts.h that allows the user to fully configure the stack and all its modules. If an option is not defined, a default value defined in opt.h file is used ● The user can choose the modules he needs for his application, so that the code size will be optimized by compiling only the selected features example: #define LWIP_UDP 1 /* Enable UDP */ ● LwIP provides a flexible way to manage memory pool sizes and organization. It reserves a fixed-size static memory area in the data segment ● The following table provides a summary of the main RAM memory options
  • 31. LwIP memory configuration LwIP memory option Definition MEM_SIZE LwIP heap memory size: used for all LwIP dynamic memory allocations MEMP_NUM_PBUF Total number of MEM_REF and MEM_ROM pbufs MEMP_NUM_UDP_PCB Total number of UDP PCB structures MEMP_NUM_TCP_PCB Total number of TCP PCB structures MEMP_NUM_TCP_PCB_LISTEN Total number of listening TCP PCBs MEMP_NUM_TCP_SEG Maximum number of simultaneously queued TCP segments
  • 32. LwIP memory configuration LwIP memory option Definition PBUF_POOL_SIZE Total number of PBUF_POOL type pbufs PBUF_POOL_BUFSIZE Size of a PBUF_POOL type pbufs TCP_MSS TCP maximum segment size TCP_SND_BUF TCP send buffer space for a connection TCP_SND_QUEUELEN Maximum number of pbufs in the TCP send queue TCP_WND Advertised TCP receive window size
  • 33. LwIP setting in STM32CubeMX ● LwIP stack is used in STM32CubeMX plug-in together with FreeRTOS, which is wrapped by the CMSIS_OS interface ● The STM32Cube IDE through STM32CubeMX plug-in allows to automatically configure LwIP stack - as a result of LwIP settings, the files in the LWIP directory of the project will be modified - automatically generated ethernetif.c file is used to link the LwIP stack to the STM32F407x HAL Ethernet driver ● Here is a list of APIs from ethernetif.c file - low_level_init : calls driver functions to initialize Ethernet - low_level_output : calls driver functions to send Ethernet packet - low_level_input : calls driver functions to receive Ethernet packet - ethernetif_init : initializes the network interface structure (netif) then calls low_level_init - ethernetif_input : calls low_level_input to receive a packet then push it onto LwIP stack
  • 39. How to use TCP Client Example ● connect GL Embedded Starter Kit to the same local network as your PC is connected to ● open Linux terminal then install and launch Wireshark to capture a connection session between the board and PC : $ sudo apt install wireshark -y $ sudo usermod -a -G wireshark $USER $ sudo reboot ● open STM32Cube IDE, select default workspace with previously imported tcp_socket_client project ● select ‘Project->Properties->C/C++Build->Settings->MCU GCC Compiler->Preprocessor’ menu item, then define SERVER=”XXX.XXX.XXX.XXX” with IP address of your PC. Build and load the firmware ● check if network interface of your board is up by pinging the board. If so, open Linux terminal and launch the following commands : $ sudo apt install ncat -y $ ncat -l 1500 --keep-open --exec /bin/cat ● push the blue button on the board and watch the packets in the Wireshark window
  • 46. How to use TCP Server Example ● connect GL Embedded Starter Kit to the same local network as your PC is connected to ● launch Wireshark to capture a connection session between the board and PC ● open STM32Cube IDE, select default workspace with previously imported tcp_socket_client project ● select ‘Project->Properties->C/C++Build->Settings->MCU GCC Compiler->Preprocessor’ menu item, check if USE_TCP_SERVER macros is defined. If not, define USE_TCP_SERVER. Build and load the firmware ● check if network interface of your board is up by pinging the board. If so, open Linux terminal and launch the following command then enter some text message to be sent : $ ncat <IP of the board> 1500 ● to read logs from TCP server through USB-UART, define USE_TCP_SERVER_PRINTF=1 in Core/Inc/main.h. Build and load the firmware
  • 51. How to use HTTP Server Demo ● connect GL Embedded Starter Kit to the same local network as your PC is connected to ● launch Wireshark to capture a connection session between the board and PC ● open STM32Cube IDE, select default workspace with previously imported tcp_socket_client project ● select ‘Project->Properties->C/C++Build->Settings->MCU GCC Compiler->Preprocessor’ menu item, check if USE_TCP_SERVER macros is defined. If so, remove USE_TCP_SERVER. Define USE_HTTP_SERVER, USE_HTTP_SERVER_SOLUTION if they are not defined. Build and load the firmware ● open your internet browser and enter the IP address of your board. Use form controls to toggle LEDs ● read humidity from DHT11 by entering ‘<IP of the board>/humidity’ in your internet browser ● read temperature from DHT11 by entering ‘<IP of the board>/temperature’ in your internet browser
  • 57. UDP Server Implementation ● Implement a UDP server, that must be launched in a separate thread of the tcp_socket_client project ● The UDP server must accept and execute the following commands from the UDP client : - led<N> on : turn on the LED<N>, where N = 3,4,5,6 - led<N> off : turn off the LED<N>, where N = 3,4,5,6 - led<N> toggle : toggle the LED<N>, where N = 3,4,5,6 - example: led3 toggle ● Use ncat utility as a UDP client : $ ncat -u <IP of the board> 5678 led3 toggle ● Use Wireshark, output through USB-UART or LCD to debug your application ● Demonstrate how your server works
  翻译: