V0.3 V0.1からアップデートできるようになりました。

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@7 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
fujita_ryohei 2009-09-08 02:23:22 +00:00
parent 604432135f
commit 39946e295a
15 changed files with 1164 additions and 1180 deletions

View File

@ -3,7 +3,7 @@
nintendo
'09 Apr
======================================================== */
#include "incs_loader.h"
#include "incs.h"
#include "adc.h"
#include "pm.h"

View File

@ -1,9 +1,9 @@
;;; 領域の定義
;32kB = 0x7FFF
MEMORY BCL0:(00000H, 01000H )
;MEMORY BCL1:(01000H, 01000H )
;MEMORY BCL1:(01000H, 01000H ) ; バックアップ領域
MEMORY ROM :(02000H, 02800H )
MEMORY ROM_:(04800H, 02800H )
;MEMORY ROM_:(04800H, 02800H ) ; バックアップ領域
MEMORY FSL :(07000H, 00C00H )
;MEMORY OCD :(0FC00H, 00400H ) ; OCDが使っているらしい
@ -11,9 +11,9 @@ MEMORY FSL :(07000H, 00C00H )
;;; セグメントの割当先設定
; ブートブロック0に割り当てる
MERGE @@LCODE: =BCL0 ; スタートアップルーチン
MERGE LDR_CODE:=BCL0
MERGE LDR_CODL:=BCL0
MERGE LDR_CODE: =BCL0
MERGE LDR_CODL: =BCL0
MERGE @@LCODE : AT( 0E00H ) =BCL0 ; スタートアップルーチン
;MERGE LDR_RINT:=BCL0
;MERGE LDR_CNST:=BCL0
@ -31,7 +31,8 @@ MERGE @@R_INIT: =ROM
; 謹製フラッシュライブラリ
MERGE FSL_CODE:=FSL
; MERGE FSL_CODE:=FSL
MERGE FSL_CODE:=BCL0
; マジックナンバー

View File

@ -31,6 +31,4 @@
#define _CODEC_CTR_
#endif
#endif

View File

