void programFlashTask(void* p){ int sector = flashSectorToWrite; uint32_t size = flashSizeToWrite; uint8_t* source = (uint8_t*)flashAddressToWrite; if(sector >= 0 && sector < MAX_USER_PATCHES && size <= 128*1024){ uint32_t addr = getFlashAddress(sector); eeprom_unlock(); int ret = eeprom_erase(addr); if(ret == 0) ret = eeprom_write_block(addr, source, size); eeprom_lock(); registry.init(); if(ret == 0){ // load and run program int pc = registry.getNumberOfPatches()-MAX_USER_PATCHES+sector; program.loadProgram(pc); // program.loadDynamicProgram(source, size); program.resetProgram(false); }else{ setErrorMessage(PROGRAM_ERROR, "Failed to write program to flash"); } }else if(sector == 0xff && size < MAX_SYSEX_FIRMWARE_SIZE){ flashFirmware(source, size); }else{ setErrorMessage(PROGRAM_ERROR, "Invalid flash program command"); } vTaskDelete(NULL); }
BoardWidget::BoardWidget(QWidget *parent) : QWidget(parent), ui(new Ui::boardWidget) { ui->setupUi(this); connect(ui->flashButton, SIGNAL(clicked()), this, SLOT(flashFirmware())); connect(ui->cancelButton, SIGNAL(clicked()), this, SIGNAL(cancelFirmwareUpload())); setBoardImage("./files/images/px4/calibration/accel_z-.png"); }
FlashTool::FlashTool(QWidget *parent) : QWidget(parent) , ui(new Ui::FlashTool) { ui->setupUi(this); updatePorts(); // Listen to device events DEV_BROADCAST_DEVICEINTERFACE devInt; ZeroMemory(&devInt, sizeof(devInt)); devInt.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); devInt.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; devInt.dbcc_classguid = GUID_DEVINTERFACE_COMPORT; HANDLE blub; blub = RegisterDeviceNotification(winId(), &devInt, DEVICE_NOTIFY_WINDOW_HANDLE); connect(ui->bootFlashButton, SIGNAL(clicked()), SLOT(flashBootloader())); connect(ui->flashButton, SIGNAL(clicked()), SLOT(flashFirmware())); }
void PiLink::receive(void){ while (piStream.available() > 0) { char inByte = piStream.read(); switch(inByte){ case ' ': case '\n': case '\r': break; #if BREWPI_SIMULATE==1 case 'y': parseJson(HandleSimulatorConfig); break; case 'Y': printSimulatorSettings(); break; #endif case 'A': // alarm on soundAlarm(true); break; case 'a': // alarm off soundAlarm(false); break; case 't': // temperatures requested printTemperatures(); break; case 'C': // Set default constants tempControl.loadDefaultConstants(); display.printStationaryText(); // reprint stationary text to update to right degree unit sendControlConstants(); // update script with new settings logInfo(INFO_DEFAULT_CONSTANTS_LOADED); break; case 'S': // Set default settings tempControl.loadDefaultSettings(); sendControlSettings(); // update script with new settings logInfo(INFO_DEFAULT_SETTINGS_LOADED); break; case 's': // Control settings requested sendControlSettings(); break; case 'c': // Control constants requested sendControlConstants(); break; case 'v': // Control variables requested, send Control Object as json sendControlVariables(); break; case 'n': // v version // s shield type // y: simulator // b: board print_P(PSTR( "N:{" "\"v\":\"" PRINTF_PROGMEM "\"," "\"n\":\"" PRINTF_PROGMEM "\"," "\"s\":%d," "\"y\":%d," "\"b\":\"%c\"," "\"l\":\"%d\"" "}"), PSTR(VERSION_STRING), // v: PSTR(stringify(BUILD_NAME)), // n: getShieldVersion(), // s: BREWPI_SIMULATE, // y: BREWPI_BOARD, // b: BREWPI_LOG_MESSAGES_VERSION); // l: printNewLine(); break; case 'l': // Display content requested printResponse('L'); piStream.print('['); char stringBuffer[21]; for(uint8_t i=0;i<4;i++){ display.getLine(i, stringBuffer); print_P(PSTR("\"%s\""), stringBuffer); char close = (i<3) ? ',':']'; piStream.print(close); } printNewLine(); break; case 'j': // Receive settings as json receiveJson(); break; #if BREWPI_EEPROM_HELPER_COMMANDS case 'e': // dump contents of eeprom openListResponse('E'); for (uint16_t i=0; i<1024;) { if (i>0) { piLink.printNewLine(); piLink.print(','); } piLink.print('\"'); for (uint8_t j=0; j<64; j++) { uint8_t d = eepromAccess.readByte(i++); printNibble(d>>4); printNibble(d); } piLink.print('\"'); } closeListResponse(); break; #endif case 'E': // initialize eeprom eepromManager.initializeEeprom(); logInfo(INFO_EEPROM_INITIALIZED); settingsManager.loadSettings(); break; case 'd': // list devices in eeprom order openListResponse('d'); deviceManager.listDevices(piStream); closeListResponse(); break; case 'U': // update device deviceManager.parseDeviceDefinition(piStream); break; case 'h': // hardware query openListResponse('h'); deviceManager.enumerateHardwareToStream(piStream); closeListResponse(); break; #if (BREWPI_DEBUG > 0) case 'Z': // zap eeprom eepromManager.zapEeprom(); logInfo(INFO_EEPROM_ZAPPED); break; #endif case 'R': // reset handleReset(); break; case 'F': // flash firmware flashFirmware(); break; default: logWarningInt(WARNING_INVALID_COMMAND, inByte); } } }