A little zenity-gui for flashing images to the neo

David Samblas dsamblasomcommunity at gmail.com
Mon Sep 8 09:10:39 CEST 2008


#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 <antisol at internode.on.net>:
> > Charles Pax wrote:
> >>
> >> On Sun, Sep 7, 2008 at 6:34 PM, Joel Newkirk <freerunner at newkirk.us>
> >> 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 at lists.openmoko.org
> > http://lists.openmoko.org/mailman/listinfo/community
> >
> >
> 
> _______________________________________________
> Openmoko community mailing list
> community at lists.openmoko.org
> http://lists.openmoko.org/mailman/listinfo/community





More information about the community mailing list