Pretty sure I'm ready to throw in the towel
Try:
-
installing create agent properly, check Install the Arduino Create Agent
-
update the board's firmware using latest IDE. Check Update connectivity module firmware with Arduino Cloud
-
Use 2.4Ghz Wifi that the SSID and password is not too long or have special characters. You can try creating a simple wifi hotspot with your phone to test connectivity.
Hi @surferjeff1. I'm going to ask you to provide some additional information that might help us to identify the problem.
This procedure is not intended to solve the problem. The purpose is to gather more information.
Please do this:
- If Arduino IDE is running, select File > Quit from the Arduino IDE menus.
All Arduino IDE windows will close.
ⓘ This is done because if you have the Arduino IDE Serial Monitor open (as it is in the screenshot you shared), that will block the communication between Arduino Cloud and the Nano 33 IoT board via it serial port. - Start Arduino Create Agent if it is not already running.
ⓘ If you see an Arduino Create Agent icon on the macOS "menu bar" then it is running. - Click on the Arduino Create Agent icon (looks like an Arduino logo) that is located in the macOS menu bar.
A menu will open. - Select "Open Debug Console" from the menu.
The "Arduino Create Agent Debug Console" page will open in your browser. - Click the third button from the right in the toolbar at the bottom of the "Arduino Create Agent Debug Console" page.
A menu will open. - Select "HIDE 'LIST' COMMANDS" from the menu.
- Click the "CLEAR LOG" button that is located near the bottom right corner of the "Arduino Create Agent Debug Console" window.
- Leaving the "Arduino Create Agent Debug Console" browser tab open, attempt to set up a new Arduino Cloud IoT Device via Arduino Cloud, just as you did before.
- Once the process fails, switch to the "Arduino Create Agent Debug Console" browser tab.
- Click the "EXPORT LOG" button in the bottom right corner of the "Arduino Create Agent Debug Console" window.
A download of a file namedagent-log.txtwill start. - Open the downloaded "
agent-log.txt" file in any text editor. - Press the Ctrl+A keyboard shortcut to select all the text.
- Press the Ctrl+C keyboard shortcut.
This will copy the selected text to the clipboard. - Open a forum reply here by clicking the "Reply" button.
- Click the
<CODE/>icon on the post composer toolbar. This will add the forum's code block markup (```) to your reply to make sure the output is correctly formatted.

