1#!/usr/bin/env 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 15############################################################################### 16# print usage help message 17############################################################################### 18usage () 19{ 20 cat <<EOF 21 Usage: $(basename $0) [-q] [-h] 22 23 options: 24 -h : (help) display options 25 -u <package> : path to update package (from sysconfig's perspective) 26 -s : use system updater (update package should contain system updater) 27 -t <dir> : patch to single title (from sysconfig's perspective) 28 -P : Use production bootloader (only applies when in NAND boot mode) 29EOF 30} 31 32############################################################################### 33# main 34############################################################################### 35 36if [ "$USE_CAFEX" == "1" ] 37then 38 # Set IFS to something that will not be in the args, so that BASH will pass the entire un-parsed string to CafeX 39 saveIFS="$IFS" 40 IFS=$'\n' 41 echo "Using CafeControl" 42 cafex.exe update $@ 43 rval=$? 44 IFS="$saveIFS" 45 exit $rval 46fi 47 48# stop the script when any command returns an error (non-zero). 49set -e 50 51CAFEUPDATE_USE_SYSTEM_UPDATER=0 52CAFEUPDATE_TITLE= 53CAFEUPDATE_PACKAGE_DEFAULT="/vol/storage_hfiomlc01/sys/update/pcfs" 54CAFEUPDATE_PACKAGE="$CAFEUPDATE_PACKAGE_DEFAULT" 55USE_MIXED_BOOTLOADER=1 56 57# init options 58while getopts hu:st:qP OPT 59do 60 case $OPT in 61 u ) CAFEUPDATE_PACKAGE="$OPTARG";; 62 s ) CAFEUPDATE_USE_SYSTEM_UPDATER=1;; 63 t ) CAFEUPDATE_TITLE="$OPTARG";; 64 P ) if [ "$CAFE_BOOT_MODE" == "NAND" ] 65 then 66 USE_MIXED_BOOTLOADER=0 67 else 68 echo "Warning: -P switch only applies to NAND mode. Ignored." 69 fi 70 ;; 71 h ) usage 72 exit;; 73 \:) echo "cafeupdate failed: missing argument" >&2 74 usage 75 exit;; 76 \?) echo "cafeupdate failed" >&2 77 usage 78 exit;; 79 esac 80done 81shift $(($OPTIND-1)) 82 83if [ "${SDK_MAJ_VER}.${SDK_MIN_VER}.${SDK_MIC_VER}" != "${SDK_VER//0/}" ]; then 84 "$CAFE_ROOT\system\bin\tool\mionps" $BRIDGE_CURRENT_IP_ADDRESS 3 -s ${SDK_VER:0:1} 85 "$CAFE_ROOT\system\bin\tool\mionps" $BRIDGE_CURRENT_IP_ADDRESS 4 -s ${SDK_VER:2:2} 86 "$CAFE_ROOT\system\bin\tool\mionps" $BRIDGE_CURRENT_IP_ADDRESS 5 -s ${SDK_VER:5:2} 87fi 88 89if [ "$CAFE_BOOT_MODE" == "NAND" ]; then 90 if [ $USE_MIXED_BOOTLOADER -eq 1 ]; then 91 echo Calling caferecover for NAND"..." 92 caferecover 93 else 94 echo Calling caferecover -production for NAND"..." 95 caferecover -production 96 fi 97 export CAFE_BOOT_MODE=NAND 98else 99 if [ "${CAFE_HARDWARE:0:2}" == "ev" -o "$CAFE_SECURITY" = "off" ] 100 then 101 echo "Sorry, bringup boot1 update not supported yet" 102 exit 0 103 fi 104 105 106 107 if [ -n "$CAFEUPDATE_TITLE" ] 108 then 109 echo "Installing title $CAFEUPDATE_TITLE using System Config Tool..." 110 cafeon -c "install $CAFEUPDATE_TITLE" -c exit 111 else 112 if [ "$CAFEUPDATE_PACKAGE" == "$CAFEUPDATE_PACKAGE_DEFAULT" ] 113 then 114 echo "Performing system update using System Config Tool..." 115 else 116 echo "Performing system update using System Config Tool from $CAFEUPDATE_PACKAGE..." 117 fi 118 119 if [ $CAFEUPDATE_USE_SYSTEM_UPDATER -eq 1 ] 120 then 121 echo "Using system updater..." 122 cafeon -c "update_launch $CAFEUPDATE_PACKAGE" 123 else 124 echo "Sourcing script setbootmode PCFS..." 125 source setbootmode PCFS 126 fi 127 sed -i -e "s|\(<argstr.*>\)\(.*\)\(</argstr.*>\)|\1system_config_tool.rpx\3|" "$CAFE_DATA_DIR/mlc/sys/title/00050010/1f700500/code/cos.xml" 128 fi 129fi 130 131