예제 #1
0
파일: fpga.c 프로젝트: 2ephyr/bladeRF
int fpga_write_to_flash(struct bladerf *dev, const char *fpga_file)
{
    int status;
    size_t buf_size;
    uint8_t *buf = NULL;

    status = file_read_buffer(fpga_file, &buf, &buf_size);
    if (status == 0) {
        if (!valid_fpga_size(dev->fpga_size, buf_size)) {
            status = BLADERF_ERR_INVAL;
        } else {
            status = flash_write_fpga_bitstream(dev, &buf, buf_size);
        }
    }

    free(buf);
    return status;
}
예제 #2
0
파일: bladerf.c 프로젝트: kaysin/bladeRF
int bladerf_flash_fpga(struct bladerf *dev, const char *fpga_file)
{
    int status;
    uint8_t *buf;
    size_t buf_size;
    const char env_override[] = "BLADERF_SKIP_FPGA_SIZE_CHECK";

    status = file_read_buffer(fpga_file, &buf, &buf_size);
    if (status == 0) {
        if (!getenv(env_override) && !valid_fpga_size(buf_size)) {
            log_info("Detected potentially invalid firmware file.\n");
            log_info("Define BLADERF_SKIP_FPGA_SIZE_CHECK in your evironment "
                       "to skip this check.\n");
            status = BLADERF_ERR_INVAL;
        } else {
            status = flash_write_fpga_bitstream(dev, &buf, buf_size);
            free(buf);
        }
    }

    return status;
}