diff --git a/build/tools/sctools/Makefile b/build/tools/sctools/Makefile index b6b7ae7..e8f1df9 100644 --- a/build/tools/sctools/Makefile +++ b/build/tools/sctools/Makefile @@ -18,7 +18,9 @@ -SUBDIRS = make_tad_table my_armadillo.TWL copy_org copy_dst auto_preinst_rom +SUBDIRS = make_tad_table my_armadillo.TWL copy_org copy_dst auto_preinst_rom + + include $(TWLSDK_ROOT)/build/buildtools/commondefs diff --git a/build/tools/sctools/auto_preinst_rom/Makefile b/build/tools/sctools/auto_preinst_rom/Makefile index 08dd46c..a978417 100644 --- a/build/tools/sctools/auto_preinst_rom/Makefile +++ b/build/tools/sctools/auto_preinst_rom/Makefile @@ -28,7 +28,7 @@ SRCS = main.c key.c font.c text.c mprintf.c logprintf.c \ myfilename.c menu_version.c \ sitedefs.c wcm_control.c netconnect.c mywlan.c \ myimport.c pre_install.c \ - my_rsa_sign.c my_aes.c my_sha.c my_sign.c + my_rsa_sign.c my_aes.c my_sha.c my_sign.c my_keys.c hatamotolib.cpp # my_rsa.c @@ -50,7 +50,7 @@ ES_ROOT = $(ES_LATEST) BSAFE_DIR = $(TWLSDK_ROOT)/build/libraries/crypto/common/mes -LINCLUDES = ../common/src ../copy_dst/src \ +LINCLUDES = ../common/src \ $(TWLSDK_ROOT)/build/libraries/lcfg/ARM9.TWL/include \ $(TWLSDK_ROOT)/build/libraries/nam/ARM9.TWL/include \ $(TWLSDK_ROOT)/build/libraries/ese/common/include \ diff --git a/build/tools/sctools/auto_preinst_rom/src/main.c b/build/tools/sctools/auto_preinst_rom/src/main.c index d35c4dd..871dc09 100644 --- a/build/tools/sctools/auto_preinst_rom/src/main.c +++ b/build/tools/sctools/auto_preinst_rom/src/main.c @@ -32,6 +32,7 @@ #include "wcm_control.h" +#define HATAMOTO_LIB 1 #define THREAD_COMMAND_INSTALL_APP 1 #define THREAD_COMMAND_INSTALL_TICKET 2 @@ -264,7 +265,7 @@ static BOOL LoadWlanConfig(void) void TwlMain(void) { - int i; + int i,n; void* newArenaLo; u8 macAddress[6]; ESError es_error_code; @@ -486,6 +487,27 @@ OS_TPrintf("%s %s %d\n", __FILE__,__FUNCTION__,__LINE__ ); else if ( keyData & PAD_BUTTON_SELECT ) { (void)start_my_thread(THREAD_COMMAND_DOWNLOAD_APP); } + else if ( keyData & PAD_KEY_RIGHT ) { + n = m_get_display_offset_x(tc[0]); + n++; + m_set_display_offset_x(tc[0], n); + } + else if ( keyData & PAD_KEY_LEFT ) { + n = m_get_display_offset_x(tc[0]); + n--; + m_set_display_offset_x(tc[0], n); + } + else if ( keyData & PAD_KEY_UP ) { + n = m_get_display_offset_y(tc[0]); + n++; + m_set_display_offset_y(tc[0], n); + } + else if ( keyData & PAD_KEY_DOWN ) { + n = m_get_display_offset_y(tc[0]); + n--; + m_set_display_offset_y(tc[0], n); + } + mfprintf(tc[1], "\fAuto Pre-install Tool\n"); @@ -592,7 +614,7 @@ OS_TPrintf("%s %s %d\n", __FILE__,__FUNCTION__,__LINE__ ); } - +#if 0 static MY_USER_APP_TID title_id_buf_ptr[] = { {0x000300044b47554a, 2, FALSE }, {0x000300044b32444a, 2, FALSE }, @@ -610,6 +632,11 @@ static MY_USER_APP_TID title_id_buf_ptr[] = { }; static int title_id_count = sizeof(title_id_buf_ptr)/sizeof(MY_USER_APP_TID); +#else +static MY_USER_APP_TID *title_id_buf_ptr; +static int title_id_count = 0; +#endif + #ifdef HATAMOTO_LIB static void ec_download_func(void) @@ -629,6 +656,7 @@ static void ec_download_func(void) mprintf("OK.\n"); m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); +#if 0 SetupShopTitleId(); /* エラーはない */ // ?:ユーザ設定がされていないと接続できないので適当に設定 @@ -639,7 +667,7 @@ static void ec_download_func(void) ret_flag = FALSE; goto end_log_e; } - +#endif // 必須:ネットワークへの接続 if( 0 != NcStart(SITEDEFS_DEFAULTCLASS) ) { mprintf("%s failed NcStart\n", __FUNCTION__); @@ -660,6 +688,7 @@ static void ec_download_func(void) /******** NHTTP & NSSLにつないだ *************/ // 必須:EC の初期化 mprintf("-setup EC\n"); + if( FALSE == SetupEC() ) { ret_flag = FALSE; mprintf(" %s failed SetupEC\n", __FUNCTION__); @@ -823,6 +852,13 @@ static void MyThreadProc(void *arg) break; case THREAD_COMMAND_DOWNLOAD_APP: #ifdef HATAMOTO_LIB + SetupShopTitleId(); /* エラーはない */ + if( FALSE == SetupVerData() ) { + mprintf("%s failed SetupVerData\n", __FUNCTION__); + } + (void)SetupEC_pre(); + pre_install_eticket_only_process( NULL, development_console_flag , + &title_id_buf_ptr,&title_id_count); ec_download_func(); #endif break; diff --git a/build/tools/sctools/common/src/my_fs_util.c b/build/tools/sctools/common/src/my_fs_util.c index edebc61..33ed612 100644 --- a/build/tools/sctools/common/src/my_fs_util.c +++ b/build/tools/sctools/common/src/my_fs_util.c @@ -981,6 +981,27 @@ static void AppErrorReport(const char *path, char *msg) } +static void AppErrorReport2(const char *path, char *msg, char *msg2) +{ + char game_code[5]; + char *dir_name1 = "nand:/shared2"; + char *dir_name2 = "nand2:/photo"; + if( !STD_StrNCmp( path, dir_name1 , STD_StrLen(dir_name1) ) ) { + (void)Error_Report_Printf(" Shared:%s %s\n", msg, msg2); + } + else if( !STD_StrNCmp( path, dir_name2 , STD_StrLen(dir_name2) ) ) { + (void)Error_Report_Printf(" Photo :%s %s\n", msg, msg2); + } + else if( TRUE == GetAppGameCode(path, game_code, NULL ) ) { + (void)Error_Report_Printf(" [%s]:%s %s\n", game_code, msg, msg2); + } + else { + (void)Error_Report_Printf(" [????]:%s %s\n path=%s\n",msg, msg2, path); + } +} + + + static u64 GetTitleIdFromSrcPath(char path[]) { u64 tid = 0; @@ -1407,8 +1428,10 @@ BOOL RestoreDirEntryList( char *path , char *log_file_name, int *list_count, int FSFile log_fd_real; FSFile *log_fd; BOOL log_active = FALSE; - - +#if 0 + int slen; + char *sfile_name; +#endif log_fd = &log_fd_real; log_active = Log_File_Open( log_fd, log_file_name ); @@ -1556,7 +1579,21 @@ BOOL RestoreDirEntryList( char *path , char *log_file_name, int *list_count, int /* ファイルでもディレクトリでもどっちでもここを通る */ if( copy_error_flag == FALSE ) { (*error_count)++; + // miya 20091113 +#if 0 + slen = STD_StrLen(list_temp.src_path); + while( slen > 0 ) { + slen--; + if( list_temp.src_path[slen] == '/' ) { + slen++; + sfile_name = &(list_temp.src_path[slen]); + break; + } + } + AppErrorReport2(list_temp.src_path, "copy file failed ",sfile_name); +#else AppErrorReport(list_temp.src_path, "copy file failed"); +#endif } else { (*list_count)++; @@ -1615,6 +1652,8 @@ BOOL RestoreDirEntryList_System_And_InstallSuccessApp(char *path , char *log_fil BOOL log_active = FALSE; u64 tid; char game_code_buf[5]; + int slen; + char *sfile_name; log_fd = &log_fd_real; log_active = Log_File_Open( log_fd, log_file_name ); @@ -1726,6 +1765,7 @@ BOOL RestoreDirEntryList_System_And_InstallSuccessApp(char *path , char *log_fil if( !STD_StrCmp( list_temp.src_path, "nand:" ) ) { /* nandのルートディレクトリはスルーする。 */ OS_TPrintf("nand: root detect \n"); + } else { @@ -1734,7 +1774,7 @@ BOOL RestoreDirEntryList_System_And_InstallSuccessApp(char *path , char *log_fil (TRUE == CheckInstallSuccessApp(list_temp.src_path, title_id_buf, title_id_count)) ) { /* 一応拡張子(*.sav)もチェックしといたほうがいいか? */ - miya_log_fprintf(log_fd, "backup %s\n",list_temp.src_path); + miya_log_fprintf(log_fd, "backup 1 %s\n",list_temp.src_path); tid = GetTitleIdFromSrcPath( list_temp.src_path ); (void)my_fs_Tid_To_GameCode(tid, game_code_buf); @@ -1786,8 +1826,11 @@ BOOL RestoreDirEntryList_System_And_InstallSuccessApp(char *path , char *log_fil } } else { + miya_log_fprintf(log_fd, "backup 2 %s\n",list_temp.src_path); + /* インストール失敗アプリの場合。 */ if( 2 == CheckInstallSuccessAppEx(list_temp.src_path, title_id_buf, title_id_count) ) { + tid = GetTitleIdFromSrcPath( list_temp.src_path ); (void)my_fs_Tid_To_GameCode(tid, game_code_buf); @@ -1809,12 +1852,26 @@ BOOL RestoreDirEntryList_System_And_InstallSuccessApp(char *path , char *log_fil if( copy_error_flag == FALSE ) { (*error_count)++; + // miya 20091113 +#if 1 + slen = STD_StrLen(list_temp.src_path); + while( slen > 0 ) { + slen--; + if( list_temp.src_path[slen] == '/' ) { + slen++; + sfile_name = &(list_temp.src_path[slen]); + break; + } + } + AppErrorReport2(list_temp.src_path, "copy failed ",sfile_name); +#else AppErrorReport(list_temp.src_path, "copy file failed"); +#endif } } - - miya_log_fprintf(log_fd, "%s Read entry count %d error count %d\n",__FUNCTION__ , *list_count, *error_count ); - + + miya_log_fprintf(log_fd, "Read entry count %d error count %d\n", *list_count, *error_count ); + #ifdef ATTRIBUTE_BACK /* add_entry_list( &readonly_list_head, &list_temp ); でリストにしたエントリーのアトリビュートを逆順で元に戻す。*/ @@ -2636,7 +2693,46 @@ BOOL CheckShopRecord(FSFile *log_fd) } -//static BOOL +BOOL CheckDevDotKP(FSFile *log_fd) +{ + FSFile f; + BOOL ret_flag = TRUE; + BOOL bSuccess; + char path[64]; + s32 readSize = 0; + /* "nand:/sys/log/shop.log */ + miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__); + + FS_InitFile(&f); + STD_StrCpy(path, "nand:/sys/dev.kp"); + + /* + shop.logは + 本体設定初期化では消さない。 + ショップの履歴消去では消す。 + 当然、ショップに再接続したら作られる。 + */ + + bSuccess = FS_OpenFileEx(&f, path, (FS_FILEMODE_R)); + if( ! bSuccess ) { + if( FS_RESULT_NO_ENTRY == FS_GetArchiveResultCode(path) ) { + /* キーペアファイルがない */ + /* Shopログファイルがない */ + ret_flag = FALSE; + // miya_log_fprintf(log_fd, "No key pair file\n"); + miya_log_fprintf(log_fd, "No shop log file\n"); + } + } + else { + (void)FS_CloseFile(&f); + } + + + miya_log_fprintf(log_fd, "%s END\n\n", __FUNCTION__); + + return ret_flag; +} + static BOOL myCleanDirectory(char *path, FSFile *log_fd, int level) { diff --git a/build/tools/sctools/common/src/my_fs_util.h b/build/tools/sctools/common/src/my_fs_util.h index fd0422e..e59d6bd 100644 --- a/build/tools/sctools/common/src/my_fs_util.h +++ b/build/tools/sctools/common/src/my_fs_util.h @@ -67,6 +67,7 @@ void write_debug_data(void); BOOL SDCardValidation(void); BOOL TWLCardValidation(void); BOOL CheckShopRecord(FSFile *log_fd); +BOOL CheckDevDotKP(FSFile *log_fd); BOOL CleanSDCardFiles(char *log_file_name); diff --git a/build/tools/sctools/common/src/mydata.h b/build/tools/sctools/common/src/mydata.h index 1067cf3..bed7e66 100644 --- a/build/tools/sctools/common/src/mydata.h +++ b/build/tools/sctools/common/src/mydata.h @@ -2,8 +2,8 @@ #define _MY_DATA_H_ -#define MY_DATA_VERSION_MAJOR 1 -#define MY_DATA_VERSION_MINOR 9 +#define MY_DATA_VERSION_MAJOR 2 +#define MY_DATA_VERSION_MINOR 0 typedef struct { u8 version_major; @@ -18,7 +18,7 @@ typedef struct { BOOL wireless_lan_param_flag; BOOL user_settings_flag; BOOL shop_record_flag; - // int num_of_user_download_app; + BOOL dev_dot_kp_flag; int num_of_user_app; int num_of_user_pre_installed_app; int num_of_user_pre_installed_eticket_only; @@ -39,7 +39,7 @@ typedef struct { char bmsDeviceId[32]; s32 volume; s32 backlight_brightness; - u32 reserve[256]; + u32 reserve[128]; } MyData; diff --git a/build/tools/sctools/common/src/mynvram.c b/build/tools/sctools/common/src/mynvram.c index 7ba36a3..db8987e 100644 --- a/build/tools/sctools/common/src/mynvram.c +++ b/build/tools/sctools/common/src/mynvram.c @@ -138,6 +138,60 @@ static void ReportLastErrorPath(const char *path) static u8 my_nor_buf[NVRAM_PERSONAL_DATA_SIZE] ATTRIBUTE_ALIGN(32); static u8 work_content[NCFG_CHECKCONFIGEX_WORK_SIZE]; + +BOOL nvram_get(u8 buf[0xa00]) +{ + BOOL ret_flag = TRUE; + u32 offset; + + if( TRUE != my_nvram_read( NVRAM_PERSONAL_DATA_OFFSET , sizeof(u16), (void* )&offset) ) { + OS_TPrintf( "nvram error: %s %s %d\n",__FILE__,__FUNCTION__,__LINE__); + } + + if( offset == 0 ) { + OS_TPrintf( "nvram error: offset = 0x%02x\n", offset); + return FALSE; + } + + offset *= 8; + offset -= 0xA00; + + if( TRUE != my_nvram_read( offset , NVRAM_PERSONAL_DATA_SIZE, (void* )buf) ) { + OS_TPrintf( "nvram error: %s %s %d\n",__FILE__,__FUNCTION__,__LINE__); + ret_flag = FALSE; + } + return ret_flag; +} + +BOOL nvram_set(u8 buf[0xa00]) +{ + BOOL ret_flag = TRUE; + u32 offset; + + if( TRUE != my_nvram_read( NVRAM_PERSONAL_DATA_OFFSET , sizeof(u16), (void* )&offset) ) { + OS_TPrintf( "nvram error: %s %s %d\n",__FILE__,__FUNCTION__,__LINE__); + ret_flag = FALSE; + } + else { + OS_TPrintf( "nvram success: offset = 0x%02x\n", offset); + } + + if( offset == 0 ) { + OS_TPrintf( "nvram error: offset = 0x%02x\n", offset); + return FALSE; + } + + /* offsetのチェックは? */ + offset *= 8; + offset -= 0xA00; + if( TRUE != my_nvram_write( offset , /* size */ NVRAM_PERSONAL_DATA_SIZE, (void* )buf) ) { + ret_flag = FALSE; + OS_TPrintf( "nvram write error: %s %s %d\n",__FILE__,__FUNCTION__,__LINE__); + } + return ret_flag; +} + + BOOL nvram_backup(char *path) { BOOL bSuccess; @@ -216,6 +270,8 @@ typedef struct tagDWCWiFiInfo { u16 randomHistory; // 乱数履歴 } DWCWiFiInfo; + + BOOL nvram_restore(char *path) { BOOL bSuccess; diff --git a/build/tools/sctools/common/src/mynvram.h b/build/tools/sctools/common/src/mynvram.h index 514c0ae..8b71485 100644 --- a/build/tools/sctools/common/src/mynvram.h +++ b/build/tools/sctools/common/src/mynvram.h @@ -8,6 +8,8 @@ extern "C" { // BOOL my_nvram_read( u32 offset, u32 size, void *buf); BOOL nvram_backup(char *path); BOOL nvram_restore(char *path); +BOOL nvram_get(u8 buf[0xa00]); +BOOL nvram_set(u8 buf[0xa00]); #ifdef __cplusplus } diff --git a/build/tools/sctools/common/src/pre_install.c b/build/tools/sctools/common/src/pre_install.c index 462dc4b..7156793 100644 --- a/build/tools/sctools/common/src/pre_install.c +++ b/build/tools/sctools/common/src/pre_install.c @@ -851,6 +851,100 @@ BOOL pre_install_debug(FSFile *log_fd, BOOL development_version_flag ) return TRUE; } + +BOOL pre_install_eticket_only_process( FSFile *log_fd, BOOL development_version_flag , + MY_USER_APP_TID **tid_buf, int *tid_count) +{ + BOOL ret_flag = TRUE; + char *tad_file_name; + PRE_INSTALL_FILE *temp_list; + u64 tid; + char game_code_buf[5]; + int count = 0; + // int i; + MY_USER_APP_TID *temp_tid; + + if( development_version_flag ) { + (void)pre_install_load_file(PRE_INSTALL_TABLE_DEV_FILE_SD, log_fd, TRUE); + (void)pre_install_load_file(PRE_INSTALL_TABLE_DEV_FILE_NAND, log_fd, FALSE); + } + else { + (void)pre_install_load_file(PRE_INSTALL_TABLE_FILE_SD, log_fd, TRUE); + (void)pre_install_load_file(PRE_INSTALL_TABLE_FILE_NAND, log_fd, FALSE); + } + + if( pre_install_file_list == NULL) { + goto end; + } + + for( temp_list = pre_install_file_list ; temp_list != NULL ; temp_list = temp_list->next ) { + count++; + } + *tid_count = count; + if( count > 0 ) { + temp_tid = (MY_USER_APP_TID *)OS_Alloc(count * sizeof(MY_USER_APP_TID)); + *tid_buf = temp_tid; + if( *tid_buf == NULL) { + mprintf("alloc error.\n"); + goto end; + } + + for( temp_list = pre_install_file_list ; temp_list != NULL ; temp_list = temp_list->next ) { + tid = temp_list->tid; + (void)my_fs_Tid_To_GameCode(tid, game_code_buf); + mprintf(" TO %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf); + temp_tid->tid = tid; + temp_tid->is_personalized = 1; + temp_tid->version = 0; + temp_tid->common_and_download = 0; + temp_tid->install_success_flag = FALSE; + + tad_file_name = temp_list->file_name; + if( tad_file_name ) { + if( !STD_StrNCmp( temp_list->file_name, "sdmc:" , STD_StrLen("sdmc:")) ) { + ret_flag = my_NAM_ImportTadTicketOnly_sign( tad_file_name ); + } + else { + ret_flag = my_NAM_ImportTadTicketOnly( tad_file_name ); + } + + if( FALSE == ret_flag ) { + /* error チケットインストール失敗? */ + miya_log_fprintf(log_fd, "NG.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* green */ + mprintf("NG.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + miya_log_fprintf(log_fd, "error: import tid=0x%08x%08x %s\n", + (u32)(tid >> 32) , (u32)(tid & 0xffffffff), tad_file_name); + ret_flag = FALSE; + } + else { + miya_log_fprintf(log_fd, "OK.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ + mprintf("OK.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + } + else { + /* error ROMにファイルがない */ + miya_log_fprintf(log_fd, "NG.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_RED ); /* green */ + mprintf("NG.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + mprintf("No file\n"); + miya_log_fprintf(log_fd, "error: no file\n"); + ret_flag = FALSE; + } + temp_tid++; + } + } + end: + + (void)pre_install_discard_list(); + return ret_flag; +} + + BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int title_id_count, MY_USER_ETICKET_TID *ticket_id_array, int ticket_id_count, BOOL development_version_flag ) { @@ -968,7 +1062,7 @@ BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int } if( ret_flag == TRUE ) { - title_id_buf_ptr[i].common_and_download = 1; /* あとでダウンロードするようにチェックをつける。 */ + title_id_buf_ptr[i].common_and_download = TRUE; /* あとでダウンロードするようにチェックをつける。 */ miya_log_fprintf(log_fd, "OK.\n"); m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ mprintf("OK.\n"); diff --git a/build/tools/sctools/common/src/pre_install.h b/build/tools/sctools/common/src/pre_install.h index e0eb909..34e718f 100644 --- a/build/tools/sctools/common/src/pre_install.h +++ b/build/tools/sctools/common/src/pre_install.h @@ -19,6 +19,9 @@ BOOL pre_install_Cleanup_User_Titles( FSFile *log_fd ); BOOL pre_install_process( FSFile *log_fd, MY_USER_APP_TID *title_id_buf_ptr, int tile_id_count, MY_USER_ETICKET_TID *ticket_id_array, int ticket_id_count ,BOOL development_version_flag ); +BOOL pre_install_eticket_only_process( FSFile *log_fd, BOOL development_version_flag, + MY_USER_APP_TID **tid_buf, int *tid_count); + BOOL pre_install_check_download_or_pre_install(u64 tid, int *flag, u8 *es_ver, u16 *ticket_ver, FSFile *log_fd); BOOL pre_install_get_version(u64 tid, u16 *version); diff --git a/build/tools/sctools/copy_dst/Makefile b/build/tools/sctools/copy_dst/Makefile index d644bf0..8b0aa77 100644 --- a/build/tools/sctools/copy_dst/Makefile +++ b/build/tools/sctools/copy_dst/Makefile @@ -28,7 +28,7 @@ SRCS = main.c mfiler.c key.c font.c text.c mprintf.c logprintf.c \ sitedefs.c wcm_control.c netconnect.c mywlan.c \ mynuc.c nuc_error_msg.c stream.c myfilename.c menu_version.c \ ntp.c myimport.c pre_install.c \ - my_rsa_sign.c my_aes.c my_sha.c my_sign.c my_keys.c + my_rsa_sign.c my_aes.c my_sha.c my_sign.c my_keys.c wifi_cfg.c TARGET_BIN = copy_dst.srl @@ -162,6 +162,8 @@ $(TARGET_AUTOBOOT): ./bin/$(TWL_BUILDTYPE)/$(TARGET_BIN) + + do-build: $(TARGETS) $(TARGET_AUTOBOOT) @@ -170,6 +172,7 @@ $(BINDIR)/$(TARGET_BIN_BASENAME).$(TWL_ELF_EXT): MakefileTad.inc MakefileTadDev. + #---------------------------------------------------------------------------- include $(TWLWIFI_ROOT)/build/buildtools/modulerules diff --git a/build/tools/sctools/copy_dst/copy_dst_china.rsf b/build/tools/sctools/copy_dst/copy_dst_china.rsf new file mode 100644 index 0000000..1184435 --- /dev/null +++ b/build/tools/sctools/copy_dst/copy_dst_china.rsf @@ -0,0 +1,331 @@ +#---------------------------------------------------------------------------- +# Project: TwlSDK - include +# File: ROM-TS.rsf +# +# Copyright 2007-2008 Nintendo. All rights reserved. +# +# These coded insructions, statements, and computer programs contain +# proprietary information of Nintendo of America Inc. and/or Nintendo +# Company Ltd., and are protected by Federal copyright law. They may +# not be disclosed to third parties or copied or duplicated in any form, +# in whole or in part, without the prior written consent of Nintendo. +# +# $Date:: 2008-09-26#$ +# $Rev: 8709 $ +# $Author: hatamoto_minoru $ +#---------------------------------------------------------------------------- +# +# TWL ROM SPEC FILE +# + +Arm9 +{ + Static "$(MAKEROM_ARM9:r).TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.FLX.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.FLX.sbin$(COMPSUFFIX9)" + Elf "$(MAKEROM_ARM9:r).tef" +} + +Arm7 +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.FLX.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.FLX.sbin$(COMPSUFFIX7)" + Elf "$(MAKEROM_ARM7_BASE:r).tef" +} + +Arm9.Ltd +{ + Static "$(MAKEROM_ARM9:r).TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayDefs "$(MAKEROM_ARM9:r)_defs.TWL.LTD.sbin$(COMPSUFFIX9)" + OverlayTable "$(MAKEROM_ARM9:r)_table.TWL.LTD.sbin$(COMPSUFFIX9)" +} + +Arm7.Ltd +{ + Static "$(MAKEROM_ARM7_BASE:r).TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayDefs "$(MAKEROM_ARM7_BASE:r)_defs.TWL.LTD.sbin$(COMPSUFFIX7)" + OverlayTable "$(MAKEROM_ARM7_BASE:r)_table.TWL.LTD.sbin$(COMPSUFFIX7)" +} + +Property +{ + ### + ### Settings for FinalROM + ### + #### BEGIN + # + # TITLE NAME: Your product name within 12bytes + # + #TitleName "MY APP NAME" + + # + # MAKER CODE: Your company ID# in 2 ascii words + # issued by NINTENDO + # + MakerCode 01 + + # + # REMASTER VERSION: Mastering version + # + #RemasterVersion 0 + + # + # ROM SPEED TYPE: [MROM/1TROM/UNDEFINED] + # + RomSpeedType $(MAKEROM_ROMSPEED) + + # + # ROM SIZE: in bit [64M/128M/256M/512M/1G/2G/4G] + # + #RomSize 256M + + # + # ROM PADDING: TRUE if finalrom + # + #RomFootPadding TRUE + + # + # ROM HEADER TEMPLATE: Provided to every product by NINTENDO + # + #RomHeaderTemplate ./etc/rom_header.template.sbin + + # + # BANNER FILE: generated from Banner Spec File + # + BannerFile "banner/banner.bnr" + + + # + # Permit LandingNormalJump: for TWL "ApplicationJump" function [TRUE/FALSE] + # + #PermitLandingNormalJump FALSE + + # + # Permit LandingTmpJump: for TWL "ApplicationJump" function [TRUE/FALSE] + # + #PermitLandingTmpJump FALSE + + ### + ### Setting for TWL + ### + + # + # ROM HEADER Ltd: Provided to every product by NINTENDO + # + RomHeaderLtd $(TWLSDK_ROOT)/tools/bin/rom_header.LTD.sbin + + # + # Digest parameters: + # + DigestParam 1024 32 + + # + # WRAM mapping: [MAP_BB_HYB/MAP_BB_LTD/MAP_TS_HYB/MAP_TS_LTD + # MAP2_BB_HYB/MAP2_BB_LTD/MAP2_TS_HYB/MAP2_TS_LTD] + # don't have to edit + # + WramMapping MAP_TS_SCR + + # + # CardRegion: card region [Japan/America/Europe/Australia/China/Korea] + # + + # + CardRegion China + + ForChina TRUE + + # CardRegion All + + # + # CommonClientKey: launcher deliver common client Key [TRUE/FALSE] + # + CommonClientKey TRUE + + # + # HwAESSlotA_SSLClientCert: launcher deliver HW AES slot A setting [TRUE/FALSE] + # + HwAESSlotA_SSLClientCert TRUE + + # + # HwAESSlotB: launcher deliver HW AES slot B setting [TRUE/FALSE] + # + HwAESSlotB TRUE + + # + # HwAESSlotB for Sign JPEG for Launcher: launcher deliver HW AES slot B setting for Sign JPEG for Launcher [TRUE/FALSE] + # + #HwAESSlotB_SignJPEGForLauncher FALSE + + # + # HwAESSlotB for Sign JPEG for User: launcher deliver HW AES slot B setting for Sign JPEG for User [TRUE/FALSE] + # + #HwAESSlotB_SignJPEGForUser FALSE + + # + # HwAESSlotC: launcher deliver HW AES slot C setting [TRUE/FALSE] + # + #HwAESSlotC FALSE + + # + # SDCardAccess: sd card access control [TRUE/FALSE] + # + SDCardAccess ReadWrite + + # + # NANDAccess: NAND access control [TRUE/FALSE] + # + NANDAccess TRUE + + # + # Codec mode: + # don't have to edit + # + CodecMode $(MAKEROM_CODEC_MODE) + + # + # Disp WiFiConnection Icon for Launcher [TRUE/FALSE] + # + #WiFiConnectionIcon FALSE + + # + # Disp DSWireless Icon for Launcher [TRUE/FALSE] + # + #DSWirelessIcon FALSE + + # + # Disable debug [TRUE/FALSE] + # + DisableDebug FALSE + + # + # Agree EULA [TRUE/FALSE] + # + #AgreeEULA FALSE + + # + # Agree EULA version [1 - 255] + # + #AgreeEULAVersion 1 + + ### + #### END +} + +AppendProperty +{ + # + # Publisher : "Nintendo" + # don't have to edit + #Publisher Nintendo + + # + # Application type : [USER/SYSTEM] + # don't have to edit + AppType System + + # + # launch title on the launcher : [TRUE/FALSE] + # don't have to edit + #Launch TRUE + + # + # Boot allowed Media: [GameCard] + # + Media GameCard + + # + # Data only title : [TRUE/FALSE] + # don't have to edit + #DataOnly FALSE + + # + # Secure title : [TRUE/FALSE] + # don't have to edit + Secure TRUE + + # + # InitialCode : Your InitialCode in 4 ascii words + # + #InitialCode ABCJ + + # + # Public save data size: [0-/0K-/0M-] + # + #PublicSaveDataSize 0K + + # + # Private save data size: [0-/0K-/0M-] + # + #PrivateSaveDataSize 0K + + # + # Enable SubBannerFile: [TRUE/FALSE] + # + #SubBannerFile FALSE + + # + # Game card power on: [TRUE/FALSE] + # + GameCardOn FALSE + + # + # Game card transferd to nitro mode: [TRUE/FALSE] + # + #GameCardNitroMode FALSE + + # + # Shared2 file size: [DISABLE/0-4194304/0K-4096K/0M-4M] + # + #Shared2File0Size Disable + #Shared2File1Size Disable + #Shared2File2Size Disable + #Shared2File3Size Disable + #Shared2File4Size Disable + #Shared2File5Size Disable +} + +RomSpec +{ + Offset 0x00000000 + Segment ALL + HostRoot $(MAKEROM_ROMROOT) + Root / + File $(MAKEROM_ROMFILES) +} + +Rating +{ + # + # Permited age to play for each rating organization + # + # Supported organization + # - CERO (OGN0) : for Japan + # - ESRB (OGN1) : for North America + # - BBFC (OGN2) : obsolete organization + # - USK (OGN3) : for German + # - PEGI_GEN (OGN4) : for Europe + # - PEGI_FINLAND (OGN5) : obsolete organization + # - PEGI_PRT (OGN6) : for Portugal + # - PEGI_BBFC (OGN7) : for UK + # - OFLC (OGN8) : for Australia and NewZealand + # - GRB (OGN9) : for Korea + # - OGN10 : reserved + # - OGN11 : reserved + # - OGN12 : reserved + # - OGN13 : reserved + # - OGN14 : reserved + # - OGN15 : reserved + # + # Available age [ 0 - 31 / PENDING / FREE ] + +# CERO FREE +# ESRB FREE +# USK FREE +# PEGI_GEN FREE +# PEGI_PRT FREE +# PEGI_BBFC FREE +# OFLC FREE +# GRB FREE +} diff --git a/build/tools/sctools/copy_dst/src/main.c b/build/tools/sctools/copy_dst/src/main.c index 8fd4adc..dfffbbd 100644 --- a/build/tools/sctools/copy_dst/src/main.c +++ b/build/tools/sctools/copy_dst/src/main.c @@ -58,6 +58,7 @@ #include "myimport.h" #include "pre_install.h" +#include "wifi_cfg.h" #include @@ -71,6 +72,7 @@ #define THREAD_COMMAND_WIFI_FUNCTION 2 #define THREAD_COMMAND_USERDATA_AND_WIFI_FUNCTION 3 #define THREAD_COMMAND_REBOOT_FUNCTION 4 +#define THREAD_COMMAND_RESTORE_SAVEDATA_FUNCTION 5 #define FREE_REG_POWERON_REBOOT 0x00 @@ -80,6 +82,7 @@ static BOOL only_wifi_config_data_trans_flag = FALSE; static BOOL user_and_wifi_config_data_trans_flag = FALSE; +static BOOL only_restore_savedata_flag = FALSE; static BOOL no_network_flag = FALSE; static BOOL completed_flag = FALSE; static FSEventHook sSDHook; @@ -163,7 +166,7 @@ static int vram_num_sub = 0; static LCFGTWLHWNormalInfo hwn_info; static LCFGTWLHWSecureInfo hws_info; -#define MY_STACK_SIZE (1024*64) /* でかいほうがいい */ +#define MY_STACK_SIZE (1024*128) /* でかいほうがいい */ //#define MY_THREAD_PRIO 20 #define MY_THREAD_PRIO 10 @@ -635,19 +638,15 @@ static BOOL RestoreFromSDCard6(void) } - +/* この関数は機能詰めすぎ。バラした方がいい。 */ static BOOL RestoreFromSDCard7(void) { - int i; - ECError rv; BOOL ret_flag = TRUE; - FSFile *log_fd; - int ec_download_ret; + FSFile *log_fd = NULL; + u64 tid; char game_code_buf[5]; int is_personalized; - u64 tid; - MY_USER_ETICKET_TID *eticket_only_id_buf = NULL; - int num_of_eticket_only_titles = 0; + int i; title_id_count = 0; if( title_id_buf_ptr != NULL ) { @@ -655,14 +654,6 @@ static BOOL RestoreFromSDCard7(void) title_id_buf_ptr = NULL; } - title_id_count = 0; - rv = EC_ERROR_OK; - - /* hws_info.serialNoは戻せない */ - - log_fd = hatamotolib_log_start( MyFile_GetEcDownloadLogFileName() ); - - if( mydata.num_of_user_app > 0 ) { miya_log_fprintf(log_fd,"User title list loading\n"); mprintf("User title list load "); @@ -709,7 +700,88 @@ static BOOL RestoreFromSDCard7(void) miya_log_fprintf(log_fd,"Original user app. list saving failed\n"); mprintf("Original user app. list saving failed\n"); } + return ret_flag; +} + + +static BOOL RestoreFromSDCard8(void) +{ + ECError rv; + BOOL ret_flag = TRUE; + FSFile *log_fd; + int ec_download_ret; +#if 0 + char game_code_buf[5]; + u64 tid; + int i; + int is_personalized; +#endif + MY_USER_ETICKET_TID *eticket_only_id_buf = NULL; + int num_of_eticket_only_titles = 0; + +#if 0 + title_id_count = 0; + if( title_id_buf_ptr != NULL ) { + OS_Free( title_id_buf_ptr ); + title_id_buf_ptr = NULL; + } +#endif + + rv = EC_ERROR_OK; + + /* hws_info.serialNoは戻せない */ + + log_fd = hatamotolib_log_start( MyFile_GetEcDownloadLogFileName() ); + +#if 0 + if( mydata.num_of_user_app > 0 ) { + miya_log_fprintf(log_fd,"User title list loading\n"); + mprintf("User title list load "); + if( TRUE == UserTitleIDLoad( MyFile_GetUserTitleIDFileName(), &title_id_buf_ptr, + &title_id_count, MyFile_GetUserTitleIDRestoreLogFileName()) ) { + + m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ + mprintf("OK.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + for( i = 0; i < title_id_count ; i++ ) { + /* + インストール成功フラグの初期化 + とりあえず全部失敗状態にする。 + */ + title_id_buf_ptr[i].install_success_flag = FALSE; + tid = title_id_buf_ptr[i].tid; + is_personalized = title_id_buf_ptr[i].is_personalized; + + (void)my_fs_Tid_To_GameCode(tid, game_code_buf); + mprintf(" id %08X %08X [%s] ", (u32)(tid >> 32), (u32)tid, game_code_buf); + if( is_personalized == 1 ) { + mprintf("Pre\n"); /* プリインストール物 */ + } + else { + mprintf("Dwn\n"); /* ダウンロード物 */ + } + + miya_log_fprintf(log_fd," id %08X %08X [%s] %c\n", (u32)(tid >> 32), (u32)tid, game_code_buf, + (is_personalized == 1)? 'P':'D'); + } + } + else { + ret_flag = FALSE; + m_set_palette(tc[0], M_TEXT_COLOR_RED ); + mprintf("NG.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + } + else if( mydata.num_of_user_app == 0 ) { + miya_log_fprintf(log_fd,"Original device has no user app.\n"); + mprintf("Original device has no user download app.\n"); + } + else { + miya_log_fprintf(log_fd,"Original user app. list saving failed\n"); + mprintf("Original user app. list saving failed\n"); + } +#endif /* miya 2009/5/8 ここで書き込み側に入ってるプリンインストールものを全部消す! @@ -783,9 +855,9 @@ static BOOL RestoreFromSDCard7(void) } } - if( no_network_flag == TRUE ) { miya_log_fprintf(log_fd,"no network flag ON\n"); + goto network_connection_end; } @@ -793,9 +865,10 @@ static BOOL RestoreFromSDCard7(void) /* ネットワークにつながなくていいか? */ miya_log_fprintf(log_fd,"no shop record \n"); mprintf(" (--no shop record--)\n"); + } else { - + network_connetion_start: miya_log_fprintf(log_fd,"EC download\n"); @@ -857,8 +930,6 @@ static BOOL RestoreFromSDCard7(void) // 不要:セーブデータ領域を作成 // NAM_Init を忘れてた - // SetupTitlesDataFile((NAMTitleId *)title_id_buf_ptr , (u32)title_id_count); - SetupTitlesDataFile((MY_USER_APP_TID *)title_id_buf_ptr , (u32)title_id_count); end_ec_f: @@ -919,7 +990,7 @@ static BOOL RestoreFromSDCard7(void) -static BOOL RestoreFromSDCard8(void) +static BOOL RestoreFromSDCard9(void) { int list_count; int error_count; @@ -965,8 +1036,57 @@ static BOOL RestoreFromSDCard8(void) return ret_flag; } +static BOOL RestoreFromSDCard10(void) +{ + int i; + BOOL first_check = FALSE; + u64 tid; + char game_code_buf[5]; + BOOL ret_flag = TRUE; -static BOOL RestoreFromSDCard9(void) + if( mydata.shop_record_flag == FALSE ) { + for( i = 0; i < title_id_count ; i++ ) { + if( title_id_buf_ptr[i].common_and_download == TRUE ) { + /* あとでダウンロードするようにチェックをつけたやつ */ + if( first_check == FALSE ) { + first_check = TRUE; + mprintf("\n"); + if( mydata.dev_dot_kp_flag == TRUE ) { + /* net.log はないけど、dev.kp はある。 */ + m_set_palette(tc[0], M_TEXT_COLOR_PINK ); + text_blink_current_line(tc[0]); + mprintf("User network account\n"); + text_blink_current_line(tc[0]); + mprintf(" has been deleted!\n"); + mprintf("\n"); + m_set_palette(tc[0], M_TEXT_COLOR_YELLOW ); + mprintf("Please update\n the following apps in the SD card\n"); + mprintf(" OR, download from the Internet.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + else { + m_set_palette(tc[0], M_TEXT_COLOR_YELLOW ); + mprintf("Please update\n the following apps in the SD card.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + } + + tid = title_id_buf_ptr[i].tid; + (void)my_fs_Tid_To_GameCode(tid, game_code_buf); + mprintf(" id %08X %08X [%s]\n", (u32)(tid >> 32), (u32)tid, game_code_buf); + } + } + if( first_check == TRUE) { + mprintf("\n"); + ret_flag = FALSE; + } + } + return ret_flag; +} + + + +static BOOL RestoreFromSDCard11(void) { if( title_id_buf_ptr != NULL ) { OS_Free( title_id_buf_ptr ); @@ -977,6 +1097,8 @@ static BOOL RestoreFromSDCard9(void) } + + typedef BOOL (*function_ptr)(void); static function_ptr function_table[] = @@ -990,10 +1112,13 @@ static function_ptr function_table[] = RestoreFromSDCard7, RestoreFromSDCard8, RestoreFromSDCard9, + RestoreFromSDCard10, + RestoreFromSDCard11, }; static int function_table_max = sizeof(function_table) / sizeof(*function_table); static int function_counter = 0; +static int current_function_table_max = sizeof(function_table) / sizeof(*function_table); static void MyThreadProc(void *arg) @@ -1003,6 +1128,7 @@ static void MyThreadProc(void *arg) BOOL flag; BOOL twl_card_validation_flag; u32 command; + int i; m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); @@ -1016,6 +1142,7 @@ static void MyThreadProc(void *arg) switch( command ) { case THREAD_COMMAND_FULL_FUNCTION: + current_function_table_max = function_table_max; m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); if( miya_debug_level == 1 || ( my_fs_get_print_debug_flag() == TRUE )) { @@ -1035,7 +1162,7 @@ static void MyThreadProc(void *arg) } break; case THREAD_COMMAND_WIFI_FUNCTION: - function_table_max = 1; + current_function_table_max = 1; function_counter = 0; if( FALSE == RestoreFromSDCard3() ) { flag = FALSE; @@ -1043,7 +1170,7 @@ static void MyThreadProc(void *arg) function_counter++; break; case THREAD_COMMAND_USERDATA_AND_WIFI_FUNCTION: - function_table_max = 2; + current_function_table_max = 2; function_counter = 0; if( FALSE == RestoreFromSDCard4() ) { flag = FALSE; @@ -1060,9 +1187,32 @@ static void MyThreadProc(void *arg) MCU_SetFreeRegister( FREE_REG_POWERON_REBOOT ); PM_ReadyToExit(); OS_Sleep(100000); + break; + case THREAD_COMMAND_RESTORE_SAVEDATA_FUNCTION: + current_function_table_max = 3; + function_counter = 0; + + if( FALSE == RestoreFromSDCard7() ) { + flag = FALSE; + } + function_counter++; + + for( i = 0 ; i < title_id_count ; i++ ) { + title_id_buf_ptr[i].install_success_flag = TRUE; + } + if( FALSE == RestoreFromSDCard9() ) { + flag = FALSE; + } + function_counter++; + + if( FALSE == RestoreFromSDCard11() ) { + flag = FALSE; + } + function_counter++; + break; default: - function_table_max = 0; + current_function_table_max = 0; function_counter = 0; flag = FALSE; mprintf("%s unknown command!\n",__FUNCTION__); @@ -1198,10 +1348,8 @@ static void MyThreadProcNuc(void *arg) m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); } - RTC_NTP_SYNC(); - /* NSSL_Init()呼んではダメ! */ log_fd = my_nuc_log_start( MyFile_GetNupLogFileName() ); ret_flag = my_numc_proc(); @@ -1314,11 +1462,25 @@ void TwlMain(void) u16 BatterylevelBuf = 0; BOOL isAcConnectedBuf = FALSE; + u32 IPADDR; + u32 NETMASK; + u32 GATEWAY; + u32 DNS1; + u32 DNS2; + #ifdef CHINA_LIMITED BOOL isIgnoreKeyInput = FALSE; + static const char *isbn[4] = { "000-0-000000-00-0", "000-0000-000", "0000", "000" }; + // static const char *isbn[4] = { "978-7-900381-62-7", "025-2004-017", "2005", "065" }; #endif +#ifdef CHINA_LIMITED + OS_InitChina(isbn, OS_CHINA_ISBN_NO_DISP); +#else OS_Init(); +#endif + + OS_InitThread(); OS_InitTick(); @@ -1656,6 +1818,7 @@ void TwlMain(void) Gfx_Set_BG1_line_Color(1, 2, (u16)M_TEXT_COLOR_ORANGE); + while( 1 ) { Gfx_Render( vram_num_main , vram_num_sub ); OS_WaitVBlankIntr(); @@ -1715,7 +1878,7 @@ void TwlMain(void) mydata.wireless_lan_param_flag = TRUE; vram_num_sub = 0; MydataLoadDecrypt_message_flag = TRUE; - MydataLoadDecrypt_dir_flag = TRUE; + // MydataLoadDecrypt_dir_flag = TRUE; MydataLoadDecrypt_success_flag = TRUE; start_my_thread( THREAD_COMMAND_WIFI_FUNCTION ); @@ -1726,11 +1889,19 @@ void TwlMain(void) mydata.wireless_lan_param_flag = TRUE; vram_num_sub = 0; MydataLoadDecrypt_message_flag = TRUE; - MydataLoadDecrypt_dir_flag = TRUE; + // MydataLoadDecrypt_dir_flag = TRUE; MydataLoadDecrypt_success_flag = TRUE; start_my_thread( THREAD_COMMAND_USERDATA_AND_WIFI_FUNCTION ); } + else if( only_restore_savedata_flag == TRUE ) { + vram_num_sub = 0; + MydataLoadDecrypt_success_flag = MydataLoadDecrypt( MyFile_GetGlobalInformationFileName(), + &mydata, sizeof(MyData), NULL); + if(TRUE == MydataLoadDecrypt_success_flag ) { + start_my_thread( THREAD_COMMAND_RESTORE_SAVEDATA_FUNCTION ); + } + } else { mprintf("Personal data. restore "); MydataLoadDecrypt_success_flag = MydataLoadDecrypt( MyFile_GetGlobalInformationFileName(), @@ -1864,15 +2035,211 @@ void TwlMain(void) mprintf("debug level %d\n", miya_debug_level ); } else if ( keyData & PAD_BUTTON_X ) { - if( TRUE == reboot_flag ) { + if( FALSE == reboot_flag ) { + //miya 20091116 + + int slot_no = 0; + char *ssid_str; + u8 key_bin_buf[0x40]; + int key_bin_len; + int wlan_mode; + + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + + mprintf("-wlan settings read "); + if( TRUE == wifi_config_nvram_get() ) { + m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ + mprintf("OK.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + else { + m_set_palette(tc[0], M_TEXT_COLOR_RED ); + mprintf("NG.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + + + mprintf("-Wireless AP conf. load "); + if( FALSE == LoadWlanConfigFile("sdmc:/wlan_cfg.txt") ) { + m_set_palette(tc[0], M_TEXT_COLOR_RED ); + mprintf("NG.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + else { + m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ + mprintf("OK.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + + // wifi_config_print(); + if( FALSE == wifi_config_clear_slot(slot_no) ) { + OS_TPrintf("Error: wifi_config_clear_slot\n"); + } + + + m_set_palette(tc[0], M_TEXT_COLOR_BLUE ); + + ssid_str = GetWlanSSID(); + if( ssid_str ) { + mprintf(" ssid = %s\n",ssid_str); + } + + if( FALSE == wifi_config_set_ssid(slot_no, ssid_str, STD_StrLen(ssid_str) ) ) { + OS_TPrintf("Error: wifi_config_set_ssid\n"); + } + + mprintf(" MODE = "); + wlan_mode = GetWlanMode(); + switch( wlan_mode ) { + case WCM_WEPMODE_NONE: + mprintf("NONE\n"); + break; + case WM_WEPMODE_40BIT: + mprintf("WEP40\n"); + break; + case WM_WEPMODE_104BIT: + mprintf("WEP104\n"); + break; + case WM_WEPMODE_128BIT: + mprintf("WEP128\n"); + break; + case WCM_WEPMODE_WPA_TKIP: + mprintf("WPA-TKIP\n"); + break; + case WCM_WEPMODE_WPA2_TKIP: + mprintf("WPA2-TKIP\n"); + break; + case WCM_WEPMODE_WPA_AES: + mprintf("WPA-AES\n"); + break; + case WCM_WEPMODE_WPA2_AES : + mprintf("WPA2-AES\n"); + break; + defalut: + mprintf("Unknow mode..\n"); + break; + } + + switch( wlan_mode ) { + case WM_WEPMODE_40BIT: + case WM_WEPMODE_104BIT: + case WM_WEPMODE_128BIT: + if( TRUE == GetKeyModeStr() ) { + if( FALSE == wifi_config_set_wep_key_str(slot_no, wlan_mode, GetWlanKEYSTR() )) { + mprintf("Error: wifi_config_wep_key_str\n"); + } + else { + mprintf(" key = %s\n", GetWlanKEYSTR()); + } + } + else { + key_bin_len = GetWlanKEYBIN(key_bin_buf); + if( FALSE == wifi_config_set_wep_key_bin(slot_no, wlan_mode, key_bin_buf, key_bin_len)){ + mprintf("Error: wifi_config_wep_key_bin\n"); + } + } + break; + case WCM_WEPMODE_WPA_TKIP: + case WCM_WEPMODE_WPA2_TKIP: + case WCM_WEPMODE_WPA_AES: + case WCM_WEPMODE_WPA2_AES: + if( TRUE == GetKeyModeStr() ) { + if( FALSE == wifi_config_set_wpa_key_str(slot_no, wlan_mode, GetWlanKEYSTR() )) { + mprintf("Error: wifi_config_wpa_key_str\n"); + } + else { + mprintf(" key = %s\n", GetWlanKEYSTR()); + } + } + else { + key_bin_len = GetWlanKEYBIN(key_bin_buf); + if( FALSE == wifi_config_set_wpa_key_bin(slot_no, wlan_mode, key_bin_buf, key_bin_len)){ + mprintf("Error: wifi_config_wpa_key_bin\n"); + } + } + break; + } + + + // SSID: + // MODE:"WPA2-AES" + // KEY-STR: + // DHCP:"ON" + // DNS auto + // IP auto + + + if( TRUE == GetDhcpMODE() ) { + mprintf(" DHCP client\n"); + } + else { + IPADDR = GetIPAddr(); + NETMASK = GetNetmask(); + GATEWAY = GetGateway(); + + + if( FALSE == wifi_config_set_ip_addr(slot_no, IPADDR) ) { + } + else { + mprintf(" IPADDR %3d.%3d.%3d.%3d\n", (u32)((IPADDR >> 24) & 0xff),(u32)((IPADDR >> 16) & 0xff), + (u32)((IPADDR >> 8) & 0xff),(u32)(IPADDR & 0xff) ); + } + if( FALSE == wifi_config_set_netmask(slot_no, NETMASK) ) { + } + else { + mprintf(" NETMASK %3d.%3d.%3d.%3d\n", (u32)((NETMASK >> 24) & 0xff),(u32)((NETMASK >> 16) & 0xff), + (u32)((NETMASK >> 8) & 0xff),(u32)(NETMASK & 0xff) ); + } + if( FALSE == wifi_config_set_gateway(slot_no, GATEWAY) ) { + } + else { + mprintf(" GATEWAY %3d.%3d.%3d.%3d\n", (u32)((GATEWAY >> 24) & 0xff),(u32)((GATEWAY >> 16) & 0xff), + (u32)((GATEWAY >> 8) & 0xff),(u32)(GATEWAY & 0xff) ); + } + } + + DNS1 = GetDNS1(); + DNS2 = GetDNS2(); + + if( FALSE == wifi_config_set_dns(slot_no, 0, DNS1) ) { + } + else { + mprintf(" DNS1 %3d.%3d.%3d.%3d\n", (u32)((DNS1 >> 24) & 0xff),(u32)((DNS1 >> 16) & 0xff), + (u32)((DNS1 >> 8) & 0xff),(u32)(DNS1 & 0xff) ); + } + if( FALSE == wifi_config_set_dns(slot_no, 1, DNS2) ) { + } + else { + mprintf(" DNS2 %3d.%3d.%3d.%3d\n", (u32)((DNS2 >> 24) & 0xff),(u32)((DNS2 >> 16) & 0xff), + (u32)((DNS2 >> 8) & 0xff),(u32)(DNS2 & 0xff) ); + } + + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + + // wifi_config_print(); + + mprintf("-wlan settings write "); + if( TRUE == wifi_config_nvram_set() ) { + m_set_palette(tc[0], M_TEXT_COLOR_GREEN ); /* green */ + mprintf("OK.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + else { + m_set_palette(tc[0], M_TEXT_COLOR_RED ); + mprintf("NG.\n"); + m_set_palette(tc[0], M_TEXT_COLOR_WHITE ); + } + } + } + else { no_network_flag = FALSE; only_wifi_config_data_trans_flag = FALSE; user_and_wifi_config_data_trans_flag = FALSE; + only_restore_savedata_flag = FALSE; Miya_debug_OFF(); my_fs_print_debug_OFF(); - + select_mode++; - select_mode %= 6; + select_mode %= 7; switch( select_mode ) { case 0: /* restore mode : default */ @@ -1892,6 +2259,9 @@ void TwlMain(void) case 5: my_fs_print_debug_ON(); break; + case 6: + only_restore_savedata_flag = TRUE; + break; default: break; } @@ -2059,7 +2429,8 @@ void TwlMain(void) } if( FALSE == reboot_flag ) { - mfprintf(tc[1], "press Y button to RESTORE mode\n"); + mfprintf(tc[1], "press Y to RESTORE mode\n"); + mfprintf(tc[1], "press X to OVERWRITE the Net setting\n"); } else { switch( select_mode ) { @@ -2087,6 +2458,10 @@ void TwlMain(void) m_set_palette(tc[1], M_TEXT_COLOR_YELLOW ); /* red */ mfprintf(tc[1],"-- debug mode --\n"); break; + case 6: + m_set_palette(tc[1], M_TEXT_COLOR_YELLOW ); /* red */ + mfprintf(tc[1],"-- savedata restore mode --\n"); + break; default: break; } @@ -2095,7 +2470,7 @@ void TwlMain(void) mfprintf(tc[1],"\n"); - mfprintf(tc[1], "function no.%d/%d\n", function_counter, function_table_max); + mfprintf(tc[1], "function no.%d/%d\n", function_counter, current_function_table_max); mfprintf(tc[2],"\f"); diff --git a/build/tools/sctools/copy_org/src/main.c b/build/tools/sctools/copy_org/src/main.c index 1743d2b..41141ec 100644 --- a/build/tools/sctools/copy_org/src/main.c +++ b/build/tools/sctools/copy_org/src/main.c @@ -1105,6 +1105,7 @@ void TwlMain(void) OS_TPrintf("DeviceID: %s\n", mydata.bmsDeviceId); } + mydata.dev_dot_kp_flag = CheckDevDotKP( NULL ); /* NAM の初期化 */ NAM_Init(&AllocForNAM, &FreeForNAM); diff --git a/build/tools/sctools/makesdtd/makesdtd.c b/build/tools/sctools/makesdtd/makesdtd.c index 0d8df5b..1c5541a 100644 --- a/build/tools/sctools/makesdtd/makesdtd.c +++ b/build/tools/sctools/makesdtd/makesdtd.c @@ -5,15 +5,11 @@ table_file.txt 名前固定 makesdtd.exe -indir [inputdir] -odir sdtads - makesdtd.exe -indir test-tad -odir sdtads + makesdtd.exe [-c] -indir test-tad -odir sdtads + openssl genrsa -out tad1024china.der 1024 -outform DER - - - openssl genrsa -out tad1024miya.der 1024 -outform DER - - - rsa_keysrcgen.exe -in tad1024miya.der + rsa_keysrcgen.exe -in tad1024china.der */ @@ -678,6 +674,7 @@ int main(int argc, char **argv) BOOL write_file_flag = FALSE; BOOL write_dir_flag = FALSE; BOOL dir_read_flag = FALSE; + BOOL china_flag = FALSE; char *prog; int badops = 0; @@ -710,24 +707,7 @@ int main(int argc, char **argv) argv++; - // printf("d = %s\n", prog); - - // strcpy(key_file_path, ".\\"); - strcat(key_file_path, prog); - - len = strlen(key_file_path); - for( pos = len - 1 ; pos > 0 ; pos--) { - if( key_file_path[pos] == '\\' ) { - strcpy( &(key_file_path[pos]), "\\tad1024.der"); - break; - } - } - - - printf("key_file_path = %s\n",key_file_path ); - - while (argc >= 1) { if (strcmp(*argv,"-indir") == 0 && !dir_read_flag ) { if (--argc < 1) { @@ -746,6 +726,9 @@ int main(int argc, char **argv) else if (strcmp(*argv,"-d") == 0 ) { debug_print_flag = TRUE; } + else if (strcmp(*argv,"-c") == 0 ) { + china_flag = TRUE; + } else if ( !read_file_flag ) { infile = *argv; read_file_flag = TRUE; @@ -761,11 +744,30 @@ int main(int argc, char **argv) if (badops) { bad: - fprintf(stderr, "%s -indir dirname -odir dirname\n",prog); + fprintf(stderr, "%s [-c] -indir dirname -odir dirname\n",prog); goto end; } + // printf("d = %s\n", prog); + // strcpy(key_file_path, ".\\"); + strcat(key_file_path, prog); + len = strlen(key_file_path); + for( pos = len - 1 ; pos > 0 ; pos--) { + if( key_file_path[pos] == '\\' ) { + if( china_flag == TRUE ) { + strcpy( &(key_file_path[pos]), "\\tad1024china.der"); + } + else { + strcpy( &(key_file_path[pos]), "\\tad1024.der"); + } + break; + } + } + printf("key_file_path = %s\n",key_file_path ); + + + if( debug_print_flag ) { printf("dir name = %s\n", indir_name); }