Added link to the DFU protocol appnote

This commit is contained in:
Andrei 2017-06-02 12:31:52 +03:00
commit 0b13607efd
7 changed files with 27 additions and 7 deletions

View File

@ -41,5 +41,5 @@ The bootloader executable works as follows:
- Init ChibiOS and UART/Serial driver using tunerstudio_io code;
- Create a thread to listen to UART (thBootloaderSerial), using dfuStartLoop();
- The PC 'stm32-flasher' software sends its request byte only once, so we don't wait for it - the bootloader sends an answer as soon as it starts (both the request & answer bytes are known consts);
- Ff the next command doesn't come immediately (<100 ms), we abort the bootloader dfu loop and run the application code - calling dfuJumpToApp() in main().
- If the next command doesn't come immediately (<100 ms), we abort the bootloader dfu loop and run the application code - calling dfuJumpToApp() in main().
- Otherwise, if at least one command is received, we stay in the bootloader mode and process commands.

View File

@ -129,7 +129,7 @@ bool dfuStartLoop(void) {
break;
}
// check if we have a correct command recieved
// check if we have a correct command received
if (complement != complementByte(command)) {
sendByte(DFU_NACK_BYTE);
continue;
@ -141,7 +141,7 @@ bool dfuStartLoop(void) {
// set normal (longer) timeout, we're not in a hurry anymore
sr5Timeout = DFU_SR5_TIMEOUT_NORMAL;
// now execute it
// now execute it (see ST appnote "AN3155")
switch (command) {
case DFU_UART_CHECK:
break;
@ -187,7 +187,7 @@ bool dfuStartLoop(void) {
break;
if (!getByte(&complement))
break;
// check if we have a correct byte recieved
// check if we have a correct byte received
if (complement != complementByte(byte)) {
sendByte(DFU_NACK_BYTE);
break;

View File

@ -13,6 +13,10 @@
#define DFU_BUFFER_SIZE 258 // Max. 256 bytes at a time plus 2 bytes (numBytes+checksum)
// DFU/USART Protocol is described in AN3155 document "Application note. USART protocol used in the STM32 bootloader"
// http://www.st.com/resource/en/application_note/cd00264342.pdf
#define DFU_UART_CHECK 0x7F // "UART handshake" escape byte
#define DFU_GET_LIST_CMD 0x00 // "Get supported commands list" command

View File

@ -184,6 +184,16 @@ void setDefaultEtbParameters(void) {
engineConfiguration->etbFreq = 300;
}
bool isETBRestartNeeded(void) {
/**
* We do not want any interruption in HW pin while adjusting other properties
*/
return engineConfiguration->bc.etbControlPin1 != activeConfiguration.bc.etbControlPin1 ||
engineConfiguration->bc.etbControlPin2 != activeConfiguration.bc.etbControlPin2 ||
engineConfiguration->bc.etbDirectionPin1 != activeConfiguration.bc.etbDirectionPin1 ||
engineConfiguration->bc.etbDirectionPin2 != activeConfiguration.bc.etbDirectionPin2;
}
void stopETBPins(void) {
unmarkPin(activeConfiguration.bc.etbControlPin1);
unmarkPin(activeConfiguration.bc.etbControlPin2);

View File

@ -13,6 +13,7 @@ void initElectronicThrottle(void);
void setDefaultEtbParameters(void);
void setEtbPFactor(float value);
void setEtbIFactor(float value);
bool isETBRestartNeeded(void);
void stopETBPins(void);
void startETBPins(void);
void onConfigurationChangeElectronicThrottleCallback(engine_configuration_s *previousConfiguration);

View File

@ -123,7 +123,7 @@ static efitimeus_t togglePwmState(PwmConfig *state) {
efitimeus_t nextSwitchTimeUs = getNextSwitchTimeUs(state);
#if DEBUG_PWM
scheduleMsg(&logger, "%s: nextSwitchTime %d", state->name, nextSwitchTime);
#endif
#endif /* DEBUG_PWM */
// signed value is needed here
// int64_t timeToSwitch = nextSwitchTimeUs - getTimeNowUs();
// if (timeToSwitch < 1) {

View File

@ -234,7 +234,10 @@ void applyNewHardwareSettings(void) {
stopInjectionPins();
stopIgnitionPins();
stopCanPins();
stopETBPins();
bool etbRestartNeeded = isETBRestartNeeded();
if (etbRestartNeeded) {
stopETBPins();
}
stopVSSPins();
stopAuxPins();
@ -293,7 +296,9 @@ void applyNewHardwareSettings(void) {
startInjectionPins();
startIgnitionPins();
startCanPins();
startETBPins();
if (etbRestartNeeded) {
startETBPins();
}
startVSSPins();
startAuxPins();