Skip to content

Commit

Permalink
Can freeze boot in order to load firmware via SWD/JTAG
Browse files Browse the repository at this point in the history
  • Loading branch information
danngreen committed Jul 26, 2023
1 parent f8b13d4 commit a704494
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/board_conf/osd32brk_conf.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ constexpr PinConf UartTX{GPIO::G, PinNum::_11, PinAF::AF_6};
constexpr PinConf BootSelectPin{GPIO::B, PinNum::_6};
constexpr bool UseBootSelect = false;

// Freeze mode: halts booting after initializing everything
// so you can load firmware via SWD/JTAG
constexpr bool UseFreezePin = false;
constexpr PinConf FreezePin{GPIO::Unused, PinNum::_0};

namespace NORFlash
{
constexpr bool HasNORFlash = false;
Expand Down
5 changes: 5 additions & 0 deletions src/board_conf/stm32disco_conf.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ using GreenLED2 = BlueLED; // For compatibility with OSD32BRK board
constexpr bool UseBootSelect = false;
constexpr PinConf BootSelectPin{GPIO::A, PinNum::_13};

// Freeze mode: halts booting after initializing everything
// so you can load firmware via SWD/JTAG
constexpr bool UseFreezePin = false;
constexpr PinConf FreezePin{GPIO::Unused, PinNum::_0};

constexpr uint32_t ConsoleUART = UART4_BASE;
constexpr PinConf UartRX{GPIO::B, PinNum::_2, PinAF::AF_8};
constexpr PinConf UartTX{GPIO::G, PinNum::_11, PinAF::AF_6};
Expand Down
12 changes: 12 additions & 0 deletions src/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ void main()

BootLoader::LoadTarget image_type = BootLoader::LoadTarget::App;

if constexpr (Board::UseFreezePin) {
Board::FreezePin.init(PinMode::Input, PinPull::Up);
// delay to allow pull-up to settle
udelay(1000);
if (!Board::FreezePin.read()) {
print("Freeze pin detected active, freezing.\n");
print("Ready to load firmware to DDR RAM via SWD/JTAG.\n");
while (true)
;
}
}

// Check Boot Select pin
if constexpr (Board::UseBootSelect) {
Board::BootSelectPin.init(PinMode::Input, PinPull::Up);
Expand Down

0 comments on commit a704494

Please sign in to comment.