Arduino Uno Wifi Rev 2 Firmware Updater
Firmware Updater
Update the firmware or loading certificates on your MKR1000 WiFi board or WiFi Shield 101
Introduction
This tutorial volition guide you in the process of updating the firmware or loading certificates on your MKR1000 WiFi board or WiFi Shield 101. If the
Check WiFi101 Firmware Version
tells yous that you lot may have problems because the firmware and library versions exercise not match, here is the solution to align them.
Goals
- How to update the firmware and loading certificates on the MKR1000 WiFi and WiFi Shield 101.
Hardware & Software Needed
-
MKR1000 WiFi
or WiFi Shield 101 connected to an Arduino lath - Arduino IDE (online
or
offline).
Excursion
The lath should exist continued to the USB port of the computer prepare with Arduino IDE.
Important note: The nineteen.6.i firmware is only available for model B of the WINC1500, this is used in the MKR1000 board. Unfortunately, the WiFi101 shield uses model A, which Atmel has stopped supporting, so there is no xix.half dozen.1 firmware release for information technology, 19.four.four will exist the latest firmware version that is uniform.
Firmware Update Procedure
To simplify the process, we have prepared a specific sketch: this
FirmwareUpdater
that you must load on the host board (either the one with the shield plugged in, or the MKR1000 itself) and an easy to apply plug-in bachelor in Arduino Software (IDE) 1.6.10 onwards.
Upload the sketch and keep the board (either the one with the shield plugged in, or the MKR1000 itself) connected to the computer. One time done, open the plug-in that is bachelor in the
Tools
menu.
If not is non on the listing, delight check that information technology is properly configured in the
Tools
carte du jour.
To update the firmware you should choose the right typer of board. You tin discover your model looking at the WiFi module: the first line in the sticker or the last line of the silk print on the right side of the PCB shows the microcontroller model. Information technology can be either MR210PA or MR510PB and the concluding letter shows yor model accordingly.
Choose in the dropdown list the model respective to your unit and proceed clicking on the
Update Firmware button. A bar at the bottom volition prove you the progress of the procedure that includes erasing, writing and verifying of the firmware. At the end you get a articulate notice of the successful performance.
Certificate Uploading
With the aforementioned process, you may load root certificates on the WiFi module to access securely specific websites. Your board must be running the
FirmwareUpdater
sketch to work. The root certificates are issued by a express number of certification authorities, just it is difficult to know which site is using which authority. To ease your life, we permit you to specify directly the URL to which you need to connect securely, leaving to usa the task to download the root document.
The list you are building is not saved from ane session to the next i. It might happen that a few websites share the aforementioned root certificate. You lot don’t take to worry virtually this as we take care of it. The space available on your WiFi module to store the certificates is express to around 10 certificates that, beingness issued by a limited number of authorities, should be more than enough for the average projects.
The procedure starts connecting your board (either the one with the shield plugged in, or the MKR1000 itself) to your computer and selecting it from the Tools menu of the Arduino Software (IDE). Load the FirmwareUpdater on the board and launch the
WiFi 101 Firmware Updater
from Tools and get to the third section of the interface.
In that location yous observe on the left an empty listing and on the right the buttons to add together or remove the URL from which you want to download the root certificates. The URL should exist exactly the one to which yous demand to connect. Add all the websites’ URLs needed and and then go along with the uploading process. Please remember that y’all erase all the existing certificates when y’all load a new gear up. Printing the ”Upload Certificates to WiFi module” and wait for the confirmation message.
Programming the Board
When you lot load the sketch on the board, it prepares the communication between the plug-in and the WiFi chip. It opens up the advice through the serial port to the WiFi module hosted on the board. Information technology is necessary to perform all the procedures managed by the Firmware Upgrader Plugin. Everything will be managed by the plug-in, only it is important to upload this sketch commencement.
The complete sketch is below:
Lawmaking
i
/*
2
iii
FirmwareUpdate.h - Firmware Updater for WiFi101 / WINC1500.
4
v
Copyright (c) 2015 Arduino LLC. All right reserved.
6
vii
This library is free software; yous can redistribute it and/or
8
9
change it nether the terms of the GNU Lesser General Public
10
11
License as published by the Complimentary Software Foundation; either
12
13
version 2.1 of the License, or (at your option) whatsoever later version.
14
15
This library is distributed in the promise that it will exist useful,
16
17
but WITHOUT ANY WARRANTY; without even the unsaid warranty of
18
19
MERCHANTABILITY or FITNESS FOR A Item PURPOSE. See the GNU
twenty
21
Lesser Full general Public License for more details.
22
23
You should have received a copy of the GNU Lesser General Public
24
25
License forth with this library; if not, write to the Gratis Software
26
27
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
29
*/
30
31
#
include
<WiFi101.h>
32
#
include
<spi_flash/include/spi_flash.h>
33
34
typedef struct
__attribute__
(
(
__packed__
)
)
{
35
36
uint8_t command
;
37
38
uint32_t address
;
39
40
uint32_t arg1
;
41
42
uint16_t payloadLength
;
43
44
// payloadLenght bytes of data follows...
45
}
UartPacket
;
46
47
static const
int
MAX_PAYLOAD_SIZE
=
1024
;
48
49
#
ascertain
CMD_READ_FLASH
0x01
50
#
ascertain
CMD_WRITE_FLASH
0x02
51
#
define
CMD_ERASE_FLASH
0x03
52
#
define
CMD_MAX_PAYLOAD_SIZE
0x50
53
#
define
CMD_HELLO
0x99
54
55
void
setup
(
)
{
56
57
Series
.
begin
(
115200
)
;
58
59
nm_bsp_init
(
)
;
60
61
if
(
m2m_wifi_download_mode
(
)
!=
M2M_SUCCESS
)
{
62
63
Serial
.
println
(
F
(
"Failed to put the WiFi module in download mode"
)
)
;
64
65
while
(
true
)
66
67
;
68
69
}
70
}
71
72
void
receivePacket
(
UartPacket
*
pkt
,
uint8_t
*
payload
)
{
73
74
// Read control
75
76
uint8_t
*
p
=
reinterpret_cast
<
uint8_t
*
>
(
pkt
)
;
77
78
uint16_t l
=
sizeof
(
UartPacket
)
;
79
80
while
(
l
>
0
)
{
81
82
int
c
=
Serial
.
read
(
)
;
83
84
if
(
c
==
-
1
)
85
86
continue
;
87
88
*
p
++
=
c
;
89
90
l
--
;
91
92
}
93
94
// Convert parameters from network byte order to cpu byte order
95
96
pkt
->
address
=
fromNetwork32
(
pkt
->
address
)
;
97
98
pkt
->
arg1
=
fromNetwork32
(
pkt
->
arg1
)
;
99
100
pkt
->
payloadLength
=
fromNetwork16
(
pkt
->
payloadLength
)
;
101
102
// Read payload
103
104
l
=
pkt
->
payloadLength
;
105
106
while
(
l
>
0
)
{
107
108
int
c
=
Serial
.
read
(
)
;
109
110
if
(
c
==
-
1
)
111
112
keep
;
113
114
*
payload
++
=
c
;
115
116
l
--
;
117
118
}
119
}
120
121
// Allocated statically so the compiler can tell us
122
// about the amount of used RAM
123
static UartPacket pkt
;
124
static uint8_t payload
[
MAX_PAYLOAD_SIZE
]
;
125
126
void
loop
(
)
{
127
128
receivePacket
(
&
pkt
,
payload
)
;
129
130
if
(
pkt
.
command
==
CMD_HELLO
)
{
131
132
if
(
pkt
.
address
==
0x11223344
&&
pkt
.
arg1
==
0x55667788
)
133
134
Series
.
print
(
"v10000"
)
;
135
136
}
137
138
if
(
pkt
.
command
==
CMD_MAX_PAYLOAD_SIZE
)
{
139
140
uint16_t res
=
toNetwork16
(
MAX_PAYLOAD_SIZE
)
;
141
142
Serial
.
write
(
reinterpret_cast
<
uint8_t
*
>
(
&
res
)
,
sizeof
(
res
)
)
;
143
144
}
145
146
if
(
pkt
.
command
==
CMD_READ_FLASH
)
{
147
148
uint32_t address
=
pkt
.
accost
;
149
150
uint32_t len
=
pkt
.
arg1
;
151
152
if
(
spi_flash_read
(
payload
,
address
,
len
)
!=
M2M_SUCCESS
)
{
153
154
Serial
.
println
(
"ER"
)
;
155
156
}
else
{
157
158
Serial
.
write
(
payload
,
len
)
;
159
160
Serial
.
print
(
"OK"
)
;
161
162
}
163
164
}
165
166
if
(
pkt
.
control
==
CMD_WRITE_FLASH
)
{
167
168
uint32_t address
=
pkt
.
address
;
169
170
uint32_t len
=
pkt
.
payloadLength
;
171
172
if
(
spi_flash_write
(
payload
,
address
,
len
)
!=
M2M_SUCCESS
)
{
173
174
Serial
.
print
(
"ER"
)
;
175
176
}
else
{
177
178
Serial
.
print
(
"OK"
)
;
179
180
}
181
182
}
183
184
if
(
pkt
.
command
==
CMD_ERASE_FLASH
)
{
185
186
uint32_t address
=
pkt
.
address
;
187
188
uint32_t len
=
pkt
.
arg1
;
189
190
if
(
spi_flash_erase
(
address
,
len
)
!=
M2M_SUCCESS
)
{
191
192
Serial
.
impress
(
"ER"
)
;
193
194
}
else
{
195
196
Serial
.
impress
(
"OK"
)
;
197
198
}
199
200
}
201
}
If you are Not opening the FirmwareUpdater from the examples available in the Arduino Software (IDE) as described in the paragraphs above and wish to copy and paste the code from this tutorial, you demand to create another TAB in your sketch and add the
Endianness.ino
listed below.
1
/*
2
iii
Endianness.ino - Network byte club conversion functions.
four
5
Copyright (c) 2015 Arduino LLC. All right reserved.
6
seven
This library is costless software; y'all can redistribute information technology and/or
viii
nine
modify information technology under the terms of the GNU Lesser General Public
x
11
License as published by the Free Software Foundation; either
12
13
version 2.1 of the License, or (at your option) any afterward version.
14
xv
This library is distributed in the hope that information technology volition be useful,
xvi
17
only WITHOUT ANY WARRANTY; without even the unsaid warranty of
18
19
MERCHANTABILITY or Fitness FOR A PARTICULAR PURPOSE. Run across the GNU
20
21
Lesser Full general Public License for more details.
22
23
You should have received a re-create of the GNU Lesser General Public
24
25
License forth with this library; if not, write to the Free Software
26
27
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
29
*/
thirty
31
bool
isBigEndian
(
)
{
32
33
uint32_t exam
=
0x11223344
;
34
35
uint8_t
*
pTest
=
reinterpret_cast
<
uint8_t
*
>
(
&
test
)
;
36
37
return
pTest
[
0
]
==
0x11
;
38
}
39
40
uint32_t
fromNetwork32
(
uint32_t from
)
{
41
42
static const
bool
exist
=
isBigEndian
(
)
;
43
44
if
(
be
)
{
45
46
return
from
;
47
48
}
else
{
49
50
uint8_t
*
pFrom
=
reinterpret_cast
<
uint8_t
*
>
(
&
from
)
;
51
52
uint32_t to
;
53
54
to
=
pFrom
[
0
]
;
to
<<=
8
;
55
56
to
|=
pFrom
[
1
]
;
to
<<=
viii
;
57
58
to
|=
pFrom
[
ii
]
;
to
<<=
8
;
59
60
to
|=
pFrom
[
iii
]
;
61
62
render
to
;
63
64
}
65
}
66
67
uint16_t
fromNetwork16
(
uint16_t from
)
{
68
69
static
bool
be
=
isBigEndian
(
)
;
lxx
71
if
(
be
)
{
72
73
return
from
;
74
75
}
else
{
76
77
uint8_t
*
pFrom
=
reinterpret_cast
<
uint8_t
*
>
(
&
from
)
;
78
79
uint16_t to
;
80
81
to
=
pFrom
[
0
]
;
to
<<=
8
;
82
83
to
|=
pFrom
[
1
]
;
84
85
return
to
;
86
87
}
88
}
89
90
uint32_t
toNetwork32
(
uint32_t to
)
{
91
92
return
fromNetwork32
(
to
)
;
93
}
94
95
uint16_t
toNetwork16
(
uint16_t to
)
{
96
97
return
fromNetwork16
(
to
)
;
98
}
Testing It Out
After yous accept uploaded the code, open the serial monitor to confirm that the update has successfully been uploaded.
Troubleshoot
If the code is not working, there are some common bug we can troubleshoot:
- You take non uploaded the sketch to the board.
- Your board is not properly configured in the
Tools
menu.
Conclusion
In this tutorial, we have learned how to update the firmware or loading certificates on the MKR1000 WiFi board or WiFi Shield 101.