Upload bootloader and bootloader aware zephyr application together

This commit is contained in:
Patrick Rathje 2020-08-20 20:20:43 +02:00
parent cfe5d56aae
commit 7a82cc2a79
4 changed files with 2529 additions and 0 deletions

2477
boot/nrf52840_dk.hex Normal file

File diff suppressed because it is too large Load Diff

44
extra_script.py Normal file
View File

@ -0,0 +1,44 @@
Import("env", "projenv")
from os.path import isdir, join
try:
import configparser
except ImportError:
import ConfigParser as configparser
config = configparser.ConfigParser()
config.read("platformio.ini")
boot_hex_file = None
if 'PIOENV' in projenv:
cur_env = "env:" + projenv['PIOENV']
if config.has_section(cur_env) and config.has_option(cur_env, "boot_hex_file"):
boot_hex_file = config.get(cur_env, "boot_hex_file")
# access to global build environment
print("Using boot hex file: " + str(boot_hex_file))
def _jlink_cmd_script_overwrite(env, source):
build_dir = env.subst("$BUILD_DIR")
if not isdir(build_dir):
makedirs(build_dir)
script_path = join(build_dir, "upload.jlink")
commands = [ "h" ]
commands.append("loadfile %s" % (boot_hex_file))
commands.append("loadfile %s" % (source))
commands.append("r")
commands.append("q")
with open(script_path, "w") as fp:
fp.write("\n".join(commands))
print(script_path)
return script_path
def before_upload(source, target, env):
env.Replace(__jlink_cmd_script=_jlink_cmd_script_overwrite)
env.AddPreAction("upload", before_upload)

View File

@ -8,6 +8,8 @@
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs = nrf52840_dk
[env:nrf52840_dk]
platform = nordicnrf52
@ -22,6 +24,9 @@ build_flags =
-DEN_INIT_MBEDTLS_ENTROPY=0
lib_deps = exposure-notification
extra_scripts = post:extra_script.py
upload_protocol = jlink
boot_hex_file = ./boot/nrf52840_dk.hex
[env:desktop]
platform = native
@ -34,3 +39,4 @@ build_flags =
-Wno-nullability-completeness
-DMBEDTLS_USER_CONFIG_FILE='"user-tls.conf"'
src_filter = --<.src/>
targets = test

View File

@ -13,3 +13,5 @@ CONFIG_MBEDTLS_USER_CONFIG_FILE="user-tls.conf"
#CONFIG_BT_HCI_TX_STACK_SIZE=1024
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
CONFIG_BOOTLOADER_MCUBOOT=y