1#!/bin/bash 2 3############################################################################### 4# 5# Copyright (C) 2009-2013 Nintendo. All rights reserved. 6# 7# These coded instructions, statements, and computer programs contain 8# proprietary information of Nintendo of America Inc. and/or Nintendo 9# Company Ltd., and are protected by Federal copyright law. They may 10# not be disclosed to third parties or copied or duplicated in any form, 11# in whole or in part, without the prior written consent of Nintendo. 12# 13############################################################################### 14 15BIN_DIR=${CAFE_ROOT}/system/bin 16RPX_NAME="content_dump.rpx" 17RPX_CATEGORY="app" 18DEBUG_FLG="" 19 20RPX_DBG_DIR="${RPX_CATEGORY}/${RPX_NAME%.rpx}/DEBUG" 21RPX_DBG="${RPX_CATEGORY}/${RPX_NAME%.rpx}/DEBUG/${RPX_NAME}" 22RPX_NDBG_DIR="${RPX_CATEGORY}/${RPX_NAME%.rpx}/NDEBUG" 23RPX_NDBG="${RPX_CATEGORY}/${RPX_NAME%.rpx}/NDEBUG/${RPX_NAME}" 24 25if [ -f ${BIN_DIR}/${TOOLCHAIN}/${PLATFORM}/${RPX_NDBG} ]; then 26 RPX_DIR=${RPX_NDBG_DIR} 27 RPX=${RPX_NDBG} 28elif [ -f ${BIN_DIR}/${TOOLCHAIN}/${PLATFORM}/${RPX_DBG} ]; then 29 RPX_DIR=${RPX_DBG_DIR} 30 RPX=${RPX_DBG} 31 DEBUG_FLG="-b" 32else 33 echo "Error: Could not find ${RPX_NAME}" 34fi 35 36DEFAULT_APP_XML=${BIN_DIR}/${TOOLCHAIN}/${PLATFORM}/boot/app_default.xml 37APP_XML=${BIN_DIR}/${TOOLCHAIN}/${PLATFORM}/${RPX_DIR}/app.xml 38 39usage() 40{ 41 cat <<EOF 42Usage: $(basename $0) [OPTION]... -t <TitleID> 43(ex. $(basename $0) -v -d usb -o c:/cygwin/temp -t 0005000011000000) 44Dump the content directory to your PC from the application in NAND memory on CAT-DEV or USB storage device. 45Dumped files is stored in the directory called "<PATH(\$CAFE_ROOT by default)>/c_<TitleID>". 46 47Options: 48 -d <dev_type> : [Device where the target title is installed]. "usb" or "nand" can be used. 49 If omitted, the application use "nand". 50 -o <path> : [The path for the output directory]. Both Cygpath and Windows path expressions can be used. 51 If omitted, use \$CAFE_ROOT as the output path. 52 -t <num> : [The title ID to be dumped]. the title ID is represented by 16 hexadecimal digits. 53 This option must be set to use this tool. 54 -v : [Enable to verify copied files]. This feature is disabled by default. 55 -h : Show this help. 56EOF 57} 58 59ENABLE_VERIFY=0 60DEV_TYPE="nand" 61DEST_PATH=${CAFE_ROOT} 62TITLE_ID= 63 64while getopts "d:o:t:vh" opt; do 65 case $opt in 66 d ) DEV_TYPE=${OPTARG} ;; 67 o ) DEST_PATH=${OPTARG} ;; 68 t ) TITLE_ID=${OPTARG} ;; 69 v ) ENABLE_VERIFY=1 ;; 70 h ) usage 71 exit 1 ;; 72 \? ) usage 73 exit 1 ;; 74 esac 75done 76 77if [ -z ${TITLE_ID} ]; then 78 usage 79 exit 1 80else 81 TITLE_ID=`echo ${TITLE_ID} | sed -e "s/0x//g" | tr "[A-Z]" "[a-z]"` 82 echo "Updating ${APP_XML} with title ID(${TITLE_ID})..." 83 cat ${DEFAULT_APP_XML} | \ 84 sed -e "s|\(<title_id .*>\)\(.*\)\(</title_id>\)|\1${TITLE_ID}\3|" | \ 85 sed -e "s|\(<title_version .*>\)\(.*\)\(</title_version>\)|\12000\3|" > ${APP_XML} 86fi 87 88if [ `echo ${DEST_PATH} | grep -ir c:/cygwin` ]; then 89 DEST_PATH=`echo ${DEST_PATH} | sed -e "s/c:\/cygwin/\/cygdrive\/c\/cygwin/g"` 90fi 91DEST_HFIO_PATH=`cygpath -a ${DEST_PATH} | sed -e "s/\/cygdrive\///g"` 92DEV_TYPE=`echo ${DEV_TYPE} | sed -e "s/0x//g" | tr "[A-Z]" "[a-z]" | sed -e "s/\"//g"` 93 94echo "caferun ${DEBUG_FLG} ${BIN_DIR}/${TOOLCHAIN}/${PLATFORM}/${RPX} ${ENABLE_VERIFY} ${DEST_HFIO_PATH} ${DEV_TYPE}" 95caferun ${DEBUG_FLG} ${BIN_DIR}/${TOOLCHAIN}/${PLATFORM}/${RPX} ${ENABLE_VERIFY} ${DEST_HFIO_PATH} ${DEV_TYPE} 96cafestop 97