NULL, 0, NULL);
}
+int thor_get_proto_ver(thor_device_handle *th)
+{
+ int ret;
+ struct res_pkt resp;
+
+ ret = t_thor_exec_cmd_full(th, RQT_INFO, RQT_INFO_VER_PROTOCOL,
+ NULL, 0, NULL, 0, &resp);
+ if (!ret)
+ ret = (resp.int_data[0] << 8) | resp.int_data[1];
+
+ return ret;
+}
+
int thor_start_session(thor_device_handle *th, off_t total)
{
int ret;
/* Close the device */
void thor_close(thor_device_handle *th);
+/* Get protocol version of the device */
+int thor_get_proto_ver(thor_device_handle *th);
+
/* Start thor "session" */
int thor_start_session(thor_device_handle *th, off_t total);
printf("\t" TERM_YELLOW "total" TERM_NORMAL" :\t%.2fMB\n\n",
(double)total_size/MB);
- if (total_size > (4*GB - 1*KB)) {
- fprintf(stderr,
- TERM_RED
- "[ERROR] Images over 4GB are not supported by thor protocol.\n"
- TERM_NORMAL);
- ret = -EOVERFLOW;
- goto release_data_srcs;
- }
+ /* Check protocol version */
+ if (thor_get_proto_ver(th) < 0x500) {
+ /*
+ * Until THOR protocol 4.0, total file size is in 32bit
+ * unsigned int[1] to show progress, so files less than 4GB
+ * are allowed.
+ */
+ if (total_size > (4*GB - 1*KB)) {
+ fprintf(stderr,
+ TERM_RED
+ "[ERROR] Images over 4GB are not supported by thor protocol.\n"
+ TERM_NORMAL);
+ ret = -EOVERFLOW;
+ goto release_data_srcs;
+ }
- if (total_size > (2*GB - 1*KB)) {
- fprintf(stderr,
- TERM_RED
- "[WARNING] Not all bootloaders support images over 2GB.\n"
- " If your download will fail this may be a reason.\n"
- TERM_NORMAL);
+ /*
+ * Early THOR protocol 4.0 bootloader set 32bit signed int[1],
+ * so only files less than 2GB are allowed.
+ */
+ if (total_size > (2*GB - 1*KB)) {
+ fprintf(stderr,
+ TERM_RED
+ "[WARNING] Not all bootloaders support images over 2GB.\n"
+ " If your download will fail this may be a reason.\n"
+ TERM_NORMAL);
+ }
}
ret = do_download(th, data_parts, entries, total_size);