Skip to content

Commit

Permalink
bootloader: Use proper CR-LF end line chars
Browse files Browse the repository at this point in the history
This fix helps to test UART output from board.

Signed-off-by: Lukasz Fundakowski <[email protected]>
  • Loading branch information
fundakol committed Jan 16, 2025
1 parent 35facd1 commit 999b074
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion subsys/bootloader/bl_boot/bl_boot.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void bl_boot(const struct fw_info *fw_info)
"Not in Privileged mode");
#endif

printk("Booting (0x%x).\r\n", fw_info->address);
printk("Booting (0x%x).\n\r", fw_info->address);

uninit_used_peripherals();

Expand Down
4 changes: 2 additions & 2 deletions subsys/bootloader/bl_validation/bl_validation.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ LOG_MODULE_REGISTER(bl_validation, CONFIG_SECURE_BOOT_VALIDATION_LOG_LEVEL);

int set_monotonic_version(counter_t version, uint16_t slot)
{
__ASSERT(version <= 0x7FFF, "version too large.\r\n");
__ASSERT(slot <= 1, "Slot must be either 0 or 1.\r\n");
__ASSERT(version <= 0x7FFF, "version too large.\n\r");
__ASSERT(slot <= 1, "Slot must be either 0 or 1.\n\r");
LOG_INF("Setting monotonic counter (version: %d, slot: %d)",
version, slot);

Expand Down
20 changes: 10 additions & 10 deletions tests/subsys/bootloader/bl_validation/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ ZTEST(bl_validation_test, test_key_looping)
ZTEST(bl_validation_test, test_validation)
{
zassert_true(bl_validate_firmware(PM_ADDRESS, PM_ADDRESS),
"Fail 1. Failed to validate current app.\r\n");
"Fail 1. Failed to validate current app.\n\r");
zassert_false(bl_validate_firmware(PM_ADDRESS, PM_ADDRESS + 0x200),
"Fail 2. Incorrectly validated app with wrong offset.\r\n");
"Fail 2. Incorrectly validated app with wrong offset.\n\r");

/* 0x1000 to account for validation info. */
uint32_t copy_len = (uint32_t)_flash_used + 1000;
Expand All @@ -44,29 +44,29 @@ ZTEST(bl_validation_test, test_validation)
erase_addr += DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size)) {
uint32_t ret = nrfx_nvmc_page_erase(erase_addr);

zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\r\n");
zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\n\r");
}
nrfx_nvmc_words_write(new_addr, (const uint32_t *)PM_ADDRESS,
(copy_len + 3) / 4);

zassert_true(bl_validate_firmware(PM_ADDRESS, new_addr),
"Fail 3. Failed to validate displaced app.\r\n");
"Fail 3. Failed to validate displaced app.\n\r");

zassert_false(bl_validate_firmware(PM_ADDRESS + 0x300, new_addr),
"Fail 4. Incorrectly validated copy against wrong addr.\r\n");
"Fail 4. Incorrectly validated copy against wrong addr.\n\r");

uint32_t mangle_addr = new_addr + 0x300;

zassert_not_equal(0, *(uint32_t *)mangle_addr,
"Unable to mangle, word is 0. \r\n");
"Unable to mangle, word is 0.\n\r");

nrfx_nvmc_word_write(mangle_addr, 0);

zassert_equal(0, *(uint32_t *)mangle_addr,
"Unable to mangle, word was not written to 0. \r\n");
"Unable to mangle, word was not written to 0.\n\r");

zassert_false(bl_validate_firmware(PM_ADDRESS, new_addr),
"Fail 5. Incorrectly validated mangled app.\r\n");
"Fail 5. Incorrectly validated mangled app.\n\r");
}


Expand All @@ -84,7 +84,7 @@ ZTEST(bl_validation_test, test_s1)
erase_addr += DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size)) {
uint32_t ret = nrfx_nvmc_page_erase(erase_addr);

zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\r\n");
zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\n\r");
}

nrfx_nvmc_words_write(new_addr, (const uint32_t *)PM_S1_ADDRESS,
Expand All @@ -94,7 +94,7 @@ ZTEST(bl_validation_test, test_s1)
erase_addr += DT_PROP(DT_CHOSEN(zephyr_flash), erase_block_size)) {
uint32_t ret = nrfx_nvmc_page_erase(erase_addr);

zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\r\n");
zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\n\r");
}

zassert_true(bl_validate_firmware(PM_S1_ADDRESS, new_addr), NULL);
Expand Down
14 changes: 7 additions & 7 deletions tests/subsys/bootloader/bl_validation_neg/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ ZTEST(test_bl_validation_neg, test_validation_neg1)
if (s1_info_copied) {
/* Second boot */
zassert_not_equal(CONFIG_FW_INFO_VALID_VAL,
s1_info_copied->valid, "Failed to invalidate S1.\r\n");
s1_info_copied->valid, "Failed to invalidate S1.\n\r");
zassert_equal((uint32_t)s1_info_copied, PM_S1_ADDRESS,
"S1 info found at wrong address.\r\n");
"S1 info found at wrong address.\n\r");
uint32_t ret = nrfx_nvmc_page_erase(PM_S1_ADDRESS);

zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\r\n");
zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\n\r");
} else {
/* First boot */

Expand All @@ -66,7 +66,7 @@ ZTEST(test_bl_validation_neg, test_validation_neg1)
erase_block_size)) {
uint32_t ret = nrfx_nvmc_page_erase(new_addr);

zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\r\n");
zassert_equal(NRFX_SUCCESS, ret, "Erase failed.\n\r");
}
nrfx_nvmc_words_write(new_addr, (const uint32_t *)PM_ADDRESS,
copy_len / 4);
Expand All @@ -76,11 +76,11 @@ ZTEST(test_bl_validation_neg, test_validation_neg1)
ROUND_UP(sizeof(s1_info), 4) / 4);

zassert_mem_equal(&s1_info, (void *)PM_S1_ADDRESS,
sizeof(s1_info), "Failed to copy S1 info.\r\n");
sizeof(s1_info), "Failed to copy S1 info.\n\r");

s1_info_copied = fw_info_find(PM_S1_ADDRESS);
zassert_equal((uint32_t)s1_info_copied, PM_S1_ADDRESS,
"S1 info wrongly copied.\r\n");
"S1 info wrongly copied.\n\r");

/* Modify copied app's validation info */
memcpy(val_info_buf, (const uint32_t *)(PM_ADDRESS + copy_len),
Expand All @@ -95,7 +95,7 @@ ZTEST(test_bl_validation_neg, test_validation_neg1)

zassert_mem_equal(validation_info_magic, val_info->magic,
MAGIC_LEN_WORDS*4,
"Could not find validation info.\r\n");
"Could not find validation info.\n\r");

val_info->address = s1_info.address;
nrfx_nvmc_words_write(s1_info.address + ROUND_UP(s1_info.size, 4), val_info,
Expand Down

0 comments on commit 999b074

Please sign in to comment.