mbed official / mbed-sdk-tools
Committer:
theotherjimmy
Date:
Wed Oct 25 14:46:50 2017 -0500
Revision:
41:2a77626a4c21
Parent:
40:7d3fa6b99b2b
Child:
43:2a7da56ebd24
Update to track Mbed OS 5.6.3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
The Other Jimmy 36:96847d42f010 1 """
theotherjimmy 40:7d3fa6b99b2b 2 Realtek Semiconductor Corp.
The Other Jimmy 36:96847d42f010 3
theotherjimmy 40:7d3fa6b99b2b 4 RTL8195A elf2bin script
The Other Jimmy 36:96847d42f010 5 """
The Other Jimmy 36:96847d42f010 6
The Other Jimmy 36:96847d42f010 7 import sys, array, struct, os, re, subprocess
The Other Jimmy 36:96847d42f010 8 import hashlib
theotherjimmy 40:7d3fa6b99b2b 9 import shutil
The Other Jimmy 36:96847d42f010 10
The Other Jimmy 36:96847d42f010 11 from tools.paths import TOOLS_BOOTLOADERS
theotherjimmy 41:2a77626a4c21 12 from tools.toolchains import TOOLCHAIN_PATHS
The Other Jimmy 36:96847d42f010 13 from datetime import datetime
The Other Jimmy 36:96847d42f010 14
The Other Jimmy 36:96847d42f010 15 # Constant Variables
theotherjimmy 40:7d3fa6b99b2b 16 RAM2_RSVD = 0x00000000
theotherjimmy 40:7d3fa6b99b2b 17 RAM2_VER = 0x8195FFFF00000000
theotherjimmy 40:7d3fa6b99b2b 18 RAM2_TAG = 0x81950001
theotherjimmy 40:7d3fa6b99b2b 19 RAM2_SHA = '0'
The Other Jimmy 36:96847d42f010 20
The Other Jimmy 36:96847d42f010 21 def write_fixed_width_string(value, width, output):
theotherjimmy 40:7d3fa6b99b2b 22 # cut string to list & reverse
theotherjimmy 40:7d3fa6b99b2b 23 line = [value[i:i+2] for i in range(0, len(value), 2)]
theotherjimmy 40:7d3fa6b99b2b 24 output.write("".join([chr(long(b, 16)) for b in line]))
The Other Jimmy 36:96847d42f010 25
The Other Jimmy 36:96847d42f010 26 def write_fixed_width_value(value, width, output):
theotherjimmy 40:7d3fa6b99b2b 27 # convert to string
theotherjimmy 40:7d3fa6b99b2b 28 line = format(value, '0%dx' % (width))
theotherjimmy 40:7d3fa6b99b2b 29 if len(line) > width:
theotherjimmy 40:7d3fa6b99b2b 30 print "[ERROR] value 0x%s cannot fit width %d" % (line, width)
theotherjimmy 40:7d3fa6b99b2b 31 sys.exit(-1)
theotherjimmy 40:7d3fa6b99b2b 32 # cut string to list & reverse
theotherjimmy 40:7d3fa6b99b2b 33 line = [line[i:i+2] for i in range(0, len(line), 2)]
theotherjimmy 40:7d3fa6b99b2b 34 line.reverse()
theotherjimmy 40:7d3fa6b99b2b 35 # convert to write buffer
theotherjimmy 40:7d3fa6b99b2b 36 output.write("".join([chr(long(b, 16)) for b in line]))
The Other Jimmy 36:96847d42f010 37
The Other Jimmy 36:96847d42f010 38 def append_image_file(image, output):
The Other Jimmy 36:96847d42f010 39 input = open(image, "rb")
The Other Jimmy 36:96847d42f010 40 output.write(input.read())
The Other Jimmy 36:96847d42f010 41 input.close()
The Other Jimmy 36:96847d42f010 42
theotherjimmy 40:7d3fa6b99b2b 43 def write_padding_bytes(output_name, size):
theotherjimmy 40:7d3fa6b99b2b 44 current_size = os.stat(output_name).st_size
theotherjimmy 40:7d3fa6b99b2b 45 padcount = size - current_size
theotherjimmy 40:7d3fa6b99b2b 46 if padcount < 0:
theotherjimmy 40:7d3fa6b99b2b 47 print "[ERROR] image is larger than expected size"
theotherjimmy 40:7d3fa6b99b2b 48 sys.exit(-1)
theotherjimmy 40:7d3fa6b99b2b 49 output = open(output_name, "ab")
theotherjimmy 40:7d3fa6b99b2b 50 output.write('\377' * padcount)
The Other Jimmy 36:96847d42f010 51 output.close()
The Other Jimmy 36:96847d42f010 52
theotherjimmy 40:7d3fa6b99b2b 53 def sha256_checksum(filename, block_size=65536):
theotherjimmy 40:7d3fa6b99b2b 54 sha256 = hashlib.sha256()
theotherjimmy 40:7d3fa6b99b2b 55 with open(filename, 'rb') as f:
theotherjimmy 40:7d3fa6b99b2b 56 for block in iter(lambda: f.read(block_size), b''):
theotherjimmy 40:7d3fa6b99b2b 57 sha256.update(block)
theotherjimmy 40:7d3fa6b99b2b 58 return sha256.hexdigest()
The Other Jimmy 36:96847d42f010 59
theotherjimmy 40:7d3fa6b99b2b 60 def get_version_by_time():
theotherjimmy 40:7d3fa6b99b2b 61 secs = int((datetime.now()-datetime(2016,11,1)).total_seconds())
theotherjimmy 40:7d3fa6b99b2b 62 return RAM2_VER + secs
The Other Jimmy 36:96847d42f010 63
The Other Jimmy 36:96847d42f010 64 # ----------------------------
The Other Jimmy 36:96847d42f010 65 # main function
The Other Jimmy 36:96847d42f010 66 # ----------------------------
theotherjimmy 40:7d3fa6b99b2b 67 def prepend(image, entry, segment, image_ram2, image_ota):
theotherjimmy 40:7d3fa6b99b2b 68
theotherjimmy 40:7d3fa6b99b2b 69 # parse input arguments
theotherjimmy 40:7d3fa6b99b2b 70 output = open(image_ram2, "wb")
theotherjimmy 40:7d3fa6b99b2b 71
theotherjimmy 40:7d3fa6b99b2b 72 write_fixed_width_value(os.stat(image).st_size, 8, output)
theotherjimmy 40:7d3fa6b99b2b 73 write_fixed_width_value(int(entry), 8, output)
theotherjimmy 40:7d3fa6b99b2b 74 write_fixed_width_value(int(segment), 8, output)
theotherjimmy 40:7d3fa6b99b2b 75
theotherjimmy 40:7d3fa6b99b2b 76 RAM2_SHA = sha256_checksum(image)
theotherjimmy 40:7d3fa6b99b2b 77 write_fixed_width_value(RAM2_TAG, 8, output)
theotherjimmy 40:7d3fa6b99b2b 78 write_fixed_width_value(get_version_by_time(), 16, output)
theotherjimmy 40:7d3fa6b99b2b 79 write_fixed_width_string(RAM2_SHA, 64, output)
theotherjimmy 40:7d3fa6b99b2b 80 write_fixed_width_value(RAM2_RSVD, 8, output)
theotherjimmy 40:7d3fa6b99b2b 81
theotherjimmy 40:7d3fa6b99b2b 82 append_image_file(image, output)
theotherjimmy 40:7d3fa6b99b2b 83 output.close()
theotherjimmy 40:7d3fa6b99b2b 84
theotherjimmy 40:7d3fa6b99b2b 85 ota = open(image_ota, "wb")
theotherjimmy 40:7d3fa6b99b2b 86 write_fixed_width_value(os.stat(image).st_size, 8, ota)
theotherjimmy 40:7d3fa6b99b2b 87 write_fixed_width_value(int(entry), 8, ota)
theotherjimmy 40:7d3fa6b99b2b 88 write_fixed_width_value(int(segment), 8, ota)
theotherjimmy 40:7d3fa6b99b2b 89 write_fixed_width_value(0xFFFFFFFF, 8, ota)
theotherjimmy 40:7d3fa6b99b2b 90 write_fixed_width_value(get_version_by_time(), 16, ota)
theotherjimmy 40:7d3fa6b99b2b 91 write_fixed_width_string(RAM2_SHA, 64, ota)
theotherjimmy 40:7d3fa6b99b2b 92 write_fixed_width_value(RAM2_RSVD, 8, ota)
theotherjimmy 40:7d3fa6b99b2b 93
theotherjimmy 40:7d3fa6b99b2b 94 append_image_file(image, ota)
theotherjimmy 40:7d3fa6b99b2b 95 ota.close()
theotherjimmy 40:7d3fa6b99b2b 96
theotherjimmy 40:7d3fa6b99b2b 97 def find_symbol(toolchain, mapfile, symbol):
theotherjimmy 40:7d3fa6b99b2b 98 ret = None
theotherjimmy 40:7d3fa6b99b2b 99
theotherjimmy 40:7d3fa6b99b2b 100 HEX = '0x0{,8}(?P<addr>[0-9A-Fa-f]{8})'
The Other Jimmy 36:96847d42f010 101 if toolchain == "GCC_ARM":
theotherjimmy 40:7d3fa6b99b2b 102 SYM = re.compile(r'^\s+' + HEX + r'\s+' + symbol + '\r?$')
The Other Jimmy 36:96847d42f010 103 elif toolchain in ["ARM_STD", "ARM", "ARM_MICRO"]:
theotherjimmy 40:7d3fa6b99b2b 104 SYM = re.compile(r'^\s+' + HEX + r'\s+0x[0-9A-Fa-f]{8}\s+Code.*\s+i\.' + symbol + r'\s+.*$')
The Other Jimmy 36:96847d42f010 105 elif toolchain == "IAR":
theotherjimmy 40:7d3fa6b99b2b 106 SYM = re.compile(r'^' + symbol + r'\s+' + HEX + '\s+.*$')
theotherjimmy 40:7d3fa6b99b2b 107
theotherjimmy 40:7d3fa6b99b2b 108 with open(mapfile, 'r') as infile:
theotherjimmy 40:7d3fa6b99b2b 109 for line in infile:
theotherjimmy 40:7d3fa6b99b2b 110 match = re.match(SYM, line)
theotherjimmy 40:7d3fa6b99b2b 111 if match:
theotherjimmy 40:7d3fa6b99b2b 112 ret = match.group("addr")
theotherjimmy 40:7d3fa6b99b2b 113
theotherjimmy 40:7d3fa6b99b2b 114 if not ret:
theotherjimmy 40:7d3fa6b99b2b 115 print "[ERROR] cannot find the address of symbol " + symbol
theotherjimmy 40:7d3fa6b99b2b 116 return 0
theotherjimmy 40:7d3fa6b99b2b 117
theotherjimmy 40:7d3fa6b99b2b 118 return int(ret,16) | 1
theotherjimmy 40:7d3fa6b99b2b 119
theotherjimmy 40:7d3fa6b99b2b 120 def parse_load_segment_gcc(image_elf):
theotherjimmy 40:7d3fa6b99b2b 121 # Program Headers:
theotherjimmy 40:7d3fa6b99b2b 122 # Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
theotherjimmy 40:7d3fa6b99b2b 123 # LOAD 0x000034 0x10006000 0x10006000 0x026bc 0x026bc RW 0x8
theotherjimmy 40:7d3fa6b99b2b 124 # LOAD 0x0026f0 0x30000000 0x30000000 0x06338 0x06338 RWE 0x4
theotherjimmy 40:7d3fa6b99b2b 125 segment_list = []
theotherjimmy 41:2a77626a4c21 126 cmd = os.path.join(TOOLCHAIN_PATHS['GCC_ARM'], 'arm-none-eabi-readelf')
theotherjimmy 41:2a77626a4c21 127 cmd = '"' + cmd + '"' + ' -l ' + image_elf
theotherjimmy 40:7d3fa6b99b2b 128 for line in subprocess.check_output(cmd, shell=True, universal_newlines=True).split("\n"):
theotherjimmy 40:7d3fa6b99b2b 129 if not line.startswith(" LOAD"):
theotherjimmy 40:7d3fa6b99b2b 130 continue
theotherjimmy 40:7d3fa6b99b2b 131 segment = line.split()
theotherjimmy 40:7d3fa6b99b2b 132 if len(segment) != 8:
theotherjimmy 40:7d3fa6b99b2b 133 continue
theotherjimmy 40:7d3fa6b99b2b 134 offset = int(segment[1][2:], 16)
theotherjimmy 40:7d3fa6b99b2b 135 addr = int(segment[2][2:], 16)
theotherjimmy 40:7d3fa6b99b2b 136 size = int(segment[4][2:], 16)
theotherjimmy 40:7d3fa6b99b2b 137 if addr != 0 and size != 0:
theotherjimmy 40:7d3fa6b99b2b 138 segment_list.append((offset, addr, size))
theotherjimmy 40:7d3fa6b99b2b 139 return segment_list
theotherjimmy 40:7d3fa6b99b2b 140
theotherjimmy 40:7d3fa6b99b2b 141 def parse_load_segment_armcc(image_elf):
theotherjimmy 40:7d3fa6b99b2b 142 # ====================================
theotherjimmy 40:7d3fa6b99b2b 143 #
theotherjimmy 40:7d3fa6b99b2b 144 # ** Program header #2
theotherjimmy 40:7d3fa6b99b2b 145 #
theotherjimmy 40:7d3fa6b99b2b 146 # Type : PT_LOAD (1)
theotherjimmy 40:7d3fa6b99b2b 147 # File Offset : 52 (0x34)
theotherjimmy 40:7d3fa6b99b2b 148 # Virtual Addr : 0x30000000
theotherjimmy 40:7d3fa6b99b2b 149 # Physical Addr : 0x30000000
theotherjimmy 40:7d3fa6b99b2b 150 # Size in file : 27260 bytes (0x6a7c)
theotherjimmy 40:7d3fa6b99b2b 151 # Size in memory: 42168 bytes (0xa4b8)
theotherjimmy 40:7d3fa6b99b2b 152 # Flags : PF_X + PF_W + PF_R + PF_ARM_ENTRY (0x80000007)
theotherjimmy 40:7d3fa6b99b2b 153 # Alignment : 8
theotherjimmy 40:7d3fa6b99b2b 154 #
theotherjimmy 40:7d3fa6b99b2b 155 (offset, addr, size) = (0, 0, 0)
theotherjimmy 40:7d3fa6b99b2b 156 segment_list = []
theotherjimmy 40:7d3fa6b99b2b 157 in_segment = False
theotherjimmy 41:2a77626a4c21 158 cmd = os.path.join(TOOLCHAIN_PATHS['ARM'], 'bin', 'fromelf')
theotherjimmy 41:2a77626a4c21 159 cmd = '"' + cmd + '"' + ' --text -v --only=none ' + image_elf
theotherjimmy 40:7d3fa6b99b2b 160 for line in subprocess.check_output(cmd, shell=True, universal_newlines=True).split("\n"):
theotherjimmy 40:7d3fa6b99b2b 161 if line == "":
theotherjimmy 40:7d3fa6b99b2b 162 pass
theotherjimmy 40:7d3fa6b99b2b 163 elif line.startswith("** Program header"):
theotherjimmy 40:7d3fa6b99b2b 164 in_segment = True
theotherjimmy 40:7d3fa6b99b2b 165 elif in_segment == False:
theotherjimmy 40:7d3fa6b99b2b 166 pass
theotherjimmy 40:7d3fa6b99b2b 167 elif line.startswith("============"):
theotherjimmy 40:7d3fa6b99b2b 168 if addr != 0 and size != 0:
theotherjimmy 40:7d3fa6b99b2b 169 segment_list.append((offset, addr, size))
theotherjimmy 40:7d3fa6b99b2b 170 in_segment = False
theotherjimmy 40:7d3fa6b99b2b 171 (offset, addr, size) = (0, 0, 0)
theotherjimmy 40:7d3fa6b99b2b 172 elif line.startswith(" Type"):
theotherjimmy 40:7d3fa6b99b2b 173 if not re.match(r'\s+Type\s+:\s+PT_LOAD\s.*$', line):
theotherjimmy 40:7d3fa6b99b2b 174 in_segment = False
theotherjimmy 40:7d3fa6b99b2b 175 elif line.startswith(" File Offset"):
theotherjimmy 40:7d3fa6b99b2b 176 match = re.match(r'^\s+File Offset\s+:\s+(?P<offset>\d+).*$', line)
theotherjimmy 40:7d3fa6b99b2b 177 if match:
theotherjimmy 40:7d3fa6b99b2b 178 offset = int(match.group("offset"))
theotherjimmy 40:7d3fa6b99b2b 179 elif line.startswith(" Virtual Addr"):
theotherjimmy 40:7d3fa6b99b2b 180 match = re.match(r'^\s+Virtual Addr\s+:\s+0x(?P<addr>[0-9a-f]+).*$', line)
theotherjimmy 40:7d3fa6b99b2b 181 if match:
theotherjimmy 40:7d3fa6b99b2b 182 addr = int(match.group("addr"), 16)
theotherjimmy 40:7d3fa6b99b2b 183 elif line.startswith(" Size in file"):
theotherjimmy 40:7d3fa6b99b2b 184 match = re.match(r'^\s+Size in file\s+:.*\(0x(?P<size>[0-9a-f]+)\).*$', line)
theotherjimmy 40:7d3fa6b99b2b 185 if match:
theotherjimmy 40:7d3fa6b99b2b 186 size = int(match.group("size"), 16)
theotherjimmy 40:7d3fa6b99b2b 187 return segment_list
theotherjimmy 40:7d3fa6b99b2b 188
theotherjimmy 40:7d3fa6b99b2b 189
theotherjimmy 40:7d3fa6b99b2b 190 def parse_load_segment_iar(image_elf):
theotherjimmy 40:7d3fa6b99b2b 191 # SEGMENTS:
theotherjimmy 40:7d3fa6b99b2b 192 #
theotherjimmy 40:7d3fa6b99b2b 193 # Type Offset Virtual Physical File Sz Mem Sz Flags Align
theotherjimmy 40:7d3fa6b99b2b 194 # ---- ------ ------- -------- ------- ------ ----- -----
theotherjimmy 40:7d3fa6b99b2b 195 # 0: load 0x34 0x10006000 0x10006000 0x26bc 0x26bc 0x6 WR 0x8
theotherjimmy 40:7d3fa6b99b2b 196 # 1: load 0x26f0 0x30000000 0x30000000 0x6338 0x6338 0x7 XWR 0x4
theotherjimmy 40:7d3fa6b99b2b 197 #
theotherjimmy 40:7d3fa6b99b2b 198 # SECTIONS:
theotherjimmy 40:7d3fa6b99b2b 199 #
theotherjimmy 40:7d3fa6b99b2b 200 # Name Type Addr Offset Size Aln Lnk Inf ESz Flags
theotherjimmy 40:7d3fa6b99b2b 201 # ---- ---- ---- ------ ---- --- --- --- --- -----
theotherjimmy 40:7d3fa6b99b2b 202 # 1: .shstrtab strtab 0xfc4d8 0x60 0x4
theotherjimmy 40:7d3fa6b99b2b 203 # 2: .strtab strtab 0xfc538 0xbb3f 0x4
theotherjimmy 40:7d3fa6b99b2b 204
theotherjimmy 40:7d3fa6b99b2b 205 segment_list = []
theotherjimmy 40:7d3fa6b99b2b 206 in_segment = False
theotherjimmy 41:2a77626a4c21 207 cmd = os.path.join(TOOLCHAIN_PATHS['IAR'], 'bin', 'ielfdumparm')
theotherjimmy 41:2a77626a4c21 208 cmd = '"' + cmd + '"' + ' ' + image_elf
theotherjimmy 40:7d3fa6b99b2b 209 for line in subprocess.check_output(cmd, shell=True, universal_newlines=True).split("\n"):
theotherjimmy 40:7d3fa6b99b2b 210 if line.startswith(" SEGMENTS:"):
theotherjimmy 40:7d3fa6b99b2b 211 in_segment = True
theotherjimmy 40:7d3fa6b99b2b 212 elif in_segment == False:
theotherjimmy 40:7d3fa6b99b2b 213 pass
theotherjimmy 40:7d3fa6b99b2b 214 elif line.startswith(" SECTIONS:"):
theotherjimmy 40:7d3fa6b99b2b 215 break
theotherjimmy 40:7d3fa6b99b2b 216 elif re.match(r'^\s+\w+:\s+load\s+.*$', line):
theotherjimmy 40:7d3fa6b99b2b 217 segment = line.split()
theotherjimmy 40:7d3fa6b99b2b 218 offset = int(segment[2][2:], 16)
theotherjimmy 40:7d3fa6b99b2b 219 addr = int(segment[3][2:], 16)
theotherjimmy 40:7d3fa6b99b2b 220 size = int(segment[5][2:], 16)
theotherjimmy 40:7d3fa6b99b2b 221 if addr < 0x10007000:
theotherjimmy 40:7d3fa6b99b2b 222 continue
theotherjimmy 40:7d3fa6b99b2b 223 if addr != 0 and size != 0:
theotherjimmy 40:7d3fa6b99b2b 224 segment_list.append((offset, addr, size))
theotherjimmy 40:7d3fa6b99b2b 225 return segment_list
theotherjimmy 40:7d3fa6b99b2b 226
theotherjimmy 40:7d3fa6b99b2b 227 def parse_load_segment(toolchain, image_elf):
theotherjimmy 40:7d3fa6b99b2b 228 if toolchain == "GCC_ARM":
theotherjimmy 40:7d3fa6b99b2b 229 return parse_load_segment_gcc(image_elf)
theotherjimmy 40:7d3fa6b99b2b 230 elif toolchain in ["ARM_STD", "ARM", "ARM_MICRO"]:
theotherjimmy 40:7d3fa6b99b2b 231 return parse_load_segment_armcc(image_elf)
theotherjimmy 40:7d3fa6b99b2b 232 elif toolchain == "IAR":
theotherjimmy 40:7d3fa6b99b2b 233 return parse_load_segment_iar(image_elf)
The Other Jimmy 36:96847d42f010 234 else:
theotherjimmy 40:7d3fa6b99b2b 235 return []
theotherjimmy 40:7d3fa6b99b2b 236
theotherjimmy 40:7d3fa6b99b2b 237 def write_load_segment(image_elf, image_bin, segment):
theotherjimmy 40:7d3fa6b99b2b 238 file_elf = open(image_elf, "rb")
theotherjimmy 40:7d3fa6b99b2b 239 file_bin = open(image_bin, "wb")
theotherjimmy 40:7d3fa6b99b2b 240 for (offset, addr, size) in segment:
theotherjimmy 40:7d3fa6b99b2b 241 file_elf.seek(offset)
theotherjimmy 40:7d3fa6b99b2b 242 # write image header - size & addr
theotherjimmy 40:7d3fa6b99b2b 243 write_fixed_width_value(addr, 8, file_bin)
theotherjimmy 40:7d3fa6b99b2b 244 write_fixed_width_value(size, 8, file_bin)
theotherjimmy 40:7d3fa6b99b2b 245 # write load segment
theotherjimmy 40:7d3fa6b99b2b 246 file_bin.write(file_elf.read(size))
theotherjimmy 40:7d3fa6b99b2b 247 delta = size % 4
theotherjimmy 40:7d3fa6b99b2b 248 if delta != 0:
theotherjimmy 40:7d3fa6b99b2b 249 padding = 4 - delta
theotherjimmy 40:7d3fa6b99b2b 250 write_fixed_width_value(0x0, padding * 2, file_bin)
theotherjimmy 40:7d3fa6b99b2b 251 file_bin.close()
theotherjimmy 40:7d3fa6b99b2b 252 file_elf.close()
theotherjimmy 40:7d3fa6b99b2b 253
theotherjimmy 40:7d3fa6b99b2b 254 # ----------------------------
theotherjimmy 40:7d3fa6b99b2b 255 # main function
theotherjimmy 40:7d3fa6b99b2b 256 # ----------------------------
theotherjimmy 40:7d3fa6b99b2b 257 def rtl8195a_elf2bin(t_self, image_elf, image_bin):
theotherjimmy 40:7d3fa6b99b2b 258 # remove target binary file/path
theotherjimmy 40:7d3fa6b99b2b 259 if os.path.isfile(image_bin):
theotherjimmy 40:7d3fa6b99b2b 260 os.remove(image_bin)
theotherjimmy 40:7d3fa6b99b2b 261 else:
theotherjimmy 40:7d3fa6b99b2b 262 shutil.rmtree(image_bin)
theotherjimmy 40:7d3fa6b99b2b 263
theotherjimmy 40:7d3fa6b99b2b 264 segment = parse_load_segment(t_self.name, image_elf)
theotherjimmy 40:7d3fa6b99b2b 265 write_load_segment(image_elf, image_bin, segment)
theotherjimmy 40:7d3fa6b99b2b 266
The Other Jimmy 36:96847d42f010 267 image_name = os.path.splitext(image_elf)[0]
theotherjimmy 40:7d3fa6b99b2b 268 image_map = image_name + '.map'
The Other Jimmy 36:96847d42f010 269
theotherjimmy 40:7d3fa6b99b2b 270 ram2_ent = find_symbol(t_self.name, image_map, "PLAT_Start")
theotherjimmy 40:7d3fa6b99b2b 271 ram1_bin = os.path.join(TOOLS_BOOTLOADERS, "REALTEK_RTL8195AM", "ram_1.bin")
theotherjimmy 40:7d3fa6b99b2b 272 ram2_bin = image_name + '-ram_2.bin'
theotherjimmy 40:7d3fa6b99b2b 273 ota_bin = image_name + '-ota.bin'
theotherjimmy 40:7d3fa6b99b2b 274 prepend(image_bin, ram2_ent, len(segment), ram2_bin, ota_bin)
The Other Jimmy 36:96847d42f010 275
The Other Jimmy 36:96847d42f010 276 # write output file
The Other Jimmy 36:96847d42f010 277 output = open(image_bin, "wb")
theotherjimmy 40:7d3fa6b99b2b 278 append_image_file(ram1_bin, output)
theotherjimmy 40:7d3fa6b99b2b 279 append_image_file(ram2_bin, output)
The Other Jimmy 36:96847d42f010 280 output.close()