maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   front-end to flasher-3.5 (https://talk.maemo.org/showthread.php?t=66048)

Cue 2010-11-23 06:41

front-end to flasher-3.5
 
would anyone be interested in a simple shell script that automates and guides you through the N900 flashing process one step at a time? I've started already but I want to know if it's of any use to anybody before I continue. What I mean is it asks you simple questions like

Which firmware do you wish to flash?
1) 1.1
2) 1.2
3) 1.3

Select one of the available regional firmware for your selected PR version.
1) China
2) US
3) Global
...

Do you wish to delete all user data on the phone too?

are you sure?

then performs the rest for you.

so would anyone be interested in this? Also is it even possible to pull the relevant firmware with wget or is there no way without the agreement and IMEI input of the firmware images webpage?

Tiboric 2010-11-23 07:07

Re: front-end to flasher-3.5
 
can you not have an input for imei. and let the script send it to the site?

A front end is a very good idea. but don't forget a kernel only flash mode and way to select and flash a specific firmware file.

just give it enough options so its not just for the new guys.
and you'll have a winner. lol

Cue 2010-11-23 07:45

Re: front-end to flasher-3.5
 
That would be difficult to do, at least for me. I do not know any way to interact with a website from a simple shell script, is this even possible? I was thinking more along the lines of wget but the links on the website are php and I don't know how to deal with those to get the relevant files.

I was thinking it would be a good Idea to have it pass all the same optional arguments on to flasher-3.5; as well as the interactive mode I mentioned above if no optional arguments are given.

ossipena 2010-11-23 08:00

Re: front-end to flasher-3.5
 
Quote:

Originally Posted by Cue (Post 880858)
I don't know how to deal with those to get the relevant files.

and there probably is no way wgetting 'em either... so this looks pretty dead end if you want to have all the functionality within the script.

what about manually downloading every fw image to predefined folder and start from there with the script?

linuxeventually 2010-11-23 08:13

Re: front-end to flasher-3.5
 
You could use zenity for the GUI, it would be pretty easy actually with BASH. And yeah the firmware images are too big to be [forcing] using wget. The script should check which firmware *.bin files are in the current directory and from those create a list in zenity. Also it wouldn't be a bad idea to have a list of firmwares built-in to the script and their MD5 hashes and compare the MD5 hash before flashing.

As far as automated the download, people here won't be in agreement as it would technically be a violation of Nokia's EULA or whatever (you have to input a valid serial# for one). However, IMO that's isn't why it would be a bad idea to wget the firmware. It's a bad idea because the images are quite large and you'd need to have the script check how much disk space is available and where the user wants to save it and it gets complicated.

Cue 2010-11-23 08:20

Re: front-end to flasher-3.5
 
Quote:

Originally Posted by ossipena (Post 880863)
what about manually downloading every fw image to predefined folder and start from there with the script?

that certainly would work but it would make the initial download pretty huge in comparison.

Is the IMEI used in any way for the downloaded file? If not, I could for example provide an ftp mirror site. Are there any legal issues if I were to do such a thing?

EDIT: Just saw linuxeventually's reply. So I guess there are legal issues with it. I had planned to do an MD5Sum check with the md5sums file provided on the same site as the images.

Cue 2010-11-23 10:59

Re: front-end to flasher-3.5
 
Here is the script but do not run it. The functions that start with DL are called at places I would like to download a file from the servers.

P.S. linuxeventually, your PM box is full.

Code:

#!/bin/bash
# A front-end to flasher-3.5, to make flashing the N900 internet tablet easier.

flasherpkg="flasher-3.5"
flasherpkgfilename="flasher-3.5.deb"
PRVersions=test.cfg

isValidYesNo()
{
 case "$1" in
  "yes" | "Yes" | "y" | "Y" ) return 0;;
  "no" | "No" | "n" | "N" ) return 0;;
  "") if [ "$2" = "" ]; then return 1; else return 0; fi ;;
  *) return 1 ;;
 esac
}

isYes()
{
 while test true ; do
  read -p "$1 [y,n]:" input </dev/tty
  if isValidYesNo "$input" "$2" ; then break; fi
 done
 case "$input" in
  "yes" | "Yes" | "y" | "Y" ) return 0;;
  "no" | "No" | "n" | "N" ) return 1;;
  "") return $2;;
 esac
}

isInstalled()
{
if dpkg -s "$1" | grep "Status: install ok installed" ; then
 return 0
else
 return 1
fi
}


get_PR_list()
{
  config_file=$1
  awk -F '[][]' '
      NF==3 && $0 ~ /^\[.*\]/ { print $2 }
  ' ${config_file}
}

