- FILE *fw;
- int offset, chunksize, ret, result;
- unsigned char buf[4096];
-
- sr_info("Uploading firmware at %s", filename);
- if ((fw = g_fopen(filename, "rb")) == NULL) {
- sr_err("Unable to open firmware file %s for reading: %s",
- filename, strerror(errno));
+ unsigned char *firmware;
+ size_t length, offset, chunksize;
+ int ret, result;
+
+ /* Max size is 64 kiB since the value field of the setup packet,
+ * which holds the firmware offset, is only 16 bit wide.
+ */
+ firmware = sr_resource_load(ctx, SR_RESOURCE_FIRMWARE,
+ name, &length, 1 << 16);
+ if (!firmware)