Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boot/zephyr/nrf_cleanup: cleanup uarte pins #303

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b137da6
[nrf fromtree] zcbor: Copy source and header files
oyvindronningstad Jan 10, 2024
0c539f6
[nrf fromtree] zcbor: Add copy notice to all copied files
oyvindronningstad Jan 10, 2024
fc20e9b
[nrf fromtree] boot_serial: Adapt to API changes in zcbor 0.8.0
oyvindronningstad Jan 10, 2024
e5d5708
[nrf fromtree] zcbor: Copy source and header files
oyvindronningstad Jan 26, 2024
9e03ad4
[nrf fromtree] boot_serial: Adapt to zcbor 0.8.x
oyvindronningstad Jan 29, 2024
df01761
[nrf fromtree] boot: zephyr: moonlight watchdogs
michalek-no Jan 9, 2024
27fc8d7
[nrf fromtree] zephyr: Add NRF54L configuration
michalek-no Nov 22, 2023
6a9b75f
[nrf fromlist] zephyr/boards: nrf54l15pdk_nrf54l15_cpuapp config
nvlsianpu Feb 15, 2024
f82a032
[nrf fromtree] boot: Fix swap-move algorithm failing to validate mult…
de-nordic Feb 1, 2024
4d7e568
[nrf noup] ci: add downstream-only NCS customizations
thst-nordic Nov 23, 2018
786e351
[nrf noup] github: Add a commit tags check workflow
carlescufi Oct 10, 2023
5c94965
[nrf noup] zephyr: Remove duplication from cmake
sigvartmh Mar 26, 2019
64740f7
[nrf noup] zephyr: add 'minimal' configuration files
mbolivar-nordic Sep 3, 2021
de32681
[nrf noup] boards: add support for Thingy:91
bjda Sep 20, 2019
5cf8423
[nrf noup] loader: work-around for multi-image builds
sigvartmh Mar 30, 2021
55683e3
[nrf noup] boot: Add shared crypto for ECDSA and SHA
sigvartmh Feb 14, 2019
ba55561
[nrf noup] crypto: ecdsa: Add required signature decoding
de-nordic Apr 21, 2023
a0c21e2
[nrf noup] crypto: ecdsa: Fix shared crypto MCUBoot EXT_ABI
sigvartmh Oct 10, 2023
fcd7281
[nrf noup] zephyr: Set at least provide EXT_API
Vge0rge Nov 8, 2021
a01d30a
[nrf noup] zephyr: Restore default RTC user channel count
Damian-Nordic Mar 21, 2022
80016fd
[nrf noup] treewide: add NCS partition manager support
SebastianBoe Dec 12, 2018
2009587
[nrf noup] boot: nrf53-specific customizations
sigvartmh Aug 27, 2020
1b0aa58
[nrf noup] zephyr: clean peripherals state before boot
nvlsianpu Feb 27, 2020
83bc352
[nrf noup] zephyr: Clean up non-secure RAM if enabled
sigvartmh Jan 6, 2023
5bdac09
[nrf noup] loader: Fix reading reset addr to support ext flash
chrta Feb 10, 2022
d9d3804
[nrf noup] zephyr: Fix path variables
nordicjm Jul 11, 2023
6024d0a
[nrf noup] loader: Fix missing PCD define check
nordicjm Aug 31, 2023
b4464ad
[nrf noup] boot: Add support for NSIB and multi-image
sigvartmh May 31, 2023
418b6fe
[nrf noup] sysflash: Move partition manager definitions to pm_sysflash.h
de-nordic Aug 10, 2023
7b87633
[nrf noup] sysflash: Add support for three images
de-nordic Aug 11, 2023
8e373cc
[nrf noup] loader: Do not check reset vector for XIP image
de-nordic Sep 22, 2023
90a91e0
[nrf noup] zephyr: Add RAM flash configuration to cache for sysbuild
nordicjm Sep 18, 2023
4b36f9f
[nrf noup] zephyr: Boot even if EXT_ABI is not provided
sigvartmh Oct 17, 2023
c5aadd7
[nrf noup] loader: Add firmware version check downgrade prevention
sigvartmh Sep 27, 2023
ed3a0c2
[nrf noup] loader: introduced cleanup of unusable secondary slot
nvlsianpu Feb 15, 2024
8bb8567
[nrf noup] boards: thingy53: disable GPIO ISR support
nika-nordic Oct 9, 2023
3c2f2ff
[nrf noup] boards: thingy91x: add board config
maxd-nordic Dec 8, 2023
f687068
[nrf noup] boot/zephyr/nrf_cleanup: cleanup uarte pins
nvlsianpu Mar 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Backport
on:
pull_request:
types:
- closed
- labeled

