アップデータ用切り出しスクリプト

x.0.D以降はこちらを使う


git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_mcu@80 013db118-44a6-b54f-8bf7-843cb86687b1
This commit is contained in:
fujita_ryohei 2010-01-12 01:17:32 +00:00
parent bdeac395b8
commit 2c359d532b

74
trunk/nec_s_2_bsrbin2.rb Executable file
View File

@ -0,0 +1,74 @@
#!/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( '/cygdrive/c/78k_data/yav-mcu-basara/bsr.hex' )
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
### 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" )