gzip: Remove gzip compression for the UBL payload
The UBL doesn't have GZIP support anymore to save some bytes for DDR RAM parameter tables.
This commit is contained in:
parent
c4856d2e75
commit
ccf642498d
63
src/main.c
63
src/main.c
|
@ -132,15 +132,6 @@ read_file_data(const char*file, u_int8_t *data, ssize_t *size_in_bytes)
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
#ifdef REMOVE_TEMP_FILES
|
|
||||||
/* Remove temporary file. */
|
|
||||||
ret = remove_file(gz_file);
|
|
||||||
if (ret) {
|
|
||||||
log_fail("Error removing temporary file");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -196,49 +187,6 @@ convert_elf_to_binary(const char *elf_file, const char *temp_file,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* size_in_bytes must be initialized with the size of the buffer.
|
|
||||||
* it will be written with the actual buffer size. */
|
|
||||||
static int
|
|
||||||
compress_binary(const char *bin_file, const char *gz_file,
|
|
||||||
u_int8_t *data, ssize_t *size_in_bytes)
|
|
||||||
{
|
|
||||||
char cmd[MAX_CMD_LENGTH];
|
|
||||||
int ret;
|
|
||||||
/*
|
|
||||||
* OBJCOPY FLAGS:
|
|
||||||
* -9
|
|
||||||
* best compression
|
|
||||||
* -f
|
|
||||||
* overwrite existing file
|
|
||||||
* --no-name
|
|
||||||
* do not save the original file name and time stamp
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
char *gzip_flags = "-9 -f --no-name";
|
|
||||||
|
|
||||||
if (*size_in_bytes == 0) {
|
|
||||||
log_fail("buffer size not specified");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
sprintf(cmd, "gzip %s %s 2>&1", gzip_flags, bin_file);
|
|
||||||
|
|
||||||
log_debug1("Running command: %s", cmd);
|
|
||||||
ret = system(cmd);
|
|
||||||
if (ret) {
|
|
||||||
log_fail("Error compressing binary file");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = read_file_data(gz_file, data, size_in_bytes);
|
|
||||||
if (ret) {
|
|
||||||
log_fail("Error reading file data");
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SEND_UBL 0
|
#define SEND_UBL 0
|
||||||
#define SEND_APP_ELF 1
|
#define SEND_APP_ELF 1
|
||||||
#define SEND_APP_BIN 2
|
#define SEND_APP_BIN 2
|
||||||
|
@ -255,7 +203,6 @@ send_binary(const char *orig_file, const char *tmp_file, int format,
|
||||||
u_int32_t crc;
|
u_int32_t crc;
|
||||||
int size_len = 4; /* RBL format is default */
|
int size_len = 4; /* RBL format is default */
|
||||||
int entry_point_len = 4; /* RBL format is default */
|
int entry_point_len = 4; /* RBL format is default */
|
||||||
char gz_file[128];
|
|
||||||
|
|
||||||
|
|
||||||
data = malloc(BINAPP_MAX_SIZE);
|
data = malloc(BINAPP_MAX_SIZE);
|
||||||
|
@ -283,16 +230,6 @@ send_binary(const char *orig_file, const char *tmp_file, int format,
|
||||||
goto error_handled;
|
goto error_handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format != SEND_UBL) {
|
|
||||||
/* Compress for UBL format */
|
|
||||||
sprintf(gz_file, "%s.gz", tmp_file);
|
|
||||||
|
|
||||||
/* No need to reset size, compressed file will be smaller. */
|
|
||||||
ret = compress_binary(tmp_file, gz_file, data, &size);
|
|
||||||
if (ret)
|
|
||||||
goto error_handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_info("Sending ACK sequence");
|
log_info("Sending ACK sequence");
|
||||||
send_message(" ACK\n");
|
send_message(" ACK\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue