ctr_mcu/flower_toriaezu1/nec_s_2_bsrbin2.rb
n2232 44d462ce13 仕様1
・スリープ(蓋閉じ)中だけ電源長押しオフを効かなくする(全機種共通)
 else if( SW_pow_count == ( HOLD_THREASHOLD ) ) が無しのイメージ?
・スリープスイッチがスリープになってるときは、HOME+PWRの短押しで電源オン
 これは機種判定してFLOWERのときのみ。CTRでは、PWRオンリー
 ON_CHECK時の電源監視での短押し判定にSW_home_countあたりをアンドする?

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@514 013db118-44a6-b54f-8bf7-843cb86687b1
2013-02-21 00:19:25 +00:00

83 lines
1.8 KiB
Ruby
Executable File
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/ruby
$KCODE = "S"
=begin
 NECの環境が吐きだしたSRECを、
  ●未指定部分には0xFFパディングし、
  ●BSRのアップデート用に必要な部分だけ切り出します。
            0x0000 - 0x0FFF, 0x2000-0x47FF
=end
=begin
if( ARGV[0] == nil )
print( "input file name is nessesary!\nabort.\n" )
exit(1)
end
unless(File.exist?( ARGV[0] ))
print( "file" << ARGV[0] << " not found.\nabort.\n" )
exit(1)
end
=end
src = File.open( 'bsr.hex' )
dest = File.new( "hoge.bin","wb" )
dest.write( 'jhl' )
### get data ##########################
src_in = Hash.new
tempA = Array.new
dataTemp = Array.new
offset = Numeric.new
bindata = Array.new( 32*1024, 0xFF )
while(src.readline)
tempA = $_.scan(/(\:)(\w\w)(\w\w\w\w)(\w\w)(\w+)(\w\w)/)
break if( tempA.size == 0 )
src_in = { "len" => tempA[0][1], "offset" => tempA[0][2], "type" => tempA[0][3], "data" => tempA[0][4], "CRC" => tempA[0][5] }
break if src_in["type"].hex == 01
break if src_in["len"].hex == 00
# next if src_in["type"].hex != 00
if( src_in["type"].hex != 00 )
# p dat
next
end
offset = src_in["offset"].hex
next if(( 0x1000 <= offset ) && ( offset < 0x2000 ))
dataTemp = src_in["data"].scan(/\w\w/)
( 0...(src_in["len"].to_s.hex) ).each{|i|
bindata[ offset + i ] = ( dataTemp[ i ] ).to_s.hex
}
end
### debug enable bit check #############
# デバッグ許可になっているとISデバッガで起動しないMCUが動作しない
p bindata[0xC3]
if( bindata[0xC3] != 0x04 )
print( "!E debug enable!!" )
exit( 1 )
end
### format data and output #############
4096.times{
bindata.delete_at(4096)
}
dest.write( bindata[0..(0x4FFF - 0x1000)].pack("c*") )
dest.close
printf( "intel-HEX to bsr bin converter\n file converted!\n\n" )