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# NOTE: this script sets two variables 16# that are to be visible by outside cripts: 17# CAFERUN_HOSTBRIDGE_VERSION 18# CAFERUN_FW_VERSION 19 20source getbridgetype 21 22############################################################################### 23# compute_flat_version 24############################################################################### 25 26compute_flat_version() 27{ 28 IFS="." 29 local v=( $1 ) 30 echo $((${v[0]} * 1000000 + ${v[1]} * 10000 + ${v[2]} * 1000 + ${v[3]})) 31} 32 33check_host_bridge_version() 34{ 35 if [ "$BRIDGE_TYPE" == "Mion" ] 36 then 37 local min_fw_ver="0.0.14.74" 38 local min_sw_ver="3.2.6.1" 39 else 40 local min_sw_ver="2.9.1.5" 41 local min_fw_ver="2.8.0.13" # firmware version installed by above software installer 42 fi 43 44 if [ ! -n "$SDIO_BRIDGE_TOOLS" ] 45 then 46 if [ ! -n "$MION_BRIDGE_TOOLS" ] 47 then 48 echo "caferun failed: Please install at least HostBridgeSetup_$min_sw_ver.exe and restart cafe.bat" 49 exit 2 50 fi 51 fi 52 53 if [ "$BRIDGE_TYPE" == "Mion" ] 54 then 55 # FSEmul -ver is safe to call here since it's guaranteed that Host Bridge is connected (checked by cafestop in caferun) 56 local fw_ver=`"$MION_BRIDGE_TOOLS/FSEmul" -ver -ip $BRIDGE_CURRENT_IP_ADDRESS | grep Firmware | tr -d '\r\n' | cut -d' ' -f4` 57 local sw_ver=`"$MION_BRIDGE_TOOLS/FSEmul" -ver -ip $BRIDGE_CURRENT_IP_ADDRESS | grep Software | tr -d '\r\n' | cut -d' ' -f4` 58 else 59 # FSEmul -ver is safe to call here since it's guaranteed that Host Bridge is connected (checked by cafestop in caferun) 60 local fw_ver=`"$SDIO_BRIDGE_TOOLS/FSEmul" -ver | grep Firmware | tr -d '\r\n' | cut -d' ' -f4` 61 local sw_ver=`"$SDIO_BRIDGE_TOOLS/FSEmul" -ver | grep Software | tr -d '\r\n' | cut -d' ' -f4` 62 fi 63 64 if [ -z "$fw_ver" -o -z "$sw_ver" ] 65 then 66 echo "caferun failed: Cannot check Host Bridge version. Please cafestop and try again" 67 exit 2 68 fi 69 70 # keep them so other scripts can check 71 CAFERUN_HOSTBRIDGE_VERSION=$sw_ver 72 CAFERUN_FW_VERSION=$fw_ver 73 74 local fw_ver_flat=$(compute_flat_version $fw_ver) 75 local sw_ver_flat=$(compute_flat_version $sw_ver) 76 local min_sw_ver_flat=$(compute_flat_version $min_sw_ver) 77 local min_fw_ver_flat=$(compute_flat_version $min_fw_ver) 78 79 if [ $sw_ver_flat -lt $min_sw_ver_flat -o $fw_ver_flat -lt $min_fw_ver_flat ] 80 then 81 echo "caferun failed: Please install at least HostBridgeSetup_$min_sw_ver.exe and restart cafe.bat" 82 echo " Current software version is $sw_ver (need $min_sw_ver)" 83 echo " Current firmware version is $fw_ver (need $min_fw_ver)" 84 exit 3 85 fi 86} 87 88check_host_bridge_version 89