summaryrefslogtreecommitdiffstats
path: root/rbutil/mktccboot/mktccboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/mktccboot/mktccboot.c')
-rw-r--r--rbutil/mktccboot/mktccboot.c101
1 files changed, 0 insertions, 101 deletions
diff --git a/rbutil/mktccboot/mktccboot.c b/rbutil/mktccboot/mktccboot.c
index 7103f23895..4f2c3258db 100644
--- a/rbutil/mktccboot/mktccboot.c
+++ b/rbutil/mktccboot/mktccboot.c
@@ -75,13 +75,6 @@ static uint32_t get_uint32le(unsigned char* p)
return (p[3] << 24) | (p[2] << 16) | (p[1]<<8) | p[0];
}
-void usage(void)
-{
- printf("Usage: mktccboot <firmware file> <boot file> <output file>\n");
-
- exit(1);
-}
-
static off_t filesize(int fd) {
struct stat buf;
@@ -181,97 +174,3 @@ int test_firmware_tcc(unsigned char* buf, int length)
return telechips_test_crc(buf, length);
}
-#ifndef LIB
-int main(int argc, char *argv[])
-{
- char *infile, *bootfile, *outfile;
- int fdout = -1;
- int n, of_size, boot_size, patched_size;
- unsigned char *of_buf;
- unsigned char *boot_buf = NULL;
- unsigned char* image = NULL;
- int ret = 0;
-
- if(argc < 3) {
- usage();
- }
-
- infile = argv[1];
- bootfile = argv[2];
- outfile = argv[3];
-
- /* Read OF and boot files */
- of_buf = file_read(infile, &of_size);
- if (!of_buf)
- {
- ret = 1;
- goto error_exit;
- }
-
- /* Validate input file */
- if (test_firmware_tcc(of_buf, of_size))
- {
- printf("[ERR] Unknown OF file used, aborting\n");
- ret = 2;
- goto error_exit;
- }
-
- boot_buf = file_read(bootfile, &boot_size);
- if (!boot_buf)
- {
- ret = 3;
- goto error_exit;
- }
-
- /* Allocate buffer for patched firmware */
- image = malloc(of_size + boot_size);
- if (image == NULL)
- {
- printf("[ERR] Could not allocate memory, aborting\n");
- ret = 4;
- goto error_exit;
- }
-
- /* Create the patched firmware */
- image = patch_firmware_tcc(of_buf, of_size, boot_buf, boot_size,
- &patched_size);
- if (!image)
- {
- printf("[ERR] Error creating patched firmware, aborting\n");
- ret = 5;
- goto error_exit;
- }
-
- fdout = open(outfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644);
- if (fdout < 0)
- {
- perror(outfile);
- ret = 6;
- goto error_exit;
- }
-
- n = write(fdout, image, patched_size);
- if (n != patched_size)
- {
- printf("[ERR] Could not write output file %s\n",outfile);
- ret = 7;
- goto error_exit;
- }
-
-error_exit:
-
- if (fdout >= 0)
- close(fdout);
-
- if (of_buf)
- free(of_buf);
-
- if (boot_buf)
- free(boot_buf);
-
- if (image)
- free(image);
-
- return ret;
-}
-#endif