Skip to content

Commit

Permalink
nRF52: Bootloader now doesn't reset RESETREAS
Browse files Browse the repository at this point in the history
            nRF52: If we reboot because of LOCKUP, don't enable DCDC converter
            Bangle.js2: Test screen now fails if no DCDC enabled
  • Loading branch information
gfwilliams committed Jan 16, 2025
1 parent 49c60d8 commit ef27cea
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
Fix escaping of `\r` in built-in modules, fixed regression that stopped Espruino WiFi 2v25 from connecting to Wifi
BLE: always return privacy info from NRF.getSecurityStatus(), regardless of connection state
Linux SDL build: mouse events now create `E.on("touch"` events like on CYD
nRF52: Bootloader now doesn't reset RESETREAS
nRF52: If we reboot because of LOCKUP, don't enable DCDC converter
Bangle.js2: Test screen now fails if no DCDC enabled

2v25 : ESP32C3: Get analogRead working correctly
Graphics: Adjust image alignment when rotating images to avoid cropping (fix #2535)
Expand Down
7 changes: 6 additions & 1 deletion libs/js/banglejs/Bangle_showTestScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@
var av = analogRead(D3), v=av*13.359;
chg |= Bangle.isCharging();
if (av>mv) cup=1;
draw(8,'Chg',v.toFixed(2)+"v "+(Bangle.isCharging()?"charge":"discharge"),chg&&cup&&(v>2)&&(v<4.4));
var ok = chg&&cup&&(v>2)&&(v<4.4), msg = v.toFixed(2)+"v "+(Bangle.isCharging()?"charge":"discharge");
if (!peek32(0x40000578)) { // DCDCEN
msg = "NO DCDC";
ok = false;
}
draw(8,'Chg',msg,ok);
},500);
},1000);
Bangle.on('swipe', e => {
Expand Down
2 changes: 1 addition & 1 deletion libs/js/banglejs/Bangle_showTestScreen.min.js

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

12 changes: 8 additions & 4 deletions targets/nrf5x/bluetooth.c
Original file line number Diff line number Diff line change
Expand Up @@ -2636,10 +2636,14 @@ static void ble_stack_init() {
NRF_SDH_SOC_OBSERVER(m_soc_observer, APP_SOC_OBSERVER_PRIO, soc_evt_handler, NULL);
#endif

#if defined(PUCKJS) || defined(RUUVITAG) || defined(ESPR_DCDC_ENABLE)
// can only be enabled if we're sure we have a DC-DC
err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
APP_ERROR_CHECK(err_code);
#if defined(ESPR_DCDC_ENABLE)
if (!(NRF_POWER->RESETREAS & POWER_RESETREAS_LOCKUP_Msk)) {
/* If we previously booted and got a LOCKUP reset, this could well be due to a DCDC
converter issue, so don't enable DCDC if that's the case. */
// can only be enabled if we're sure we have a DC-DC
err_code = sd_power_dcdc_mode_set(NRF_POWER_DCDC_ENABLE);
APP_ERROR_CHECK(err_code);
}
#endif
#if defined(ESPR_DCDC_HV_ENABLE)
err_code = sd_power_dcdc0_mode_set(NRF_POWER_DCDC_ENABLE);
Expand Down
4 changes: 0 additions & 4 deletions targets/nrf5x_dfu/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,6 @@ int main(void)
} else {
// DICKENS: Enter bootloader only if BTN2 held as well
if (!get_btn2_state()) {
// Clear reset reason flags
NRF_POWER->RESETREAS = 0xFFFFFFFF;
#ifdef ESPR_BOOTLOADER_SPIFLASH
lcd_init();
#ifndef DICKENS
Expand Down Expand Up @@ -427,8 +425,6 @@ int main(void)
while (*reasons) reasons++;
reasons++;
}
// Clear reset reason flags
NRF_POWER->RESETREAS = 0xFFFFFFFF;
print_fw_version();
#ifdef ESPR_BOOTLOADER_SPIFLASH
if (!get_btn1_state()) flashCheckAndRun();
Expand Down

0 comments on commit ef27cea

Please sign in to comment.