Uno R4 Wifi server.available() does not return connection

I have been playing with Uno R4 WiFi and find that intermittently,
server.available()
does not return the connection.

Hard to track this down in the ESP side, but symptoms are as follows
start up server listening on port (actually 4989 in my test case.)
connect from terminal
server.available() does not return the connection.
i.e. the output
Serial.println("We have a new client");
is not printed.
The client side sees an open socket and can send data but since the arduino code does not see the connection nothing is returned.
The client side times out waiting for the response and reconnects.
Same result.

This seems to depend on the timing between starting the client and the server.
If you kill the client and reboot the Uno R4 WiFi then restart the client it ususally works.

I note that the ESP code allows for 8 clients. One would be enough for my purposes.

The problem may be in the sketch that you have not posted (HINT)

there are errors in the firmware

1 Like

Thanks.
Will try that fix when update becomes available as an update
This is the wireshark data for my problem example

40	2.146858	10.1.1.71	10.1.1.140	TCP	66	55632 → 4989 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM
41	2.365051	10.1.1.140	10.1.1.71	TCP	58	4989 → 55632 [SYN, ACK] Seq=0 Ack=1 Win=5744 Len=0 MSS=1436
42	2.365112	10.1.1.71	10.1.1.140	TCP	54	55632 → 4989 [ACK] Seq=1 Ack=1 Win=64240 Len=0
44	2.469632	10.1.1.71	10.1.1.140	TCP	57	55632 → 4989 [PSH, ACK] Seq=1 Ack=1 Win=64240 Len=3
45	2.634567	10.1.1.140	10.1.1.71	TCP	54	4989 → 55632 [ACK] Seq=1 Ack=4 Win=5741 Len=0

I am trying to compile the change myself on Windows following these instructions

I downloaded zip of code (to Downloads). Unzipped to
C:\Users...\Downloads\uno-r4-wifi-usb-bridge-main
cd to
C:\Users..\Downloads\uno-r4-wifi-usb-bridge-main
installed arduino-cli.exe in C:\Users..\Downloads\uno-r4-wifi-usb-bridge-main

ran .\compile.sh which downloade ESP32 and patched it.
Then renamed arduino-cli.yaml.orig to arduino-cli.yaml
and ran

arduino-cli compile -e --config-file arduino-cli.yaml --fqbn=esp32-patched:esp32:arduino_unor4wifi_usb_bridge:JTAGAdapter=default,PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=default,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=unor4wifi,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none -v UNOR4USBBridge

But get error msg

Error during build: Platform 'esp32-patched:esp32' not found: platform not installed
Platform esp32-patched:esp32 is not found in any known index
Maybe you need to add a 3rd party URL?

How do I make the esp32-patched install known to arduino-cli.exe

you run git core_esp32.patch in packages/esp32/hardware/esp32/2.0.9

Edit - -
see last post for latest progress


Ok did that and ran this cmd from the Arduino sketch dir

C:\Users\...\Documents\Arduino>arduino-cli compile -e --config-file arduino-cli.yaml --fqbn=esp32:esp32:arduino_unor4wifi_usb_bridge:JTAGAdapter=default,PSRAM=disabled,FlashMode=qio,FlashSize=4M,LoopCore=1,EventsCore=1,USBMode=default,CDCOnBoot=default,MSCOnBoot=default,DFUOnBoot=default,UploadMode=default,PartitionScheme=unor4wifi,CPUFreq=240,UploadSpeed=921600,DebugLevel=none,EraseFlash=none -v UNOR4USBBridge >compilerOutput.txt
C:\Users\....\Documents\Arduino\UNOR4USBBridge\UNOR4USBBridge.ino:16:10: fatal error: Arduino_DebugUtils.h: No such file or directory
 #include "Arduino_DebugUtils.h"
          ^~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

I used the IDE to install the Arduino_DebugUtils and ArduinoBLE libraries but same error.
How do I force arduino-cli to pick up the libraries?

Here is my config dump which seems to suggest the C:\Users...\Documents\Arduino\libraries dir should be being referenced for the libraries
my C:\Users...\Documents\Arduino\libraries dir contains the Arduino_DebugUtils and ArduinoBLE libraries

C:\Users\...\Documents\Arduino>arduino-cli config dump
board_manager:
  additional_urls: []
build_cache:
  compilations_before_purge: 10
  ttl: 720h0m0s
daemon:
  port: "50051"
directories:
  data: C:\Users\matthew\AppData\Local\Arduino15
  downloads: C:\Users\...\AppData\Local\Arduino15\staging
  user: C:\Users\...\Documents\Arduino
library:
  enable_unsafe_install: false
logging:
  file: ""
  format: text
  level: info
metrics:
  addr: :9090
  enabled: true
output:
  no_color: false
sketch:
  always_export_binaries: false
updater:
  enable_notification: true

p.s. I renamed arduino-cli.yaml.orig to arduino-cli.yaml to use with arduino-cli.exe

