Skip to content

Commit

Permalink
Merge pull request #956 from bernd-herzog/boot_improvements
Browse files Browse the repository at this point in the history
removed need for cpld mode setup for QFP100
  • Loading branch information
gullradriel committed May 5, 2023
2 parents 9b263de + 7116f92 commit 31031ed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
9 changes: 6 additions & 3 deletions firmware/application/portapack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,13 @@ bool init() {

chThdSleepMilliseconds(10);

if( !portapack::cpld::update_if_necessary(portapack_cpld_config()) ) {
portapack::cpld::CpldUpdateStatus result = portapack::cpld::update_if_necessary(portapack_cpld_config());
if ( result == portapack::cpld::CpldUpdateStatus::Program_failed ) {

chThdSleepMilliseconds(10);
// If using a "2021/12 QFP100", press and hold the left button while booting. Should only need to do once.
if (load_config() != 3 && load_config() != 4){
// Mode left (R1) and right (R2,H2,H2+) bypass going into hackrf mode after failing CPLD update
// Mode center (autodetect), up (R1) and down (R2,H2,H2+) will go into hackrf mode after failing CPLD update
if (load_config() != 3 /* left */ && load_config() != 4 /* right */){
shutdown_base();
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions firmware/common/cpld_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
namespace portapack {
namespace cpld {

bool update_if_necessary(
CpldUpdateStatus update_if_necessary(
const Config config
) {
jtag::GPIOTarget target {
Expand All @@ -51,7 +51,7 @@ bool update_if_necessary(

/* Run-Test/Idle */
if( !cpld.idcode_ok() ) {
return false;
return CpldUpdateStatus::Idcode_check_failed;
}

cpld.sample();
Expand All @@ -62,7 +62,7 @@ bool update_if_necessary(
* in passive state.
*/
if( !cpld.silicon_id_ok() ) {
return false;
return CpldUpdateStatus::Silicon_id_check_failed;
}

/* Verify CPLD contents against current bitstream. */
Expand All @@ -86,7 +86,7 @@ bool update_if_necessary(
cpld.disable();
}

return ok;
return ok ? CpldUpdateStatus::Success : CpldUpdateStatus::Program_failed;
}

} /* namespace cpld */
Expand Down
9 changes: 8 additions & 1 deletion firmware/common/cpld_update.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@
namespace portapack {
namespace cpld {

bool update_if_necessary(
enum class CpldUpdateStatus {
Success = 0,
Idcode_check_failed = 1,
Silicon_id_check_failed = 2,
Program_failed = 3
};

CpldUpdateStatus update_if_necessary(
const Config config
);

Expand Down

0 comments on commit 31031ed

Please sign in to comment.