summaryrefslogtreecommitdiff
path: root/common/tools/mksimage/mksimage.c
diff options
context:
space:
mode:
authorJérémy Dufour2012-11-06 14:55:04 +0100
committerJérémy Dufour2012-11-21 17:09:43 +0100
commitd78cbb0ad8d879911c24d34fa9ce59ce1e43eedf (patch)
tree08f155d5554ca044c19829d2131a732091db1c1b /common/tools/mksimage/mksimage.c
parentb1bc8ec2f9fa8708591ceb4984110805dd399f7a (diff)
{common, cleo/linux/scripts}: move mksimage from linux to common, refs #3452
In order to have a common mksimage between SPC300 and MSE500-200, we move mksimage to common and replace it by a symbolic link.
Diffstat (limited to 'common/tools/mksimage/mksimage.c')
-rw-r--r--common/tools/mksimage/mksimage.c114
1 files changed, 114 insertions, 0 deletions
diff --git a/common/tools/mksimage/mksimage.c b/common/tools/mksimage/mksimage.c
new file mode 100644
index 0000000000..99df798ab9
--- /dev/null
+++ b/common/tools/mksimage/mksimage.c
@@ -0,0 +1,114 @@
+/*
+ * scripts/spidhdr/spidhdr.c
+ *
+ * (C) Copyright 2009 SPiDCOM Technologies
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * Author(s):
+ * 30 Apr 2009 Drasko DRASKOVIC <drasko.draskovic@spidcom.com>
+ */
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "spid_img_desc.h"
+
+spidcom_image_desc_t image = {
+ .magic = SPIDCOM_IMG_DESC_MAGIC,
+ .index = 0xffffffff, /* mandatory to be changed into the flash */
+ .is_valid = 1,
+ .is_1st_boot = 1,
+ .is_not_success = 1,
+ .is_not_update = 1,
+ .type = 0,
+ .version = "v0.0",
+ .description = "SPiDCOM image",
+ .arch = SPIDCOM_IMG_DESC_SPC300,
+ .plc_ram = SPIDCOM_IMG_DESC_PLC_RAM
+};
+
+static void print_usage(const char *cmd)
+{
+ fprintf(stderr, "%s : \n", cmd);
+}
+
+int main(int argc, char **argv)
+{
+ int c, i = 0;
+ int j = 0;
+ char tmpstr[3];
+
+ struct option opt[] =
+ {
+ { "size", required_argument, NULL, 's' },
+ { "ldaddr", required_argument, NULL, 'l' },
+ { "ver", required_argument, NULL, 'v' },
+ { "desc", required_argument, NULL, 'd' },
+ { "md5", required_argument, NULL, 'm' },
+ { "platform", required_argument, NULL, 'p' },
+ { "plc-ram", required_argument, NULL, 'r' },
+ { "help", no_argument, NULL, 'h' }
+ };
+
+ while((c = getopt_long(argc, argv, "s:l:v:d:m:p:r:h", opt, &i)) != EOF)
+ {
+ switch(c)
+ {
+ case 's' :
+ image.size = atoi(optarg);
+ break;
+ case 'v' :
+ strncpy(image.version, optarg, sizeof(image.version));
+ break;
+ case 'd' :
+ strncpy(image.description, optarg, sizeof(image.description));
+ break;
+ case 'm' :
+ for (j=0; j<16; j++)
+ {
+ strncpy(tmpstr, optarg + j*2, 2);
+ tmpstr[2] = '\0';
+ image.md5_sum[j] = (unsigned char)strtoul(tmpstr, NULL, 16);
+ }
+ break;
+#if 0
+ case 'p' :
+ if (!strncmp(optarg, "arizona", 7))
+ image.arch = SPIDCOM_IMG_DESC_SPC300;
+ else
+ image.arch = SPIDCOM_IMG_DESC_SPC300_UNKNOWN;
+ break;
+#endif
+ case 'r' :
+ image.plc_ram = atoi(optarg) * 1024 * 1024;
+ break;
+ case 'h' :
+ case '?' :
+ print_usage(argv[0]);
+ return -1;
+ }
+ }
+
+ write(fileno(stdout), &image, sizeof(spidcom_image_desc_t));
+ return 0;
+}