25th August 2023 - martin.ruppert@microchip.com - ESE/Microchip
The intention of this demo is to show how create a transparent bridge between the the ethernet and wifi interface. The demo is acting as a Access Point with a shared maximum bandwidth of 20Mbit/sec and 8 clients.
All IP frames are transparently forwarded between the two interfaces.
AP = Access Point
STA = Station (Wlan client)
example: "an STA connects to an AP"
https://www.microchip.com/en-us/development-tool/ev12f11a

https://www.microchip.com/en-us/development-tool/AC320004-3
but could be also onw of these
| AC320004-2 | IC PLUS IP101G |
| AC320004-3 | LAN8720A |
| AC320004-4 | LAN9303 (3 Port Switch) |
| AC320004-5 | KSZ8041 |
| AC320004-6 | KSZ8061 |
| AC320004-7 | KSZ8863 |
- MPLABX v6.15
- XC32 v3.01
- MHC v3.8.5 (Standalone)
- Contenmanager v1.7.1 (Standalone)
- Java Runtime Enviroment
- Terraterm
| v3.11.1 | core |
| v3.16.0 | csp |
| v3.8.0 | wireless_wifi |
| v3.9.0 | usb |
| v3.13.1 | dev_packs |
| v3.7.0 | wireless_system_pic32mzw1_wfi32e01 |
| v5.4.0 | wolfssl |
| v3.8.0 | net |
| v3.7.6 | crypto |
| v10.4.6 | CMSIS-FreeRTOS |
-
Create a working directory somewhere with any name and switch into it. Clone the following repository wich contains batch jobs which then clone everything else for the projec
-
Then switch to the "scripts_bridge" folder and run the script
git_clone_bridge.bat -
Then with MPLABX v6.15 open the project in the following folder
..\apps\apps\wfi32_bridge\firmware\pic32mz_w1_curiosity_freertos.X -
Build with the XC32 v3.01
-
Populate a WFI32 Curiosity Board with an Ethernet Daughter Board (LAN8740) and connect it to an Ethernet port of a switch that is connected to a router (with DHCP).
-
Plug in the USB port of the WFI32 (this is the one in the middle)
-
Put the jumper J202 near the socket on "VBUS-PKOB".
-
Plug in the USB of the onboard debugger, select and program in the MPLABX The two jumpers of the J301 must be plugged in for this.
These lines are ICSPDAT and ICSPCLK from the debugger to the target
Programming takes about 1 minute 43 seconds for about 600kB -
Using an external debugger instead (I use the SNAP), Jumper J301 must be pulled
The SNAP takes only 15 seconds with the setting "Program Speed: High" -
When the firmware starts, a virtual COM port opens. This COM port is created by the CDC driver in the firmware. Therefore, no UART needs to be connected.
Open this COM port with Terraterm.
After pressing the "Reset" button, you should see the following:
-
An access point with the name "DEMO_AP_SOFTAP" becomes visible. He has the password "password"
If an STA (“station”, e.g. a smart phone) connects to the AP (access point), the message appears:
All IP packets are forwarded from the STA to the Ethernet switch and all packets from the switch back to the STA.
This creates a "transparent layer 2 bridge". The switch sees an Ethernet client and no Wifi STA.
As a result, the STA's DHCP client request is forwarded to the Ethernet switch and a DHCP server visible there will then assign an IP to the client.
If the STA then books itself out again

-
If the Ethernet cable is removed, the firmware restarts
-
When the cable is plugged into a PC, the firmware waits 5 seconds for a response from a DHCP server.
Since this does not come with a PC, the firmware switches on its own DHCP server and assigns the PC an IP address

A STA that registers with the AP then gets an IP with the same netwbrork mask, so that the PC and the STA can "see" each other
If the STA-AP connection is interrupted because the STA (smartphone) thinks, for example, that it cannot reach the Internet, then everything starts again automatically until the connection remains stable.
The restart occurs so quickly that the STAs try to negotiate the connection again independently because the AP requests them to do so. Then the session keys of the WPA encryption are regenerated. All of this happens so quickly that the user doesn't notice anything.
So it is not a problem if the firmware reboots during a SoftAP connection to an STA. -
Restarting the firmware on interruptions allows the connections to be dynamically changed without user interaction on the device. It has proven to be problematic to reestablish the STA connections at runtime, especially in connection with iPhones.
On the command line there are some commands
resetRestarts the Firmware
heapDisplays the heap utilization. The FreeRTOS heap is used because it contains diagnostic functions in contrast to the heap management of the C runtime library

dumpstonSwitches on a status display that is refreshed once per second in the top two lines, while the cursor position remains normal. This is realized by VT100 Escape Sequences

stofSwitches the status display off again
dhofEnds all DHCP functions (client and, if applicable, server)
-
The MHC is still used for configuration. This is available as a separate executable file in the framework:
\frameworks\app\mhc\runmhc.batThe configuration of the project is loaded there
\apps\apps\wfi32_bridge\firmware\src\config\pic32mz_w1_eth_wifi_freertos\And all code can be regenerated.
This allows the MHC to be used to add, remove or re-parameterize other components -
In the project directory there is a batch job
pic32mz_w1_curiosity_freertos.X\create_listing_release.batthat creates a complete disassambling listing filer from the generated ELF file
pic32mz_w1_curiosity_freertos.X.production.disassembly.txtand a listing of all symbols sorted by memory address
"pic32mz_w1_curiosity_freertos.X.production.symbols.txt"The tool "cmsort.exe" is used for this, which is also checked in in the repo.
If an exception occurs, the CPU registers are dumped in a RAM memory area that is not initialized when the firmware is restarted. That is, if the exception occurs and the firmware restarts, a register dumb is issued when restarting.
With the help of the erroneous commanddump 0 1(an attempt is made to read from an address 0 that does not exist), an exception can be provoked.
The exception occurred at the address "addr=9004f314".
According to the disassembly file, the address is in the functionstatic void CommandDump(SYS_CMD_DEVICE_NODE* pCmdIO, int argc, char** argv) {in the line:
This allows errors in firmware to be analyzed without a debugger. -
The firmware also has a TCP - UART bridge.
A server can be reached under TCP port 47111, which directs all incoming data to the UART and outputs the data received on the UART via the server service.
This can be tested with "telnet" from a host: telnet 192.168.0.11 at the TCP port 47111 -
The Telnet Service is aktive as well
-
Zerconf is active on both interfaces
git clone https://github.com/zabooh/scripts_bridge
