furi_hal_bootloader.c 732 B

12345678910111213141516171819202122232425
  1. #include <furi_hal_bootloader.h>
  2. #include <furi_hal_rtc.h>
  3. #include <furi.h>
  4. #define TAG "FuriHalBoot"
  5. // Boot request enum
  6. #define BOOT_REQUEST_TAINTED 0x00000000
  7. #define BOOT_REQUEST_CLEAN 0xDADEDADE
  8. #define BOOT_REQUEST_DFU 0xDF00B000
  9. void furi_hal_bootloader_init() {
  10. #ifndef DEBUG
  11. furi_hal_rtc_set_register(FuriHalRtcRegisterBoot, BOOT_REQUEST_TAINTED);
  12. #endif
  13. FURI_LOG_I(TAG, "Init OK");
  14. }
  15. void furi_hal_bootloader_set_mode(FuriHalBootloaderMode mode) {
  16. if(mode == FuriHalBootloaderModeNormal) {
  17. furi_hal_rtc_set_register(FuriHalRtcRegisterBoot, BOOT_REQUEST_CLEAN);
  18. } else if(mode == FuriHalBootloaderModeDFU) {
  19. furi_hal_rtc_set_register(FuriHalRtcRegisterBoot, BOOT_REQUEST_DFU);
  20. }
  21. }