Auto-flash AMD/ATI video card firmware

From lurkmore wiki
Jump to navigationJump to search

This page contains a PHP script for auto-flashing an AMD (ATI) video card's (GPU) firmware using a simple command line through Linux:

<?php

//created by ugtarmas 
	//if this is useful, donate to LRv8b23mQSZah7bg16n7tjT5RVDnZtMi4Z
	//you must download atiflash from http://liteshack.com/files/atiflash and put into /usr/local/bin/ dir
	//or try your luck here: https://www.google.com/search?q=atiflash+for+linux

//usage:
	//php flash.php /path/to/bios.rom 035
	//this will flash /path/to/bios.rom gpu 0, 3 and 5.

$path_to_rom = $argv[1];
$gpu_count = $argv[2];

$gpu_array = str_split($gpu_count);

foreach($gpu_array as $gpu){
	if(is_numeric($gpu)){
		$gpus[] = $gpu;
	}
}

$gpu_string = implode(",",$gpus);
$count = count($gpus);

if($count < 1){ exit ("\nyou need to specify the gpus that you want to flash\n\n"); }
if(!file_exists($path_to_rom)){ exit("\nthe file $path_to_rom does not exist\n\n"); }

echo "\nattempting to flash $path_to_rom to gpus $gpu_string:\n\n";

foreach($gpus as $gpu){ 

	`atiflash -s $gpu /tmp/flash_$gpu.rom`;
	echo "backed up gpu $gpu bios to /tmp/flash_$gpu.rom...\n";

	`atiflash -unlockrom $gpu`;
	echo "unlocked rom on gpu $gpu, flashing bios...\n";

	while(true){

        	`atiflash -f -p $gpu $path_to_rom > /tmp/flash_$gpu`;

	        $result = file_get_contents("/tmp/flash_$gpu");

	        if(eregi("Restart",$result)) { echo " done flashing gpu $gpu\n"; break;}
	
	        echo "|";

	        }
}

echo "You may now save any flash_* backups from /tmp, because anything in /tmp gets deleted upon reboot.\n"
?>