Esempio n. 1
0
	bool FalconFirmware::loadFirmware(bool skip_checksum)
	{
		if(m_firmwareFilename.length() == 0)
		{
			m_errorCode = FALCON_FIRMWARE_FILE_NOT_VALID;
			return false;
		}
		std::fstream firmware_file(m_firmwareFilename.c_str(), std::fstream::in | std::fstream::binary);
		if(!firmware_file.is_open())
		{
			m_errorCode = FALCON_FIRMWARE_FILE_NOT_VALID;
			return false;
		}
		long begin, end, file_size;
		begin = firmware_file.tellg();
		firmware_file.seekg (0, std::ios::end);
		end = firmware_file.tellg();
		file_size = end-begin;
		firmware_file.seekg (0, std::ios::beg);

		uint8_t* buf = new uint8_t[file_size];		
		firmware_file.read((char*)buf, file_size);
		bool success = loadFirmware(skip_checksum, file_size, buf);
		firmware_file.close();
		delete[] buf;
		return success;
	}
Esempio n. 2
0
	bool FalconFirmware::loadFirmware(int retries, bool skip_checksum)
	{
		for(int i = 0; i < retries; ++i)
		{
			if(loadFirmware(skip_checksum))
			{
				return true;
			}
		}
		return false;
	}
Esempio n. 3
0
void ExtractorExchange::init() {
    qs1rio_init();

    qWarning() << "Detecting device...";
    if (findQsDevice( ) == -1) { // Try to initialize board
        qWarning() << "Could not find QS1R! Make sure board is connected and powered up.";
        return;  // Board is probably not connected?
    }
    qWarning() << "Device found!";

    std::string path = "";
    std::string path_filename = "";

    if ( readFwSn() != ID_FWWR ) {
        qWarning() << "Loading firmware.";
        path_filename.append( path );
        path_filename.append( QS1R_FIRMWARE_NAME );
        if ( loadFirmware( path_filename.c_str( ) ) == -1) {
            qWarning() << "Could not load QS1R firmware!";
            return;
        }

        qWarning() << "Firmware loaded... reinit...";
        Sleep(10000);   // delay for reenumeration

        if ( findQsDevice( ) == -1 ) { // try to initialize board again
            qWarning() << "Could not find QS1R! ";
            return;  // board is probably not connected or firmware not loaded?
        }
    }
    qWarning() << "Found QS1R...";
    Sleep(500);

    if ( readMultibusInt( MB_ID_REG ) != ID_1RXWR ) { // is FPGA loaded with proper file?
        qWarning() << "Loading QS1R FPGA... Please wait...";
        path_filename.clear( );
        path_filename.append( path );
        path_filename.append( QS1R_FPGA_NAME );
        if ( loadFpga( path_filename.c_str( ) ) == -1 ) {
            qWarning() << "Could not load QS1R Fpga!";
            return;  // Can't find rbf file?
        }
    }

    qWarning() << "QS1R FPGA is loaded...";
    Sleep(500);
}
DeviceWidget::DeviceWidget(QWidget *parent) :
    QWidget(parent)
{
    myDevice = new Ui_deviceWidget();
    myDevice->setupUi(this);

    // Initialization of the Device icon display
    myDevice->verticalGroupBox_loaded->setVisible(false);
    myDevice->groupCustom->setVisible(false);
    myDevice->confirmCheckBox->setVisible(false);
    myDevice->gVDevice->setScene(new QGraphicsScene(this));
    connect(myDevice->retrieveButton, SIGNAL(clicked()), this, SLOT(downloadFirmware()));
    connect(myDevice->updateButton, SIGNAL(clicked()), this, SLOT(uploadFirmware()));
    connect(myDevice->pbLoad, SIGNAL(clicked()), this, SLOT(loadFirmware()));
    connect(myDevice->confirmCheckBox, SIGNAL(stateChanged(int)), this, SLOT(confirmCB(int)));
    myDevice->statusIcon->setPixmap(QPixmap(":uploader/images/view-refresh.svg"));

    myDevice->lblCertified->setText("");
}
Esempio n. 5
0
/**
   Fills the various fields for the device
 */
void DeviceWidget::populate()
{
    int id = m_dfu->devices[deviceID].ID;

    myDevice->lbldevID->setText(tr("Device ID: ") + QString::number(id, 16));
    // DeviceID tells us what sort of HW we have detected:
    // display a nice icon:
    myDevice->gVDevice->scene()->clear();
    myDevice->lblDevName->setText(deviceDescriptorStruct::idToBoardName(id));
    myDevice->lblHWRev->setText(tr("HW Revision: ") + QString::number(id & 0x00FF, 16));

    switch (id) {
    case 0x0101:
    case 0x0201:
        devicePic.load("");
        break;
    case 0x0301:
        devicePic.load(":/uploader/images/gcs-board-oplink.png");
        break;
    case 0x0401:
        devicePic.load(":/uploader/images/gcs-board-cc.png");
        break;
    case 0x0402:
        devicePic.load(":/uploader/images/gcs-board-cc3d.png");
        break;
    case 0x0903:
        devicePic.load(":/uploader/images/gcs-board-revo.png");
        break;
    case 0x0904:
        devicePic.load(":/uploader/images/gcs-board-revo.png");
        break;
    default:
        // Clear
        devicePic.load("");
        break;
    }
    myDevice->gVDevice->scene()->addPixmap(devicePic);
    myDevice->gVDevice->setSceneRect(devicePic.rect());
    myDevice->gVDevice->fitInView(devicePic.rect(), Qt::KeepAspectRatio);

    bool r = m_dfu->devices[deviceID].Readable;
    bool w = m_dfu->devices[deviceID].Writable;

    myDevice->lblAccess->setText(tr("Flash access: ") + QString(r ? "R" : "-") + QString(w ? "W" : "-"));
    myDevice->lblMaxCode->setText(tr("Max code size: ") + QString::number(m_dfu->devices[deviceID].SizeOfCode));
    myDevice->lblCRC->setText(QString::number(m_dfu->devices[deviceID].FW_CRC));
    myDevice->lblBLVer->setText(tr("BL version: ") + QString::number(m_dfu->devices[deviceID].BL_Version));
    int size = ((OP_DFU::device)m_dfu->devices[deviceID]).SizeOfDesc;
    m_dfu->enterDFU(deviceID);
    QByteArray desc = m_dfu->DownloadDescriptionAsBA(size);

    if (!populateBoardStructuredDescription(desc)) {
        // desc was not a structured description
        QString str = m_dfu->DownloadDescription(size);
        myDevice->lblDescription->setText((!str.isEmpty()) ? str : tr("Unknown"));
        myDevice->lblCertified->setPixmap(QPixmap(":uploader/images/warning.svg"));
        myDevice->lblCertified->setToolTip(tr("Custom Firmware Build"));
        myDevice->lblBuildDate->setText(tr("Unknown"));
        myDevice->lblGitTag->setText(tr("Unknown"));
        myDevice->lblBrdName->setText(tr("Unknown"));
    }
    myDevice->filenameLabel->setText(tr("No file loaded"));
    status("Ready...", STATUSICON_INFO);
    QString fwFileName = getDevFirmwarePath();
    QFile fwFile(fwFileName);
    if (fwFile.exists()) {
        loadFirmware(fwFileName);
    }
}
Esempio n. 6
0
void DeviceWidget::loadFirmware()
{
    QString file = setOpenFileName();

    loadFirmware(file);
}