jobs:
backport:
runs-on: ubuntu-18.04
name: Backport
steps:
- name: Backport Bot
uses: Gaurav0/[email protected]
with:
bot_username: NordicBuilder
bot_token: 151a9b45052f9ee8be5a59963d31ad7b92c3ecb5
bot_token_key: 67bb1f1f998d546859786a4088917c65415c0ebd
github_token: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/commit-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Commit tags

on: pull_request

jobs:
commit_tags:
runs-on: ubuntu-22.04
name: Run commit tags checks on patch series (PR)
steps:
- name: Update PATH for west
run: |
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Checkout the code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Install python dependencies
run: |
pip3 install setuptools
pip3 install wheel
pip3 install gitlint

- name: Run the commit tags
uses: nrfconnect/action-commit-tags@main
with:
target: '.'
baserev: origin/${{ github.base_ref }}
revrange: 'none'
57 changes: 57 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# All these sections are optional, edit this file as you like.
[general]
ignore=title-trailing-punctuation, T3, title-max-length, T1, body-hard-tab, B3, B1
# verbosity should be a value between 1 and 3, the commandline -v flags take precedence over this
verbosity = 3
# By default gitlint will ignore merge commits. Set to 'false' to disable.
ignore-merge-commits=true
# Enable debug mode (prints more output). Disabled by default
debug = false

# Set the extra-path where gitlint will search for user defined rules
# See http://jorisroovers.github.io/gitlint/user_defined_rules for details
extra-path=../../zephyr/scripts/gitlint

[title-max-length-no-revert]
line-length=72

[body-min-line-count]
min-line-count=1

[body-max-line-count]
max-line-count=200

[title-starts-with-subsystem]
regex = ^(?!subsys:)(([^:]+):)(\s([^:]+):)*\s(.+)$

[title-must-not-contain-word]
# Comma-separated list of words that should not occur in the title. Matching is case
# insensitive. It's fine if the keyword occurs as part of a larger word (so "WIPING"
# will not cause a violation, but "WIP: my title" will.
words=wip

[title-match-regex]
# python like regex (https://docs.python.org/2/library/re.html) that the
# commit-msg title must be matched to.
# Note that the regex can contradict with other rules if not used correctly
# (e.g. title-must-not-contain-word).
#regex=^US[0-9]*

[max-line-length-with-exceptions]
# B1 = body-max-line-length
line-length=72

[body-min-length]
min-length=3

[body-is-missing]
# Whether to ignore this rule on merge commits (which typically only have a title)
# default = True
ignore-merge-commits=false

[body-changed-file-mention]
# List of files that need to be explicitly mentioned in the body when they are changed
# This is useful for when developers often erroneously edit certain files or git submodules.
# By specifying this rule, developers can only change the file when they explicitly reference
# it in the commit message.
#files=gitlint/rules.py,README.md
6 changes: 6 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@Library("CI_LIB") _

def pipeline = new ncs.sdk_mcuboot.Main()

pipeline.run(JOB_NAME)

8 changes: 4 additions & 4 deletions boot/boot_serial/src/boot_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ bs_set(char *buf, int len)
#endif

zcbor_state_t zsd[4];
zcbor_new_state(zsd, sizeof(zsd) / sizeof(zcbor_state_t), (uint8_t *)buf, len, 1);
zcbor_new_state(zsd, sizeof(zsd) / sizeof(zcbor_state_t), (uint8_t *)buf, len, 1, NULL, 0);

