STM32 ETHERNET using Mongoose #4 || OTA Firmware Update
May 31, 2025
Mongoose Homepage :::: https://mongoose.ws/u/yctech4 ________________________________________________________________________________________ Mongoose Wizard :::: https://mongoose.ws/wizard/#/ Mongoose PART3 :::: https://youtu.be/aj4JGlvtznk STM32 Playlist :::: https://www.youtube.com/playlist?list=PLfIJKC1ud8gga7xeUUJ-bRUbeChfTOOBd DOWNLOAD THIS PROJECT FROM :::: https://controllerstech.com/stm32-ethernet-using-mongoose-part-4/ ________________________________________________________________________________________ ******* SUPPORT US BY DONATING****** https://paypal.me/controllertech *******Join the Membership******* https://www.youtube.com/channel/UCkdqtSMnhYuMsJkyHOxiPZQ/join Join the Discord Server https://discord.gg/D32JE5wKyD
View Video Transcript
0:09
hello and welcome to controllers tech
0:12
this is the fourth video in the sdm32
0:15
ethernet series using the mongoose
0:17
library in the previous video we saw how
0:21
to create a simple weather station to
0:23
log the temperature pressure and
0:25
humidity data to the web interface
0:28
today we will create another project
0:30
involving the mongoose library we will
0:34
see how to use the mongoose wizard to
0:36
update the firmware over the air i am
0:39
going to implement the dhcp in today's
0:42
project so we will be able to update the
0:44
firmware using any device on the same
0:47
network before we proceed with the
0:49
project let's quickly review the
0:51
mongoose library
0:54
mongoose is a network library for
0:57
cc++ it provides event-driven
1:00
non-blocking apis for tcp udp http
1:05
websocket mqtt and other
1:08
protocols it is designed for connecting
1:11
devices and bringing them online
1:14
on the market since 2004 used by a vast
1:17
number of open-source and commercial
1:19
products it even runs on the
1:21
international space
1:23
station mongoose makes embedded network
1:26
programming fast robust and easy the
1:30
mongoose wizard simplifies the creation
1:32
of professional interfaces without
1:34
requiring design or front-end expertise
1:38
it supports user authentication with
1:41
multiple access levels which can be
1:43
enabled effortlessly via a single
1:46
checkbox additionally dashboards are
1:48
kept up to date with a built-in device
1:50
connection indicator on the
1:53
toolbar ui controls such as drop-downs
1:56
toggles and inputs can be easily mapped
1:59
to see structures by adjusting getter
2:01
and setter functions
2:03
conditional display functionality allows
2:06
data exceeding predefined thresholds to
2:08
be highlighted using alternative
2:11
styles moreover mongus provides seamless
2:14
firmware update support for
2:16
microcontrollers like
2:18
sdm32 esb32 and others requiring no
2:22
additional
2:23
configuration all right let's start the
2:26
mongoose wizard to design the web ui i
2:30
already have my test project here so i
2:33
am creating a new
2:35
project set the destination directory
2:37
for the
2:38
project i am naming it project one as i
2:42
will create one more project to test the
2:44
ot
2:45
update i am using the same h745
2:48
discovery board and the build
2:50
environment is cube
2:52
ide we will start with the blank
2:56
dashboard let's add a container first
2:59
now add a panel inside the
3:02
container remove all the unnecessary
3:05
elements from this
3:06
panel let's rename this panel firmware
3:10
update add the same text here now delete
3:14
this input field and instead here we
3:16
will insert the firmware update button
3:20
you can see that the api variable for
3:22
this button is automatically assigned
3:24
and if you check the rest api section
3:27
here you can see the api endpoint is
3:29
created for the ot button so we do not
3:33
need to do anything everything is set up
3:35
by default now go to the sidebar section
3:39
and here i am naming the toolbar as
3:41
project one so that you can identify
3:44
which project is running on the board
3:47
that is all let's generate the project
3:50
now here you can see the project one
3:53
folder contains all the files to this
3:56
project we will now load this project in
3:59
the cube
4:00
ide click on import project locate the
4:04
project folder and select finish to
4:06
import it the project has been
4:09
successfully imported to the
4:11
ide as i mentioned in the beginning i
4:14
will use the dhcp today therefore the
4:17
static ip configuration is commented out
4:19
here
4:20
we do not need to modify anything on
4:22
this project let's just build it to
4:25
check for
4:26
errors the project builds fine without
4:29
any
4:29
errors note the output on the console
4:33
here by default the cube ide does not
4:36
generate the binary file so we need to
4:38
enable it in
4:40
settings right click on the project and
4:43
open the
4:44
properties go to cc++ build settings
4:49
now go to postbu
4:51
outputs here check this box for
4:54
generating binary
4:55
file apply this configuration and
4:59
generate the project again here you can
5:02
see the binary file has been
5:05
generated you can browse the file in the
5:07
project folder cm7
5:11
debug here is the binary file for this
5:14
project
5:15
go back to the cube id and flash the
5:18
project to the board we will see the
5:22
logs in the serial
5:25
console you can see the device is
5:28
sending the dhcp request and here it
5:31
finally got the ip let's copy this ip
5:34
address and paste it in the browser the
5:38
web ui has been loaded
5:40
successfully let's try to update the
5:42
firmware once i will use the binary file
5:46
generated for this project itself you
5:49
can see the update logs in the serial
5:59
console the update has been flashed and
6:02
now the board is rebooting you can see
6:05
the dhcp has assigned the same ip again
6:09
the web server is loading just fine with
6:12
the same ip address
6:14
let's delete this project from the ide
6:17
as we will load a new project here let's
6:20
rename the binary file and copy it to
6:23
the desktop we will later load this
6:25
project from another computer on this
6:28
same network let's create a new project
6:31
on the wizard i am naming this project
6:34
as project two the rest of the things
6:37
are the same as the previous project i
6:40
have selected a led toggle dashboard
6:46
template the api variable is already
6:49
created for this led button but i am
6:52
changing the data field name to
6:58
state let's update it in the elements
7:01
page this toggle button will control the
7:04
led connected to the board i want to add
7:08
one more control for the display
7:10
backlight on the board let's duplicate
7:13
this panel widget itself this is going
7:16
to be the backlight control panel and we
7:18
need to create another endpoint for
7:22
it let's name this endpoint as backlight
7:25
the data field name is state and it is
7:28
going to be a boolean type variable
7:35
update the api on the page
7:38
elements i want to change the text here
7:41
based on the state of the toggle button
7:43
the data will be fetched from the
7:45
backlight api variable if the button is
7:49
in the on state we will display the text
7:51
enabled otherwise we will display the
7:54
text
7:55
disabled right now the button state is
7:57
false hence the text disabled is being
8:00
shown here let's change the state to
8:03
true and you can see the text enabled
8:06
now so this is working fine we can also
8:10
use the variable text along with some
8:12
fixed text here the text will display on
8:16
or off based on the state of the toggle
8:18
button there seems to be some error in
8:21
the formatting let me give space
8:27
here all right the error is gone so
8:30
let's quickly test this by modifying the
8:33
data field value in the rest
8:42
api now go to the sidebar section and we
8:45
will add a new page
8:51
here i am calling this page firmware
8:54
update let's modify the toolbar text so
8:58
that we can identify that project 2 is
9:03
running we will again create a panel to
9:06
upgrade the firmware on this page now we
9:10
have two pages one for controlling the
9:12
leds and second for updating the
9:16
firmware let's generate this project
9:21
now import the project in cube
9:25
ide we need to configure the led and the
9:28
backlight pins in the cube mx so open
9:31
the cube file first go to system core
9:36
gpio the led on board is connected to
9:39
the pin pj2 which is already configured
9:42
as the output pin we just need to assign
9:45
this pin to the cortex m7 core as this
9:48
is a dual core board i am changing the
9:52
default output level to high i will
9:54
explain this in a while the display
9:57
backlight is connected to pin pk0 but
10:00
this pin is configured in the input mode
10:03
let's change its mode to output and
10:05
assign this pin to the cortex m7 core
10:09
that is all the changes we need to make
10:11
click save to generate the
10:16
project here is the schematic of the
10:19
h745 discovery board as you can see the
10:23
led is connected between the 3.3 volts
10:26
and the pin on the
10:27
mcu the led pin which is basically the
10:31
pin pj2 is connected to the negative
10:34
terminal of the led so if the pin pj2 is
10:38
set to low the led will turn on and if
10:41
the pin pj2 is set to high the led will
10:44
turn off that is why i configured the
10:47
default state of the pin as high so the
10:50
led will be off by default let's
10:53
continue with the project now the rest
10:56
api functions are generated in the
10:58
mongus glue source file let's copy the
11:02
led related functions in our main file
11:05
we will add the led related code here
11:07
itself doing this will prevent our
11:10
modified code being overwritten when we
11:12
regenerate the modified project from the
11:14
mongoose dashboard we need to rename
11:17
these functions first let's modify the
11:21
getter function first this function is
11:24
called by the web ui whenever it wants
11:26
to fetch the led status here we will
11:29
read the status of the pin
11:32
pj2 if the pin is high that means the
11:35
led is turned off and we will assign the
11:38
value zero to the button state otherwise
11:41
assign the value one indicating that the
11:43
led is on similarly the led setter
11:47
function is called when we toggle the
11:49
led button on the ui here we will check
11:52
the value of the led state variable if
11:56
the value is one we will turn the led on
11:59
by resetting the pin pj2
12:02
otherwise turn the led off by setting
12:04
the same pin now modify the backlight
12:08
related
12:13
functions the backlight pin can be
12:15
controlled directly if we want to turn
12:18
the light on we will set the pin pk0 and
12:22
if we want to turn it off we will reset
12:24
the same pin we have created the
12:27
functions for the getter and setter
12:28
parts for the ui but by default the ui
12:31
interfaces with the functions it
12:33
generated for these
12:34
purposes in order to set our functions
12:37
for getter and setter we need to set the
12:39
http
12:41
handlers the name is the name of the api
12:44
endpoint and then we need to mention the
12:46
getter and setter
12:51
functions similarly we will set the http
12:54
handlers for the backlight functions
13:00
that is all let's build the project now
13:04
the project builds fine without any
13:07
errors we also need to enable binary
13:10
file generation for this
13:12
project so let's do it in the project
13:16
properties build the project again and
13:18
now it will generate the bin file too
13:22
let me rename it to project 2.bin and
13:25
copy it to the desktop
13:29
now we will do a proper test of firmware
13:32
update by loading the project 2 binary
13:36
file you can again see the logs on the
13:39
serial console the project has been
13:42
flashed and now the board is rebooting
13:46
the dhcp has assigned the same ip
13:48
address to the board you can see that
13:51
the project 2 has been loaded to the
13:53
board and we see the ui for the same
13:57
let's test the toggle buttons now check
14:00
the led on board and how it reacts to
14:03
the toggle button the led is responding
14:06
fine now let's see the display backlight
14:10
also note the text changing with the
14:12
state of the toggle button so everything
14:15
is working
14:18
fine now we will flash the project one
14:21
binary
14:25
file the file has been flashed and the
14:28
board is rebooting
14:32
now you can see that project one has
14:35
been loaded to the
14:37
board now we will flash these projects
14:40
using some other computer which is
14:42
connected on the same network i am
14:45
copying these binary files to my google
14:48
drive so that i can load them from
14:50
another
14:53
computer all right here i have another
14:55
computer running windows
14:57
os let me first copy the binary files
15:01
from google drive to the
15:06
computer now go to the ip address
15:09
assigned by the
15:10
dhcp project one is currently running on
15:13
the
15:16
board i am loading the project 2 binary
15:19
file from this computer itself you can
15:22
see the logs on the serial terminal
15:25
which is fetched from another computer
15:27
as the board is connected to it the
15:30
project has been loaded and the board is
15:32
now rebooting
15:38
you can see that project 2 is running on
15:40
the board we can as usual control the
15:43
led and backlight on the board now let's
15:47
load the project one binary
15:52
file it has been loaded successfully and
15:55
the board is rebooting now you can see
15:58
that project one has been loaded to the
16:00
board so we can load the binary files
16:03
from any device connected on the same
16:06
network if you enable the port
16:08
forwarding you can even load the binary
16:11
files from anywhere in the world we saw
16:14
how to use the otaa to update the
16:16
firmware on the sdm32 device using the
16:19
mongoose library this is it for the
16:22
video you can download the projects from
16:25
the link in the
16:26
description leave comments in case of
16:29
any doubt keep watching and have a nice
16:32
day ahead
#Distributed & Cloud Computing
#Networking