Ola 960 made some progress towards software jump to DFU #809
This commit is contained in:
parent
5fc6043a14
commit
3a2e1c9990
|
@ -271,6 +271,8 @@ static void handleCommandX14(uint16_t index) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jump_to_bootloader();
|
||||||
|
|
||||||
// todo: this is probably a wrong place for this method now
|
// todo: this is probably a wrong place for this method now
|
||||||
void executeTSCommand(uint16_t subsystem, uint16_t index) {
|
void executeTSCommand(uint16_t subsystem, uint16_t index) {
|
||||||
scheduleMsg(logger, "IO test subsystem=%d index=%d", subsystem, index);
|
scheduleMsg(logger, "IO test subsystem=%d index=%d", subsystem, index);
|
||||||
|
@ -301,8 +303,9 @@ void executeTSCommand(uint16_t subsystem, uint16_t index) {
|
||||||
} else if (subsystem == 0x79) {
|
} else if (subsystem == 0x79) {
|
||||||
scheduleStopEngine();
|
scheduleStopEngine();
|
||||||
} else if (subsystem == 0xba) {
|
} else if (subsystem == 0xba) {
|
||||||
// todo: this does not work yet
|
#if EFI_PROD_CODE
|
||||||
// DFU mode
|
jump_to_bootloader();
|
||||||
|
#endif /* EFI_PROD_CODE */
|
||||||
} else if (subsystem == 0xbb) {
|
} else if (subsystem == 0xbb) {
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
rebootNow();
|
rebootNow();
|
||||||
|
|
|
@ -134,4 +134,25 @@ int getAdcChannelPin(adc_channel_e hwChannel) {
|
||||||
return getHwPin("get_pin", brainPin);
|
return getHwPin("get_pin", brainPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void jump_to_bootloader() {
|
||||||
|
// todo: this does not work yet
|
||||||
|
|
||||||
|
RCC->CR &= RCC_CR_HSITRIM | RCC_CR_HSION; /* CR Reset value. */
|
||||||
|
RCC->CFGR = 0; /* CFGR reset value. */
|
||||||
|
sdStop (&SD2);
|
||||||
|
// sduStop (&SDU1);
|
||||||
|
usbStop (&USBD1);
|
||||||
|
__disable_irq();
|
||||||
|
chSysDisable();
|
||||||
|
SysTick->CTRL = SysTick->LOAD = SysTick->VAL = 0;
|
||||||
|
SYSCFG->MEMRMP = 0x01;
|
||||||
|
SCB->VTOR = 0;
|
||||||
|
SCB->ICSR = (0x1U << 27); //ICSR_PENDSVCLR;
|
||||||
|
const uint32_t p = (*((uint32_t *) 0x1FFF0000));
|
||||||
|
__set_MSP(p);
|
||||||
|
void (*SysMemBootJump)(void);
|
||||||
|
SysMemBootJump = (void (*)(void)) (*((uint32_t *) 0x1FFF0004));
|
||||||
|
SysMemBootJump();
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* HAL_USE_ADC */
|
#endif /* HAL_USE_ADC */
|
||||||
|
|
Loading…
Reference in New Issue