Skip to content

Commit d27d6e6

Browse files
fdcavalcantixiaoxiang781216
authored andcommitted
examples/mcuboot: add example to update from binary in local storage
This example makes it possible to use a binary from local storage for MCUBoot update. It copies the binary file to the secondary slot instead of downloading from a remote URL. Can be used to update from a SD Card, for example. Signed-off-by: Filipe Cavalcanti <filipe.cavalcanti@espressif.com>
1 parent a7e4a2a commit d27d6e6

File tree

5 files changed

+429
-0
lines changed

5 files changed

+429
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ##############################################################################
2+
# apps/examples/mcuboot/update_agent_local/CMakeLists.txt
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
7+
# license agreements. See the NOTICE file distributed with this work for
8+
# additional information regarding copyright ownership. The ASF licenses this
9+
# file to you under the Apache License, Version 2.0 (the "License"); you may not
10+
# use this file except in compliance with the License. You may obtain a copy of
11+
# the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations under
19+
# the License.
20+
#
21+
# ##############################################################################
22+
23+
if(CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT)
24+
nuttx_add_application(
25+
NAME
26+
${CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT_PROGNAME}
27+
SRCS
28+
mcuboot_local_agent_main.c
29+
STACKSIZE
30+
${CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT_STACKSIZE}
31+
PRIORITY
32+
${CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT_PRIORITY})
33+
endif()
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# For a description of the syntax of this configuration file,
3+
# see the file kconfig-language.txt in the NuttX tools repository.
4+
#
5+
6+
config EXAMPLES_MCUBOOT_LOCAL_AGENT
7+
tristate "MCUBoot Local Update Agent"
8+
default n
9+
depends on BOOT_MCUBOOT
10+
select BOARDCTL
11+
select BOARDCTL_RESET
12+
---help---
13+
Enable the MCUBoot Local Update Agent example.
14+
This application reads a firmware binary from local storage
15+
and copies it to the MCUBoot secondary flash slot for update.
16+
17+
if EXAMPLES_MCUBOOT_LOCAL_AGENT
18+
19+
config EXAMPLES_MCUBOOT_LOCAL_AGENT_PROGNAME
20+
string "Program name"
21+
default "mcuboot_local_agent"
22+
---help---
23+
This is the name of the program that will be used when the NSH ELF
24+
program is installed.
25+
26+
config EXAMPLES_MCUBOOT_LOCAL_AGENT_PRIORITY
27+
int "MCUBoot Local Agent task priority"
28+
default 100
29+
30+
config EXAMPLES_MCUBOOT_LOCAL_AGENT_STACKSIZE
31+
int "MCUBoot Local Agent stack size"
32+
default DEFAULT_TASK_STACKSIZE
33+
34+
config EXAMPLES_MCUBOOT_LOCAL_AGENT_DEFAULT_PATH
35+
string "Default firmware file path"
36+
default "/mnt/sdcard/firmware.bin"
37+
---help---
38+
Default path to the firmware binary file on local storage.
39+
This can be overridden by passing a path as a command line argument.
40+
41+
endif # EXAMPLES_MCUBOOT_LOCAL_AGENT
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
############################################################################
2+
# apps/examples/mcuboot/update_agent_local/Make.defs
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
ifneq ($(CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT),)
24+
CONFIGURED_APPS += $(APPDIR)/examples/mcuboot/update_agent_local
25+
endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
############################################################################
2+
# apps/examples/mcuboot/update_agent_local/Makefile
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Licensed to the Apache Software Foundation (ASF) under one or more
7+
# contributor license agreements. See the NOTICE file distributed with
8+
# this work for additional information regarding copyright ownership. The
9+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
10+
# "License"); you may not use this file except in compliance with the
11+
# License. You may obtain a copy of the License at
12+
#
13+
# http://www.apache.org/licenses/LICENSE-2.0
14+
#
15+
# Unless required by applicable law or agreed to in writing, software
16+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
17+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
18+
# License for the specific language governing permissions and limitations
19+
# under the License.
20+
#
21+
############################################################################
22+
23+
include $(APPDIR)/Make.defs
24+
25+
MAINSRC = mcuboot_local_agent_main.c
26+
27+
PROGNAME = $(CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT_PROGNAME)
28+
PRIORITY = $(CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT_PRIORITY)
29+
STACKSIZE = $(CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT_STACKSIZE)
30+
MODULE = $(CONFIG_EXAMPLES_MCUBOOT_LOCAL_AGENT)
31+
32+
include $(APPDIR)/Application.mk

0 commit comments

Comments
 (0)