@ -58,7 +58,7 @@ void hdwinit(void);
void power_save();
extern void main_loop();
extern u8 chk_bootCluster();
// ========================================================
@ -70,17 +70,19 @@ void main(){
}while( i != 0 );
while(1){
// 電池投入 //
// hdwinit(); 自動実行
// 電池投入時のみ初期化 //
#if 0
// ファームの整合性チェック //
{
u8 i;
u8 comp = 0;
// ローダーと本体は同じバージョンか?
for( i = 0; i < sizeof( __TIME__ ); i++ ){ // sizeof( __TIME__ ) = 8 らし
comp += ( *(u8*)( MGC_HEAD + i ) == *(__far u8*)( MGC_LOAD + i ) )? 0: 1;
@ -98,6 +100,9 @@ void main(){
// 帰ってこない。リセットをかける。
}
}
#endif
chk_bootCluster();
// 通常運転
main_loop();

View File

@ -4,11 +4,17 @@
(touchしてね)
****************************************************************************/
#pragma section @@CNSTL MGC_LOAD AT 0x0FF6
__far static const unsigned char MGC_LOAD[] = __TIME__;
//__far static const unsigned char MGC_LOAD[] = __TIME__;
__far static const unsigned char MGC_LOAD[] =
{ 0x30, 0x38, 0x3A, 0x34, 0x35, 0x3A, 0x33, 0x39, 0x00, 0x00 };
#pragma section @@CNST MGC_MIMI AT 0x2100
static const unsigned char MGC_HEAD[] = __TIME__;
//static const unsigned char MGC_HEAD[] = __TIME__;
static const unsigned char MGC_HEAD[] =
{ 0x30, 0x38, 0x3A, 0x34, 0x35, 0x3A, 0x33, 0x39, 0x00, 0x00 };
#pragma section @@CNST MGC_TAIL AT 0x47F6
static const unsigned char MGC_TAIL[] = __TIME__;
//static const unsigned char MGC_TAIL[] = __TIME__;
static const unsigned char MGC_TAIL[] =
{ 0x30, 0x38, 0x3A, 0x34, 0x35, 0x3A, 0x33, 0x39, 0x00, 0x00 };

View File

@ -18,8 +18,9 @@
// ========================================================
const u8 fsl_fx_MHz_u08 = 4;
const u8 fsl_low_voltage_u08 = 0;
const u8 fsl_fx_MHz_u08 = 8;
const u8 fsl_low_voltage_u08 = 1;
// 自己フラッシュパラメータ
#define SAM_BLOCK_SIZE 1024
@ -70,12 +71,19 @@ static void FSL_Open(void);
static void FSL_Close(void);
err firm_restore();
extern void self_update_reboot( u8 flag );
// magic.c の記述と違わないように注意!
#define N_MGC_L 0x1FF6
#define N_MGC_T 0x47F6
// ========================================================
u8 boot_ura; // ブートクラスタ 0/1
/* ========================================================
======================================================== */
err firm_update(){
@ -89,6 +97,10 @@ err firm_update(){
flg_rcv_end = 0;
TOE0 = 0x0000;
TOE0 = 0x0020;
// 書き替え前準備 //
FSL_Open(); // 割り込み禁止など
DI();
@ -144,7 +156,6 @@ err firm_update(){
while( FSL_IVerify( target_block ) != FSL_OK ){ ; }
}
// 書き替え //
/*
@ -163,7 +174,6 @@ err firm_update(){
for( target_block = INACTIVE_BOOTSECT_TOP;
target_block <= UPDATE_BLOCK_LAST;
target_block += 1 ){
// 分割書き込み
for( split_write_count = 0;
(( split_write_count < SELF_UPDATE_SPLIT_WRITE_NUM ) && ( !SPD ));
@ -191,7 +201,6 @@ err firm_update(){
}
}
// 1ブロック書き込み完了。内部ベリファイを行う
while( FSL_IVerify( target_block ) != FSL_OK ){;}
@ -203,8 +212,6 @@ err firm_update(){
firm_update_end:
WREL = 1;
// 書き込んだファームのチェック //
{
u8 i;
@ -212,14 +219,16 @@ firm_update_end:
// 少なくとも、ローダーのマジックと、本文の末尾のマジックは同じか確認
for( i = 0; i < sizeof( __TIME__ ); i++ ){
comp += ( *(u8*)( N_MGC_L - sizeof( __TIME__ ) + i ) == *(u8*)( N_MGC_T - sizeof( __TIME__ ) + i ) )? 0: 1;
comp += ( *(u8*)( N_MGC_L + i ) == *(u8*)( N_MGC_T + i ) )? 0: 1;
}
if( comp == 0 ){
FSL_InvertBootFlag();
FSL_SwapBootCluster();
// 戻ってこない //
}else{
FSL_ForceReset();
FSL_Close();
firm_restore();
// 戻ってこない //
}
}
}
@ -230,7 +239,8 @@ firm_update_end:
/* ========================================================
0x4800 - 0x7FFF ( 18 - 27) 0x2000 - 0x47FF (8 - 17)
======================================================== */
err firm_restore(){
u8 flg_rcv_end = 0;
@ -241,9 +251,11 @@ err firm_restore(){
fsl_u08 err;
__far u8* p_rom;
TOE0 = 0x0000;
TOE0 = 0x0080;
// 書き替え前準備 //
FSL_Open(); // 割り込み禁止など
DI();
FSL_Open(); // 割り込み禁止など
err = FSL_Init( data_buffer ); // ライブラリ初期化。割り込み中断考慮せず
err += FSL_ModeCheck(); // ライトプロテクトチェック。失敗することを考慮せず
@ -296,13 +308,25 @@ err firm_restore(){
//  それでもだなら、LEDちかちかとかさせて、サービス送りにしてもらう
// リブート
// スワップは不要です!
FSL_ForceReset();
return( ERR_SUCCESS );
}
u8 chk_bootCluster(){
u8 data_buffer[ SELF_UPDATE_BUFF_SIZE ];
u8 err;
DI();
FSL_Open(); // 割り込み禁止など
err = FSL_Init( data_buffer ); // ライブラリ初期化。割り込み中断考慮せず
err |= FSL_ModeCheck(); // ライトプロテクトチェック。失敗することを考慮せず
err |= FSL_GetActiveBootCluster( &boot_ura );
FSL_Close();
}

View File

@ -5,6 +5,7 @@
#include "incs.h"
extern u8 boot_ura;
/* ========================================================
WiFi ŠÖŚW
@ -89,8 +90,9 @@ task_interval tsk_debug2(){
&& ( system_status.pwr_state != ON_TRIG )){
iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 3, vreg_ctr[ VREG_C_IRQ0 ] );
iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 2, vreg_ctr[ VREG_C_IRQ1 ] );
iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, boot_ura );
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, vreg_ctr[ VREG_C_SND_VOL ] );
iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, vreg_ctr[ VREG_C_3D_DEPTH ] );
// iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 1, vreg_ctr[ VREG_C_3D_DEPTH ] );
iic_mcu_write_a_byte( IIC_SLA_DBG_MONITOR, 0, vreg_ctr[ VREG_C_ACC_ZH ] );
}
return( 50/2 );

View File

@ -139,8 +139,11 @@ task_interval tsk_sys(){
vreg_ctr[ VREG_C_ACC_CONFIG_HOSU ] = 0x01;
renge_task_immed_add( acc_set );
P1 &= ~0x20;
break;
case ON: //-------------------------------------------------------
break;
@ -199,6 +202,7 @@ task_interval tsk_sys(){
system_status.pwr_state = OFF;
DI();
STOP(); // 割り込み待ちで寝る
// while( SW_POW_n ){;}
EI();
#ifdef _PMIC_TWL_
MK2L = 0b01111111; // wifi_TX 割り込み

View File

@ -162,9 +162,7 @@ void vreg_ctr_write( u8 adrs, u8 data ){
&& ( vreg_ctr[ VREG_C_DBG2 ] == 'h' )
&& ( data == 'l' )
){
firm_update(); // 戻ってこない
}
}
firm_update(); // 戻ってこない
}
break;
}

View File

@ -133,7 +133,7 @@ enum VREG_C{ //
VREG_C_ACC_CONFIG_HOSU,
VREG_C_ACC_CONFIG,
VREG_C_ACC_R_ADRS,
// VREG_C_ACC_R_BUF,
VREG_C_RESERVED5,
VREG_C_ACC_W_ADRS,
VREG_C_ACC_W_BUF,

View File

@ -1,32 +1,14 @@
C:\WINDOWS\system32\cmd.exe /c touch magic.c
"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\bin\cc78k0r.exe" -cF100964 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -irenge -i"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r" -ms -qcjl1wtg -sainter_asm -zp -w0 -no magic.c
C:\WINDOWS\system32\cmd.exe /c echo touch magic.c
touch magic.c
"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\bin\cc78k0r.exe" -cF100964 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -irenge -i"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r" -ms -qcjl1wtg -sainter_asm -zp -w0 -no loader.c
Compilation complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\ra78k0r.exe" -cF100964 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff inter_asm\magic.asm
Assembly complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\bin\cc78k0r.exe" -cF100964 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -irenge -i"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\inc78k0r" -ms -qcjl1wtg -sainter_asm -zp -w0 -no vreg_ctr.c
Compilation complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\ra78k0r.exe" -cF100964 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff inter_asm\vreg_ctr.asm
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\ra78k0r.exe" -cF100964 -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff inter_asm\loader.asm
Assembly complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\lk78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -obsr_k0r.lmf "..\..\Program Files\NEC Electronics Tools\CC78K0R\W2.10\lib78k0r\s0rml.rel" -go85h,0FC00h,1024 -gi0FFFFFFFFFFFFFFFFFFFFh -pbsr_k0r.map -nkd -kp -gb6EFBFFh -b"C:\Program Files\NEC Electronics Tools\FSL78K0R_Type02ES\V1.20\lib78k0r\fsl.lib" -bcl0rdm.lib -bcl0rm.lib -bcl0rmf.lib -i"C:\Program Files\NEC Electronics Tools\CC78K0R\W2.10\lib78k0r" -dbsr_mcu.dr -s -w0 loader.rel pm.rel i2c_ctr.rel main.rel magic.rel WDT.rel i2c_mcu.rel i2c_twl.rel ini_VECT.rel led.rel rtc.rel vreg_ctr.rel vreg_twl.rel tasks.rel adc.rel renge.rel tasks_sys.rel accero.rel self_flash.rel
Link complete, 0 error(s) and 0 warning(s) found.
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\oc78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -o.\bsr.hex bsr_k0r.lmf
"C:\Program Files\NEC Electronics Tools\RA78K0R\W1.31\bin\oc78k0r.exe" -y"C:\Program Files\NEC Electronics Tools\DEV" -_msgoff -o.\bsr.hex -nu -ki bsr_k0r.lmf
Object Conversion Complete, 0 error(s) and 0 warning(s) found.
C:\WINDOWS\system32\cmd.exe /c ruby C:\Cygwin\home\fujita_ryohei\nesdev\jhl\inthex_flatter.rb bsr.hex
C:/Cygwin/home/fujita_ryohei/nesdev/jhl/inthex_flatter.rb:28: syntax error, unexpected ',', expecting tASSOC
src_in = { "len", tempA[0][1], "offset", tempA...
^
C:/Cygwin/home/fujita_ryohei/nesdev/jhl/inthex_flatter.rb:28: syntax error, unexpected ',', expecting tCOLON2 or '[' or '.'
...{ "len", tempA[0][1], "offset", tempA[0][2], "type", tempA[0...
... ^
C:/Cygwin/home/fujita_ryohei/nesdev/jhl/inthex_flatter.rb:28: syntax error, unexpected ',', expecting tCOLON2 or '[' or '.'
... "offset", tempA[0][2], "type", tempA[0][3], "data", tempA[0...
... ^
C:/Cygwin/home/fujita_ryohei/nesdev/jhl/inthex_flatter.rb:28: syntax error, unexpected ',', expecting tCOLON2 or '[' or '.'
...], "type", tempA[0][3], "data", tempA[0][4], "CRC", tempA[0]...
... ^
C:/Cygwin/home/fujita_ryohei/nesdev/jhl/inthex_flatter.rb:28: syntax error, unexpected ',', expecting tCOLON2 or '[' or '.'
...3], "data", tempA[0][4], "CRC", tempA[0][5] }
... ^
C:/Cygwin/home/fujita_ryohei/nesdev/jhl/inthex_flatter.rb:39: syntax error, unexpected '}', expecting $end
C:\WINDOWS\system32\cmd.exe /c ruby C:\Cygwin\home\fujita_ryohei\ctr\nec_s_2_bsrbin.rb bsr.hex
C:/Cygwin/home/fujita_ryohei/ctr/nec_s_2_bsrbin.rb:2: warning: variable $KCODE is no longer effective; ignored
Build Total error(s) : 0 Total warning(s) : 0

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -12,14 +12,13 @@ OpenFile5=magic.c,0,307,203,1275,828,0,15,0,0
OpenFile6=fsl_user.h,0,330,330,1574,1087,53,63,53,0
OpenFile7=renge\renge_task_immediate.h,0,243,127,1487,884,0,1,0,0
OpenFile8=renge\renge.c,0,270,117,1514,874,45,105,45,0
OpenFile9=adc.c,0,220,220,1464,977,48,79,0,0
OpenFile10=ProjectWindow
OpenFile9=i2c_twl.c,0,110,110,1354,867,0,7,27,0
OpenFile10=loader.c,0,352,69,1596,826,26,77,26,0
OpenFile11=OutputWindow
OutputPos=0,541,1089,701,1562
OpenFile12=ProjectWindow
PrjPos=0,0,752,0,250
OpenFile11=tasks_sys.c,0,411,63,1119,909,4,171,0,0
OpenFile12=pm.c,0,220,220,1464,977,15,320,0,0
OpenFile13=vreg_ctr.c,0,286,286,1530,1043,0,4,0,0
OpenFile14=OutputWindow
OutputPos=0,271,1065,313,1174
OpenFile13=self_flash.c,0,220,220,1464,977,0,254,0,0
ActivePRJ=yav_mcu_bsr.prj
[ProjectWindow]
ProjectWindowDispType=0

View File

@ -1,7 +1,7 @@
[SdbInfo]
Ver=5
[loader.c]
T=4a9b7c2e
T=4aa4e4e3
1=incs_loader.h
2=fsl.h
3=fsl_user.h
@ -10,46 +10,46 @@ T=4a9b7c2e
6=pm.h
7=rtc.h
[pm.c]
T=4a9d1a9d
T=4a9e6e71
1=incs_loader.h
2=adc.h
3=led.h
4=pm.h
[i2c_ctr.c]
T=4a9b8168
T=4a9e6e71
1=incs.h
[main.c]
T=4a9b2fe1
T=4a9e6e71
1=incs.h
2=WDT.h
3=rtc.h
4=pm.h
5=accero.h
[magic.c]
T=4a9dc834
T=4aa4d76e
[WDT.c]
T=4a8bb921
T=4a9e6e71
1=incs_loader.h
[i2c_mcu.c]
T=4a95d465
T=4a9e6e71
1=incs_loader.h
2=i2c_mcu.h
[i2c_twl.c]
T=4a9b5586
T=4a9e6e71
1=incs.h
2=i2c_twl_defs.h
[ini_VECT.c]
T=4a8a91dd
1=config.h
[led.c]
T=4a8bbf14
T=4a9e6e71
1=incs.h
2=led.h
[rtc.c]
T=4a8bbd28
T=4a9e6e71
1=incs.h
[vreg_ctr.c]
T=4a9d1a9d
T=4a9f065a
1=incs.h
2=vreg_ctr.h
3=rtc.h
@ -57,15 +57,15 @@ T=4a9d1a9d
5=accero.h
6=pm.h
[vreg_twl.c]
T=4a97560a
T=4a9e6e71
1=incs.h
2=jhl_defs.h
3=vreg_twl.h
[tasks.c]
T=4a9dc70c
T=4aa0b01d
1=incs.h
[adc.c]
T=4a9dc7eb
T=4a9e6e71
1=incs_loader.h
2=adc.h
3=pm.h
@ -77,7 +77,7 @@ T=4a7d2b02
2=renge\renge_task_immediate.h
3=WDT.h
[tasks_sys.c]
T=4a9ce593
T=4aa4c968
1=incs.h
2=i2c_twl.h
3=i2c_ctr.h
@ -86,16 +86,16 @@ T=4a9ce593
6=pm.h
7=rtc.h
[accero.c]
T=4a94f989
T=4a9e6e71
1=incs.h
[self_flash.c]
T=4a8bba9e
T=4aa4698a
1=incs_loader.h
2=fsl.h
3=fsl_user.h
4=i2c_ctr.h
[incs_loader.h]
T=4a950ca2
T=4a9e6e71
1=jhl_defs.h
2=user_define.h
3=bsr_system.h
@ -105,12 +105,12 @@ T=4a950ca2
7=i2c_mcu.h
8=WDT.h
[jhl_defs.h]
T=4a8bb83c
T=4a9e6e71
[user_define.h]
T=4a951723
T=4a9e6e71
1=config.h
[config.h]
T=4a9dc849
T=4aa0a25c
[bsr_system.h]
T=4a023057
1=jhl_defs.h
@ -124,14 +124,14 @@ T=4a5547e1
T=4a8a7575
1=renge\renge_defs.h
[vreg_ctr.h]
T=4a9ce593
T=4a9f09c2
[loader.h]
T=4a7a31d0
1=jhl_defs.h
[i2c_mcu.h]
T=4a94fcc6
T=4a9e6e71
[WDT.h]
T=4a8bb92f
T=4a9e6e71
[fsl.h]
T=47ec5c12
[fsl_user.h]
@ -139,16 +139,16 @@ T=4a7bf458
[i2c_ctr.h]
T=4a7c0777
[pm.h]
T=4a9d1a9d
T=4a9e6e71
[rtc.h]
T=4a8bbf80
T=4a9e6e71
[adc.h]
T=4a2e6395
1=jhl_defs.h
[led.h]
T=4a8aa5ff
[incs.h]
T=4a8bb7e6
T=4a9e6e71
1=jhl_defs.h
2=user_define.h
3=bsr_system.h
@ -157,9 +157,9 @@ T=4a8bb7e6
6=vreg_twl.h
7=i2c_mcu.h
[vreg_twl.h]
T=4a973fd7
T=4a9e6e71
[accero.h]
T=4a94f6c8
T=4a9e6e71
1=jhl_defs.h
[i2c_twl_defs.h]
T=4a7c074e