struct zcbor_map_decode_key_val image_set_state_decode[] = {
ZCBOR_MAP_DECODE_KEY_DECODER("confirm", zcbor_bool_decode, &confirm),
Expand Down Expand Up @@ -655,7 +655,7 @@ bs_upload(char *buf, int len)
#endif

zcbor_state_t zsd[4];
zcbor_new_state(zsd, sizeof(zsd) / sizeof(zcbor_state_t), (uint8_t *)buf, len, 1);
zcbor_new_state(zsd, sizeof(zsd) / sizeof(zcbor_state_t), (uint8_t *)buf, len, 1, NULL, 0);

struct zcbor_map_decode_key_val image_upload_decode[] = {
ZCBOR_MAP_DECODE_KEY_DECODER("image", zcbor_uint32_decode, &img_num_tmp),
Expand Down Expand Up @@ -908,7 +908,7 @@ bs_echo(char *buf, int len)
uint32_t rc = MGMT_ERR_EINVAL;

zcbor_state_t zsd[4];
zcbor_new_state(zsd, sizeof(zsd) / sizeof(zcbor_state_t), (uint8_t *)buf, len, 1);
zcbor_new_state(zsd, sizeof(zsd) / sizeof(zcbor_state_t), (uint8_t *)buf, len, 1, NULL, 0);

if (!zcbor_map_start_decode(zsd)) {
goto out;
Expand All @@ -932,7 +932,7 @@ bs_echo(char *buf, int len)
}

zcbor_map_start_encode(cbor_state, 10);
zcbor_tstr_put_term(cbor_state, "r");
zcbor_tstr_put_lit(cbor_state, "r");
if (zcbor_tstr_encode(cbor_state, &value) && zcbor_map_end_encode(cbor_state, 10)) {
boot_serial_output();
return;
Expand Down
64 changes: 58 additions & 6 deletions boot/bootutil/include/bootutil/crypto/ecdsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#if (defined(MCUBOOT_USE_TINYCRYPT) + \
defined(MCUBOOT_USE_CC310) + \
defined(MCUBOOT_USE_NRF_EXTERNAL_CRYPTO) + \
defined(MCUBOOT_USE_PSA_OR_MBED_TLS)) != 1
#error "One crypto backend must be defined: either CC310/TINYCRYPT/MBED_TLS/PSA_CRYPTO"
#endif
Expand Down Expand Up @@ -70,12 +71,18 @@
#include "bootutil/sign_key.h"
#include "common.h"

#if defined(MCUBOOT_USE_NRF_EXTERNAL_CRYPTO)
#include <bl_crypto.h>
#define NUM_ECC_BYTES (256 / 8)
#endif /* MCUBOOT_USE_NRF_EXTERNAL_CRYPTO */

#ifdef __cplusplus
extern "C" {
#endif

#if (defined(MCUBOOT_USE_TINYCRYPT) || defined(MCUBOOT_USE_MBED_TLS) || \
defined(MCUBOOT_USE_CC310)) && !defined(MCUBOOT_USE_PSA_CRYPTO)
defined(MCUBOOT_USE_CC310) || defined(MCUBOOT_USE_NRF_EXTERNAL_CRYPTO)) \
&& !defined(MCUBOOT_USE_PSA_CRYPTO)
/*
* Declaring these like this adds NULL termination.
*/
Expand Down Expand Up @@ -127,8 +134,6 @@ static int bootutil_import_key(uint8_t **cp, uint8_t *end)
}
#endif /* (MCUBOOT_USE_TINYCRYPT || MCUBOOT_USE_MBED_TLS || MCUBOOT_USE_CC310) && !MCUBOOT_USE_PSA_CRYPTO */

#if defined(MCUBOOT_USE_TINYCRYPT)
#ifndef MCUBOOT_ECDSA_NEED_ASN1_SIG
/*
* cp points to ASN1 string containing an integer.
* Verify the tag, and that the length is 32 bytes. Helper function.
Expand Down Expand Up @@ -178,8 +183,8 @@ static int bootutil_decode_sig(uint8_t signature[NUM_ECC_BYTES * 2], uint8_t *cp
}
return 0;
}
#endif /* not MCUBOOT_ECDSA_NEED_ASN1_SIG */

