diff options
Diffstat (limited to 'scripts/mkknlimg')
-rwxr-xr-x | scripts/mkknlimg | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/scripts/mkknlimg b/scripts/mkknlimg index cfd76d569..3dff94899 100755 --- a/scripts/mkknlimg +++ b/scripts/mkknlimg @@ -1,6 +1,16 @@ #!/usr/bin/env perl +# ---------------------------------------------------------------------- +# mkknlimg by Phil Elwell for Raspberry Pi +# based on extract-ikconfig by Dick Streefland +# +# (c) 2009,2010 Dick Streefland <dick@streefland.net> +# (c) 2014,2015 Raspberry Pi (Trading) Limited <info@raspberrypi.org> +# +# Licensed under the terms of the GNU General Public License. +# ---------------------------------------------------------------------- use strict; +use warnings; use integer; my $trailer_magic = 'RPTL'; @@ -9,14 +19,19 @@ my $tmpfile1 = "/tmp/mkknlimg_$$.1"; my $tmpfile2 = "/tmp/mkknlimg_$$.2"; my $dtok = 0; +my $is_283x = 0; -while ($ARGV[0] =~ /^-/) +while (@ARGV && ($ARGV[0] =~ /^-/)) { my $arg = shift(@ARGV); if ($arg eq '--dtok') { $dtok = 1; } + elsif ($arg eq '--283x') + { + $is_283x = 1; + } else { print ("* Unknown option '$arg'\n"); @@ -37,15 +52,18 @@ if (! -r $kernel_file) my @wanted_config_lines = ( - 'CONFIG_BCM2708_DT' + 'CONFIG_BCM2708_DT', + 'CONFIG_ARCH_BCM2835' ); my @wanted_strings = ( 'bcm2708_fb', + 'brcm,bcm2835-mmc', + 'brcm,bcm2835-sdhost', 'brcm,bcm2708-pinctrl', 'brcm,bcm2835-gpio', - 'of_find_property' + 'brcm,bcm2835-pm-wdt' ); my $res = try_extract($kernel_file, $tmpfile1); @@ -64,21 +82,28 @@ $res = try_decompress('\002\041\114\030', 'xy', 'lz4 -d', 1, my $append_trailer; my $trailer; +my $kver = '?'; $append_trailer = $dtok; if ($res) { - print("Version: $res->{''}\n"); + $kver = $res->{''} || '?'; + print("Version: $kver\n"); $append_trailer = $dtok; if (!$dtok) { - if (config_bool($res, 'bcm2708_fb')) + if (config_bool($res, 'bcm2708_fb') || + config_bool($res, 'brcm,bcm2835-mmc') || + config_bool($res, 'brcm,bcm2835-sdhost')) { $dtok ||= config_bool($res, 'CONFIG_BCM2708_DT'); + $dtok ||= config_bool($res, 'CONFIG_ARCH_BCM2835'); $dtok ||= config_bool($res, 'brcm,bcm2708-pinctrl'); $dtok ||= config_bool($res, 'brcm,bcm2835-gpio'); + $is_283x ||= config_bool($res, 'CONFIG_ARCH_BCM2835'); + $is_283x ||= config_bool($res, 'brcm,bcm2835-pm-wdt'); $append_trailer = 1; } else @@ -95,12 +120,14 @@ elsif (!$dtok) if ($append_trailer) { printf("DT: %s\n", $dtok ? "y" : "n"); + printf("283x: %s\n", $is_283x ? "y" : "n"); my @atoms; push @atoms, [ $trailer_magic, pack('V', 0) ]; - push @atoms, [ 'KVer', $res->{''} ]; + push @atoms, [ 'KVer', $kver ]; push @atoms, [ 'DTOK', pack('V', $dtok) ]; + push @atoms, [ '283x', pack('V', $is_283x) ]; $trailer = pack_trailer(\@atoms); $atoms[0]->[1] = pack('V', length($trailer)); @@ -154,7 +181,7 @@ END { sub usage { - print ("Usage: mkknlimg [--dtok] <vmlinux|zImage|bzImage> <outfile>\n"); + print ("Usage: mkknlimg [--dtok] [--283x] <vmlinux|zImage|bzImage> <outfile>\n"); exit(1); } @@ -216,6 +243,7 @@ sub try_decompress { chomp($pos); $pos = (split(/[\r\n]+/, $pos))[$idx]; + return undef if (!defined($pos)); $pos =~ s/:.*[\r\n]*$//s; my $cmd = "tail -c+$pos \"$knl\" | $zcat > $tmp2 2> /dev/null"; my $err = (system($cmd) >> 8); @@ -242,5 +270,6 @@ sub pack_trailer sub config_bool { my ($configs, $wanted) = @_; - return (($configs->{$wanted} eq 'y') || ($configs->{$wanted} eq '1')); + my $val = $configs->{$wanted} || 'n'; + return (($val eq 'y') || ($val eq '1')); } |