git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlToolsRED@38 7061adef-622a-194b-ae81-725974e89856

This commit is contained in:
miya 2008-11-06 01:03:44 +00:00
parent fa7c5fcb6f
commit e4a581a3ba
10 changed files with 474 additions and 192 deletions

View File

@ -24,6 +24,11 @@ void Error_Report_End(void)
{
ERROR_REPORT *er_temp;
ERROR_REPORT *er_next;
if( er_active == FALSE ) {
return;
}
er_temp = er_head;
while( er_temp != NULL ) {
if( er_temp->report_str ) {
@ -103,6 +108,11 @@ BOOL Error_Report_Printf(const char *fmt, ...)
char str_buf[STR_BUF_LEN];
int ret;
va_list vlist;
if( er_active == FALSE ) {
return FALSE;
}
va_start(vlist, fmt);
ret = STD_TVSNPrintf(str_buf, STR_BUF_LEN, fmt, vlist);
va_end(vlist);

View File

@ -24,6 +24,36 @@
#include "mprintf.h"
#include "my_fs_util.h"
#include <twl/os/common/ownerInfoEx.h>
#define OS_ADDR_TWL_SETTINGSDATA ( (OSTWLSettingsData *)HW_PARAM_TWL_SETTINGS_DATA )
void WLAN_FORCE_ON(void)
{
OSTWLSettingsData *p = (OSTWLSettingsData*)OS_ADDR_TWL_SETTINGSDATA;
OS_TPrintf("w flag %d\n",p->flags.isAvailableWireless);
if( p->flags.isAvailableWireless != 0x1 ) {
p->flags.isAvailableWireless = 0;
}
}
/*
BOOL OS_IsAvailableWireless(void)
{
BOOL result;
OSTWLSettingsData *p;
if( OS_IsRunOnTwl() )
{
p = (OSTWLSettingsData*)OS_ADDR_TWL_SETTINGSDATA;
result = (p->flags.isAvailableWireless == 0x1);
}
else
{
result = TRUE;
}
return (result);
}
*/
/*
// TWL本体設定データリード関数内でNTR本体設定データのリードも行う。

View File

@ -41,7 +41,7 @@ BOOL MiyaRestoreTWLSettings(const char *path);
BOOL MiyaReadHWNormalInfo( LCFGTWLHWNormalInfo *Info );
BOOL MiyaReadHWSecureInfo( LCFGTWLHWSecureInfo *Info );
BOOL MiyaReadHWNormalInfo_From_SD(const char *path, LCFGTWLHWNormalInfo *info);
void WLAN_FORCE_ON(void);
#if 0
typedef struct LCFGTWLHWNormalInfo

View File

@ -956,9 +956,7 @@ BOOL GetUserAppTitleList( MY_DIR_ENTRY_LIST *head, u64 **pBuffer, int *size, cha
if( !log_active ) {
log_fd = NULL;
}
else {
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
}
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
if( head == NULL ) {
*pBuffer = NULL;
@ -1101,9 +1099,7 @@ BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path, int *list_count, in
if( !log_active ) {
log_fd = NULL;
}
else {
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
}
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
if( (list_count == NULL) || (error_count == NULL) ) {
miya_log_fprintf(log_fd, "%s Error:invalid argument\n", __FUNCTION__);
@ -1196,6 +1192,7 @@ BOOL SaveDirEntryList( MY_DIR_ENTRY_LIST *head , char *path, int *list_count, in
}
if( copy_error_flag == TRUE ) {
/* エントリリストのセーブ */
writtenSize = FS_WriteFile(&f, (void *)list_temp, (s32)sizeof(MY_DIR_ENTRY_LIST) );
if( writtenSize != sizeof(MY_DIR_ENTRY_LIST) ) {
miya_log_fprintf(log_fd, "%s %d: Failed write file\n", __FUNCTION__ , __LINE__ );
@ -1296,6 +1293,7 @@ BOOL RestoreDirEntryList( char *path , char *log_file_name, int *list_count, int
while( 1 ) {
/* リストはルートディレクトリに近い順から入っている */
/* エントリリストのロード */
readSize = FS_ReadFile(&f, (void *)&list_temp, (s32)sizeof(MY_DIR_ENTRY_LIST) );
if( readSize == 0 ) {
/* 終わり */
@ -1920,9 +1918,7 @@ BOOL TitleIDLoad(const char *path, u64 **pBuffer, int *count, char *log_file_nam
if( !log_active ) {
log_fd = NULL;
}
else {
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
}
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_R);
if( ! bSuccess ) {
@ -1999,9 +1995,8 @@ BOOL TitleIDSave(const char *path, u64 *pData, int count, char *log_file_name )
if( !log_active ) {
log_fd = NULL;
}
else {
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
}
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
bSuccess = FS_OpenFileEx(&f, path, FS_FILEMODE_W);
if( ! bSuccess ) {
@ -2144,7 +2139,7 @@ BOOL SDCardValidation(void)
*/
BOOL CheckShopRecord(u8 region, FSFile *log_fd)
BOOL CheckShopRecord(FSFile *log_fd)
{
#pragma unused(log_fd)
@ -2153,7 +2148,7 @@ BOOL CheckShopRecord(u8 region, FSFile *log_fd)
BOOL ret_flag = TRUE;
BOOL bSuccess;
char path[256];
char path[64];
s32 readSize = 0;
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
@ -2172,7 +2167,12 @@ BOOL CheckShopRecord(u8 region, FSFile *log_fd)
(void)FS_CloseFile(&f);
}
/*
*/
#if 0
// STD_StrCpy(path, "nand:/title/00030015/484e464a/data/ec.cfg"); /* ショップアカウント情報 */
/* 海外だと変わってくる・・ */
/* リージョンコードと合わせる-> リージョンコードは変えられないから。 */
@ -2224,7 +2224,7 @@ BOOL CheckShopRecord(u8 region, FSFile *log_fd)
ret_flag = FALSE;
}
miya_log_fprintf(log_fd, "\n");
#endif
if( ret_flag == TRUE ) {
bSuccess = FS_OpenFileEx(&f, path, (FS_FILEMODE_R));
@ -2243,6 +2243,93 @@ BOOL CheckShopRecord(u8 region, FSFile *log_fd)
return ret_flag;
}
BOOL CleanSDCardFiles(char *log_file_name)
{
char *path = "sdmc:/";
FSFile *log_fd;
FSFile log_fd_real;
FSFile f;
FSDirectoryEntryInfo direntry;
BOOL ret_value = TRUE;
char path_full[FILE_PATH_LEN];
log_fd = &log_fd_real;
if( FALSE == Log_File_Open( log_fd, log_file_name ) ) {
log_fd = NULL;
}
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
/* ソースディレクトリオープン */
FS_InitFile(&f);
if(FS_OpenDirectory(&f, path, FS_PERMIT_R | FS_PERMIT_W ) == 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( STD_StrCmp(direntry.longname, "wlan_cfg.txt") == 0 ) {
}
else if( STD_StrCmp(direntry.longname, "nup_log.txt") == 0 ) {
}
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( FALSE == FS_DeleteDirectoryAuto( path_full ) ) {
OS_TPrintf("FS_DeleteDirectoryAuto failed.: ");
PrintAttributes(direntry.attributes, log_fd);
OS_TPrintf(" %s\n", path_full);
mprintf("FS_DeleteDirectoryAuto failed. %s\n", path_full);
ret_value = FALSE;
}
}
else {
/* ファイルの場合 */
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;
}
}
}
}
/* ソースディレクトリクローズ */
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; /* いらないかも?あとで考える */
}
end_process:
miya_log_fprintf(log_fd, "%s END\n\n", __FUNCTION__);
Log_File_Close(log_fd);
return ret_value;
}
int get_title_id(MY_DIR_ENTRY_LIST **headp, const char *path_src, int *save_parent_dir_info_flag, char *log_file_name, int level )
{
static FSFile *log_fd;
@ -2564,9 +2651,7 @@ int copy_r( MY_DIR_ENTRY_LIST **headp, const char *path_dst, const char *path_sr
if( level == 0 ) {
log_fd = &log_fd_real;
log_active = Log_File_Open( log_fd, log_file_name );
if( log_active ) {
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
}
miya_log_fprintf(log_fd, "%s START\n", __FUNCTION__);
}
level++;

View File

@ -41,7 +41,10 @@ void write_debug_data(void);
BOOL SDCardValidation(void);
BOOL TWLCardValidation(void);
BOOL CheckShopRecord(u8 region, FSFile *log_fd);
BOOL CheckShopRecord(FSFile *log_fd);
BOOL CleanSDCardFiles(char *log_file_name);
//BOOL MydataSave(const char *path, void *pData, int size, FSFile *log_fd);
//BOOL MydataLoad(const char *path, void *pBuffer, int size, FSFile *log_fd);

View File

@ -3,11 +3,14 @@
#define MY_DATA_VERSION_MAJOR 0
#define MY_DATA_VERSION_MINOR 5
#define MY_DATA_VERSION_MINOR 6
typedef struct {
u8 version_major;
u8 version_minor;
BOOL sys_ver_flag;
u16 sys_ver_major;
u16 sys_ver_minor;
BOOL rtc_date_flag;
BOOL rtc_time_flag;
RTCDate rtc_date;

View File

@ -217,7 +217,8 @@ int NcStart(const char* apClass)
int len;
u8 key_bin_buf[MAX_KEY_BIN_BUF];
int timeout_counter;
int sec = 0;
SiteDefs_Init();
if( TRUE == GetKeyModeStr() ) {
@ -294,42 +295,68 @@ int NcStart(const char* apClass)
#define WCM_PHASE_TERMINATING 13 // WCM ライブラリの強制停止シーケンス中
#endif
#define TIMEOUT_SEC 60
switch( counter ) {
case 0:
mprintf("\r-LINK UP. ");
mprintf("\r-LINK UP. %02d/%02d",sec,TIMEOUT_SEC);
if( timeout_counter > (TIMEOUT_SEC * 1000 / 200) ) {
goto error_ret;
}
break;
case 1:
mprintf("\r-LINK UP.. ");
mprintf("\r-LINK UP.. %02d/%02d",sec,TIMEOUT_SEC);
if( timeout_counter > (TIMEOUT_SEC * 1000 / 200) ) {
goto error_ret;
}
break;
case 2:
mprintf("\r-LINK UP... ");
mprintf("\r-LINK UP... %02d/%02d",sec,TIMEOUT_SEC);
if( timeout_counter > (TIMEOUT_SEC * 1000 / 200) ) {
goto error_ret;
}
break;
case 3:
mprintf("\r-LINK UP.... ");
mprintf("\r-LINK UP.... %02d/%02d",sec,TIMEOUT_SEC);
if( timeout_counter > (TIMEOUT_SEC * 1000 / 200) ) {
goto error_ret;
}
break;
case 5:
mprintf("\r-LINK UP..... ");
mprintf("\r-LINK UP..... %02d/%02d",sec,TIMEOUT_SEC);
if( timeout_counter > (TIMEOUT_SEC * 1000 / 200) ) {
goto error_ret;
}
break;
case 6:
mprintf("\r-LINK UP......");
mprintf("\r-LINK UP...... %02d/%02d",sec,TIMEOUT_SEC);
counter = -1;
if( timeout_counter > (TIMEOUT_SEC * 1000 / 200) ) {
goto error_ret;
}
break;
}
timeout_counter++;
if( timeout_counter > (60 * 1000 / 200) ) {
mprintf("%s -timeout\n",__FUNCTION__);
return NC_ERROR_TIMEOUT;
}
sec = timeout_counter*200/1000;
OS_Sleep(200);
counter++;
}
OS_TPrintf("connected\n");
mprintf(" connected\n");
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
mprintf(" OK.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return ncStartWiFi();
// return 0; /* 0 means success */
error_ret:
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf(" NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
return NC_ERROR_TIMEOUT;
}
void NcFinish()

View File

@ -19,6 +19,9 @@
#include <twl/na.h>
#include <twl/nam.h>
#include <NitroWiFi/nhttp.h>
#include </twl/os/common/ownerInfoEx.h>
#include "nssl.h"
#include "font.h"
@ -53,7 +56,6 @@
// #define MIYA_MCU 1
static BOOL no_reboot_flag = FALSE;
static BOOL only_wifi_config_data_trans_flag = FALSE;
static BOOL user_and_wifi_config_data_trans_flag = FALSE;
static BOOL no_network_flag = FALSE;
@ -62,9 +64,10 @@ static FSEventHook sSDHook;
static BOOL sd_card_flag = FALSE;
//static BOOL reboot_flag = FALSE;
static BOOL ec_download_success_flag = FALSE;
static u8 org_region = 0;
static u64 org_fuseId = 0;
static int select_mode = 0;
static volatile BOOL reboot_flag;
static int miya_debug_level = 0;
@ -377,8 +380,12 @@ static BOOL RestoreFromSDCard8(void)
Error_Report_Init();
if( mydata.num_of_app_save_data > 0 ) {
mprintf("App. save data restore ");
if( no_network_flag == TRUE ) {
if( (no_network_flag == TRUE) || (ec_download_success_flag == FALSE) ) {
mprintf("Sys-App. save data restore ");
if( TRUE == RestoreDirEntryListSystemBackupOnly( MyFile_GetSaveDataListFileName() ,
MyFile_GetSaveDataRestoreLogFileName(),
&list_count, &error_count )) {
@ -394,6 +401,7 @@ static BOOL RestoreFromSDCard8(void)
}
}
else {
mprintf("App. save data restore ");
if( TRUE == RestoreDirEntryList( MyFile_GetSaveDataListFileName() ,
MyFile_GetSaveDataRestoreLogFileName(),
&list_count, &error_count )) {
@ -729,6 +737,14 @@ static BOOL RestoreFromSDCard7(void)
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
}
if( ret_flag == TRUE ) {
ec_download_success_flag = TRUE;
}
else {
ec_download_success_flag = FALSE;
}
hatamotolib_log_end();
return ret_flag;
@ -835,9 +851,6 @@ static void MyThreadProcNuc(void *arg)
FSFile *log_fd;
BOOL ret_flag;
while( 1 ) {
(void)OS_SendMessage(&MyMesgQueue_response, (OSMessage)0, OS_MESSAGE_NOBLOCK);
(void)OS_ReceiveMessage(&MyMesgQueue_request, &message, OS_MESSAGE_BLOCK);
@ -848,7 +861,18 @@ static void MyThreadProcNuc(void *arg)
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
if( 0 != NcStart(SITEDEFS_DEFAULTCLASS) ) {
mprintf("connection failed!\n\n");
mprintf("-connect to the AP ");
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
Gfx_Set_BG1_Color((u16)M_TEXT_COLOR_DARKRED);
if( TRUE == stream_play_is_end() ) {
stream_play2(); /* ng.aiff */
}
mprintf("Network Update failed!\n");
OS_TPrintf("Network Update failed!\n");
while( 1 ) {
keyData = m_get_key_code();
if ( keyData & (PAD_BUTTON_A | PAD_BUTTON_START) ) {
@ -857,6 +881,12 @@ static void MyThreadProcNuc(void *arg)
OS_Sleep(20);
}
}
else {
mprintf("-connect to the AP ");
m_set_palette(tc[0], M_TEXT_COLOR_GREEN );
mprintf("OK.\n");
m_set_palette(tc[0], M_TEXT_COLOR_WHITE );
}
/* NSSL_Init()呼んではダメ! */
@ -877,28 +907,16 @@ static void MyThreadProcNuc(void *arg)
stream_play0(); /* cursor.aiff */
}
/* ハードウェアリセットを行い、自分自身を起動します。 */
if( no_reboot_flag == FALSE ) {
mprintf("\n");
text_blink_current_line(tc[0]);
mprintf("press A button to start RESTORE\n\n");
MCU_SetFreeRegister( 0x55 );
while( 1 ) {
keyData = m_get_key_code();
if ( keyData & (PAD_BUTTON_A | PAD_BUTTON_START) ) {
OS_RebootSystem();
}
OS_Sleep(20);
}
}
else {
mprintf("\n");
// text_blink_current_line(tc[0]);
while( 1 ) {
keyData = m_get_key_code();
if ( keyData & (PAD_BUTTON_A | PAD_BUTTON_START) ) {
}
OS_Sleep(20);
mprintf("\n");
text_blink_current_line(tc[0]);
mprintf("press A button to start RESTORE\n\n");
MCU_SetFreeRegister( 0x55 );
while( 1 ) {
keyData = m_get_key_code();
if ( keyData & (PAD_BUTTON_A | PAD_BUTTON_START) ) {
OS_RebootSystem();
}
OS_Sleep(20);
}
}
else {
@ -958,14 +976,18 @@ void TwlMain(void)
u8 macAddress[6];
MY_ENTRY_LIST *mfiler_list_head = NULL;
u16 s_major, s_minor;
BOOL s_flag;
s64 sys_version_org;
s64 sys_version;
u32 s_timestamp;
ESError es_error_code;
BOOL MydataLoadDecrypt_message_flag = TRUE;
BOOL MydataLoadDecrypt_dir_flag = TRUE;
BOOL MydataLoadDecrypt_success_flag = TRUE;
BOOL dir_select_mode = FALSE;
int select_mode = 0;
u8 free_reg;
u8 mode;
OS_Init();
OS_InitThread();
@ -974,6 +996,10 @@ void TwlMain(void)
OS_InitAlarm();
/* 無線LAN設定の強制ON */
WLAN_FORCE_ON();
// マスター割り込みフラグを許可に
(void)OS_EnableIrq();
@ -1022,24 +1048,6 @@ void TwlMain(void)
if( free_reg == 0x55 ) {
reboot_flag = TRUE;
}
else if( free_reg == 0x66 ) {
reboot_flag = TRUE;
no_network_flag = TRUE;
}
else if( free_reg == 0x77 ) {
no_reboot_flag = TRUE;
mprintf("no_reboot_flag ON\n");
}
else if( free_reg == 0x88 ) {
reboot_flag = TRUE;
only_wifi_config_data_trans_flag = TRUE;
mprintf("only_wifi_config_data_trans ON\n");
}
else if( free_reg == 0x99 ) {
reboot_flag = TRUE;
user_and_wifi_config_data_trans_flag = TRUE;
mprintf("user_and_wifi_config_data ON\n");
}
else {
reboot_flag = FALSE;
}
@ -1048,9 +1056,6 @@ void TwlMain(void)
/* miya */
// reboot_flag = TRUE;
PM_SetAutoExit( FALSE );
PM_SetExitCallbackInfo( &pmexitcallbackinfo,pmexitcallback, NULL);
PM_PrependPreExitCallback( &pmexitcallbackinfo );
@ -1080,12 +1085,19 @@ void TwlMain(void)
s_major = 0;
s_minor = 0;
s_timestamp = 0;
s_flag = FALSE;
sys_version = -1;
}
else {
s_flag = TRUE;
sys_version = (s64)(((u32)s_major) << 16 | (u32)s_minor);
}
ES_InitLib();
if( FALSE == MiyaReadHWNormalInfo( &hwn_info ) ) {
m_set_palette(tc[0], 0x1); /* red */
mprintf("HW Normal Info. read error.\n");
@ -1099,13 +1111,13 @@ void TwlMain(void)
m_set_palette(tc[0], 0xF); /* white */
}
#if 1
// ニックネームが空なら適当に設定
if( *LCFG_TSD_GetNicknamePtr() == L'\0' ) {
LCFG_TSD_SetNickname((const u16*)(L"repair-tool"));
// mprintf("Set dummy Nickname\n");
}
#endif
// 国が選択されていないなら適当に設定
if( LCFG_TSD_GetCountry() == LCFG_TWL_COUNTRY_UNDEFINED ) {
@ -1125,18 +1137,17 @@ void TwlMain(void)
mydata.shop_record_flag = FALSE;
es_error_code = ES_GetDeviceId(&mydata.deviceId);
if( es_error_code == ES_ERR_OK ) {
if( TRUE == CheckShopRecord( hws_info.region, NULL ) ) {
if( TRUE == CheckShopRecord( NULL ) ) {
mydata.shop_record_flag = TRUE;
}
else {
mprintf("no ec.cfg file\n");
mprintf("no shop record\n");
}
}
else {
OS_TPrintf("es_error_code = %d\n", es_error_code );
}
// (void)CheckShopRecord( hws_info.region, NULL );
if( TRUE == mydata.shop_record_flag ) {
snprintf(mydata.bmsDeviceId, sizeof(mydata.bmsDeviceId), "%lld", ((0x3ull << 32) | mydata.deviceId));
@ -1145,10 +1156,19 @@ void TwlMain(void)
}
if( FALSE == reboot_flag ) {
mprintf("Network update mode\n");
/* 最初はネットワークアップデート。 */
if( FALSE == OS_IsAvailableWireless() ) {
// m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("Warning:WLAN Enable flag = OFF\n");
m_set_palette(tc[0], 0xF); /* white */
OS_TPrintf("WLAN Enable flag OFF\n");
}
// NSSL_Init(&s_sslConfig);
// SetupNSSL();
if (!NA_LoadVersionDataArchive(WorkForNA, NA_VERSION_DATA_WORK_SIZE)) {
@ -1161,12 +1181,6 @@ void TwlMain(void)
OS_TPrintf("Client cert load error\n");
mprintf("Client cert load error\n");
}
#if 0
else {
OS_TPrintf("Client cert load success\n");
mprintf("Client cert load success\n");
}
#endif
(void)NA_UnloadVersionDataArchive();
}
@ -1283,6 +1297,16 @@ void TwlMain(void)
mprintf("Personal data. restore ");
MydataLoadDecrypt_success_flag = MydataLoadDecrypt( MyFile_GetGlobalInformationFileName(),
&mydata, sizeof(MyData), NULL);
if( mydata.sys_ver_flag == TRUE ) {
sys_version_org = (s64)(((u32)(mydata.sys_ver_major)) << 16 | (u32)(mydata.sys_ver_minor));
}
else {
sys_version_org = -1;
}
if(TRUE == MydataLoadDecrypt_success_flag ) {
if( org_region != mydata.region ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
@ -1314,6 +1338,16 @@ void TwlMain(void)
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
}
else if( s_flag && mydata.sys_ver_flag && (sys_version < sys_version_org) ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf("NG.\n");
m_set_palette(tc[0], M_TEXT_COLOR_YELLOW );
mprintf(" illegal System menu version.\n");
mprintf(" org. version %d.%d\n", mydata.sys_ver_major,mydata.sys_ver_minor);
mprintf(" cur. version %d.%d\n", s_major,s_minor);
m_set_palette(tc[0], 0xF); /* white */
MydataLoadDecrypt_message_flag = FALSE;
}
else {
m_set_palette(tc[0], 0x2); /* green */
mprintf("OK.\n");
@ -1352,16 +1386,6 @@ void TwlMain(void)
}
}
else if ( keyData & PAD_BUTTON_B ) {
miya_debug_level++;
miya_debug_level &= 1;
if( miya_debug_level ) {
Miya_debug_ON();
mprintf("debug ON\n");
}
else {
Miya_debug_OFF();
mprintf("debug OFF\n");
}
}
#if 0
/* スタートボタンはAボタンと同じ扱い */
@ -1371,37 +1395,40 @@ void TwlMain(void)
else if ( keyData & PAD_BUTTON_SELECT ) {
}
else if ( keyData & PAD_BUTTON_X ) {
select_mode++;
switch( select_mode ) {
case 1:
free_reg = mode = 0x55;
break;
case 2:
free_reg = mode = 0x66;
no_network_flag = TRUE;
break;
case 3:
free_reg = mode = 0x77;
no_reboot_flag = TRUE;
break;
case 4:
free_reg = mode = 0x88;
only_wifi_config_data_trans_flag = TRUE;
break;
case 5:
free_reg = mode = 0x99;
user_and_wifi_config_data_trans_flag = TRUE;
break;
default:
free_reg = mode = 0;
select_mode = 0;
break;
if( TRUE == reboot_flag ) {
no_network_flag = FALSE;
only_wifi_config_data_trans_flag = FALSE;
user_and_wifi_config_data_trans_flag = FALSE;
Miya_debug_OFF();
select_mode++;
select_mode %= 5;
switch( select_mode ) {
case 0:
/* restore mode : default */
break;
case 1:
no_network_flag = TRUE;
break;
case 2:
only_wifi_config_data_trans_flag = TRUE;
break;
case 3:
user_and_wifi_config_data_trans_flag = TRUE;
break;
case 4:
Miya_debug_ON();
break;
default:
break;
}
}
}
else if ( keyData & PAD_BUTTON_Y ) {
MCU_SetFreeRegister( mode);
OS_RebootSystem();
if( FALSE == reboot_flag ) {
MCU_SetFreeRegister( 0x55 );
OS_RebootSystem();
}
}
else if ( keyData & PAD_KEY_RIGHT ) {
n = m_get_display_offset_x(tc[0]);
@ -1518,46 +1545,41 @@ void TwlMain(void)
rtc_date.year + 2000, rtc_date.month , rtc_date.day,
rtc_time.hour , rtc_time.minute , rtc_time.second );
if( FALSE == reboot_flag ) {
if( free_reg == 0x55 ) {
mfprintf(tc[1],"restart to RESTORE mode\n");
}
else if( free_reg == 0x66 ) {
mfprintf(tc[1],"network-connection OFF mode\n");
}
else if( free_reg == 0x77 ) {
mfprintf(tc[1],"no_reboot_flag ON\n");
}
else if( free_reg == 0x88 ) {
mfprintf(tc[1],"only wifi config data\n");
}
else if( free_reg == 0x99 ) {
mfprintf(tc[1],"only user settings data\n");
}
else {
mfprintf(tc[1],"just reboot\n");
}
mfprintf(tc[1], "press Y button to restart.\n");
mfprintf(tc[1], "press Y button to RESTORE mode\n");
}
else {
mfprintf(tc[1], "function no.%d/%d\n\n", function_counter, function_table_max);
switch( select_mode ) {
case 0:
/* restore mode : default */
mfprintf(tc[1],"-- normal mode --\n");
break;
case 1:
m_set_palette(tc[1], M_TEXT_COLOR_YELLOW );
mfprintf(tc[1],"-- no network connection mode --\n");
break;
case 2:
m_set_palette(tc[1], M_TEXT_COLOR_YELLOW );
mfprintf(tc[1],"-- only wifi data mode --\n");
break;
case 3:
m_set_palette(tc[1], M_TEXT_COLOR_YELLOW );
mfprintf(tc[1],"-- only user data mode --\n");
break;
case 4:
m_set_palette(tc[1], M_TEXT_COLOR_RED ); /* red */
mfprintf(tc[1],"-- NG mode --\n");
break;
default:
break;
}
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
mfprintf(tc[1],"\n");
mfprintf(tc[1], "function no.%d/%d\n", function_counter, function_table_max);
if( free_reg == 0x66 ) {
mfprintf(tc[1],"network-connection OFF mode\n");
}
else if( free_reg == 0x77 ) {
mfprintf(tc[1],"no_reboot_flag ON\n");
}
else if( free_reg == 0x88 ) {
mfprintf(tc[1],"only wifi config data\n");
}
else if( free_reg == 0x99 ) {
mfprintf(tc[1],"only user settings data\n");
}
mfprintf(tc[2],"\f");
if( MydataLoadDecrypt_dir_flag == FALSE ) {

View File

@ -123,6 +123,72 @@ char *MFILER_Get_CurrentDir(void)
return NULL;
}
#if 1
#define LOCAL_FILE_PATH_LEN 64
int MFILER_ReadDir(MY_ENTRY_LIST **headp, const char *path_src)
{
FSFile f_src;
FSDirectoryEntryInfo entry_src;
BOOL bSuccess;
char path_src_dir[LOCAL_FILE_PATH_LEN];
char path_src_full[LOCAL_FILE_PATH_LEN];
int ret_value = 0;
FS_InitFile(&f_src);
bSuccess = FS_OpenDirectory(&f_src, path_src, FS_PERMIT_R);
if(!bSuccess) {
#if 0
mprintf("Failed Open SRC Directory\n");
mprintf(" %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path_src) ));
#endif
ret_value = -1;
goto end_process;
}
STD_MemSet((void *)path_src_dir, 0, LOCAL_FILE_PATH_LEN);
STD_MemSet((void *)path_src_full, 0, LOCAL_FILE_PATH_LEN);
STD_StrCpy(path_src_dir, path_src);
STD_StrCat(path_src_dir, "/");
while( FS_ReadDirectory(&f_src, &entry_src) ) {
if( STD_StrCmp(entry_src.longname, ".") == 0 ) {
}
else if( STD_StrCmp(entry_src.longname, "..") == 0 ) {
}
else if( STD_StrCmp(entry_src.longname, "wlan_cfg.txt") == 0 ) {
}
else if( STD_StrCmp(entry_src.longname, "nup_log.txt") == 0 ) {
}
else if( entry_src.attributes & FS_ATTRIBUTE_DOS_VOLUME ) {
}
else {
STD_StrCpy( path_src_full , path_src_dir );
STD_StrCat( path_src_full , entry_src.longname );
mfilter_add_list( headp, &entry_src, path_src_full );
}
}
bSuccess = FS_CloseDirectory(&f_src);
if(!bSuccess) {
#if 0
mprintf("Failed Close SRC Directory\n");
mprintf(" %s\n", my_fs_util_get_fs_result_word( FS_GetArchiveResultCode(path_src) ));
#endif
ret_value = -1;
// goto end_process;
}
end_process:
return ret_value;
}
#else
int MFILER_ReadDir(MY_ENTRY_LIST **headp, const char *path_src)
{
FSFile f_src;
@ -167,7 +233,7 @@ int MFILER_ReadDir(MY_ENTRY_LIST **headp, const char *path_src)
while( FS_ReadDirectory(&f_src, &entry_src) ) {
#if 1
if( STD_StrCmp(entry_src.longname, ".") == 0 ) {
}
@ -184,11 +250,6 @@ int MFILER_ReadDir(MY_ENTRY_LIST **headp, const char *path_src)
STD_StrCat( path_src_full , entry_src.longname );
mfilter_add_list( headp, &entry_src, path_src_full );
}
#else
STD_StrCpy( path_src_full , path_src_dir );
STD_StrCat( path_src_full , entry_src.longname );
mfilter_add_list( headp, &entry_src, path_src_full );
#endif
}
bSuccess = FS_CloseDirectory(&f_src);
@ -212,6 +273,8 @@ int MFILER_ReadDir(MY_ENTRY_LIST **headp, const char *path_src)
return ret_value;
}
#endif
void MFILER_DisplayDir(TEXT_CTRL *tc, MY_ENTRY_LIST **headp, int mode )
{
MY_ENTRY_LIST *list_temp;
@ -303,6 +366,7 @@ void MFILER_DisplayDir(TEXT_CTRL *tc, MY_ENTRY_LIST **headp, int mode )
}
}
BOOL MFILER_ClearDir(MY_ENTRY_LIST **headp)
{
MY_ENTRY_LIST *list_temp1 = *headp;

View File

@ -44,7 +44,7 @@
static BOOL completed_flag = FALSE;
static FSEventHook sSDHook;
static BOOL sd_card_flag = FALSE;
static int miya_debug_level = 0;
//static int miya_debug_level = 0;
static void SDEvents(void *userdata, FSEvent event, void *arg)
@ -607,6 +607,8 @@ void TwlMain(void)
u16 s_major, s_minor;
u32 s_timestamp;
ESError es_error_code;
int select_mode = 0;
BOOL no_sd_clean_flag = FALSE;
OS_Init();
OS_InitThread();
@ -657,6 +659,10 @@ void TwlMain(void)
OS_TPrintf("MCU Free Reg. 0x%02x\n",MCU_GetFreeReg());
STD_MemSet((void *)&mydata, 0, sizeof(MyData));
if( FALSE == Read_SystemMenuVersion(&s_major, &s_minor, &s_timestamp) ) {
m_set_palette(tc[0], M_TEXT_COLOR_RED );
mprintf( "system menu ver. read error!\n");
@ -664,6 +670,12 @@ void TwlMain(void)
s_major = 0;
s_minor = 0;
s_timestamp = 0;
mydata.sys_ver_flag = FALSE;
}
else {
mydata.sys_ver_flag = TRUE;
mydata.sys_ver_major = s_major;
mydata.sys_ver_minor = s_minor;
}
@ -673,6 +685,7 @@ void TwlMain(void)
// 必須ES の初期化
ES_InitLib();
if( FALSE == MiyaReadHWNormalInfo( &hwn_info ) ) {
mydata.uniqueid_flag = FALSE;
m_set_palette(tc[0], 0x1); /* red */
@ -750,11 +763,11 @@ void TwlMain(void)
mydata.shop_record_flag = FALSE;
es_error_code = ES_GetDeviceId(&mydata.deviceId);
if( es_error_code == ES_ERR_OK ) {
if( TRUE == CheckShopRecord( hws_info.region, NULL ) ) {
if( TRUE == CheckShopRecord( NULL ) ) {
mydata.shop_record_flag = TRUE;
}
else {
mprintf("no ec.cfg file\n");
mprintf("no shop record\n");
}
}
else {
@ -805,6 +818,7 @@ void TwlMain(void)
init_my_thread();
if( sd_card_flag == TRUE ) {
text_blink_current_line(tc[0]);
mprintf("press A button to start BACKUP\n\n");
}
@ -859,6 +873,10 @@ void TwlMain(void)
/* ユーザーデータ吸出しモード */
if(completed_flag == FALSE ) {
if( sd_card_flag == TRUE ) {
if( no_sd_clean_flag == FALSE ) {
(void)CleanSDCardFiles(NULL);
}
text_blink_clear(tc[0]);
if( FALSE == start_my_thread() ) {
OS_TPrintf("\nnow backup..\n\n");
@ -872,16 +890,6 @@ void TwlMain(void)
}
}
else if ( keyData & PAD_BUTTON_B ) {
miya_debug_level++;
miya_debug_level &= 1;
if( miya_debug_level ) {
Miya_debug_ON();
mprintf("debug ON\n");
}
else {
Miya_debug_OFF();
mprintf("debug OFF\n");
}
}
#if 0
/* スタートボタンはAボタンと同じ扱い */
@ -891,6 +899,20 @@ void TwlMain(void)
else if ( keyData & PAD_BUTTON_SELECT ) {
}
else if ( keyData & PAD_BUTTON_X ) {
select_mode++;
select_mode %= 3;
Miya_debug_OFF();
no_sd_clean_flag = FALSE;
if( select_mode == 0 ) {
}
else if(select_mode == 1 ) {
no_sd_clean_flag = TRUE;
}
else if(select_mode == 2 ) {
Miya_debug_ON();
}
}
else if ( keyData & PAD_BUTTON_Y ) {
}
@ -984,6 +1006,22 @@ void TwlMain(void)
rtc_time.hour , rtc_time.minute , rtc_time.second );
if( select_mode == 0 ) {
mfprintf(tc[1],"-- normal mode(default) --\n");
}
else if( select_mode == 1 ) {
m_set_palette(tc[1], M_TEXT_COLOR_YELLOW );
mfprintf(tc[1],"-- no SDCard clean mode --\n");
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
}
else if( select_mode == 2 ) {
m_set_palette(tc[1], M_TEXT_COLOR_RED ); /* red */
mfprintf(tc[1],"-- NG mode --\n");
m_set_palette(tc[1], M_TEXT_COLOR_WHITE );
}
mfprintf(tc[1],"\n");
mfprintf(tc[1], "function no.%d/%d\n", function_counter, function_table_max);
loop_counter++;