OpenCores
URL https://opencores.org/ocsvn/xenie/xenie/trunk

Subversion Repositories xenie

[/] [xenie/] [trunk/] [examples/] [Eth_example/] [outputs/] [prepend_header_to_marvell_fw.tcl] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 DFC
 
2
# This script prepends header to marvell FW
3
# Header is needed during reading FW from flash
4
# It specifies mainly length of FW, but contains other
5
# information that are not necessary but convenient to have
6
#
7
# It takes the first file in src_data/marvell_fw as a FW, so only one
8
# file should be always in this folder
9
#
10
#
11
# Header is formatted like this:
12
# 4 byte magic number - binary form of ascii string "MVFW"
13
# 4 byte unsigned integer offset of FW in the flash (related to header start)
14
# 4 byte unsigned integer length of FW
15
# zero-ended string of creation date
16
# zero-ended string name of file with FW
17
#
18
# Script is supposed to be placed in outputs directory.
19
# It is independent of opened project.
20
#
21
 
22
set origin_dir [file normalize [file dirname [info script]]]
23
set fw_dir "$origin_dir/src_data/marvell_fw"
24
 
25
 
26
set fout [open $origin_dir/res/marvell_fw_hdr.bin w]
27
fconfigure $fout -translation binary
28
 
29
set potential_fw_list [glob -type f [concat $fw_dir/*] ]
30
 
31
set fw_full_filename [lindex $potential_fw_list 0]
32
set fw_filename [file tail $fw_full_filename]
33
set fw_length [file size $fw_full_filename]
34
set fw_filename_length [string length $fw_filename]
35
 
36
set creation_date [clock format [clock seconds] -format {%Y-%m-%d %H:%M:%S}]
37
set creation_date_length [string length $creation_date]
38
 
39
#calculate offset of FW
40
set fw_offset [expr 4 + 4 + 4 + $creation_date_length + 1 + \
41
      $fw_filename_length + 1]
42
 
43
 
44
 
45
# write file header
46
puts -nonewline $fout "MVFW"
47
puts -nonewline $fout [binary format i $fw_offset]
48
puts -nonewline $fout [binary format i $fw_length]
49
puts -nonewline $fout $creation_date
50
puts -nonewline $fout \000
51
puts -nonewline $fout $fw_filename
52
puts -nonewline $fout \000
53
 
54
# write FW payload
55
set fin [open $fw_full_filename]
56
fconfigure $fin -translation binary
57
fcopy $fin $fout
58
close $fin
59
 
60
# close output file
61
close $fout

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.