summaryrefslogtreecommitdiff
path: root/packages/simpad-utilities/genboot
diff options
context:
space:
mode:
authorKoen Kooi <koen@openembedded.org>2005-06-30 08:19:37 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2005-06-30 08:19:37 +0000
commitc8e5702127e507e82e6f68a4b8c546803accea9d (patch)
tree00583491f40ecc640f2b28452af995e3a63a09d7 /packages/simpad-utilities/genboot
parent87ec8ca4d2e2eb4d1c1e1e1a6b46a395d56805b9 (diff)
import clean BK tree at cset 1.3670
Diffstat (limited to 'packages/simpad-utilities/genboot')
-rw-r--r--packages/simpad-utilities/genboot/.mtn2git_empty0
-rw-r--r--packages/simpad-utilities/genboot/arnold_boot.h28
-rw-r--r--packages/simpad-utilities/genboot/gen_boot.c99
-rwxr-xr-x[-rw-r--r--]packages/simpad-utilities/genboot/simpad-make-flashimg89
4 files changed, 216 insertions, 0 deletions
diff --git a/packages/simpad-utilities/genboot/.mtn2git_empty b/packages/simpad-utilities/genboot/.mtn2git_empty
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/packages/simpad-utilities/genboot/.mtn2git_empty
diff --git a/packages/simpad-utilities/genboot/arnold_boot.h b/packages/simpad-utilities/genboot/arnold_boot.h
index e69de29bb2..7c8399ac2e 100644
--- a/packages/simpad-utilities/genboot/arnold_boot.h
+++ b/packages/simpad-utilities/genboot/arnold_boot.h
@@ -0,0 +1,28 @@
+
+#define ARNOLDMAGIC "ARNOLDBOOTBLOCK"
+#define MAXSEG 32
+#define WRITE_SMART_MAGIC 3141 /* write tftp data to smart */
+#define BOOT_SMART_MAGIC 9876 /* Start an Smartmedia */
+#define REBOOT_MAGIC 9123 /* restart old image ? */
+#define EXTRA_BOOT 0xdead /* Load named image */
+
+struct segment { void *base; long len; }; /* len MUST be Multiple of 512 */
+
+struct arnold_bootheader {
+ char magic[16];
+ long exec_adr;
+ long nosegs;
+ struct segment lseg[MAXSEG];
+ long stack_p;
+ short debuggit;
+ short writesmart;
+ unsigned short extrafile;
+ char otherfile[20];
+
+ char reserved[1]; /* reserved for future use */
+};
+union bootblock {
+ char buffer[512];
+ struct arnold_bootheader boot;
+};
+
diff --git a/packages/simpad-utilities/genboot/gen_boot.c b/packages/simpad-utilities/genboot/gen_boot.c
index e69de29bb2..1444f60d0b 100644
--- a/packages/simpad-utilities/genboot/gen_boot.c
+++ b/packages/simpad-utilities/genboot/gen_boot.c
@@ -0,0 +1,99 @@
+#include "arnold_boot.h"
+#include <stdio.h>
+volatile void
+error (char *msg)
+{
+ fprintf (stderr, "Fatal Error:%s\n", msg);
+ exit (2);
+}
+#ifdef LITTLE_END
+#define order(x) ((x&0xff)<<24 | (x&0xff00) << 8 | (x&0xff0000) >>8 | (x&0xff000000)>>24)
+#define swap(x) ((x&0xff)<<8 | (x&0xff00)>>8)
+#else
+#define order(x) (x)
+#define swap(x) (x)
+#endif
+
+main (int argc, char *argv[])
+{
+ union bootblock block0;
+ char *ep;
+ int nseg;
+
+ memset ((void *) &block0, 0, sizeof (block0));
+ strcpy (block0.boot.magic, ARNOLDMAGIC);
+ if (argc < 3)
+ error ("Bad Number of args:\n"
+ " Usage: gen_boot [-d[n]][-w][-r][-x filename] exec_adr nseg base1 len1 [base len]");
+
+ if (strncmp (argv[1], "-d",2) == 0)
+ {
+ /* Set debugging to value (default 1) */
+ if ( argv[1][2] == 0 ) {
+ block0.boot.debuggit = swap(1);
+ }else{
+ block0.boot.debuggit = swap(argv[1][2] - '0');
+ }
+ argv++;
+ argc--;
+ }
+ if (strcmp (argv[1], "-w") == 0)
+ {
+ block0.boot.writesmart = swap(WRITE_SMART_MAGIC);
+ argv++;
+ argc--;
+ }
+ if (strcmp (argv[1], "-r") == 0)
+ {
+ block0.boot.writesmart = swap(REBOOT_MAGIC); /* Try to reboot ram image */
+ argv++;
+ argc--;
+ }
+ if (strcmp (argv[1], "-x") == 0)
+ {
+ block0.boot.extrafile=swap(EXTRA_BOOT);
+ strncpy (block0.boot.otherfile,argv[2],sizeof(block0.boot.otherfile));
+
+ argv+=2;
+ argc-=2;
+ }
+ block0.boot.exec_adr = order (strtoul (argv[1], &ep, 0));
+ if (ep != 0 && *ep != 0)
+ {
+ error ("Exec_addr ?");
+ }
+ argv++;
+ argc--;
+ nseg = strtoul (argv[1], &ep, 0);
+ block0.boot.nosegs = order (nseg);
+ if (ep != 0 && *ep != 0)
+ {
+ error ("Number of Segments ?");
+ }
+ argv++;
+ argc--;
+ argv++;
+ argc--; /* Start from index 0 */
+ if (argc != (nseg * 2))
+ {
+ error ("Wrong number of arguments");
+ }
+ for (nseg = 0; (nseg * 2) < argc; nseg++)
+ {
+ block0.boot.lseg[nseg].base = (void *) order (strtoul (argv[nseg * 2], &ep, 0));
+ if (ep != 0 && *ep != 0)
+ {
+ error ("Base addr of Segment ?");
+ }
+ block0.boot.lseg[nseg].len = order (strtoul (argv[nseg * 2 + 1], &ep, 0));
+ if (ep != 0 && *ep != 0)
+ {
+ error ("Length of Segment ?");
+ }
+ }
+ fwrite((void *) &block0, sizeof(block0), 1, stdout);
+ fflush(stdout);
+// write (1, block0, sizeof (block0));
+
+ exit (0);
+}
diff --git a/packages/simpad-utilities/genboot/simpad-make-flashimg b/packages/simpad-utilities/genboot/simpad-make-flashimg
index e69de29bb2..e29de3f94f 100644..100755
--- a/packages/simpad-utilities/genboot/simpad-make-flashimg
+++ b/packages/simpad-utilities/genboot/simpad-make-flashimg
@@ -0,0 +1,89 @@
+#!/bin/sh
+# Script to build a full (kernel+initrd) flash rom bootimage
+# (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de>
+# Use serload to flash the image on your SIMpad
+
+#
+# vars
+#
+GENBOOT=genboot
+PAD=pad
+KERNEL=$2
+INITRD=$3
+
+doComplete()
+{
+ kernel=$(basename $KERNEL)
+ initrd=$INITRD
+ outfile=/tmp/tmpfile
+ padfile=/tmp/tmpfile2
+ flashfile=$kernel.initrd.flashfile
+
+ cp -f $KERNEL $padfile
+ $PAD 1048556 $padfile
+ cat $padfile $initrd >$outfile
+ set X`ls -l $outfile`
+ filelen=$5
+
+ loader_start="0xc0208000"
+ loader_entry="0xc0208000"
+
+ echo "File: $flashfile Exec: $loader_entry $filelen "
+ $GENBOOT -d3 $loader_entry 1 $loader_start $filelen >/tmp/bheader
+ cat /tmp/bheader $outfile >$flashfile
+ rm $outfile
+ rm $padfile
+ exit 0
+}
+
+doKernel()
+{
+ kernel=$(basename $KERNEL)
+ outfile=/tmp/tmpfile
+ flashfile=$kernel.flashfile
+
+ cat $KERNEL >$outfile
+ set X`ls -l $outfile`
+ filelen=$5
+
+ loader_start="0xc0208000"
+ loader_entry="0xc0208000"
+
+ echo "File: $flashfile Exec: $loader_entry $filelen "
+ $GENBOOT -d3 $loader_entry 1 $loader_start $filelen >/tmp/bheader
+ cat /tmp/bheader $outfile >$flashfile
+ rm $outfile
+ exit 0
+}
+
+doKernelInPlace()
+{
+ kernel=$(basename $KERNEL)
+ outfile=/tmp/tmpfile
+ flashfile=$kernel.flashfile
+
+ cat $KERNEL >$outfile
+ set X`ls -l $outfile`
+ filelen=$5
+
+ loader_start="0xc0080000"
+ loader_entry="0xc0080000"
+
+ echo "File: $flashfile Exec: $loader_entry $filelen "
+ $GENBOOT $loader_entry 1 $loader_start $filelen >/tmp/bheader
+ cat /tmp/bheader $outfile >$flashfile.inplace
+ rm $outfile
+ exit 0
+}
+
+if [ $# -lt 2 ]
+ then echo "Usage: ./simpad-make-flashimg [kernel|complete|inplace] <kernel> [rootfs.jffs2]" && exit -1
+fi
+
+case "$1" in
+kernel) doKernel;;
+complete) doComplete;;
+inplace) doKernelInPlace;;
+*) echo "Usage: ./simpad-make-flashimg [kernel|complete|inplace] <kernel> [rootfs.jffs2]"; exit;;
+esac
+