Merge branch 'ofw-dev' into dev

This commit is contained in:
MX 2023-08-23 19:49:00 +03:00
commit 8df9947d42
No known key found for this signature in database
GPG key ID: 7CCC66B7DBDD1C83
6 changed files with 47 additions and 53 deletions

View file

@ -224,7 +224,6 @@ void desktop_lock(Desktop* desktop) {
scene_manager_set_scene_state(
desktop->scene_manager, DesktopSceneLocked, SCENE_LOCKED_FIRST_ENTER);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneLocked);
notification_message(desktop->notification, &sequence_display_backlight_off_delay_1000);
DesktopStatus status = {.locked = true};
furi_pubsub_publish(desktop->status_pubsub, &status);

View file

@ -128,19 +128,22 @@ void furi_hal_resources_init_early() {
furi_hal_resources_init_input_pins(GpioModeInput);
// Explicit, surviving reset, pulls
LL_PWR_EnablePUPDCfg();
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_8); // gpio_vibro
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_8); // gpio_speaker
// SD Card stepdown control
furi_hal_gpio_write(&gpio_periph_power, 1);
furi_hal_gpio_init(&gpio_periph_power, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
// Display pins
furi_hal_gpio_write(&gpio_display_rst_n, 1);
furi_hal_gpio_write(&gpio_display_rst_n, 0);
furi_hal_gpio_init_simple(&gpio_display_rst_n, GpioModeOutputPushPull);
furi_hal_gpio_init(&gpio_display_di, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
// Pullup display reset pin for shutdown
SET_BIT(PWR->PUCRB, gpio_display_rst_n.pin);
CLEAR_BIT(PWR->PDCRB, gpio_display_rst_n.pin);
SET_BIT(PWR->CR3, PWR_CR3_APC);
LL_PWR_EnableGPIOPullUp(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_0); // gpio_display_rst_n
furi_hal_gpio_write(&gpio_display_di, 0);
furi_hal_gpio_init_simple(&gpio_display_di, GpioModeOutputPushPull);
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_1); // gpio_display_di
// Hard reset USB
furi_hal_gpio_write(&gpio_usb_dm, 1);
@ -182,18 +185,6 @@ void furi_hal_resources_init() {
// Button pins
furi_hal_resources_init_input_pins(GpioModeInterruptRiseFall);
// Explicit pulls pins
LL_PWR_EnablePUPDCfg();
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_8); // gpio_speaker
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_8); // gpio_vibro
// Display pins
furi_hal_gpio_init(&gpio_display_rst_n, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_write(&gpio_display_rst_n, 0);
furi_hal_gpio_init(&gpio_display_di, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_write(&gpio_display_di, 0);
// SD pins
furi_hal_gpio_init(&gpio_sdcard_cd, GpioModeInput, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_write(&gpio_sdcard_cd, 0);

View file

@ -117,19 +117,23 @@ void furi_hal_resources_init_early() {
furi_hal_resources_init_input_pins(GpioModeInput);
// Explicit, surviving reset, pulls
LL_PWR_EnablePUPDCfg();
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_8); // gpio_vibro
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_8); // gpio_speaker
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_9); // gpio_infrared_tx
// SD Card stepdown control
furi_hal_gpio_write(&gpio_periph_power, 1);
furi_hal_gpio_init(&gpio_periph_power, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow);
// Display pins
furi_hal_gpio_write(&gpio_display_rst_n, 1);
furi_hal_gpio_write(&gpio_display_rst_n, 0);
furi_hal_gpio_init_simple(&gpio_display_rst_n, GpioModeOutputPushPull);
LL_PWR_EnableGPIOPullUp(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_0); // gpio_display_rst_n
furi_hal_gpio_write(&gpio_display_di, 0);
furi_hal_gpio_init_simple(&gpio_display_di, GpioModeOutputPushPull);
// Alternative pull configuration for shutdown
SET_BIT(PWR->PUCRB, DISPLAY_RST_Pin);
CLEAR_BIT(PWR->PDCRB, DISPLAY_RST_Pin);
SET_BIT(PWR->CR3, PWR_CR3_APC);
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_1); // gpio_display_di
// Hard reset USB
furi_hal_gpio_write(&gpio_usb_dm, 1);
@ -171,19 +175,6 @@ void furi_hal_resources_init() {
// Button pins
furi_hal_resources_init_input_pins(GpioModeInterruptRiseFall);
// Explicit, surviving reset, pulls
LL_PWR_EnablePUPDCfg();
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_9); // gpio_infrared_tx
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_B, LL_PWR_GPIO_BIT_8); // gpio_speaker
LL_PWR_EnableGPIOPullDown(LL_PWR_GPIO_A, LL_PWR_GPIO_BIT_8); // gpio_vibro
// Display pins
furi_hal_gpio_init(&gpio_display_rst_n, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_write(&gpio_display_rst_n, 0);
furi_hal_gpio_init(&gpio_display_di, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_write(&gpio_display_di, 0);
// SD pins
furi_hal_gpio_init(&gpio_sdcard_cd, GpioModeInput, GpioPullNo, GpioSpeedLow);
furi_hal_gpio_write(&gpio_sdcard_cd, 0);

View file

@ -1,5 +1,8 @@
#!/usr/bin/env python3
import time
from typing import Optional
from flipper.app import App
from flipper.storage import FlipperStorage
from flipper.utils.cdc import resolve_port
@ -27,8 +30,20 @@ class Main(App):
)
self.parser_reboot2dfu.set_defaults(func=self.reboot2dfu)
def _get_flipper(self):
if not (port := resolve_port(self.logger, self.args.port)):
def _get_flipper(self, retry_count: Optional[int] = 1):
port = None
self.logger.info(f"Attempting to find flipper with {retry_count} attempts.")
for i in range(retry_count):
time.sleep(1)
self.logger.info(f"Attempting to find flipper #{i}.")
if port := resolve_port(self.logger, self.args.port):
self.logger.info(f"Found flipper at {port}")
break
if not port:
self.logger.info(f"Failed to find flipper")
return None
flipper = FlipperStorage(port)
@ -36,28 +51,28 @@ class Main(App):
return flipper
def power_off(self):
if not (flipper := self._get_flipper()):
if not (flipper := self._get_flipper(retry_count=10)):
return 1
self.logger.debug("Powering off")
self.logger.info("Powering off")
flipper.send("power off" + "\r")
flipper.stop()
return 0
def reboot(self):
if not (flipper := self._get_flipper()):
if not (flipper := self._get_flipper(retry_count=10)):
return 1
self.logger.debug("Rebooting")
self.logger.info("Rebooting")
flipper.send("power reboot" + "\r")
flipper.stop()
return 0
def reboot2dfu(self):
if not (flipper := self._get_flipper()):
if not (flipper := self._get_flipper(retry_count=10)):
return 1
self.logger.debug("Rebooting to DFU")
self.logger.info("Rebooting to DFU")
flipper.send("power reboot2dfu" + "\r")
flipper.stop()

View file

@ -22,14 +22,14 @@ def flp_serial_by_name(flp_name):
if os.path.exists(flp_serial):
return flp_serial
else:
logging.info(f"Couldn't find {logging.info} on this attempt.")
logging.info(f"Couldn't find {flp_name} on this attempt.")
if os.path.exists(flp_name):
return flp_name
else:
return ""
UPDATE_TIMEOUT = 60 * 4 # 4 minutes
UPDATE_TIMEOUT = 30 * 4 # 4 minutes
def main():
@ -50,7 +50,7 @@ def main():
if flipper == "":
logging.error("Flipper not found!")
sys.exit(1)
exit(1)
logging.info(f"Found Flipper at {flipper}")

View file

@ -20,14 +20,12 @@ def main():
logging.error("Flipper not found!")
sys.exit(1)
with serial.Serial(flp_serial, timeout=10) as flipper:
with serial.Serial(flp_serial, timeout=150) as flipper:
logging.info(f"Found Flipper at {flp_serial}")
flipper.baudrate = 230400
flipper.flushOutput()
flipper.flushInput()
flipper.timeout = 300
flipper.read_until(b">: ").decode("utf-8")
flipper.write(b"unit_tests\r")
data = flipper.read_until(b">: ").decode("utf-8")