dfu.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include <furi.h>
  2. #include <furi_hal.h>
  3. #include <flipper.h>
  4. #include <alt_boot.h>
  5. #include <u8g2_glue.h>
  6. #include <assets_icons.h>
  7. void flipper_boot_dfu_show_splash() {
  8. // Initialize
  9. furi_hal_compress_icon_init();
  10. u8g2_t* fb = malloc(sizeof(u8g2_t));
  11. memset(fb, 0, sizeof(u8g2_t));
  12. u8g2_Setup_st756x_flipper(fb, U8G2_R0, u8x8_hw_spi_stm32, u8g2_gpio_and_delay_stm32);
  13. u8g2_InitDisplay(fb);
  14. u8g2_SetDrawColor(fb, 0x01);
  15. uint8_t* splash_data = NULL;
  16. furi_hal_compress_icon_decode(icon_get_data(&I_DFU_128x50), &splash_data);
  17. u8g2_DrawXBM(fb, 0, 64 - 50, 128, 50, splash_data);
  18. u8g2_SetFont(fb, u8g2_font_helvB08_tr);
  19. u8g2_DrawStr(fb, 2, 8, "Update & Recovery Mode");
  20. u8g2_DrawStr(fb, 2, 21, "DFU Started");
  21. u8g2_SetPowerSave(fb, 0);
  22. u8g2_SendBuffer(fb);
  23. }
  24. void flipper_boot_dfu_exec() {
  25. // Show DFU splashscreen
  26. flipper_boot_dfu_show_splash();
  27. // Errata 2.2.9, Flash OPTVERR flag is always set after system reset
  28. WRITE_REG(FLASH->SR, FLASH_SR_OPTVERR);
  29. // Cleanup before jumping to DFU
  30. furi_hal_deinit_early();
  31. // Remap memory to system bootloader
  32. LL_SYSCFG_SetRemapMemory(LL_SYSCFG_REMAP_SYSTEMFLASH);
  33. // Jump
  34. furi_hal_switch(0x0);
  35. }