Skip to content

Commit cca1d55

Browse files
committed
armcc - remove fromelf output before regenerating
Fix armcc recompile errors during elf2bin stage. Errors shown as follows: Elf2Bin: mbed-os-example-wifi Error: Q0147E: Failed to create Directory .\BUILD\REALTEK_RTL8195AM\ARM\mbed-os-example-wifi.bin\IMAGE2_TABLE: File exists Finished: 0 information, 0 warning and 1 error messages. [ERROR] Error: Q0147E: Failed to create Directory .\BUILD\REALTEK_RTL8195AM\ARM\mbed-os-example-wifi.bin\IMAGE2_TABLE: File exists Finished: 0 information, 0 warning and 1 error messages. Signed-off-by: Tony Wu <[email protected]>
1 parent fe2e4a3 commit cca1d55

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/toolchains/arm.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@
1616
"""
1717
import re
1818
from copy import copy
19-
from os.path import join, dirname, splitext, basename, exists, relpath
20-
from os import makedirs, write, curdir
19+
from os.path import join, dirname, splitext, basename, exists, relpath, isfile
20+
from os import makedirs, write, curdir, remove
2121
from tempfile import mkstemp
22+
from shutil import rmtree
2223

2324
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2425
from tools.hooks import hook_tool
@@ -251,6 +252,14 @@ def binary(self, resources, elf, bin):
251252
bin_arg = {".bin": "--bin", ".hex": "--i32"}[fmt]
252253
cmd = [self.elf2bin, bin_arg, '-o', bin, elf]
253254
cmd = self.hook.get_cmdline_binary(cmd)
255+
256+
# remove target binary file/path
257+
if exists(bin):
258+
if isfile(bin):
259+
remove(bin)
260+
else:
261+
rmtree(bin)
262+
254263
self.cc_verbose("FromELF: %s" % ' '.join(cmd))
255264
self.default_cmd(cmd)
256265

0 commit comments

Comments
 (0)