summaryrefslogtreecommitdiffstats
path: root/recipes-bsp/x-load
diff options
context:
space:
mode:
authorKoen Kooi <koen@dominion.thruhere.net>2011-07-20 10:05:14 +0200
committerKoen Kooi <koen@dominion.thruhere.net>2011-07-20 10:20:52 +0200
commiteab43c77d7908c2ee095f11597c38c1f8608d2d0 (patch)
treeb11e2c3b42dd4315af6872b728936983c5e0f4bf /recipes-bsp/x-load
parent654b6c9a594654324dd9612cd0a0b27be21df6dc (diff)
downloadmeta-ti-eab43c77d7908c2ee095f11597c38c1f8608d2d0.tar.gz
signgp: add util needed for old x-loader versions
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'recipes-bsp/x-load')
-rw-r--r--recipes-bsp/x-load/signgp.bb18
-rw-r--r--recipes-bsp/x-load/signgp/signGP.c108
2 files changed, 126 insertions, 0 deletions
diff --git a/recipes-bsp/x-load/signgp.bb b/recipes-bsp/x-load/signgp.bb
new file mode 100644
index 00000000..7aead670
--- /dev/null
+++ b/recipes-bsp/x-load/signgp.bb
@@ -0,0 +1,18 @@
1LICENSE = "NewBSD"
2DESCRIPTION = "Tool to sign omap3 x-loader images"
3LIC_FILES_CHKSUM = "file://signGP.c;md5=960f484fea13941ca88821366f9dade0"
4
5SRC_URI = "file://signGP.c"
6
7do_compile() {
8 ${CC} ${CFLAGS} ${LDFLAGS} ${WORKDIR}/signGP.c -o signGP
9}
10
11do_install() {
12 install -d ${D}${bindir}
13 install -m 0755 signGP ${D}${bindir}
14}
15
16NATIVE_INSTALL_WORKS = "1"
17
18BBCLASSEXTEND = "native nativesdk"
diff --git a/recipes-bsp/x-load/signgp/signGP.c b/recipes-bsp/x-load/signgp/signGP.c
new file mode 100644
index 00000000..93250640
--- /dev/null
+++ b/recipes-bsp/x-load/signgp/signGP.c
@@ -0,0 +1,108 @@
1/*
2 * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
3 *
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the
15 * distribution.
16 *
17 * Neither the name of Texas Instruments Incorporated nor the names of
18 * its contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33*/
34
35
36//
37// signGP.c
38// Read the x-load.bin file and write out the x-load.bin.ift file.
39// The signed image is the original pre-pended with the size of the image
40// and the load address. If not entered on command line, file name is
41// assumed to be x-load.bin in current directory and load address is
42// 0x40200800.
43
44#include <stdio.h>
45#include <stdlib.h>
46#include <fcntl.h>
47#include <sys/stat.h>
48#include <string.h>
49#include <malloc.h>
50
51
52main(int argc, char *argv[])
53{
54 int i;
55 char ifname[FILENAME_MAX], ofname[FILENAME_MAX], ch;
56 FILE *ifile, *ofile;
57 unsigned long loadaddr, len;
58 struct stat sinfo;
59
60
61 // Default to x-load.bin and 0x40200800.
62 strcpy(ifname, "x-load.bin");
63 loadaddr = 0x40200800;
64
65 if ((argc == 2) || (argc == 3))
66 strcpy(ifname, argv[1]);
67
68 if (argc == 3)
69 loadaddr = strtol(argv[2], NULL, 16);
70
71 // Form the output file name.
72 strcpy(ofname, ifname);
73 strcat(ofname, ".ift");
74
75 // Open the input file.
76 ifile = fopen(ifname, "rb");
77 if (ifile == NULL) {
78 printf("Cannot open %s\n", ifname);
79 exit(0);
80 }
81
82 // Get file length.
83 stat(ifname, &sinfo);
84 len = sinfo.st_size;
85
86 // Open the output file and write it.
87 ofile = fopen(ofname, "wb");
88 if (ofile == NULL) {
89 printf("Cannot open %s\n", ofname);
90 fclose(ifile);
91 exit(0);
92 }
93
94 // Pad 1 sector of zeroes.
95 //ch = 0x00;
96 //for (i=0; i<0x200; i++)
97 // fwrite(&ch, 1, 1, ofile);
98
99 fwrite(&len, 1, 4, ofile);
100 fwrite(&loadaddr, 1, 4, ofile);
101 for (i=0; i<len; i++) {
102 fread(&ch, 1, 1, ifile);
103 fwrite(&ch, 1, 1, ofile);
104 }
105
106 fclose(ifile);
107 fclose(ofile);
108}