diff --git a/build/tools/sctools/common/src/hwi.c b/build/tools/sctools/common/src/hwi.c index 883f765..653188a 100644 --- a/build/tools/sctools/common/src/hwi.c +++ b/build/tools/sctools/common/src/hwi.c @@ -189,6 +189,11 @@ BOOL MiyaBackupTWLSettings(const char *path) return FALSE; } +#if 0 /* miya */ + mprintf("cfg_data.country = %d\n", cfg_data.country ); +#endif + + #if 0 writtenSize = FS_WriteFile(&f, (void *)&cfg_data, (s32)sizeof(LCFGTWLSettingsData) ); #else @@ -284,6 +289,10 @@ BOOL MiyaRestoreTWLSettings(const char *path) readSize = my_fs_crypto_read(&f, (void *)&cfg_data, (s32)sizeof(LCFGTWLSettingsData) ); +#if 0 /* miya */ + mprintf("cfg_data.country = %d\n", cfg_data.country ); +#endif + if( readSize != sizeof(LCFGTWLSettingsData) ) { fsResult = FS_GetArchiveResultCode(path); mprintf("Failed read file 2 - HWNormal Info.:%d\n", fsResult ); @@ -307,6 +316,11 @@ BOOL MiyaRestoreTWLSettings(const char *path) return FALSE; } + // LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_JAPAN); + LCFG_TSD_SetCountry(cfg_data.country); + + + return TRUE; } diff --git a/build/tools/sctools/common/src/my_fs_util.c b/build/tools/sctools/common/src/my_fs_util.c index ab43080..bfda574 100644 --- a/build/tools/sctools/common/src/my_fs_util.c +++ b/build/tools/sctools/common/src/my_fs_util.c @@ -130,7 +130,7 @@ char *my_fs_util_get_fs_result_word( FSResult res ) { FS_RESULT_UNSUPPORTED, "FS_RESULT_UNSUPPORTED" }, { FS_RESULT_ERROR, "FS_RESULT_ERROR" }, { FS_RESULT_INVALID_PARAMETER, "FS_RESULT_INVALID_PARAMETER" }, - { FS_RESULT_NO_MORE_RESOUCE, "FS_RESULT_NO_MORE_RESOUCE" }, + { FS_RESULT_NO_MORE_RESOURCE, "FS_RESULT_NO_MORE_RESOURCE" }, { FS_RESULT_ALREADY_DONE, "FS_RESULT_ALREADY_DONE" }, { FS_RESULT_PERMISSION_DENIED, "FS_RESULT_PERMISSION_DENIED" }, { FS_RESULT_MEDIA_FATAL, "FS_RESULT_MEDIA_FATAL" }, @@ -2525,6 +2525,133 @@ BOOL CheckShopRecord(FSFile *log_fd) } +//static BOOL + +static BOOL myCleanDirectory(char *path, FSFile *log_fd, int level) +{ + FSFile f; + BOOL ret_value = TRUE; + // FSDirectoryEntryInfo direntry; + // char path_full[FILE_PATH_LEN]; + FSDirectoryEntryInfo *direntry; + char *path_full; + + // OS_TPrintf("level = %d\n", level); /* 8になったらOpenDirectoryでエラーになる。 */ + + path_full = (char *)OS_Alloc( FILE_PATH_LEN ); + if( path_full == NULL ) { + miya_log_fprintf(log_fd, "Error: alloc error path_full\n"); + ret_value = FALSE; + goto end_process; + } + + direntry = (FSDirectoryEntryInfo *)OS_Alloc( sizeof(FSDirectoryEntryInfo) ); + if( direntry == NULL ) { + miya_log_fprintf(log_fd, "Error: alloc error FSDirectoryEntryInfo\n"); + ret_value = FALSE; + goto end_process; + } + + /* ソースディレクトリオープン */ + FS_InitFile(&f); + + if(FS_OpenDirectory(&f, path, FS_PERMIT_R | FS_PERMIT_W ) == FALSE ) { + // if(FS_OpenDirectory(&f, path, 0 ) == FALSE ) { + + miya_log_fprintf(log_fd, "%s %d: Failed Open Directory\n", __FUNCTION__ , __LINE__ ); + miya_log_fprintf(log_fd, " %s\n", path); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path) ) ); + ret_value = FALSE; + (void)Error_Report_Printf(" Open directory failed:%s\n",path); + goto end_process; + } + + while( FS_ReadDirectory(&f, direntry) ) { + if( STD_StrCmp(direntry->longname, ".") == 0 ) { + } + else if( STD_StrCmp(direntry->longname, "..") == 0 ) { + } + else if( direntry->attributes & FS_ATTRIBUTE_DOS_VOLUME ) { + } + else { + + STD_StrCpy( path_full , path ); + STD_StrCat( path_full, "/"); + STD_StrCat( path_full , direntry->longname ); + + if( (direntry->attributes & FS_ATTRIBUTE_IS_DIRECTORY) != 0 ) { + if( level >= 6 ) { + if( FALSE == FS_DeleteDirectoryAuto( path_full ) ) { + OS_TPrintf("FS_DeleteDirectoryAuto failed.: "); + PrintAttributes(direntry->attributes, log_fd); + OS_TPrintf(" %s\n", path_full); + OS_TPrintf(" %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path_full) ) ); + mprintf("FS_DeleteDirectoryAuto failed. %s\n", path_full); + ret_value = FALSE; + } + else { + // OS_TPrintf("done\n"); + } + } + else { + (void)myCleanDirectory(path_full, log_fd, level+1 ); + // OS_TPrintf("FS_DeleteDirectory "); + + if( FALSE == FS_DeleteDirectory( path_full ) ) { + OS_TPrintf("FS_DeleteDirectory failed.: "); + PrintAttributes(direntry->attributes, log_fd); + OS_TPrintf(" %s\n", path_full); + OS_TPrintf(" %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path_full) ) ); + mprintf("FS_DeleteDirectory failed. %s\n", path_full); + ret_value = FALSE; + } + else { + // OS_TPrintf("done\n"); + } + } + } + else { + /* ファイルの場合 */ + // OS_TPrintf("FS_DeleteFile "); + + if( FALSE == FS_DeleteFile( path_full ) ) { + OS_TPrintf("FS_DeleteFile failed.: "); + PrintAttributes(direntry->attributes, log_fd); + OS_TPrintf(" %s\n", path_full); + mprintf("FS_DeleteFile failed. %s\n", path_full); + ret_value = FALSE; + } + else { + // OS_TPrintf("done\n"); + } + } + } + } + + end_process: + + + if( FS_CloseDirectory(&f) == FALSE) { + miya_log_fprintf(log_fd, "%s %d: Failed Close Directory\n", __FUNCTION__ , __LINE__ ); + miya_log_fprintf(log_fd, " %s\n", path); + miya_log_fprintf(log_fd, " %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path))); + // ret_value |= 1; /* いらないかも?あとで考える */ + } + + if( path_full != NULL ) { + OS_Free(path_full); + } + + if( direntry != NULL ) { + OS_Free(direntry); + } + + return ret_value; + + +} + + BOOL CleanSDCardFiles(char *log_file_name) { char *path = "sdmc:/"; @@ -2567,11 +2694,15 @@ BOOL CleanSDCardFiles(char *log_file_name) else if( direntry.attributes & FS_ATTRIBUTE_DOS_VOLUME ) { } else { + STD_StrCpy( path_full , path ); STD_StrCat( path_full , direntry.longname ); if( (direntry.attributes & FS_ATTRIBUTE_IS_DIRECTORY) != 0 ) { /* ディレクトリの場合 */ +#if 0 + OS_TPrintf("FS_DeleteDirectoryAuto "); + if( FALSE == FS_DeleteDirectoryAuto( path_full ) ) { OS_TPrintf("FS_DeleteDirectoryAuto failed.: "); PrintAttributes(direntry.attributes, log_fd); @@ -2579,9 +2710,31 @@ BOOL CleanSDCardFiles(char *log_file_name) mprintf("FS_DeleteDirectoryAuto failed. %s\n", path_full); ret_value = FALSE; } + else { + OS_TPrintf("done. \n"); + } +#else + ret_value = myCleanDirectory(path_full, log_fd, 1 /* 0? */ ); + if( FALSE == FS_DeleteDirectory( path_full ) ) { + OS_TPrintf("FS_DeleteDirectory failed.: "); + PrintAttributes(direntry.attributes, log_fd); + OS_TPrintf(" %s\n", path_full); + OS_TPrintf(" %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path_full) ) ); + mprintf("FS_DeleteDirectory failed. %s\n", path_full); + ret_value = FALSE; + } + else { + // OS_TPrintf("done. \n"); + } + + +#endif + } else { /* ファイルの場合 */ + OS_TPrintf("FS_DeleteFile \n"); + if( FALSE == FS_DeleteFile( path_full ) ) { OS_TPrintf("FS_DeleteFile failed.: "); PrintAttributes(direntry.attributes, log_fd); @@ -2589,10 +2742,17 @@ BOOL CleanSDCardFiles(char *log_file_name) mprintf("FS_DeleteFile failed. %s\n", path_full); ret_value = FALSE; } + else { + OS_TPrintf("done. \n"); + } } } } + OS_TPrintf("\n"); + + end_process: + /* ソースディレクトリクローズ */ if( FS_CloseDirectory(&f) == FALSE) { miya_log_fprintf(log_fd, "%s %d: Failed Close Directory\n", __FUNCTION__ , __LINE__ ); @@ -2601,7 +2761,7 @@ BOOL CleanSDCardFiles(char *log_file_name) // ret_value |= 1; /* いらないかも?あとで考える */ } - end_process: + miya_log_fprintf(log_fd, "%s END\n\n", __FUNCTION__); Log_File_Close(log_fd); diff --git a/build/tools/sctools/common/src/mydata.h b/build/tools/sctools/common/src/mydata.h index 04d52f1..812bb41 100644 --- a/build/tools/sctools/common/src/mydata.h +++ b/build/tools/sctools/common/src/mydata.h @@ -3,7 +3,7 @@ #define MY_DATA_VERSION_MAJOR 1 -#define MY_DATA_VERSION_MINOR 2 +#define MY_DATA_VERSION_MINOR 3 typedef struct { u8 version_major; @@ -19,6 +19,7 @@ typedef struct { BOOL user_settings_flag; BOOL shop_record_flag; int num_of_user_download_app; + int num_of_user_download_app_by_nam; int num_of_app_save_data; int num_of_photo_files; int num_of_shared2_files; diff --git a/build/tools/sctools/common/src/mynvram.c b/build/tools/sctools/common/src/mynvram.c index 01ee560..7ba36a3 100644 --- a/build/tools/sctools/common/src/mynvram.c +++ b/build/tools/sctools/common/src/mynvram.c @@ -225,12 +225,7 @@ BOOL nvram_restore(char *path) int len; // char nor_file_path[FS_FILE_NAME_MAX]; char *nor_file_path = path; - NCFGConfig *p_ncfgc = NULL; -#if 0 - DWCWiFiInfo buf_content; - DWCWiFiInfo *buf = &buf_content; - u8 Wifi[14]; -#endif + u64 id1; u64 id2; @@ -267,52 +262,18 @@ BOOL nvram_restore(char *path) } - p_ncfgc = (NCFGConfig *)my_nor_buf; // DWCWiFiInfo *buf; // u8 Wifi[14]; // > となります。DWCライブラリによる修復を使わない場合は // > ・0x0f0と0x1f0にあるIDを確認して、両方のIDが同じ、かつ0でない場合にコピーする -#if 0 - MI_CpuCopy8(&p_ncfgc->slot[0].wifi[0], Wifi, 14); - MI_CpuCopy8(&Wifi[ 0], &buf->attestedUserId, 6); - buf->attestedUserId &= 0x07FFFFFFFFFF; - - MI_CpuCopy8(&Wifi[ 5], &buf->notAttestedId, 6); - buf->notAttestedId >>= 3; - buf->notAttestedId &= 0x07FFFFFFFFFF; - MI_CpuCopy8(&Wifi[10], &buf->pass, 2); - buf->pass >>= 6; - buf->pass &= 0x03FF; - MI_CpuCopy8(&Wifi[12], &buf->randomHistory, 2); - - id1 = buf->attestedUserId; -#else // MI_CpuCopy8(&p_ncfgc->slot[0].wifi[0], &id1, 6); MI_CpuCopy8(&my_nor_buf[0x600+ 0xf0], &id1, 6); id1 &= 0x07FFFFFFFFFF; -#endif - -#if 0 - MI_CpuCopy8(&p_ncfgc->slot[1].wifi[0], Wifi, 14); - MI_CpuCopy8(&Wifi[ 0], &buf->attestedUserId, 6); - buf->attestedUserId &= 0x07FFFFFFFFFF; - MI_CpuCopy8(&Wifi[ 5], &buf->notAttestedId, 6); - buf->notAttestedId >>= 3; - buf->notAttestedId &= 0x07FFFFFFFFFF; - MI_CpuCopy8(&Wifi[10], &buf->pass, 2); - buf->pass >>= 6; - buf->pass &= 0x03FF; - MI_CpuCopy8(&Wifi[12], &buf->randomHistory, 2); - - id2 = buf->attestedUserId; -#else - // MI_CpuCopy8(&p_ncfgc->slot[1].wifi[0], &id2, 6); MI_CpuCopy8(&my_nor_buf[0x600+ 0x1f0], &id2, 6); id2 &= 0x07FFFFFFFFFF; -#endif if( (id1 == id2) && (id1 != 0) ) { if( TRUE != my_nvram_write( offset , /* size */ NVRAM_PERSONAL_DATA_SIZE, (void* )my_nor_buf) ) { diff --git a/build/tools/sctools/copy_dst/src/hatamotolib.cpp b/build/tools/sctools/copy_dst/src/hatamotolib.cpp index b881533..11fe318 100644 --- a/build/tools/sctools/copy_dst/src/hatamotolib.cpp +++ b/build/tools/sctools/copy_dst/src/hatamotolib.cpp @@ -79,6 +79,8 @@ static void* AllocForEC(u32 size, int align) if(align <= 32) { return Alloc(size); } + mprintf("Failed to %s %d\n", __FUNCTION__,__LINE__); + return NULL; } @@ -93,6 +95,11 @@ static void* ReallocForNSSL(void* p, u32 size) if( p != NULL ) { void* newp = Alloc(size); + if( newp == NULL ) { + Free(p); + mprintf("Failed to %s %d\n", __FUNCTION__,__LINE__); + return NULL; + } MI_CpuCopy8(p, newp, size); Free(p); return newp; @@ -411,7 +418,7 @@ BOOL SetupEC(void) return TRUE; } - +static ECError WaitEC_result; BOOL WaitEC(ECOpId opId) { ECError result; @@ -430,6 +437,7 @@ BOOL WaitEC(ECOpId opId) for(;;) { result = EC_GetProgress(opId, &progress); + WaitEC_result = result; if( (result != EC_ERROR_OK) && (result != EC_ERROR_NOT_DONE) ) { if( result == EC_ERROR_NOT_ACTIVE ) @@ -493,7 +501,7 @@ BOOL WaitEC(ECOpId opId) break; } - OS_Sleep(300); + OS_Sleep(100); } return TRUE;; } @@ -692,6 +700,14 @@ static BOOL DownloadTitles(const NAMTitleId* pTitleIds, u32 numTitleIds) game_code_buf[4] = '\0'; mprintf(" downloading.. [%s] ", game_code_buf); if( FALSE == WaitEC(progress) ) { + + /* EC_ERROR_NET_CONTENTはずす?エラーにせずにバックアップだけ復活してやるか? */ + /* + if( WaitEC_result == EC_ERROR_NET_CONTENT ) { + tid を記録だけしてエラーにしない。 + } + + */ m_set_palette(tc[0], M_TEXT_COLOR_RED ); mprintf("NG.\n"); m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); @@ -769,7 +785,7 @@ int ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds) } else { miya_log_fprintf(log_fd, "OK.\n"); - m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ + m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); mprintf("OK.\n"); m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); } @@ -785,7 +801,7 @@ int ECDownload(const NAMTitleId* pTitleIds, u32 numTitleIds) } else { miya_log_fprintf(log_fd, "OK.\n"); - m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ + m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); mprintf("OK.\n"); m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); } diff --git a/build/tools/sctools/copy_dst/src/main.c b/build/tools/sctools/copy_dst/src/main.c index 41989c7..b1d1ef9 100644 --- a/build/tools/sctools/copy_dst/src/main.c +++ b/build/tools/sctools/copy_dst/src/main.c @@ -68,7 +68,6 @@ #define FREE_REG_RESTOREMODE_REBOOT 0x55 #define FREE_REG_RESTOREMODE_AND_RTC_DONE_REBOOT 0x66 -// #define MIYA_MCU 1 static BOOL only_wifi_config_data_trans_flag = FALSE; static BOOL user_and_wifi_config_data_trans_flag = FALSE; @@ -201,6 +200,113 @@ static BOOL start_my_thread(u32 command) return FALSE; } +#if 0 + +static void DeleteKnownTitles(NAMTitleId* pTitleIds, int num) +{ + int i; + NAMTitleId tid; + u32 hi; + + /* + + タイトルIDリスト + 「TitleID_Hi」_「TitleID_Lo」 + ------------------------------------------ + システムアプリ +   00030017_484E41?? [HNA?] DSiメニュー +   00030015_484E42?? [HNB?] 本体設定 +   00030015_484E46?? [HNF?] DSiショップ +   0003000F_484E4341 [HNCA] 無線ファーム +   0003000F_484E4841 [HNHA] ホワイトリスト +   0003000F_484E4C?? [HNL?] バージョン情報 +   00030005_484E4441 [HNDA] ダウンロードプレイ +   00030005_484E4541 [HNEA] PictChat +   00030005_484E49?? [HNI?] DSiカメラ +   00030005_484E4A?? [HNJ?] ニンテンドーゾーンビューア +   00030005_484E4B?? [HNK?] DSiサウンド + + ユーザーアプリ +   00030004_484E47?? [HNG?] DSiブラウザ +   00030004_4B4755?? [KGU?] うごくメモ帳 + + TitleID_Loの4桁目(言語コード) +   ?=[J, E, P, U]=[4A, 45, 50, 55] + + アプリのインストールされるパス +   "nand:/title//" + + */ + + + for( i = 0; i < num; i++ ) { + tid = *pTitleIds++; + hi = NAM_GetTitleIdHi(tid); + if( hi == 0x00030004 ) { + // NAM_DeleteTitleCompletely(tid); + NAM_DeleteTitle(tid); + } + } +} + +#endif + +static BOOL Clean_User_Titles(void) +{ +#define NAM_TITLE_ID_S 128 + + NAMTitleId pArray[NAM_TITLE_ID_S]; + s32 i; + BOOL ret_flag = TRUE; + s32 num = 0; + u64 id; + + num = NAM_GetNumTitles(); + if( num > 0 ) { + if( NAM_OK != NAM_GetTitleList( pArray , NAM_TITLE_ID_S ) ) { + return FALSE; + } + OS_TPrintf("NAND Installed titles\n"); + for( i = 0 ; i < num ; i++ ) { + id = pArray[i]; + + /* + No. 0 0003000f484e4c41 + No. 1 0003000f484e4841 + No. 2 0003000f484e4341 + No. 3 00030015484e4241 + No. 4 00030017484e4141 launcher + ^ + | ここの最下位ビットが1のやつがシステムアプリ + | + システムアプリはダウンロード対象外 + */ + if( id & 0x0000000100000000 ) { + /* system app. */ + OS_TPrintf(" sys.:%3d:0x%llx\n", i, id); + + } + else { + /* user app. */ + OS_TPrintf(" usr.:%3d:0x%llx\n", i, id); + if( NAM_OK != NAM_DeleteTitle( id ) ) { + OS_TPrintf(" Error: NAM_DeleteTitle id = 0x%llx\n", id); + ret_flag = FALSE; + } + else { + OS_TPrintf(" Delete Title id = 0x%llx\n", id); + } + } + } + } + return ret_flag; +} + + + + + + static void RTC_NTP_SYNC(void) { @@ -620,12 +726,19 @@ static BOOL RestoreFromSDCard7(void) log_fd = hatamotolib_log_start( MyFile_GetEcDownloadLogFileName() ); - if( mydata.shop_record_flag == FALSE ) { + if( mydata.shop_record_flag == FALSE && mydata.num_of_user_download_app == 0 ) { /* ネットワークにつながなくていいか? */ - miya_log_fprintf(log_fd,"no shop record\n"); + miya_log_fprintf(log_fd,"no shop record \n"); mprintf(" (--no shop record--)\n"); } else { +#ifdef PRE_INSTALLED_APP + /* miya 2009/03/03 */ + if( mydata.shop_record_flag == FALSE ) { + miya_log_fprintf(log_fd,"only pre-installed apps\n"); + mprintf("only pre-installed apps\n"); + } +#endif miya_log_fprintf(log_fd,"EC download\n"); mprintf("EC download\n"); @@ -829,7 +942,7 @@ static BOOL RestoreFromSDCard8(void) if( (no_network_flag == TRUE) || (ec_download_success_flag == FALSE) - || ( mydata.shop_record_flag == FALSE ) ) { + || ( mydata.shop_record_flag == FALSE && mydata.num_of_user_download_app == 0 ) ) { mprintf("Sys-App. save data restore "); if( TRUE == RestoreDirEntryListSystemBackupOnly( MyFile_GetSaveDataListFileName() , MyFile_GetSaveDataRestoreLogFileName(), @@ -918,6 +1031,23 @@ static void MyThreadProc(void *arg) command = (u32)message; switch( command ) { case THREAD_COMMAND_FULL_FUNCTION: + +#ifdef PRE_INSTALLED_APP + /* miya 2009/2/23 */ + mprintf("CleanUp installed user titles "); + if( TRUE == Clean_User_Titles() ) { + m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); + mprintf("OK.\n"); + } + else { + m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* red */ + mprintf("NG.\n"); + flag = FALSE; + } +#endif + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + + if( miya_debug_level == 1 ) { m_set_palette(tc[0], M_TEXT_COLOR_PINK ); mprintf("Free mem size %d bytes\n", OS_GetTotalFreeSize(OS_ARENA_MAIN, hHeap)); @@ -1271,11 +1401,6 @@ void TwlMain(void) /* OS_IsRebootedなんかおかしい・・ */ -#if 1 /* miya */ - OS_TPrintf("NCFGConfig = %d 0x%04x\n", sizeof(NCFGConfig),sizeof(NCFGConfig)); - OS_TPrintf("NCFGConfigEx = %d 0x%04x\n", sizeof(NCFGConfigEx), sizeof(NCFGConfigEx)); -#endif - MIYA_MCU_Init(); OS_TPrintf("MCU Free Reg. 0x%02x\n", MCU_GetFreeReg()); @@ -1361,16 +1486,53 @@ void TwlMain(void) } - // 国が選択されていないなら適当に設定 - if( LCFG_TSD_GetCountry() == LCFG_TWL_COUNTRY_UNDEFINED ) { - LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_JAPAN); - // mprintf("Set dummy Country code\n"); - } // region org_region = LCFG_THW_GetRegion(); // ES Device ID + // 国が選択されていないなら適当に設定 + if( LCFG_TSD_GetCountry() == LCFG_TWL_COUNTRY_UNDEFINED ) { + + mprintf("Set dummy Country code "); + + switch( org_region ) { + case OS_TWL_REGION_JAPAN: + LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_JAPAN); + mprintf("JPN"); + break; + case OS_TWL_REGION_AMERICA: + LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_UNITED_STATES); + mprintf("USA"); + break; + case OS_TWL_REGION_EUROPE: + LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_UNITED_KINGDOM); + mprintf("UK"); + break; + case OS_TWL_REGION_AUSTRALIA: + LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_AUSTRALIA); + mprintf("AUS"); + break; + case OS_TWL_REGION_CHINA: + LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_CHINA); + mprintf("CHN"); + break; + case OS_TWL_REGION_KOREA: + LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_SOUTH_KOREA); + mprintf("KOR"); + break; + case OS_TWL_REGION_MAX: + default: + mprintf("JPN"); + LCFG_TSD_SetCountry(LCFG_TWL_COUNTRY_JAPAN); + break; + } + mprintf("\n"); + + } + + + org_fuseId = SCFG_ReadFuseData(); OS_TPrintf("eFuseID: %08X%08X\n", (u32)(org_fuseId >> 32), (u32)(org_fuseId)); @@ -1443,10 +1605,11 @@ void TwlMain(void) text_blink_current_line(tc[0]); mprintf("insert SD card\n"); } - + } + /* FALSE == reboot_flag ここまで */ else { - + /* ここからリブート後 */ if( FALSE == wlan_active_flag ) { select_mode = 1; no_network_flag = TRUE; @@ -1858,6 +2021,8 @@ void TwlMain(void) m_set_palette(tc[1], M_TEXT_COLOR_LIGHTBLUE ); mfprintf(tc[1],"Device ID: "); m_set_palette(tc[1], M_TEXT_COLOR_WHITE ); + + /* ここで mydata.shop_record_flag といっしょに */ if( TRUE == mydata.shop_record_flag ) { mfprintf(tc[1],"%s\n", mydata.bmsDeviceId); } diff --git a/build/tools/sctools/copy_org/src/main.c b/build/tools/sctools/copy_org/src/main.c index d3eb964..dd3d064 100644 --- a/build/tools/sctools/copy_org/src/main.c +++ b/build/tools/sctools/copy_org/src/main.c @@ -128,6 +128,71 @@ static BOOL start_my_thread(void) return FALSE; } +static void *AllocForNAM(size_t size) +{ + OSIntrMode old = OS_DisableInterrupts(); + void* p = OS_Alloc(size); + OS_RestoreInterrupts(old); + return p; +} + +static void FreeForNAM(void* ptr) +{ + if( ptr != NULL ) { + OSIntrMode old = OS_DisableInterrupts(); + OS_Free(ptr); + OS_RestoreInterrupts(old); + } +} + + +static int Check_User_Titles(void) +{ + +#define NAM_TITLE_ID_S 128 + + NAMTitleId pArray[NAM_TITLE_ID_S]; + s32 i; + s32 num = 0; + int user_tilte_count = 0; + u64 id; + + + num = NAM_GetNumTitles(); + if( num > 0 ) { + if( NAM_OK != NAM_GetTitleList( pArray , NAM_TITLE_ID_S ) ) { + return -1; /* error */ + } + OS_TPrintf("NAND Installed titles\n"); + for( i = 0 ; i < num ; i++ ) { + id = pArray[i]; + + /* + No. 0 0003000f484e4c41 + No. 1 0003000f484e4841 + No. 2 0003000f484e4341 + No. 3 00030015484e4241 + No. 4 00030017484e4141 launcher + ^ + | ここの最下位ビットが1のやつがシステムアプリ + | + システムアプリはダウンロード対象外 + */ + if( id & 0x0000000100000000 ) { + /* system app. */ + OS_TPrintf(" sys.:%3d:0x%llx\n", i, id); + + } + else { + /* user app. */ + OS_TPrintf(" usr.:%3d:0x%llx\n", i, id); + user_tilte_count++; + } + } + } + return user_tilte_count; +} + static BOOL SDBackupToSDCard2(void) @@ -444,11 +509,16 @@ static BOOL SDBackupToSDCard7(void) } (void)ClearDirEntryList( &dir_entry_list_head ); + if( TRUE == Error_Report_Display(tc[0]) ) { mprintf("\n"); } Error_Report_End(); + if(TRUE == no_sd_clean_flag ) { + mprintf("num of user tiltes = %d\n",mydata.num_of_user_download_app); + } + return flag; } @@ -525,7 +595,7 @@ static void MyThreadProc(void *arg) (void)OS_ReceiveMessage(&MyMesgQueue_request, &message, OS_MESSAGE_BLOCK); if( no_sd_clean_flag == FALSE ) { - mprintf("cleaning up SD card.. "); + mprintf("cleaning up SD card files "); (void)CleanSDCardFiles(NULL); mprintf("done.\n"); } @@ -804,9 +874,14 @@ void TwlMain(void) if( es_error_code == ES_ERR_OK ) { if( TRUE == CheckShopRecord( NULL ) ) { mydata.shop_record_flag = TRUE; + mprintf("Shop record was found.\n"); } else { - mprintf("no shop record\n"); + /* + ショップに繋いだことがあるかどうかを判定している。 + プリインストール時はどうなの? + */ + mprintf("no Shop record.\n"); } } else { @@ -819,6 +894,15 @@ void TwlMain(void) OS_TPrintf("DeviceID: %s\n", mydata.bmsDeviceId); } + + /* NAM の初期化 */ + NAM_Init(&AllocForNAM, &FreeForNAM); + + + mydata.num_of_user_download_app_by_nam = Check_User_Titles(); + mprintf("num of user tiltes = %d\n",mydata.num_of_user_download_app_by_nam); + + mprintf("\n"); mydata.volume = (s32)MCU_GetVolume(); diff --git a/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnhttp.nssl.TWL.LTD.a b/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnhttp.nssl.TWL.LTD.a index 0ad9e69..c81bc1f 100644 Binary files a/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnhttp.nssl.TWL.LTD.a and b/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnhttp.nssl.TWL.LTD.a differ diff --git a/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnhttp.nssl.TWL.LTD.thumb.a b/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnhttp.nssl.TWL.LTD.thumb.a index 28dedbe..19463d7 100644 Binary files a/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnhttp.nssl.TWL.LTD.thumb.a and b/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnhttp.nssl.TWL.LTD.thumb.a differ diff --git a/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnssl.TWL.LTD.a b/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnssl.TWL.LTD.a index 07acfdc..d5412a9 100644 Binary files a/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnssl.TWL.LTD.a and b/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnssl.TWL.LTD.a differ diff --git a/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnssl.TWL.LTD.thumb.a b/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnssl.TWL.LTD.thumb.a index 3710c5b..6cbeaee 100644 Binary files a/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnssl.TWL.LTD.thumb.a and b/build/tools/sctools/wifilib/ARM9-TS.LTD/Release/libnssl.TWL.LTD.thumb.a differ