Well I think I have cracked it. Reading the latest on line cheat sheet I notice that it recommends using pin 40 to the connected to the USB Serial port on the RA4M1. This worked but again like using pin 21 subsequent downloads failed.
EDIT :- in the light of the comments below I have changed my answer here. Pin 21is the correct one to use. However, if the select line is left high then it requires a double click on the reset to get it to load again. Where as, if it is left low then a power cycle will reset the board.
However, the reset procedure for the board was to unplug and reconnect the board from the computer's USB. This then set the WIFI board ready to receive a new download.
Shades here of the Raspberry Pico 2040 when you use one way to program it in C. What I did in that case was to make a small board that contained a slide switch to allow the power from the computer's USB to be removed and reconnected. Thus not necessitating plugging an unplugging of connectors and so avoiding excessive plug / socket wear.
So I dragged out this switch and used it on the WIFI board and it was successful in resetting the board for a new download.
I believe there is a link on the back of the WIFI board that might do the same thing. The cheat sheet says:-
On the back of the UNO R4 WiFi you will find solder pads labelled "RA4M1 USB". If you create a short circuit between these pads, by for example creating a bridge across them with solder, the RA4M1 will be connected to the USB Serial port, instead of the ESP32.
But I prefer not to do this as it reduces the flexibility of the board. It will probably be great for using the WIFI in a dedicated application.
So this is the setup function which makes the Basic IO application work.
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
/* correction for WIFI board to switch the USB back to the RA4M1
this also requires resetting the WIFI board by unplugging and replugging
the board from the USB, or cycling the power from it
*/
pinMode(21, OUTPUT);
digitalWrite(21, LOW);
MIDI.begin(4); // Launch MIDI and listen to channel 4
Serial.begin(115200); // HAIRLESS DEFAULT SPEED
}
If you are interested in making your own power switch, here is the layout of how to wire it up on strip board, along with some pictures of how it looks.