ctr_mcu/trunk/nec_s_2_bsrbin2.rb
n2232 221bd1ccbc ■1.33(区別できるように) 内容は1.32と同じでデバッグを不許可にしただけ
IS箱でP40,41がGNDに接続されている状態で、デバッグ許可状態のバイナリを書き込むとMCUが動作しなくなる(デバッガ接続待ち?)
 誤った状態ではhoge.binが出来ないようにスクリプトを修正


git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@327 013db118-44a6-b54f-8bf7-843cb86687b1
2011-04-13 08:16:22 +00:00

83 lines
1.8 KiB
Ruby
Executable File
Raw Permalink 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" )