Edit: --
Ok found all the libraries in the esp32-pached hardware dir
Deleted the libraries from the Arduino IDE esp32 package and copied over the libraries dir from the esp32-pached

====================================
I got a bit further by using the --libraries option for arduino-cli
Needed to install the following libraries
Arduino_DebugUtils V1.4.0
ArduinoBLE V1.3.6
Arduino_ESP32_OTA V0.1.1
and removed the non src dirs to suppress msgs about missing headers.

But now stuck on

In file included from C:\Users\...\Documents\Arduino\UNOR4USBBridge\at_handler.cpp:14:
C:\Users\matthew\Documents\Arduino\UNOR4USBBridge\cmds_ota.h:6:10: fatal error: BossaArduino.h: No such file or directory
 #include <BossaArduino.h>

The IDE library manager does not return an entry for BossaArduino.
Neither does a web search for BossaArduino.h

Next problem
arduino-cli fails with

Error at line 8: Value 'undefined' is not valid. Known keywords: esphttpd, phy, efuse, nvs, fat, spiffs, ota, coredump, nvs_keys

Error during build: exit status 2

Which seems to refer to the entry in the patched Partition file
unor4wifi.csv

# Name,   Type, SubType,   Offset,  Size, Flags
nvs,      data, nvs,       0x9000,  0x005000,
otadata,  data, ota,       0xe000,  0x002000,
app0,     app,  ota_0,     0x10000, 0x190000,
app1,     app,  ota_1,     0x1A0000,0x190000,
spiffs,   data, spiffs,    0x330000,0x080000,
coredump, data, coredump,  0x3B0000,0x010000,
cert,     data, undefined, 0x3C0000,0x040000,

I for now commented out cmds_ota

got passed that problem.
current problem is invalid partition file created from patch.

I had no problem to patch the 2.0.9 version

Could you share more details about this step?
I have encountered the same problem and my "uno-r4-wifi-usb-bridge-main" folder is located in "G:\Arduino15\packages\esp32\hardware\esp32\2.0.9". And i install "arduino-cli.exe" in "uno-r4-wifi-usb-bridge-main" folder. Please!

in the folder with the esp32 package

git apply core_esp32.patch

Finished, thank you.

ISSUE:
After compiling the UNOR4USBBridge code and it "Successfully created esp32s3 image." it reports it's too large, warning
Sketch uses 1363789 bytes (104%) of program storage space. Maximum is 1310720 bytes

The compilation steps already include -Os (optimize for size).

Question: How can I reduce the size, is there something in platform.txt to leave out a module or two?

I just need an updated ESP32 AT modem driver beyond 0.3.0 that includes the "AT server.available fix" for the Arduino R4 WiFi. I wrote a Server Side Event program but the server.available() call only allows one client connection at a time, and I'm pretty sure this fix will make it work.

DETAILS
Here's what the end of ./compile.sh looks like with the size issue highlighted, and the error message near the bottom:

Built in Git Bash on Windows 10.

To arrive at this point (successfully generated esp32s3 image) I had to address all of the issues already listed in this thread, plus some new ones:

  • manually merging the newer files into the main source code folder since the "git core_esp32.patch" didn't exist
  • changing compile.sh from -fqbn=esp32-patched:esp32:.. to =esp32:esp32:.. I found no other way to get past this step, even after editing a .yaml file and packages etc. to get it to recognize esp32-patched.
  • adding #include <unordered_map> to at_handler.h
  • adding -std=gnu++17 to build.extra_flags.esp32 in platform.txt (several places) due to errors for the use of auto in a lambda parameter
  • manually recompiling at_handler.cpp and server.cpp by copying the failed command line and editing the -std=gnu++11 to -std=gnu++17 (could not figure out where the gnu++11 was coming from)

I would really appreciate if the uno-r4-wifi-usb-bridge build instructions were more detailed, such as typical locations for the main code and the fix-code folders and how they are linked together. I would appreciate if it compiled on Windows without so much work.

I could not get this to work on Windows, so my current solution is to just junk the Uno R4 WiFi boards and go back to plain ESP32 e.g. SparkFun IoT RedBoard - ESP32

I am now separating all the WiFi message processing onto just one core so that I have similar separation of loop() code from WiFi code as offered by more complex Uno R4 WiFi setup

see High Speed ESP32 Control for Beginners

This lets me run the loop() at high speed without the WiFi interrupting it.
So cannot see much advantage in trying to get Uno R4 WiFi running

Hi @bmathman.

The patched platform is now provided as a submodule of the arduino/uno-r4-wifi-usb-bridge repository:

Then it seems you aren't using the patched "esp32" boards platform. Did you run the git submodule update --init command after you cloned the arduino/uno-r4-wifi-usb-bridge repository, per the instructions in the readme?:

https://github.com/arduino/uno-r4-wifi-usb-bridge/tree/main?tab=readme-ov-file#update-submodules

Per, sorry, but the firmware release is months overdue. they again work on something new instead of fixing the previous thing?