Skip to content

Commit

Permalink
mkuboot: produce raw binaries if requested
Browse files Browse the repository at this point in the history
mkuboot generates images bootable in u-boot.  These images
contain a header and the actual kernel object code.

This program was improved so it can embed kernel symbols
and the ramdisk into the generated image, like a bootloader
would do when booting from an actual ELF kernel.

Sometimes having a blob with ksyms+ramdisk _without_ the
image header for u-boot can be useful.  This change add
a flag 'r' which indicates that it should output the binary
in raw mode, without the u-boot headers.

"sounds fine then." drahn@
  • Loading branch information
bluerise committed Feb 11, 2015
1 parent 0e45598 commit 18d548b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions usr.sbin/mkuboot/mkuboot.8
Expand Up @@ -27,6 +27,7 @@
.Op Fl l Ar loadaddr
.Op Fl n Ar name
.Op Fl o Ar os
.Op Fl r
.Op Fl t Ar type
.Ar infile outfile
.Sh DESCRIPTION
Expand Down Expand Up @@ -56,6 +57,8 @@ can be either
.Dq Linux
or
.Dq OpenBSD .
.It Fl r
Produce a raw binary instead of a U-Boot image.
.It Fl t Ar type
Sets the type of the object to be loaded.
For a list of valid arguments, see below.
Expand Down
11 changes: 7 additions & 4 deletions usr.sbin/mkuboot/mkuboot.c
Expand Up @@ -144,17 +144,20 @@ main(int argc, char *argv[])
const char *os = "OpenBSD";
const char *type = "kernel";
const char *imgname = "boot";
int ifd, ofd;
int ifd, ofd, raw = 0;
uint32_t fsize;
u_long crc;
int c, ep, load;

ep = load = 0;
while ((c = getopt(argc, argv, "a:e:l:n:o:t:")) != -1) {
while ((c = getopt(argc, argv, "a:e:l:n:o:rt:")) != -1) {
switch (c) {
case 'a':
arch = optarg;
break;
case 'r':
raw = 1;
break;
case 'e':
sscanf(optarg, "0x%x", &ep);
break;
Expand Down Expand Up @@ -233,7 +236,7 @@ main(int argc, char *argv[])
}

/* Write initial header. */
if (write(ofd, &ih, sizeof ih) != sizeof ih)
if (!raw && write(ofd, &ih, sizeof ih) != sizeof ih)
err(1, "%s", oname);

/* Write data, calculating the data CRC as we go. */
Expand Down Expand Up @@ -270,7 +273,7 @@ main(int argc, char *argv[])
/* Write finalized header. */
if (lseek(ofd, 0, SEEK_SET) != 0)
err(1, "%s", oname);
if (write(ofd, &ih, sizeof ih) != sizeof ih)
if (!raw && write(ofd, &ih, sizeof ih) != sizeof ih)
err(1, "%s", oname);

return(0);
Expand Down

0 comments on commit 18d548b

Please sign in to comment.