17#pragma GCC diagnostic push
18#pragma GCC diagnostic ignored "-Wunused-function"
19#include "wideband_firmware/for_rusefi/wideband_can.h"
20#pragma GCC diagnostic pop
26#define EVT_BOOTLOADER_ACK EVENT_MASK(0)
38 if (CAN_EID(frame) != WB_ACK) {
46 }
else if (frame.
DLC == 8)
50 auto data =
reinterpret_cast<const wbo::PongData*
>(&frame.
data8[0]);
65 chEvtSignal(t, EVT_BOOTLOADER_ACK);
70 return chEvtWaitAnyTimeout(EVT_BOOTLOADER_ACK, TIME_MS2I(timeout)) != 0;
83 if (hwIndex == 0xff) {
97 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
102 efiPrintf(
"***************************************");
103 efiPrintf(
" WIDEBAND INDEX SET");
104 efiPrintf(
"***************************************");
106 if (hwIndex == 0xff) {
107 efiPrintf(
"Setting all connected widebands to index %d...", index);
109 efiPrintf(
"Setting wideband with hwIndex %d to CAN index %d...", hwIndex, index);
114 efiPrintf(
"Wideband index set failed: no controller detected!");
129 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
143 efiPrintf(
"Wideband sensor type set failed: no controller detected!");
165 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
178 efiPrintf(
"Wideband ping failed: no controller detected!");
181 efiPrintf(
"WBO_RE_DONE");
195 static int counter = 0;
213 for (
size_t i = 0; i < CAN_WBO_COUNT; i++) {
225#if EFI_WIDEBAND_FIRMWARE_UPDATE
234 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
239 efiPrintf(
"***************************************");
240 efiPrintf(
" WIDEBAND FIRMWARE UPDATE");
241 efiPrintf(
"***************************************");
242 if (hwIndex != 0xff) {
243 efiPrintf(
"Wideband Update: Rebooting WBO hwIndex %d to bootloader...", hwIndex);
245 efiPrintf(
"Wideband Update: Rebooting any WBO to bootloader...");
250 for (
int i = 0; i < 2; i++) {
256 if ((hwIndex != 0xff) && (i == 0)) {
265 efiPrintf(
"Wideband Update ERROR: Expected ACK from entry to bootloader, didn't get %s.",
266 i ?
"second (from bootloader)" :
"first (from app)");
272 chThdSleepMilliseconds(200);
275 efiPrintf(
"Wideband Update: in update mode, erasing flash...");
285 efiPrintf(
"Wideband Update ERROR: Expected ACK from flash erase command, didn't get one.");
299 efiPrintf(
"Wideband Update: Update complete! Rebooting controller.");
307 efiPrintf(
"Wideband Update ERROR: No ack on reboot command");
322static const char wboFileName[] =
"fw/wbo/wideband_image_with_bl.bin";
331 size_t totalSize = 0;
336 efiPrintf(
"Wideband Update: filed to open %s",
wboFileName);
341 efiPrintf(
"Wideband Update: filed to seek");
354 for (
size_t i = 0; i < totalSize; i += 8) {
358 if (f_read(&fil, tmp,
sizeof(tmp), &br) != FR_OK) {
359 efiPrintf(
"Wideband Update: filed to read");
371 memcpy(&m[0], tmp, 8);
375 efiPrintf(
"Wideband Update ERROR: Expected ACK from data write, didn't get one.");
399#include "wideband_firmware/for_rusefi/wideband_image.h"
403 size_t totalSize =
sizeof(build_wideband_image_bin);
411 efiPrintf(
"Wideband Update: Flash erased! Sending %d bytes...", totalSize);
414 for (
size_t i = 0; i < totalSize; i += 8) {
417 memcpy(&m[0], build_wideband_image_bin + i, 8);
421 efiPrintf(
"Wideband Update ERROR: Expected ACK from data write, didn't get one.");
TunerStudioOutputChannels outputChannels
static float getOrZero(SensorType type)
static EngineAccessor engine
static constexpr engine_configuration_s * engineConfiguration
static int updateWidebandFirmwarePrepare(size_t bus, uint8_t hwIndex)
static const size_t wboFwMaxSize
static int updateWidebandFirmwareFinalize(size_t bus, uint8_t)
void handleWidebandCan(const size_t busIndex, const CANRxFrame &frame)
void updateWidebandFirmwareFromFile(uint8_t hwIndex)
static thread_t * waitingBootloaderThread
void setWidebandSensorType(uint8_t hwIndex, uint8_t type)
bool waitAck(int timeout=1000)
static const size_t wboFwOffset
static char widebandRestart
void setWidebandOffsetNoWait(uint8_t hwIndex, uint8_t index)
void pingWideband(uint8_t hwIndex)
static const char wboFileName[]
static void setStatus(can_wbo_re_status_e status)
void setWidebandOffset(uint8_t hwIndex, uint8_t index)
void updateWidebandFirmware(uint8_t hwIndex)
uint8_t data8[8]
Frame data.
wbo_s canWbo[CAN_WBO_COUNT]
bool heaterControlEnabled
uint8_t canReWidebandCmdStatus
uint8_t canReWidebandFwYear
uint8_t canReWidebandVersion
uint8_t canReWidebandFwDay
uint8_t canReWidebandFwMon
can_wbo_re_hwidx_e reHwidx