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)
37 if (CAN_EID(frame) != WB_ACK) {
45 }
else if (frame.
DLC == 8)
49 auto data =
reinterpret_cast<const wbo::PongData*
>(&frame.
data8[0]);
64 chEvtSignal(t, EVT_BOOTLOADER_ACK);
69 return chEvtWaitAnyTimeout(EVT_BOOTLOADER_ACK, TIME_MS2I(timeout)) != 0;
82 if (hwIndex == 0xff) {
96 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
101 efiPrintf(
"***************************************");
102 efiPrintf(
" WIDEBAND INDEX SET");
103 efiPrintf(
"***************************************");
105 if (hwIndex == 0xff) {
106 efiPrintf(
"Setting all connected widebands to index %d...", index);
108 efiPrintf(
"Setting wideband with hwIndex %d to CAN index %d...", hwIndex, index);
113 efiPrintf(
"Wideband index set failed: no controller detected!");
128 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
142 efiPrintf(
"Wideband sensor type set failed: no controller detected!");
164 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
177 efiPrintf(
"Wideband ping failed: no controller detected!");
180 efiPrintf(
"WBO_RE_DONE");
189 static int counter = 0;
202 for (
size_t i = 0; i < CAN_WBO_COUNT; i++) {
214#if EFI_WIDEBAND_FIRMWARE_UPDATE
223 chEvtGetAndClearEvents(EVT_BOOTLOADER_ACK);
228 efiPrintf(
"***************************************");
229 efiPrintf(
" WIDEBAND FIRMWARE UPDATE");
230 efiPrintf(
"***************************************");
231 if (hwIndex != 0xff) {
232 efiPrintf(
"Wideband Update: Rebooting WBO hwIndex %d to bootloader...", hwIndex);
234 efiPrintf(
"Wideband Update: Rebooting any WBO to bootloader...");
239 for (
int i = 0; i < 2; i++) {
245 if ((hwIndex != 0xff) && (i == 0)) {
254 efiPrintf(
"Wideband Update ERROR: Expected ACK from entry to bootloader, didn't get %s.",
255 i ?
"second (from bootloader)" :
"first (from app)");
261 chThdSleepMilliseconds(200);
264 efiPrintf(
"Wideband Update: in update mode, erasing flash...");
274 efiPrintf(
"Wideband Update ERROR: Expected ACK from flash erase command, didn't get one.");
288 efiPrintf(
"Wideband Update: Update complete! Rebooting controller.");
296 efiPrintf(
"Wideband Update ERROR: No ack on reboot command");
311static const char wboFileName[] =
"fw/wbo/wideband_image_with_bl.bin";
320 size_t totalSize = 0;
325 efiPrintf(
"Wideband Update: filed to open %s",
wboFileName);
330 efiPrintf(
"Wideband Update: filed to seek");
343 for (
size_t i = 0; i < totalSize; i += 8) {
347 if (f_read(&fil, tmp,
sizeof(tmp), &br) != FR_OK) {
348 efiPrintf(
"Wideband Update: filed to read");
360 memcpy(&m[0], tmp, 8);
364 efiPrintf(
"Wideband Update ERROR: Expected ACK from data write, didn't get one.");
388#include "wideband_firmware/for_rusefi/wideband_image.h"
392 size_t totalSize =
sizeof(build_wideband_image_bin);
400 efiPrintf(
"Wideband Update: Flash erased! Sending %d bytes...", totalSize);
403 for (
size_t i = 0; i < totalSize; i += 8) {
406 memcpy(&m[0], build_wideband_image_bin + i, 8);
410 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
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