#if defined(MCUBOOT_USE_TINYCRYPT)
typedef uintptr_t bootutil_ecdsa_context;
static inline void bootutil_ecdsa_init(bootutil_ecdsa_context *ctx)
{
Expand Down Expand Up @@ -248,16 +253,20 @@ static inline int bootutil_ecdsa_verify(bootutil_ecdsa_context *ctx,
{
(void)ctx;
(void)pk_len;
(void)sig_len;
(void)hash_len;
uint8_t dsig[2 * NUM_ECC_BYTES];

if (bootutil_decode_sig(dsig, sig, sig + sig_len)) {
return -1;
}

/* Only support uncompressed keys. */
if (pk[0] != 0x04) {
return -1;
}
pk++;

return cc310_ecdsa_verify_secp256r1(hash, pk, sig, BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE);
return cc310_ecdsa_verify_secp256r1(hash, pk, dsig, BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE);
}

static inline int bootutil_ecdsa_parse_public_key(bootutil_ecdsa_context *ctx,
Expand Down Expand Up @@ -594,6 +603,49 @@ static inline int bootutil_ecdsa_parse_public_key(bootutil_ecdsa_context *ctx,

#endif /* MCUBOOT_USE_MBED_TLS */

#if defined(MCUBOOT_USE_NRF_EXTERNAL_CRYPTO)
typedef uintptr_t bootutil_ecdsa_context;
static inline void bootutil_ecdsa_init(bootutil_ecdsa_context *ctx)
{
(void)ctx;
}

static inline void bootutil_ecdsa_drop(bootutil_ecdsa_context *ctx)
{
(void)ctx;
}

static inline int bootutil_ecdsa_verify(bootutil_ecdsa_context *ctx,
uint8_t *pk, size_t pk_len,
uint8_t *hash, size_t hash_len,
uint8_t *sig, size_t sig_len)
{
(void)ctx;
(void)pk_len;
(void)hash_len;
uint8_t dsig[2 * NUM_ECC_BYTES];

if (bootutil_decode_sig(dsig, sig, sig + sig_len)) {
return -1;
}

/* Only support uncompressed keys. */
if (pk[0] != 0x04) {
return -1;
}
pk++;

return bl_secp256r1_validate(hash, BOOTUTIL_CRYPTO_ECDSA_P256_HASH_SIZE, pk, dsig);
}

static inline int bootutil_ecdsa_parse_public_key(bootutil_ecdsa_context *ctx,
uint8_t **cp,uint8_t *end)
{
(void)ctx;
return bootutil_import_key(cp, end);
}
#endif /* MCUBOOT_USE_NRF_EXTERNAL_CRYPTO */

#ifdef __cplusplus
}
#endif
Expand Down
32 changes: 32 additions & 0 deletions boot/bootutil/include/bootutil/crypto/sha.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#if (defined(MCUBOOT_USE_PSA_OR_MBED_TLS) + \
defined(MCUBOOT_USE_TINYCRYPT) + \
defined(MCUBOOT_USE_NRF_EXTERNAL_CRYPTO) + \
defined(MCUBOOT_USE_CC310)) != 1
#error "One crypto backend must be defined: either CC310/MBED_TLS/TINYCRYPT/PSA_CRYPTO"
#endif
Expand Down Expand Up @@ -206,6 +207,37 @@ static inline int bootutil_sha_finish(bootutil_sha_context *ctx,
}
#endif /* MCUBOOT_USE_CC310 */

#if defined(MCUBOOT_USE_NRF_EXTERNAL_CRYPTO)

#include <bl_crypto.h>

typedef bl_sha256_ctx_t bootutil_sha_context;

static inline void bootutil_sha_init(bootutil_sha_context *ctx)
{
bl_sha256_init(ctx);
}

static inline void bootutil_sha_drop(bootutil_sha_context *ctx)
{
(void)ctx;
}

static inline int bootutil_sha_update(bootutil_sha_context *ctx,
const void *data,
uint32_t data_len)
{
return bl_sha256_update(ctx, data, data_len);
}

static inline int bootutil_sha_finish(bootutil_sha_context *ctx,
uint8_t *output)
{
bl_sha256_finalize(ctx, output);
return 0;
}
#endif /* MCUBOOT_USE_NRF_EXTERNAL_CRYPTO */

#ifdef __cplusplus
}
#endif
Expand Down
Loading
Loading