| #!/bin/sh |
| # Set variable upload_over: DUMP media sequence |
| # 1: SD -> USB, try usb no matter SD pass or fail for internal auto tool flow |
| # 2: SD -> FLASH -> USB, reboot on any success |
| # 3: SD->FLASH, reboot on any success, stall on final fail |
| # 4: SD->FLASH, reboot on any success, reboot on final fail |
| # 5: USB Only |
| |
| upload_over=5 #default mode |
| |
| if [ ! -e /dev/rdr ]; then |
| echo No RAMDUMP found > /dev/kmsg |
| exit 0 |
| fi |
| |
| echo =========================================== > /dev/kmsg |
| echo RAMDUMP prepared by U-boot in RAM found > /dev/kmsg |
| echo Script $0 is running > /dev/kmsg |
| echo upload_over == $upload_over > /dev/kmsg |
| |
| # Use fixed File-Name: |
| # RDNAME=RAMDUMP0000 |
| # Use File-Name with RAMDUMP_YYMMDD-HHMM: |
| RDNAME=RAMDUMP_$(date +%y%m%d-%H%M) |
| CPDUMPNAME=cpdump_$(date +%y%m%d-%H%M) |
| COMDDRNAME=COM_DDR_$(date +%y%m%d-%H%M) |
| DSPDDRNAME=DSP_DDR_$(date +%y%m%d-%H%M) |
| BMBUFFNAME=bm_buffer_$(date +%y%m%d-%H%M) |
| ADSPSHMNAME=adsp_shm_$(date +%y%m%d-%H%M) |
| ADSPDTCMNAME=adsp_dtcm_$(date +%y%m%d-%H%M) |
| ADSPDDRNAME=adsp_ddr_$(date +%y%m%d-%H%M) |
| ADSPSQUNAME=adsp_squ_$(date +%y%m%d-%H%M) |
| |
| #flash dump name should be fixed name |
| AP_DUMPTXT=ap_dump.txt |
| AP_DUMPGZ=ap_dump.gz |
| COM_CP_DUMP=com_RW_DDR.bin |
| COM_DSP_DUMP=com_dsp_ddr.bin |
| |
| FBMBUFFNAME=bm_buffer |
| FADSPSHMNAME=adsp_shm |
| FADSPDTCMNAME=adsp_dtcm |
| FADSPDDRNAME=adsp_ddr |
| FADSPSQUNAME=adsp_squ |
| |
| SD_DUMP_DIR=/sdcard/modem_dump/ |
| FLASH_DUMP_DIR=/data/modem_dump/ |
| |
| iscpdump=`cat /proc/cmdline | grep "cpdump"` |
| |
| function no_usbdump_reboot { |
| echo "=========NO usbdump rboot" > /dev/kmsg |
| sync |
| sleep 3 |
| sync |
| echo "reboot" > /dev/kmsg |
| # Clear ramdump descriptor before restart |
| echo c > /dev/rdr |
| ifconfig usbnet0 down |
| echo 0 > /sys/class/android_usb/android0/enable |
| reboot |
| exit 0 |
| } |
| |
| function sd_dump { |
| /etc/init.d/sdcard_mount start |
| sleep 5 |
| |
| if [ ! -e /sdcard ]; then |
| echo "no /sdcard directory" > /dev/kmsg |
| return 1 |
| fi |
| |
| if [ ! -e "$SD_DUMP_DIR" ]; then |
| echo "mkdir /sdcard/modem_dump" > /dev/kmsg |
| mkdir -p $SD_DUMP_DIR |
| fi |
| |
| if [ ! -e "$SD_DUMP_DIR" ]; then |
| echo "!!!!!no /sdcard/modem_dump directory" > /dev/kmsg |
| return 1 |
| fi |
| |
| if [ -n "$iscpdump" ]; then |
| echo t > /dev/rdr |
| cp /dev/rdr $SD_DUMP_DIR/$COMDDRNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "sd dump CP image failed" > /dev/kmsg |
| return 1 |
| fi |
| |
| echo d > /dev/rdr |
| cp /dev/rdr $SD_DUMP_DIR/$DSPDDRNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "sd dump DSP image failed" > /dev/kmsg |
| return 1 |
| fi |
| |
| if [ -e /sys/kernel/debug/adsp/adsp_shm ]; then |
| echo "sd dump adsp_shm" > /dev/kmsg |
| cp /sys/kernel/debug/adsp/adsp_shm $SD_DUMP_DIR/$ADSPSHMNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "sd dump adsp_shm failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| if [ -e /sys/kernel/debug/adsp/adsp_dtcm ]; then |
| echo "sd dump adsp_dtcm" > /dev/kmsg |
| cp /sys/kernel/debug/adsp/adsp_dtcm $SD_DUMP_DIR/$ADSPDTCMNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "sd dump adsp_dtcm failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| if [ -e /sys/kernel/debug/adsp/adsp_ddr ]; then |
| echo "sd dump adsp_ddr" > /dev/kmsg |
| cp /sys/kernel/debug/adsp/adsp_ddr $SD_DUMP_DIR/$ADSPDDRNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "sd dump adsp_ddr failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| |
| if [ -e /sys/kernel/debug/adsp/adsp_squ ]; then |
| echo "sd dump adsp_squ" > /dev/kmsg |
| cp /sys/kernel/debug/adsp/adsp_squ $SD_DUMP_DIR/$ADSPSQUNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "sd dump adsp_squ failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| if [ -e /sys/kernel/debug/bm/buffer ]; then |
| echo "sd dump bm_buffer" > /dev/kmsg |
| cp /sys/kernel/debug/bm/buffer $SD_DUMP_DIR/$BMBUFFNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "sd dump bm_buffer failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| else |
| echo t > /dev/rdr |
| cp /dev/rdr $SD_DUMP_DIR/$RDNAME.txt |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "!!!!!!!!!!sd dump txt image failed" > /dev/kmsg |
| return 1 |
| fi |
| |
| echo d > /dev/rdr |
| cp /dev/rdr $SD_DUMP_DIR/$RDNAME.gz |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "!!!!!!!!!!sd dump GZ image failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| return 0 |
| } |
| |
| function flash_dump { |
| if [ ! -e "$FLASH_DUMP_DIR" ]; then |
| echo "mkdir $FLASH_DUMP_DIR" > /dev/kmsg |
| mkdir -p $FLASH_DUMP_DIR |
| fi |
| |
| if [ ! -e "$FLASH_DUMP_DIR" ]; then |
| echo "!!!!!no $FLASH_DUMP_DIR" > /dev/kmsg |
| return 1 |
| fi |
| |
| #remove the old dump files, as flash space is limited |
| rm $FLASH_DUMP_DIR/* |
| |
| if [ -n "$iscpdump" ]; then |
| echo t > /dev/rdr |
| cp /dev/rdr $FLASH_DUMP_DIR/$COM_CP_DUMP |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "flash dump CP image failed" > /dev/kmsg |
| rm $FLASH_DUMP_DIR/$COM_CP_DUMP |
| return 1 |
| fi |
| |
| echo d > /dev/rdr |
| cp /dev/rdr $FLASH_DUMP_DIR/$COM_DSP_DUMP |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "flash dump DSP image failed" > /dev/kmsg |
| rm $COM_DSP_DUMP |
| return 1 |
| fi |
| |
| if [ -e /sys/kernel/debug/adsp/adsp_shm ]; then |
| echo "flash dump adsp_shm" > /dev/kmsg |
| cp /sys/kernel/debug/adsp/adsp_shm $FLASH_DUMP_DIR/$FADSPSHMNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "flash dump adsp_shm failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| if [ -e /sys/kernel/debug/adsp/adsp_dtcm ]; then |
| echo "flash dump adsp_dtcm" > /dev/kmsg |
| cp /sys/kernel/debug/adsp/adsp_dtcm $FLASH_DUMP_DIR/$FADSPDTCMNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "flash dump adsp_dtcm failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| if [ -e /sys/kernel/debug/adsp/adsp_ddr ]; then |
| echo "flash dump adsp_ddr" > /dev/kmsg |
| cp /sys/kernel/debug/adsp/adsp_ddr $FLASH_DUMP_DIR/$FADSPDDRNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "flash dump adsp_ddr failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| if [ -e /sys/kernel/debug/adsp/adsp_squ ]; then |
| echo "flash dump adsp_squ" > /dev/kmsg |
| cp /sys/kernel/debug/adsp/adsp_squ $FLASH_DUMP_DIR/$FADSPSQUNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "flash dump adsp_squ failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| |
| if [ -e /sys/kernel/debug/bm/buffer ]; then |
| echo "flash dump bm_buffer" > /dev/kmsg |
| cp /sys/kernel/debug/bm/buffer $FLASH_DUMP_DIR/$FBMBUFFNAME.bin |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "flash dump bm_buffer failed" > /dev/kmsg |
| return 1 |
| fi |
| fi |
| else |
| echo t > /dev/rdr |
| cp /dev/rdr $FLASH_DUMP_DIR/$AP_DUMPTXT |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "!!!!!!!!!!flash dump txt image failed" > /dev/kmsg |
| rm $FLASH_DUMP_DIR/$AP_DUMPTXT |
| return 1 |
| fi |
| |
| echo d > /dev/rdr |
| cp /dev/rdr $FLASH_DUMP_DIR/$AP_DUMPGZ |
| result=$? |
| if [ $result -ne 0 ]; then |
| echo "!!!!!!!!!!flash dump GZ image failed" > /dev/kmsg |
| rm $FLASH_DUMP_DIR/$AP_DUMPGZ |
| return 1 |
| fi |
| fi |
| |
| return 0 |
| } |
| |
| |
| # 1: SD -> USB, try usb no matter SD pass or fail for internal auto tool flow |
| # 2: SD -> FLASH -> USB, reboot on any success |
| # 3: SD->FLASH, reboot on any success, stall on final fail |
| # 4: SD->FLASH, reboot on any success, reboot on final fail |
| if [ $upload_over -eq 1 ]; then |
| sd_dump |
| result=$? |
| if [ $result -eq 0 ]; then |
| echo "=========sd dump success" > /dev/kmsg |
| fi |
| elif [ $upload_over -eq 2 ]; then |
| sd_dump |
| result=$? |
| if [ $result -eq 0 ]; then |
| echo "=========sd dump success" > /dev/kmsg |
| no_usbdump_reboot |
| fi |
| flash_dump |
| result=$? |
| if [ $result -eq 0 ]; then |
| echo "=========flash dump success" > /dev/kmsg |
| no_usbdump_reboot |
| fi |
| elif [ $upload_over -eq 3 ]; then |
| sd_dump |
| result=$? |
| if [ $result -eq 0 ]; then |
| echo "=========sd dump success" > /dev/kmsg |
| no_usbdump_reboot |
| fi |
| flash_dump |
| result=$? |
| if [ $result -eq 0 ]; then |
| echo "=========flash dump success" > /dev/kmsg |
| no_usbdump_reboot |
| fi |
| #stall on fail |
| while [ 1 ] |
| do |
| sleep 100 |
| done |
| elif [ $upload_over -eq 4 ]; then |
| sd_dump |
| result=$? |
| if [ $result -eq 0 ]; then |
| echo "=========sd dump success" > /dev/kmsg |
| no_usbdump_reboot |
| fi |
| flash_dump |
| result=$? |
| if [ $result -eq 0 ]; then |
| echo "=========flash dump success" > /dev/kmsg |
| no_usbdump_reboot |
| fi |
| no_usbdump_reboot |
| else |
| echo "don't check storage media" > /dev/kmsg |
| fi |
| |
| FTP_SERV_IP="" |
| loop_net=0 |
| #leave 3 days(for weekend test, 259200 secs) to check network on |
| while [ $loop_net -le 259200 -a -z $FTP_SERV_IP ] |
| do |
| if [ -z "$1" ]; then |
| cat /proc/net/arp > /tmp/tmp_arp1 |
| sed -n '/br-lan/p' /tmp/tmp_arp1 > /tmp/tmp_arp2 |
| sed -n '/0x2/p' /tmp/tmp_arp2 > /tmp/sed_arp_output |
| sed -n '1p' /tmp/sed_arp_output > /tmp/ip_string1 |
| sed -n '2p' /tmp/sed_arp_output > /tmp/ip_string2 |
| FTP_SERV_IP=`awk '{print $1}' /tmp/ip_string1` |
| echo $FTP_SERV_IP > /dev/kmsg |
| local_ip=`echo $FTP_SERV_IP |grep 192.168` |
| if [ -n "$local_ip" ]; then |
| break |
| fi |
| FTP_SERV_IP=`awk '{print $1}' /tmp/ip_string2` |
| local_ip=`echo $FTP_SERV_IP |grep 192.168` |
| echo $FTP_SERV_IP > /dev/kmsg |
| if [ -n "$local_ip" ]; then |
| break |
| fi |
| else |
| FTP_SERV_IP=$1 |
| fi |
| loop_net=$((loop_net+1)) |
| echo Searching PC SRV to dump image ... > /dev/kmsg |
| sleep 1 |
| done |
| |
| if [ -z "$FTP_SERV_IP" ]; then |
| echo "!!!!!!!!!!!!! Can't find any SRV PC to dump image" > /dev/kmsg |
| exit 0 |
| else |
| echo FTP_SERV_IP $FTP_SERV_IP > /dev/kmsg |
| fi |
| |
| #if [ $upload_over -eq 1 ]; then |
| # echo ...Upload to SD /sdcard/$RDNAME.* > /dev/kmsg |
| # #echo t > /dev/rdr - default |
| # cp /dev/rdr /sdcard/$RDNAME.txt |
| # echo d > /dev/rdr |
| # cp /dev/rdr /sdcard/$RDNAME.gz |
| # result=$? |
| #fi |
| |
| if [ 1 ]; then |
| echo ...Upload to TFTP $FTP_SERV_IP > /dev/kmsg |
| loop=0 |
| #wait for enough time to prepare the PC server |
| #the timeout is for weekend time(3 days) |
| while [ $loop -le 259200 ] |
| do |
| echo t > /dev/rdr |
| |
| if [ -n "$iscpdump" ]; then |
| tftp -p -l /dev/rdr -r $COMDDRNAME.bin $FTP_SERV_IP |
| else |
| tftp -p -l /dev/rdr -r $RDNAME.txt $FTP_SERV_IP |
| fi |
| |
| result=$? |
| if [ $result -eq 0 ]; then |
| echo "======dump text ok" > /dev/kmsg |
| echo d > /dev/rdr |
| if [ -n "$iscpdump" ]; then |
| busybox tftp -p -l /dev/rdr -r $DSPDDRNAME.bin $FTP_SERV_IP |
| else |
| busybox tftp -p -l /dev/rdr -r $RDNAME.gz $FTP_SERV_IP |
| fi |
| result=$? |
| fi |
| |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======dump gz ok" > /dev/kmsg |
| if [ -n "$iscpdump" ]; then |
| if [ ! -e /log/cp_dump.tar.gz ]; then |
| echo ================= cpdump image does not exsit > /dev/kmsg |
| loop=400000 |
| else |
| tftp -p -l /log/cp_dump.tar.gz -r $CPDUMPNAME.tar.gz $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======cp dump transfer ok" > /dev/kmsg |
| loop=400000 |
| else |
| # No answer from server or error. Try again |
| loop=$((loop+1)) |
| echo TFTP uploading cpdump retry ... > /dev/kmsg |
| sleep 2 |
| fi |
| fi |
| else |
| echo "======no cp assert dump done" > /dev/kmsg |
| loop=400000 |
| fi |
| else |
| # No answer from server or error. Try again |
| loop=$((loop+1)) |
| echo TFTP uploading RDP retry ... > /dev/kmsg |
| sleep 2 |
| fi |
| done |
| fi |
| |
| if [ -n "$iscpdump" ]; then |
| if [ ! -e /sys/kernel/debug/bm/buffer ]; then |
| echo ================= no bm_buffer to be dump > /dev/kmsg |
| else |
| tftp -p -l /sys/kernel/debug/bm/buffer -r $BMBUFFNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======bm buffer dump ok" > /dev/kmsg |
| else |
| #try again |
| echo "======retry to dump bm buffer" > /dev/kmsg |
| tftp -p -l /sys/kernel/debug/bm/buffer -r $BMBUFFNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======bm buffer dump ok" > /dev/kmsg |
| else |
| echo "======bm buffer dump failed" > /dev/kmsg |
| fi |
| fi |
| fi |
| fi |
| |
| #dump ADSP bins |
| if [ -n "$iscpdump" ]; then |
| if [ ! -e /sys/kernel/debug/adsp/adsp_shm ]; then |
| echo ================= no adsp_shm to dump > /dev/kmsg |
| else |
| tftp -p -l /sys/kernel/debug/adsp/adsp_shm -r $ADSPSHMNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======adsp_shm dump ok" > /dev/kmsg |
| else |
| #try again |
| echo "======retry to dump adsp_shm" > /dev/kmsg |
| tftp -p -l /sys/kernel/debug/adsp/adsp_shm -r $ADSPSHMNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======adsp_shm dump ok" > /dev/kmsg |
| else |
| echo "======dump adsp_shm failed" > /dev/kmsg |
| fi |
| fi |
| fi |
| |
| if [ ! -e /sys/kernel/debug/adsp/adsp_dtcm ]; then |
| echo ================= no adsp_dtcm to dump > /dev/kmsg |
| else |
| tftp -p -l /sys/kernel/debug/adsp/adsp_dtcm -r $ADSPDTCMNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======adsp_dtcm dump ok" > /dev/kmsg |
| else |
| #try again |
| echo "======retry to dump adsp_dtcm" > /dev/kmsg |
| tftp -p -l /sys/kernel/debug/adsp/adsp_dtcm -r $ADSPDTCMNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======adsp_dtcm dump ok" > /dev/kmsg |
| else |
| echo "======dump adsp_dtcm failed" > /dev/kmsg |
| fi |
| fi |
| fi |
| |
| if [ ! -e /sys/kernel/debug/adsp/adsp_ddr ]; then |
| echo ================= no adsp_ddr to dump > /dev/kmsg |
| else |
| tftp -p -l /sys/kernel/debug/adsp/adsp_ddr -r $ADSPDDRNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======adsp_ddr dump ok" > /dev/kmsg |
| else |
| #try again |
| echo "======retry to dump adsp_ddr" > /dev/kmsg |
| tftp -p -l /sys/kernel/debug/adsp/adsp_ddr -r $ADSPDDRNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======adsp_ddr dump ok" > /dev/kmsg |
| else |
| echo "======dump adsp_ddr failed" > /dev/kmsg |
| fi |
| fi |
| fi |
| |
| if [ ! -e /sys/kernel/debug/adsp/adsp_squ ]; then |
| echo ================= no adsp_squ to dump > /dev/kmsg |
| else |
| tftp -p -l /sys/kernel/debug/adsp/adsp_squ -r $ADSPSQUNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======adsp_squ dump ok" > /dev/kmsg |
| else |
| #try again |
| echo "======retry to dump adsp_squ" > /dev/kmsg |
| tftp -p -l /sys/kernel/debug/adsp/adsp_squ -r $ADSPSQUNAME.bin $FTP_SERV_IP |
| result=$? |
| if [ $result -eq 0 ]; then |
| # Uploaded with ok. Exit loop |
| echo "======adsp_squ dump ok" > /dev/kmsg |
| else |
| echo "======dump adsp_squ failed" > /dev/kmsg |
| fi |
| fi |
| fi |
| fi |
| |
| if [ $loop -ne 400000 ]; then |
| echo "!!!!!!!!!!!!!!!!!ramdump failed, please check tftp server or firewall" > /dev/kmsg |
| exit 0 |
| fi |
| |
| echo RAMDUMP upload finished with $result ----- Re-Start ---- > /dev/kmsg |
| # Clear ramdump descriptor before restart |
| echo c > /dev/rdr |
| |
| echo "sending rdp_ok.txt to server" > /dev/kmsg |
| echo "rdp_ok" > /tmp/rdp_ok.txt |
| tftp -p -l /tmp/rdp_ok.txt -r rdp_ok.txt $FTP_SERV_IP |
| |
| echo "sleep 15s for auto test" > /dev/kmsg |
| sleep 15 |
| |
| ifconfig usbnet0 down |
| echo 0 > /sys/class/android_usb/android0/enable |
| |
| reboot |
| |