Skip to content

Commit

Permalink
Added developer mode to EEPROM
Browse files Browse the repository at this point in the history
  • Loading branch information
ClemensElflein committed Dec 17, 2024
1 parent b47b147 commit a4d45f4
Show file tree
Hide file tree
Showing 9 changed files with 416 additions and 230 deletions.
112 changes: 90 additions & 22 deletions bootloader/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 0 additions & 8 deletions bootloader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,6 @@ target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined symbols
)

if(${BOOTLOADER_UNSAFE})
message("Building Unsafe Bootloader")
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
# Add user defined symbols
ALLOW_UNSAFE_BOOT
)
endif ()

# Add linked libraries
target_link_libraries(${CMAKE_PROJECT_NAME} PUBLIC
# Add user defined libraries
Expand Down
12 changes: 0 additions & 12 deletions bootloader/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
"configurePreset": "Release",
"name": "Release"
},
{
"configurePreset": "ReleaseUnsafe",
"name": "ReleaseUnsafe"
},
{
"configurePreset": "MinSizeRel",
"name": "MinSizeRel"
Expand Down Expand Up @@ -51,14 +47,6 @@
"inherits": "default",
"name": "Release"
},
{
"cacheVariables": {
"BOOTLOADER_UNSAFE": true,
"CMAKE_BUILD_TYPE": "Release"
},
"inherits": "default",
"name": "ReleaseUnsafe"
},
{
"cacheVariables": {
"CMAKE_BUILD_TYPE": "MinSizeRel"
Expand Down
3 changes: 0 additions & 3 deletions bootloader/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,8 @@ COPY . /project

WORKDIR /project
RUN mkdir -p build && cd build && cmake .. --preset=Release && cd Release && make -j$(nproc)
RUN mkdir -p build && cd build && cmake .. --preset=ReleaseUnsafe && cd ReleaseUnsafe && make -j$(nproc)


FROM scratch
COPY --from=builder /project/build/Release/xcore-boot.elf /
COPY --from=builder /project/build/Release/xcore-boot.bin /
COPY --from=builder /project/build/ReleaseUnsafe/xcore-boot.elf /xcore-boot-unsafe.elf
COPY --from=builder /project/build/ReleaseUnsafe/xcore-boot.bin /xcore-boot-unsafe.bin
12 changes: 11 additions & 1 deletion bootloader/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void link_up(struct netif *netif) {

void jump_to_user_program(void) {
RTC->BKP0R = 0xB0043D;
#if defined(BOARD_HAS_EEPROM) && !defined(ALLOW_UNSAFE_BOOT)
#if defined(BOARD_HAS_EEPROM)

// Check, if we have a valid image
struct bootloader_info info = {0};
Expand All @@ -34,6 +34,16 @@ void jump_to_user_program(void) {
return;
}

if (info.developer_mode == 1) {
// Developer mode, reboot into user program
RTC->BKP0R = 0xB0043D;
MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BOOT_ADD0,
(BOOT_ADDRESS >> 16) << SYSCFG_UR2_BOOT_ADD0_Pos);
NVIC_SystemReset();
while (1)
;
}

if (info.image_present != 1) {
return;
}
Expand Down
Loading

0 comments on commit a4d45f4

Please sign in to comment.