Re: A little zenity-gui for flashing images to the neo

2008-09-08 Thread Dale Maggee

Charles Pax wrote:

On Sun, Sep 7, 2008 at 6:34 PM, Joel Newkirk [EMAIL PROTECTED] wrote:

  

Sounds like you did a cut'n'paste from email.  The problem is that long
lines are wrapped, which breaks programs/scripts.  There's at least three
places in the script that suffer from word-wrap, including several lines
that start at line 66.




Yup, did a cut n' paste. I tried the attachment and it worked just fine.
Maybe a future version can offer to fetch dfu-util. Thanks for the help.

-Charles
  

Nice suggestion! Done!

-Dale
#!/bin/bash
# dfu-util Image-Flashing Gui 0.2

function check_dfu {

if [ ! -x $dfutils_path ]; then
#look in current folder...
if [ -x './dfu-util' ]; then
dfutils_path='./dfu-util'
else
zenity --question --text The dfu utility could not be 
found at $dfutils_path, or is not exceutable. Do you want to automagically 
download it from downloads.openmoko.org?
if [ $? = 0 ]; then
rm ./dfu-util  /dev/null
wget 
http://downloads.openmoko.org/daily/dfu-util
chmod a+x ./dfu-util /dev/null
dfutils_path='./dfu-util'
else
dfutils_path=$(zenity --file-selection 
--title=Locate the dfu-util executable: --filename=$dfutils_path)
fi

if [ -z $dfutils_path ]; then
echo Cancelled!
exit
fi
#check selection...
check_dfu
fi
fi
}

function perform_flash {
# $1 - what we're flashing (for display)
# $2 - dfu-params
# $3 - file to flash

echo
echo *** Flashing $1 with $3 ...
echo

$dfutils_path $2 $3 2 $tmp_error_log_path
# add the following line to the previous line to get back the zenity 
progress dialog:
# | zenity --progress --pulsate --percentage=0 --title Flashing in 
progress.. --auto-close

if [ ${PIPESTATUS[0]} != 0 ];then
zenity --error --text Some error occured while flashing 
$1.\n\nError message:\n`cat $tmp_error_log_path`
exit
else
#sleep to allow dfu to reset...
sleep 2
fi
}

dfutils_path='/usr/local/bin/dfu-util'

check_dfu

tmp_error_log_path='/tmp/flash-error-log'

ans=$(zenity  --list --text What do you wanna flash? --title dfu-util gui 
--checklist --column Pick --column Option TRUE Root-Filesystem TRUE Kernel 
FALSE Bootloader)

if [ -z $ans ]; then
#handle cancel / no selection...
echo Nothing to do!
exit
fi

txt=The flashing will now start.\n\nMake sure your Neo is connected to the 
USB-Device and booted into the Nor (for kernel and rootfs) or Nand (for u-boot) 
screen before proceeding.\nRemember that flashing a large image like a rootfs 
will take some time so don't abort it.\n\n

