You are not logged in.
I'd like to upgrade my BIOS, but I no longer have the Asus script to automate this as I installed Mandriva Linux over the main partition (I still have the two small FAT partitions that the script presumably uses). Any chance someone could post it? I'm pretty au fait with Perl, so I can check whether it'll work with my new system before running it.
The file is: /usr/sbin/biosupdate.pl
If not, I guess I'll just have to reformat a USB stick and do it manually, as per the wiki...
Offline
here it is :
#!/usr/bin/perl
use strict;
use Getopt::Long;
my $wget = '/usr/bin/wget --quiet';
my $baseurl = 'http://update.eeepc.asus.com';
my $pathfile = '/bios/path.idx';
my $product = 'EeePC';
my %opt;
GetOptions (\%opt, "list", "install=s", "current") || exit 1;
if (!%opt) {
print "Arguments for this script:\n";
print " --list: lists available updates.\n";
print " --install <url>: installs BIOS update from provided URL.\n";
print " --current: returns the current installed version\n";
exit 0;
}
elsif (keys(%opt) > 1) {
print "Only one argument allowed.\n";
exit 1;
}
elsif (defined($opt{list})) {
my $file;
checkRoot();
# Get product name
my $partcode = getPartCode();
$file = "$baseurl/$pathfile";
print STDERR "Retrieving $file...\n";
(my @pathidx = `$wget -O- $file`) || exit 16;
my %products = readIdxPaths($file, \@pathidx);
#printHash(\%products);
$file = "$baseurl$products{$product}";
print STDERR "Retrieving $file...\n";
(my @platformidx = `$wget -O- $file`) || exit 16;
my %platform = readIdxPaths($file, \@platformidx);
#printHash(\%platform);
$file = "$baseurl$platform{$partcode}";
print STDERR "Retrieving $file...\n";
(my @partidx = `$wget -O- $file`) || exit 16;
my %part = readIdxVersions($file, \@partidx);
foreach my $key (keys(%part)) {
print $key . '|' . $part{$key}{release} . '|' .
$part{$key}{description} . '|' .
$baseurl . $part{$key}{path} . "\n";
}
}
elsif (defined($opt{install})) {
checkRoot();
my $partcode = getPartCode();
exit 7 if ($partcode eq '');
my $dir = `/bin/mktemp -d`;
chomp $dir;
chdir $dir;
system("$wget $opt{install}") && exit 16;
my $file = $opt{install};
$file =~ s/^.*\///;
if (system("/usr/bin/unzip -qq $file")) {
print STDERR "Corrupt ZIP file.\n";
exit 8;
}
my $rom = `find -name \*.[Rr][Oo][Mm] | head -n1`;
chomp $rom;
if ($rom eq '') {
print STDERR "Cannot find ROM file.\n";
exit 9;
}
mkdir ('mnt', 0755) || exit 10;
system("/bin/mount -L BIOS mnt") && exit 10;
system("/bin/cp $rom mnt/$partcode.rom") && exit 10;
system("/bin/umount mnt") && exit 10;
system("/bin/echo 0x030c > /proc/acpi/asus/hdps") && exit 10;
system("rm -fr $dir");
print STDERR "Success. Please reboot.\n";
}
elsif (defined($opt{current})) {
checkRoot();
my $version = `/usr/sbin/dmidecode -s bios-version`;
$version =~ s/^\s*(\d+)\s*$/$1/;
print "$version\n";
}
sub readIdxPaths {
my $file = shift;
my $raw = shift;
my %p;
my $pflag = 0;
my $product;
my $line = 0;
foreach(@$raw) {
$line++;
s/\r//;
chomp;
if (/^.*<product>\s*(.*\S)\s*$/) {
parseError($file, $line, 'Unexpected <product> tag.') if ($pflag);
$product = $1;
$pflag = 1;
}
elsif (/^.*<path>\s*(.*\S)\s*$/ && $pflag) {
$p{$product} = $1;
$p{$product} =~ s/\\/\//g;
$p{$product} =~ s/^(\w)/\/$1/;
}
elsif (/^.*<~product>/) {
parseError($file, $line, 'Unexpected <~product> tag.') if (!$pflag);
$pflag = 0;
}
}
parseError($file, $line, 'Unexpected EOF.') if ($pflag);
return %p;
}
sub readIdxVersions {
my $file = shift;
my $raw = shift;
my %p;
my $pflag = 0;
my $vflag = 0;
my $dflag = 0;
my $product;
my $version;
my $line = 0;
foreach(@$raw) {
$line++;
s/\r//;
chomp;
if (/^.*<product>\s*(.*\S)\s*$/) {
parseError($file, $line, 'Unexpected <product> tag.') if ($pflag);
$product = $1;
$pflag = 1;
}
elsif (/^.*<version>\s*(.*\S)\s*$/ && $pflag) {
parseError($file, $line, 'Unexpected <version> tag.') if ($vflag);
$version = $1;
$vflag = 1;
}
elsif (/^.*<release-date>\s*(.*\S)\s*$/ && $pflag && $vflag) {
$p{$version}{release} = $1;
}
elsif (/^.*<path>\s*(.*\S)\s*$/ && $pflag && $vflag) {
$p{$version}{path} = $1;
$p{$version}{path} =~ s/^(\w)/\/$1/;
}
elsif (/^.*<description>\s*(.*\S)\s*<~description>\s*$/ && $pflag && $vflag) {
$p{$version}{description} = $1;
}
elsif (/^.*<description>.*$/ && $pflag && $vflag) {
parseError($file, $line, 'Unexpected <description> tag.') if ($dflag);
$dflag = 1;
}
elsif (/^.*<~description>/) {
parseError($file, $line, 'Unexpected <~description> tag.') if (!$dflag);
$dflag = 0;
# Clean up the description
$p{$version}{description} =~ s/\\n$//;
$p{$version}{description} =~ s/\|/ /g;
}
elsif ($dflag && /^\s*(.*\S)\s*$/ && $pflag && $vflag) {
$p{$version}{description} .= $1 . '\n';
}
elsif (/^.*<~version>/) {
parseError($file, $line, 'Unexpected <~version> tag.') if (!$vflag);
$vflag = 0;
}
elsif (/^.*<~product>/) {
parseError($file, $line, 'Unexpected <~product> tag.') if (!$pflag);
$pflag = 0;
}
}
parseError($file, $line, 'Unexpected EOF.') if ($pflag || $vflag || $dflag);
return %p;
}
sub getPartCode {
my $partcode = `/usr/sbin/dmidecode -s baseboard-product-name`;
$partcode =~ s/^\s*(\S+)\s*$/$1/;
return $partcode;
}
sub printHash {
my $hash = shift;
print "================================================\n";
foreach my $key (keys(%$hash)) {
print $key . '=' . $$hash{$key} . "\n";
}
print "================================================\n";
}
sub checkRoot {
if ($< != 0) {
print "This option must be run as root user.\n";
exit 1;
}
}
sub parseError {
my $file = shift;
my $line = shift;
my $reason = shift;
print STDERR "Error parsing IDX file:\n";
print STDERR " $file\n";
print STDERR " Line: $line. $reason\n";
exit 32;
}Offline
Brilliant - thanks!
All went smoothly and now booting on the new BIOS, so hopefully it will be stable (I grabbed copy of 0501 off the Asus website just in case I need to roll it back).![]()
Offline