- Press the Ctrl+V keyboard shortcut. This will paste the output into the code block.
- Move the cursor outside of the code block markup before you add any additional text to your reply.
- Click the "Reply" button to post the output.
Please let me know if you have any questions or problems while following those instructions.
downloadtool windows-drivers latest arduino keep
downloadtool bossac 1.7.0 arduino keep
downloadtool arduino-fwuploader latest arduino keep
downloadtool rp2040tools latest arduino keep
{
"DownloadStatus": "Pending",
"Msg": "We couldn't find a tool with the name windows-drivers and version latest packaged by arduino"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
close /dev/cu.usbmodem101
{
"Error": "We could not find the serial port /dev/cu.usbmodem101 that you were trying to close."
}
downloadtool windows-drivers latest arduino keep
downloadtool bossac 1.7.0 arduino keep
downloadtool arduino-fwuploader latest arduino keep
downloadtool rp2040tools latest arduino keep
{
"DownloadStatus": "Pending",
"Msg": "We couldn't find a tool with the name windows-drivers and version latest packaged by arduino"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
close /dev/cu.usbmodem101
{
"Error": "We could not find the serial port /dev/cu.usbmodem101 that you were trying to close."
}
downloadtool windows-drivers latest arduino keep
downloadtool bossac 1.7.0 arduino keep
downloadtool arduino-fwuploader latest arduino keep
downloadtool rp2040tools latest arduino keep
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "We couldn't find a tool with the name windows-drivers and version latest packaged by arduino"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
downloadtool windows-drivers latest arduino keep
downloadtool bossac 1.7.0 arduino keep
downloadtool arduino-fwuploader latest arduino keep
downloadtool rp2040tools latest arduino keep
{
"DownloadStatus": "Pending",
"Msg": "We couldn't find a tool with the name windows-drivers and version latest packaged by arduino"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
{
"DownloadStatus": "Pending",
"Msg": "The tool is already present on the system"
}
{
"DownloadStatus": "Success",
"Msg": "Map Updated"
}
Are you certain the device creation process failed with that "Executing command: exit status 1" error shown in your video during the session that produced the Debug Console logs you shared?
I was expected to see the error message in the logs, but there is nothing at all of interest in them.
{
"Cmd": "Serial",
"ProgrammerStatus": "Starting"
}
{
"Msg": "Restarting in bootloader mode",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Flashing with command:/Users/ttp/.arduino-create/arduino/bossac/1.7.0-arduino3/bossac -i -d --port=cu.usbmodem101 -U true -i -e -w -v /var/folders/7_/ltc0t8n52g57nld2hmkhdd3w0000gn/T/arduino-create-agent1391128853/provisioning.bin -R",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Set binary mode",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0)=0x20007ffc",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0xe000ed00)=0x410cc601",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41002018)=0x10010305",
"ProgrammerStatus": "Busy"
}
{
"Msg": "version()=v2.0 [Arduino:XYZ] Apr 19 2019 14:38:48",
"ProgrammerStatus": "Busy"
}
{
"Msg": "chipId=0x10010005",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Connected at 921600 baud",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0)=0x20007ffc",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0xe000ed00)=0x410cc601",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41002018)=0x10010305",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Atmel SMART device 0x10010005 found",
"ProgrammerStatus": "Busy"
}
{
"Msg": "write(addr=0x20004000,size=0x34)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeWord(addr=0x20004030,value=0x10)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeWord(addr=0x20004020,value=0x20008000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Device : ATSAMD21G18A",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0)=0x20007ffc",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0xe000ed00)=0x410cc601",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41002018)=0x10010305",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Chip ID : 10010005",
"ProgrammerStatus": "Busy"
}
{
"Msg": "version()=v2.0 [Arduino:XYZ] Apr 19 2019 14:38:48",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Version : v2.0 [Arduino:XYZ] Apr 19 2019 14:38:48",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Address : 8192",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Pages : 3968",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Page Size : 64 bytes",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Total Size : 248KB",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Planes : 1",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Lock Regions : 16",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Locked : readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004020)=0xffff",
"ProgrammerStatus": "Busy"
}
{
"Msg": "none",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41004018)=0",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Security : false",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Boot Flash : true",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x40000834)=0x7000a",
"ProgrammerStatus": "Busy"
}
{
"Msg": "BOD : true",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x40000834)=0x7000a",
"ProgrammerStatus": "Busy"
}
{
"Msg": "BOR : true",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Arduino : FAST_CHIP_ERASE",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Arduino : FAST_MULTI_PAGE_WRITE",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Arduino : CAN_CHECKSUM_MEMORY_BUFFER",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Erase flash",
"ProgrammerStatus": "Busy"
}
{
"Msg": "chipErase(addr=0x2000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "done in 0.970 seconds",
"ProgrammerStatus": "Busy"
}
{
"Msg": "",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Write 79604 bytes to flash (1244 pages)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x2000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[= ] 5% (64/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x3000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[=== ] 10% (128/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x4000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[==== ] 15% (192/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x5000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[====== ] 20% (256/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x6000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[======= ] 25% (320/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x7000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[========= ] 30% (384/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x8000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[========== ] 36% (448/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x9000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[============ ] 41% (512/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0xa000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[============= ] 46% (576/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0xb000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[=============== ] 51% (640/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0xc000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[================ ] 56% (704/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0xd000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[================== ] 61% (768/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0xe000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[==================== ] 66% (832/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0xf000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[===================== ] 72% (896/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x10000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[======================= ] 77% (960/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x11000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[======================== ] 82% (1024/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x12000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[========================== ] 87% (1088/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x13000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[=========================== ] 92% (1152/1244 pages)write(addr=0x20005000,size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x14000, size=0x1000)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[============================= ] 97% (1216/1244 pages)write(addr=0x20005000,size=0x700)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeBuffer(scr_addr=0x20005000, dst_addr=0x15000, size=0x700)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "\r[==============================] 100% (1244/1244 pages)",
"ProgrammerStatus": "Busy"
}
{
"Msg": "done in 0.551 seconds",
"ProgrammerStatus": "Busy"
}
{
"Msg": "",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Verify 79604 bytes of flash with checksum.",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x2000, size=0x1000) = 2cd4",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x3000, size=0x1000) = 7026",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x4000, size=0x1000) = ae18",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x5000, size=0x1000) = 7cb1",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x6000, size=0x1000) = 70a1",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x7000, size=0x1000) = d55",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x8000, size=0x1000) = 8926",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x9000, size=0x1000) = c094",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0xa000, size=0x1000) = 839e",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0xb000, size=0x1000) = 62d4",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0xc000, size=0x1000) = d1c",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0xd000, size=0x1000) = ca73",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0xe000, size=0x1000) = dc0c",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0xf000, size=0x1000) = 5485",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x10000, size=0x1000) = abea",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x11000, size=0x1000) = f247",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x12000, size=0x1000) = 4f72",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x13000, size=0x1000) = b81b",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x14000, size=0x1000) = 92f7",
"ProgrammerStatus": "Busy"
}
{
"Msg": "checksumBuffer(start_addr=0x15000, size=0x6f4) = a3bd",
"ProgrammerStatus": "Busy"
}
{
"Msg": "Verify successful",
"ProgrammerStatus": "Busy"
}
{
"Msg": "done in 0.066 seconds",
"ProgrammerStatus": "Busy"
}
{
"Msg": "CPU reset.",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0)=0x20007ffc",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0xe000ed00)=0x410cc601",
"ProgrammerStatus": "Busy"
}
{
"Msg": "readWord(addr=0x41002018)=0x10010305",
"ProgrammerStatus": "Busy"
}
{
"Msg": "writeWord(addr=0xe000ed0c,value=0x5fa0004)",
"ProgrammerStatus": "Busy"
}
{
"Flash": "Ok",
"ProgrammerStatus": "Done"
}
This was as far as I was able to get would not pass the secure number 3. Will always fail there.
After 3 days of fighting with it.. Was able to pass the certificate request check and finish the registration on arduino cloud. First attempt failed, but clicked try again and it went all the way through the 3rd checkpoint. Now showing online. Below is the example sketch I overwrote via Arduino IDE locally before this last attempt. Not sure if it was a coincidence or not. Just glad it works at this point.
/*
FirmwareUpdate.h - Firmware Updater for WiFi101 / WINC1500.
Copyright (c) 2015 Arduino LLC. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <WiFi101.h>
#include <spi_flash/include/spi_flash.h>
typedef struct __attribute__((__packed__)) {
uint8_t command;
uint32_t address;
uint32_t arg1;
uint16_t payloadLength;
// payloadLenght bytes of data follows...
} UartPacket;
static const int MAX_PAYLOAD_SIZE = 1024;
#define CMD_READ_FLASH 0x01
#define CMD_WRITE_FLASH 0x02
#define CMD_ERASE_FLASH 0x03
#define CMD_MAX_PAYLOAD_SIZE 0x50
#define CMD_HELLO 0x99
void setup() {
Serial.begin(115200);
nm_bsp_init();
if (m2m_wifi_download_mode() != M2M_SUCCESS) {
Serial.println(F("Failed to put the WiFi module in download mode"));
while (true)
;
}
}
void receivePacket(UartPacket *pkt, uint8_t *payload) {
// Read command
uint8_t *p = reinterpret_cast<uint8_t *>(pkt);
uint16_t l = sizeof(UartPacket);
while (l > 0) {
int c = Serial.read();
if (c == -1)
continue;
*p++ = c;
l--;
}
// Convert parameters from network byte order to cpu byte order
pkt->address = fromNetwork32(pkt->address);
pkt->arg1 = fromNetwork32(pkt->arg1);
pkt->payloadLength = fromNetwork16(pkt->payloadLength);
// Read payload
l = pkt->payloadLength;
while (l > 0) {
int c = Serial.read();
if (c == -1)
continue;
*payload++ = c;
l--;
}
}
// Allocated statically so the compiler can tell us
// about the amount of used RAM
static UartPacket pkt;
static uint8_t payload[MAX_PAYLOAD_SIZE];
void loop() {
receivePacket(&pkt, payload);
if (pkt.command == CMD_HELLO) {
if (pkt.address == 0x11223344 && pkt.arg1 == 0x55667788)
Serial.print("v10000");
}
if (pkt.command == CMD_MAX_PAYLOAD_SIZE) {
uint16_t res = toNetwork16(MAX_PAYLOAD_SIZE);
Serial.write(reinterpret_cast<uint8_t *>(&res), sizeof(res));
}
if (pkt.command == CMD_READ_FLASH) {
uint32_t address = pkt.address;
uint32_t len = pkt.arg1;
if (spi_flash_read(payload, address, len) != M2M_SUCCESS) {
Serial.println("ER");
} else {
Serial.write(payload, len);
Serial.print("OK");
}
}
if (pkt.command == CMD_WRITE_FLASH) {
uint32_t address = pkt.address;
uint32_t len = pkt.payloadLength;
if (spi_flash_write(payload, address, len) != M2M_SUCCESS) {
Serial.print("ER");
} else {
Serial.print("OK");
}
}
if (pkt.command == CMD_ERASE_FLASH) {
uint32_t address = pkt.address;
uint32_t len = pkt.arg1;
if (spi_flash_erase(address, len) != M2M_SUCCESS) {
Serial.print("ER");
} else {
Serial.print("OK");
}
}
}
I'm glad it is working now. Thank you for taking the time to post an update!
Regards,
Per
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