get_PR_vars()
{
  config_file=$1 #file name
  config=$2 #set name
  var_prefix=$3 #prefix variable with this
 
        awk -F= -v Config="${config}" -v Prefix="${var_prefix}" '
        BEGIN {
          Config = toupper(Config);
          patternConfig = "\\[" Config "]";
        }
        toupper($0)  ~ patternConfig,(/\[/ && toupper($0) !~ patternConfig)  {
          if (/\[/ || NF <2) next;
          sub(/^[[:space:]]*/, "");
          sub(/[[:space:]]*=[[:space:]]/, "=");
          print Prefix $0;
        } ' ${config_file}
}

OKmd5()
{
if md5sum -c MD5SUMS | grep "$1: OK"); then
 return 0
else
 return 1
fi
}

DLflasherpkgfile()
{
 wget $1
}

DLfirmwareimage()
{
 wget $1
}

DLeMMCimage()
DLImagemd5sums()

######################################################################

if isInstalled "$flasherpkg" ; then
 echo "$flasherpkg found"
else
 echo -e "\033[1;31m $flasherpkg has not been installed or is broken \033[0m"
 if isYes "Do you wish to install ${flasherpkg}?" ; then
  if [ ! -f "$flasherpkgfilename" ] ; then DLflasherpkgfile ; fi
  sudo dpkg -i "$flasherpkgfilename"
 else
  exit
 fi
fi

if [ $# -gt 1 ]; then
 shift
 echo -e "\033[1;34m flasher-3.5 $@ \033[0m"
 exit
fi

echo -e "\033[1;31m Flashing an older firmware than that found on your N900 can result in no 2G/3G and would require a reflash. \033[0m"

PS3="Select a number corresponding to the PR version you wish to flash (NOT the PR version number itself):"
select PRVersion in $(get_PR_list ${PRVersions}) ; do
 PS3="Select a region"
 select PRVar in $(get_PR_vars ${PRVersions} ${PRVersion}) ; do
  PRimagefilename=${PRVar#*=}
  break 2
 done
done

if isYes "Do you want to delete all user data too?" ; then
 flasheMMC=true
else
 flasheMMC=false
fi

emmcimagefilename="emmcImage.bin"

DLImagemd5sums
if [ flasheMMC == false ]; then
 if [ ! -f $PRimagefilename ]; then DLfirmwareimage; fi
 if OKmd5 $PRimagefilename ; then
  echo -e "\033[1;34m flasher-3.5 -F $PRImagefilename -f -R \033[0m"
 else
  echo -e "\033[1;31m Image file $PRImagefilename is corrupt \033[0m"
 fi
else
 if [ ! -f $PRimagefilename ]; then DLfirmwareimage; fi
 if [ ! -f $emmcimagefilename ]; then DLeMMCimage; fi
 if OKmd5 $PRimagefilename ; then
  if OKmd5 $emmcimagefilename ; then
  echo -e "\033[1;34m flasher-3.5 -F $PRImagefilename -f \033[0m"
  echo -e "\033[1;34m flasher-3.5 -F $emmcimagefilename -f -R \033[0m"
  else
  echo -e "\033[1;31m Image file $emmcimagefilename is corrupt \033[0m"
  fi
 else
  echo -e "\033[1;31m Image file $PRImagefilename is corrupt \033[0m"
 fi
fi


Cue 2010-11-23 18:59

Re: front-end to flasher-3.5
 
Just got back and fixed the script above but still cant automate the image downloads. was thinking of using perl and the WWW::Mechanize module but that would require the user to install it through cpanp which sort of defeats the purpose of the script, to make things easy.
Can anyone provide a simple script to fill in the requested info for the images site and download the file?

MohammadAG 2010-11-23 19:09

Re: front-end to flasher-3.5
 
Wouldn't it be better as a Qt app? That way you could run it on Windows, Linux, and Mac (I remember seeing a flasher for it) (and maybe on the N900 itself, I managed to get a device into flashing mode with hostmode, so flashing one N900 from another might be possible later on)

optimistprime 2010-11-23 19:09

Re: front-end to flasher-3.5
 
Yeah, alot of "regular" n900 users would appreciate this. Just looking over all of the "how do i flash" threads, this is something that would benefit the community greatly. I hate to say it, but the way Itunes handles the iphone restoring process is a dream. A more attractive, automated process could be just what the n900 needs. Especially when alot more n900's start hitting ebay when the N9 debuts. Alot of people are going to get their hands on n900's for the first time, with a need to flash( alot).


All times are GMT. The time now is 06:32.

vBulletin® Version 3.8.8