Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor-Misic committed Dec 16, 2024
1 parent 371322a commit e1eb742
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 10 deletions.
6 changes: 2 additions & 4 deletions Bootloader/Src/binary_update.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ BinaryUpdate_handleDetectedBinary(signatureType_E detected_binary) {
break;

case signatureType_UNKNOWN:
default:
//we support unsigned binary but handle it as firmware for flash
success = false;
s_address = FLASH_FIRMWARE_ADDRESS;
break;

default:
break;
}

return success;
Expand Down Expand Up @@ -103,7 +101,7 @@ BinaryUpdate_getJumpAddress(void) {

void
BinaryUpdate_resetJumpAddress(void) {
boot_info.jump_address = signatureType_FIRMWARE_FLASH;;
boot_info.jump_address = FLASH_FIRMWARE_ADDRESS;;
}

bool
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pixhawk4:
pixhawk4_ram:
${MAKE} stm32f7xx_ram BOARD=PIXHAWK4 BOARD_FILE_NAME=$@

test_cmock test_all test_clean:
test_cmock test_all test_clean test_binary_update test_board_info:
${MAKE} -C Tests $@

#
Expand Down
72 changes: 67 additions & 5 deletions Tests/test_binary_update.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "binary_update.h"
#include "flash_adapter.h"

#include "unity.h"
#include "unity_fixture.h"

extern volatile bootInfo_S boot_info;

TEST_GROUP(BinaryUpdate);

TEST_SETUP(BinaryUpdate) {
Expand All @@ -13,12 +16,71 @@ TEST_TEAR_DOWN(BinaryUpdate) {

TEST_GROUP_RUNNER(BinaryUpdate) {
RUN_TEST_CASE(BinaryUpdate, BinaryUpdate_handleDetectedBinary);
RUN_TEST_CASE(BinaryUpdate, BinaryUpdate_handleBootInfo);
RUN_TEST_CASE(BinaryUpdate, BinaryUpdate_shortFunctions);
}

TEST(BinaryUpdate, BinaryUpdate_handleDetectedBinary) {
{
signatureType_E detected_binary = signatureType_FIRMWARE_FLASH;
bool success = BinaryUpdate_handleDetectedBinary(detected_binary);
TEST_ASSERT_TRUE(success);
}

signatureType_E detected_binary;
bool success = false;

detected_binary = signatureType_FIRMWARE_FLASH;
success = BinaryUpdate_handleDetectedBinary(detected_binary);
TEST_ASSERT_TRUE(success);

detected_binary = signatureType_BOOTLOADER_FLASH;
success = BinaryUpdate_handleDetectedBinary(detected_binary);
TEST_ASSERT_TRUE(success);

detected_binary = signatureType_FIRMWARE_RAM;
success = BinaryUpdate_handleDetectedBinary(detected_binary);
TEST_ASSERT_TRUE(success);

detected_binary = signatureType_BOOTLOADER_RAM;
success = BinaryUpdate_handleDetectedBinary(detected_binary);
TEST_ASSERT_TRUE(success);

detected_binary = signatureType_UNKNOWN;
success = BinaryUpdate_handleDetectedBinary(detected_binary);
TEST_ASSERT_FALSE(success);

detected_binary = signatureType_UNKNOWN + 1;
success = BinaryUpdate_handleDetectedBinary(detected_binary);
TEST_ASSERT_FALSE(success);
}

TEST(BinaryUpdate, BinaryUpdate_handleBootInfo) {

boot_info.jump_address = FLASH_FIRMWARE_ADDRESS;
boot_info.skip_bl_loop = true;
BinaryUpdate_handleBootInfo();
TEST_ASSERT_TRUE(boot_info.skip_bl_loop);

boot_info.jump_address = FLASH_BOOTLOADER_ADDRESS;
BinaryUpdate_handleBootInfo();
TEST_ASSERT_TRUE(boot_info.skip_bl_loop);

boot_info.jump_address = RAM_FIRMWARE_ADDRESS;
BinaryUpdate_handleBootInfo();
TEST_ASSERT_TRUE(boot_info.skip_bl_loop);

boot_info.jump_address = 0x08888888UL; //Unknown
BinaryUpdate_handleBootInfo();
TEST_ASSERT_FALSE(boot_info.skip_bl_loop);
}

TEST(BinaryUpdate, BinaryUpdate_shortFunctions) {

boot_info.jump_address = FLASH_FIRMWARE_ADDRESS;
uint32_t jump_address = BinaryUpdate_getJumpAddress();
BinaryUpdate_handleBootInfo();
TEST_ASSERT_EQUAL_UINT32(FLASH_FIRMWARE_ADDRESS, jump_address);

BinaryUpdate_resetJumpAddress();

BinaryUpdate_checkSkipLoopFlag();

BinaryUpdate_disableLoopFlag();

}

0 comments on commit e1eb742

Please sign in to comment.