if [ -n `echo $ans | grep Root-Filesystem` ];then
du_param_r='-a rootfs -R -D'
rootfs=True
img_file_r=$(zenity --file-selection --title=Select an image-file for 
the ROOTFS:)
if [ $img_file_r =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing rootfs with $img_file_r \n\n
fi

if [ -n `echo $ans | grep Kernel` ];then
du_param_k='-a kernel -R -D'
kernel=True
img_file_k=$(zenity --file-selection --title=Select an image-file for 
the KERNEL:)
if [ $img_file_k =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing kernel with $img_file_k \n\n
fi

if [ -n ` echo $ans | grep Bootloader` ];then
du_param_u='-a u-boot -R -D'
uboot=True
img_file_u=$(zenity --file-selection --title=Select an image-file for 
UBOOT:)
if [ $img_file_u =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing uboot with $img_file_u \n\n
fi

touch $tmp_error_log_path

zenity --info --text $txt

if [ $rootfs = True ]; then
perform_flash rootfs $du_param_r $img_file_r
fi

if [ $kernel = True ]; then
perform_flash kernel $du_param_k $img_file_k
fi

if [ $uboot = True ]; then
perform_flash uboot $du_param_u $img_file_u
fi

rm $tmp_error_log_path
exit 0

___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: A little zenity-gui for flashing images to the neo

2008-09-08 Thread Daniel Hedblom
Nice work,

I used the dfu-util from debian Lenny that gets installed in /usr/bin
instead of /usr/local/bin. Anyone that has a nice way of checking the
users paths for a specific app?

//danielh

2008/9/8 Dale Maggee [EMAIL PROTECTED]:
 Charles Pax wrote:

 On Sun, Sep 7, 2008 at 6:34 PM, Joel Newkirk [EMAIL PROTECTED]
 wrote:



 Sounds like you did a cut'n'paste from email.  The problem is that long
 lines are wrapped, which breaks programs/scripts.  There's at least three
 places in the script that suffer from word-wrap, including several lines
 that start at line 66.



 Yup, did a cut n' paste. I tried the attachment and it worked just fine.
 Maybe a future version can offer to fetch dfu-util. Thanks for the help.

 -Charles


 Nice suggestion! Done!

 -Dale

 #!/bin/bash
 # dfu-util Image-Flashing Gui 0.2

 function check_dfu {

if [ ! -x $dfutils_path ]; then
#look in current folder...
if [ -x './dfu-util' ]; then
dfutils_path='./dfu-util'
else
zenity --question --text The dfu utility could not
 be found at $dfutils_path, or is not exceutable. Do you want to
 automagically download it from downloads.openmoko.org?
if [ $? = 0 ]; then
rm ./dfu-util  /dev/null
wget
 http://downloads.openmoko.org/daily/dfu-util
chmod a+x ./dfu-util /dev/null
dfutils_path='./dfu-util'
else
dfutils_path=$(zenity --file-selection
 --title=Locate the dfu-util executable: --filename=$dfutils_path)
fi

if [ -z $dfutils_path ]; then
echo Cancelled!
exit
fi
#check selection...
check_dfu
fi
fi
 }

 function perform_flash {
# $1 - what we're flashing (for display)
# $2 - dfu-params
# $3 - file to flash

echo
echo *** Flashing $1 with $3 ...
echo

$dfutils_path $2 $3 2 $tmp_error_log_path
# add the following line to the previous line to get back the zenity
 progress dialog:
# | zenity --progress --pulsate --percentage=0 --title Flashing in
 progress.. --auto-close

if [ ${PIPESTATUS[0]} != 0 ];then
zenity --error --text Some error occured while flashing
 $1.\n\nError message:\n`cat $tmp_error_log_path`
exit
else
#sleep to allow dfu to reset...
sleep 2
fi
 }

 dfutils_path='/usr/local/bin/dfu-util'

 check_dfu

 tmp_error_log_path='/tmp/flash-error-log'

 ans=$(zenity  --list --text What do you wanna flash? --title dfu-util
 gui --checklist --column Pick --column Option TRUE Root-Filesystem TRUE
 Kernel FALSE Bootloader)

 if [ -z $ans ]; then
#handle cancel / no selection...
echo Nothing to do!
exit
 fi

 txt=The flashing will now start.\n\nMake sure your Neo is connected to the
 USB-Device and booted into the Nor (for kernel and rootfs) or Nand (for
 u-boot) screen before proceeding.\nRemember that flashing a large image like
 a rootfs will take some time so don't abort it.\n\n

 if [ -n `echo $ans | grep Root-Filesystem` ];then
du_param_r='-a rootfs -R -D'
rootfs=True
img_file_r=$(zenity --file-selection --title=Select an image-file
 for the ROOTFS:)
if [ $img_file_r =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing rootfs with $img_file_r \n\n
 fi

 if [ -n `echo $ans | grep Kernel` ];then
du_param_k='-a kernel -R -D'
kernel=True
img_file_k=$(zenity --file-selection --title=Select an image-file
 for the KERNEL:)
if [ $img_file_k =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing kernel with $img_file_k \n\n
 fi

 if [ -n ` echo $ans | grep Bootloader` ];then
du_param_u='-a u-boot -R -D'
uboot=True
img_file_u=$(zenity --file-selection --title=Select an image-file
 for UBOOT:)
if [ $img_file_u =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing uboot with $img_file_u \n\n
 fi

 touch $tmp_error_log_path

 zenity --info --text $txt

 if [ $rootfs = True ]; then
perform_flash rootfs $du_param_r $img_file_r
 fi

 if [ $kernel = True ]; then
perform_flash kernel $du_param_k $img_file_k
 fi

 if [ $uboot = True ]; then
perform_flash uboot $du_param_u $img_file_u
 fi

 rm $tmp_error_log_path
 exit 0


 ___
 Openmoko community mailing list
 community@lists.openmoko.org
 http://lists.openmoko.org/mailman/listinfo/community




Re: A little zenity-gui for flashing images to the neo

2008-09-08 Thread David Samblas
#which command_here 
will return the full path of the command.
example: 
#which which
/usr/bin/which  
El lun, 08-09-2008 a las 08:59 +0200, Daniel Hedblom escribió:
 Nice work,
 
 I used the dfu-util from debian Lenny that gets installed in /usr/bin
 instead of /usr/local/bin. Anyone that has a nice way of checking the
 users paths for a specific app?
 
 //danielh
 
 2008/9/8 Dale Maggee [EMAIL PROTECTED]:
  Charles Pax wrote:
 
  On Sun, Sep 7, 2008 at 6:34 PM, Joel Newkirk [EMAIL PROTECTED]
  wrote:
 
 
 
  Sounds like you did a cut'n'paste from email.  The problem is that long
  lines are wrapped, which breaks programs/scripts.  There's at least three
  places in the script that suffer from word-wrap, including several lines
  that start at line 66.
 
 
 
  Yup, did a cut n' paste. I tried the attachment and it worked just fine.
  Maybe a future version can offer to fetch dfu-util. Thanks for the help.
 
  -Charles
 
 
  Nice suggestion! Done!
 
  -Dale
 
  #!/bin/bash
  # dfu-util Image-Flashing Gui 0.2
 
  function check_dfu {
 
 if [ ! -x $dfutils_path ]; then
 #look in current folder...
 if [ -x './dfu-util' ]; then
 dfutils_path='./dfu-util'
 else
 zenity --question --text The dfu utility could not
  be found at $dfutils_path, or is not exceutable. Do you want to
  automagically download it from downloads.openmoko.org?
 if [ $? = 0 ]; then
 rm ./dfu-util  /dev/null
 wget
  http://downloads.openmoko.org/daily/dfu-util
 chmod a+x ./dfu-util /dev/null
 dfutils_path='./dfu-util'
 else
 dfutils_path=$(zenity --file-selection
  --title=Locate the dfu-util executable: --filename=$dfutils_path)
 fi
 
 if [ -z $dfutils_path ]; then
 echo Cancelled!
 exit
 fi
 #check selection...
 check_dfu
 fi
 fi
  }
 
  function perform_flash {
 # $1 - what we're flashing (for display)
 # $2 - dfu-params
 # $3 - file to flash
 
 echo
 echo *** Flashing $1 with $3 ...
 echo
 
 $dfutils_path $2 $3 2 $tmp_error_log_path
 # add the following line to the previous line to get back the zenity
  progress dialog:
 # | zenity --progress --pulsate --percentage=0 --title Flashing in
  progress.. --auto-close
 
 if [ ${PIPESTATUS[0]} != 0 ];then
 zenity --error --text Some error occured while flashing
  $1.\n\nError message:\n`cat $tmp_error_log_path`
 exit
 else
 #sleep to allow dfu to reset...
 sleep 2
 fi
  }
 
  dfutils_path='/usr/local/bin/dfu-util'
 
  check_dfu
 
  tmp_error_log_path='/tmp/flash-error-log'
 
  ans=$(zenity  --list --text What do you wanna flash? --title dfu-util
  gui --checklist --column Pick --column Option TRUE Root-Filesystem TRUE
  Kernel FALSE Bootloader)
 
  if [ -z $ans ]; then
 #handle cancel / no selection...
 echo Nothing to do!
 exit
  fi
 
  txt=The flashing will now start.\n\nMake sure your Neo is connected to the
  USB-Device and booted into the Nor (for kernel and rootfs) or Nand (for
  u-boot) screen before proceeding.\nRemember that flashing a large image like
  a rootfs will take some time so don't abort it.\n\n
 
  if [ -n `echo $ans | grep Root-Filesystem` ];then
 du_param_r='-a rootfs -R -D'
 rootfs=True
 img_file_r=$(zenity --file-selection --title=Select an image-file
  for the ROOTFS:)
 if [ $img_file_r =  ]; then
 echo Cancelled!
 exit
 fi
 txt=$txt - Flashing rootfs with $img_file_r \n\n
  fi
 
  if [ -n `echo $ans | grep Kernel` ];then
 du_param_k='-a kernel -R -D'
 kernel=True
 img_file_k=$(zenity --file-selection --title=Select an image-file
  for the KERNEL:)
 if [ $img_file_k =  ]; then
 echo Cancelled!
 exit
 fi
 txt=$txt - Flashing kernel with $img_file_k \n\n
  fi
 
  if [ -n ` echo $ans | grep Bootloader` ];then
 du_param_u='-a u-boot -R -D'
 uboot=True
 img_file_u=$(zenity --file-selection --title=Select an image-file
  for UBOOT:)
 if [ $img_file_u =  ]; then
 echo Cancelled!
 exit
 fi
 txt=$txt - Flashing uboot with $img_file_u \n\n
  fi
 
  touch $tmp_error_log_path
 
  zenity --info --text $txt
 
  if [ $rootfs = True ]; then
 perform_flash rootfs $du_param_r $img_file_r
  fi
 
  if [ $kernel = True ]; then
 perform_flash 

Re: A little zenity-gui for flashing images to the neo

2008-09-08 Thread Dale Maggee
Minh Ha Duong wrote:
 Hi,

 According to this mail:
   http://lists.openmoko.org/pipermail/devel/2008-September/001726.html
 the boot image is flasheable too, and the next upgrade will upgrade it.
 Does this look like something that zenity-gui could do ?
   
Yes, it is. I'll update the script sometime soon and re-post it.
 I can't find a  zenity  page on the wiki, do you want me to start one ?
   
I don't really think this is appropriate - zenity is the tool which 
allows me to use gtk dialog boxes from within a shell script, it doesn't 
really have anything to do with openmoko or the FreeRunner. More info at 
[1].

if you're talking about adding this script to the wiki, then yes, it 
should be in the wiki, but it would more properly belong in [2]

The reason I haven't wikified it yet is that I'm not finished playing 
with it. here are my plans:
- making use of the 'which' command to locate dfu-util as suggested by 
david samblas
- checking that it's being run as root
- add support for flashing 'splash'

slightly longer-term:
- use dialog instead of zenity (all text output for more consistent 
look, faster, more flexible)
- use a settings file to save the location of dfu-util
- I've also written a script to backup the freerunner using this method 
[3]. I'm planning on integrating these two scripts into a nice 
menu-driven uberscript for both backup and flashing

[1] http://www.linuxmanpages.com/man1/zenity.1.php
[2] http://wiki.openmoko.org/wiki/Flashing_the_Neo_FreeRunner
[3] 
http://wiki.openmoko.org/wiki/Pre-Flash_Backup#Backing-up_flash_images_.28alternative.29

-Dale

___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: A little zenity-gui for flashing images to the neo

2008-09-07 Thread Dale Maggee
Rorschach wrote:
 Hi,
 I was bored and just wrote a little zenity-gui for flashing images to the 
 neo: http://paste.ubuntuusers.de/391300/ .

 For the zenity-gui you need of course zenity and a bash-shell. To make the 
 progress-bar work you need to patch dfu-util:
   
Hi,

I was more bored and wanted to exercise my scripting skillz, so I made 
some changes to this script.

new stuff:

- ability to flash more than one image at once - the 'what do you wanna 
flash' now has checkboxes instead of radio buttons, and all your 
selections are flashed one after the other. (which i find very handy, 
stops the FR powering down while you're typing the next dfu-util 
command, or locating the next image - works great for flashing a new 
distro  kernel). if an error occurs, subsequent files will not be flashed.

- more confirmation / idiot-proofing - it now tells you what you're 
doing much more clearly (i.e: about to flash Kernel with /foo/bar.bin, 
rootfs with /foo/bar.jffs. allows you to confirm that you chose the 
right images). also the 'choose file' dialogs tell you what you're 
browsing for

- ability for users to press 'cancel' at the various dialogs and exit 
gracefully.

- checks that dfu-util exists and is executable. I moved my dfu-util to 
/usr/local/bin, so it looks there first, but it will also check the 
current directory and prompt if it can't find it

- I wasn't a fan of patching dfu-util, and the pulsating zenity progress 
dialog drags my (prehistoric) PC to a crawl, so I disabled the progress 
bar and use the text output of dfu-util instead.

hope somebody finds it usefull, enjoy!

-Dale

---BEGIN---

#!/bin/bash
# dfu-util Image-Flashing Gui 0.2

function check_dfu {

if [ ! -x $dfutils_path ]; then
#look in current folder...
if [ -x './dfu-util' ]; then
dfutils_path='./dfu-util'
else
zenity --info --text The dfu utility could not 
be found at $dfutils_path, or is not exceutable. Please point me to the 
dfu-util...
dfutils_path=$(zenity --file-selection 
--title=Select the dfu-util executable: --filename=$dfutils_path)
if [ -z $dfutils_path ]; then
echo Cancelled!
exit
fi
#check selection...
check_dfu
fi
fi
}

function perform_flash {
# $1 - what we're flashing (for display)
# $2 - dfu-params
# $3 - file to flash

echo
echo *** Flashing $1 with $3 ...
echo

$dfutils_path $2 $3 2 $tmp_error_log_path
# add the following line to the previous line to get back the 
zenity progress dialog:
# | zenity --progress --pulsate --percentage=0 --title Flashing 
$1 in progress.. --auto-close
if [ ${PIPESTATUS[0]} != 0 ];then
zenity --error --text Some error occured while flashing 
$1.\n\nError message:\n`cat $tmp_error_log_path`
exit
else
#sleep to allow dfu to reset...
sleep 2
fi
}

dfutils_path='/usr/local/bin/dfu-util'

check_dfu

tmp_error_log_path='/tmp/flash-error-log'

ans=$(zenity  --list --text What do you wanna flash? --title dfu-util 
gui --checklist --column Pick --column Option TRUE Root-Filesystem 
TRUE Kernel FALSE Bootloader)

if [ -z $ans ]; then
#handle cancel / no selection...
echo Nothing to do!
exit
fi

txt=The flashing will now start.\n\nMake sure your Neo is connected to 
the USB-Device and booted into the Nor (for kernel and rootfs) or Nand 
(for u-boot) screen before proceeding.\nRemember that flashing a large 
image like a rootfs will take some time so don't abort it.\n\n

if [ -n `echo $ans | grep Root-Filesystem` ];then
du_param_r='-a rootfs -R -D'
rootfs=True
img_file_r=$(zenity --file-selection --title=Select an 
image-file for the ROOTFS:)
if [ $img_file_r =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing rootfs with $img_file_r \n\n
fi

if [ -n `echo $ans | grep Kernel` ];then
du_param_k='-a kernel -R -D'
kernel=True
img_file_k=$(zenity --file-selection --title=Select an 
image-file for the KERNEL:)
if [ $img_file_k =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing kernel with $img_file_k \n\n
fi

if [ -n ` echo $ans | grep Bootloader` ];then
du_param_u='-a u-boot -R -D'
uboot=True
img_file_u=$(zenity --file-selection --title=Select an 
image-file for UBOOT:)
if [ $img_file_u =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing uboot with $img_file_u \n\n
fi

touch $tmp_error_log_path

zenity --info --text $txt

if [ $rootfs = True ]; then
   

Re: A little zenity-gui for flashing images to the neo

2008-09-07 Thread Charles Pax
On Sun, Sep 7, 2008 at 1:19 PM, Dale Maggee [EMAIL PROTECTED]wrote:

 I was more bored and wanted to exercise my scripting skillz, so I made
 some changes to this script.

 I saved your code into a file called flasher and make it executable. I
get the following error.

./flasher: line 67: syntax error near unexpected token `('
./flasher: line 67: `the USB-Device and booted into the Nor (for kernel and
rootfs) or Nand'

-Charles
___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: A little zenity-gui for flashing images to the neo

2008-09-07 Thread Joel Newkirk
On Sun, 7 Sep 2008 14:50:20 -0400, Charles Pax [EMAIL PROTECTED]
wrote:
 On Sun, Sep 7, 2008 at 1:19 PM, Dale Maggee
 [EMAIL PROTECTED]wrote:
 
 I was more bored and wanted to exercise my scripting skillz, so I made
 some changes to this script.

 I saved your code into a file called flasher and make it executable. I
 get the following error.
 
 ./flasher: line 67: syntax error near unexpected token `('
 ./flasher: line 67: `the USB-Device and booted into the Nor (for kernel
 and
 rootfs) or Nand'
 
 -Charles

Sounds like you did a cut'n'paste from email.  The problem is that long
lines are wrapped, which breaks programs/scripts.  There's at least three
places in the script that suffer from word-wrap, including several lines
that start at line 66.

Something like a bash script really MUST be sent as an attachment, to
ensure this breakage doesn't happen.  Meanwhile you can go through the
script and removed the extra newlines, so that echo statements and comments
(the things I noted glancing at the script) are not wrapped.

j



___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: A little zenity-gui for flashing images to the neo

2008-09-07 Thread Joel Newkirk
On Sun, 7 Sep 2008 14:50:20 -0400, Charles Pax [EMAIL PROTECTED]
wrote:
 On Sun, Sep 7, 2008 at 1:19 PM, Dale Maggee
 [EMAIL PROTECTED]wrote:
 
 I was more bored and wanted to exercise my scripting skillz, so I made
 some changes to this script.

 I saved your code into a file called flasher and make it executable. I
 get the following error.
 
 ./flasher: line 67: syntax error near unexpected token `('
 ./flasher: line 67: `the USB-Device and booted into the Nor (for kernel
 and
 rootfs) or Nand'
 
 -Charles

Woops, please replace 'echo' with 'zenity' in my previous post - I was
thinking 'output' and just type 'echo' without thinking further.

j



___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: A little zenity-gui for flashing images to the neo

2008-09-07 Thread Dale Maggee

Joel Newkirk wrote:

On Sun, 7 Sep 2008 14:50:20 -0400, Charles Pax [EMAIL PROTECTED]
wrote:
  

On Sun, Sep 7, 2008 at 1:19 PM, Dale Maggee
[EMAIL PROTECTED]wrote:



I was more bored and wanted to exercise my scripting skillz, so I made
some changes to this script.

I saved your code into a file called flasher and make it executable. I
  

get the following error.

./flasher: line 67: syntax error near unexpected token `('
./flasher: line 67: `the USB-Device and booted into the Nor (for kernel
and
rootfs) or Nand'

-Charles


Something like a bash script really MUST be sent as an attachment, to
ensure this breakage doesn't happen.  Meanwhile you can go through the
script and removed the extra newlines, so that echo statements and comments
(the things I noted glancing at the script) are not wrapped.

j


  

aah, damn word wrap!

here it is as an attachment, hope they're allowed.

-Dale

#!/bin/bash
# dfu-util Image-Flashing Gui 0.2

function check_dfu {

if [ ! -x $dfutils_path ]; then
#look in current folder...
if [ -x './dfu-util' ]; then
dfutils_path='./dfu-util'
else
zenity --info --text The dfu utility could not be 
found at $dfutils_path, or is not exceutable. Please point me to the 
dfu-util...
dfutils_path=$(zenity --file-selection --title=Select 
the dfu-util executable: --filename=$dfutils_path)
if [ -z $dfutils_path ]; then
echo Cancelled!
exit
fi
#check selection...
check_dfu
fi
fi
}

function perform_flash {
# $1 - what we're flashing (for display)
# $2 - dfu-params
# $3 - file to flash

echo
echo *** Flashing $1 with $3 ...
echo

$dfutils_path $2 $3 2 $tmp_error_log_path
# add the following line to the previous line to get back the zenity 
progress dialog:
# | zenity --progress --pulsate --percentage=0 --title Flashing in 
progress.. --auto-close

if [ ${PIPESTATUS[0]} != 0 ];then
zenity --error --text Some error occured while flashing 
$1.\n\nError message:\n`cat $tmp_error_log_path`
exit
else
#sleep to allow dfu to reset...
sleep 2
fi
}

dfutils_path='/usr/local/bin/dfu-util'

check_dfu

tmp_error_log_path='/tmp/flash-error-log'

ans=$(zenity  --list --text What do you wanna flash? --title dfu-util gui 
--checklist --column Pick --column Option TRUE Root-Filesystem TRUE Kernel 
FALSE Bootloader)

if [ -z $ans ]; then
#handle cancel / no selection...
echo Nothing to do!
exit
fi

txt=The flashing will now start.\n\nMake sure your Neo is connected to the 
USB-Device and booted into the Nor (for kernel and rootfs) or Nand (for u-boot) 
screen before proceeding.\nRemember that flashing a large image like a rootfs 
will take some time so don't abort it.\n\n

if [ -n `echo $ans | grep Root-Filesystem` ];then
du_param_r='-a rootfs -R -D'
rootfs=True
img_file_r=$(zenity --file-selection --title=Select an image-file for 
the ROOTFS:)
if [ $img_file_r =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing rootfs with $img_file_r \n\n
fi

if [ -n `echo $ans | grep Kernel` ];then
du_param_k='-a kernel -R -D'
kernel=True
img_file_k=$(zenity --file-selection --title=Select an image-file for 
the KERNEL:)
if [ $img_file_k =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing kernel with $img_file_k \n\n
fi

if [ -n ` echo $ans | grep Bootloader` ];then
du_param_u='-a u-boot -R -D'
uboot=True
img_file_u=$(zenity --file-selection --title=Select an image-file for 
UBOOT:)
if [ $img_file_u =  ]; then
echo Cancelled!
exit
fi
txt=$txt - Flashing uboot with $img_file_u \n\n
fi

touch $tmp_error_log_path

zenity --info --text $txt

if [ $rootfs = True ]; then
perform_flash rootfs $du_param_r $img_file_r
fi

if [ $kernel = True ]; then
perform_flash kernel $du_param_k $img_file_k
fi

if [ $uboot = True ]; then
perform_flash uboot $du_param_u $img_file_u
fi

rm $tmp_error_log_path
exit 0

___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community


Re: A little zenity-gui for flashing images to the neo

2008-09-07 Thread Charles Pax
On Sun, Sep 7, 2008 at 6:34 PM, Joel Newkirk [EMAIL PROTECTED] wrote:

 Sounds like you did a cut'n'paste from email.  The problem is that long
 lines are wrapped, which breaks programs/scripts.  There's at least three
 places in the script that suffer from word-wrap, including several lines
 that start at line 66.


Yup, did a cut n' paste. I tried the attachment and it worked just fine.
Maybe a future version can offer to fetch dfu-util. Thanks for the help.

-Charles
___
Openmoko community mailing list
community@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/community