Skip to content
This repository was archived by the owner on Mar 7, 2026. It is now read-only.

Commit 3ca8674

Browse files
committed
flashstub: Fix ELF to hexdump conversion
1 parent f9e0169 commit 3ca8674

1 file changed

Lines changed: 46 additions & 5 deletions

File tree

src/target/flashstub/meson.build

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ lmi_stub = []
3333
efm32_stub = []
3434
rp2040_stub = []
3535

36-
# If we're doing a firmware build, type to find hexdump
36+
# If we're doing a firmware build, type to find hexdump and objcopy
3737
if is_firmware_build
38+
objcopy = find_program('objcopy', required: false)
3839
hexdump = find_program('hexdump', required: false)
3940
else
41+
objcopy = disabler()
4042
hexdump = disabler()
4143
endif
4244
# If we cannot or we're not a firmware build, we're done
43-
if not hexdump.found()
45+
if not hexdump.found() or not objcopy.found()
4446
subdir_done()
4547
endif
4648

@@ -74,6 +76,19 @@ lmi_stub_elf = executable(
7476
install: false,
7577
)
7678

79+
lmi_stub_bin = custom_target(
80+
'lmi_stub-bin',
81+
command: [
82+
objcopy,
83+
'-Obinary',
84+
'-j.text',
85+
'@INPUT@',
86+
'@OUTPUT@'
87+
],
88+
input: lmi_stub_elf,
89+
output: 'lmi_stub_bin',
90+
)
91+
7792
lmi_stub = custom_target(
7893
'lmi_stub-hex',
7994
command: [
@@ -82,7 +97,7 @@ lmi_stub = custom_target(
8297
'-e', '/2 "0x%04X, "',
8398
'@INPUT@'
8499
],
85-
input: lmi_stub_elf,
100+
input: lmi_stub_bin,
86101
output: 'lmi.stub',
87102
capture: true,
88103
)
@@ -105,6 +120,19 @@ efm32_stub_elf = executable(
105120
install: false,
106121
)
107122

123+
efm32_stub_bin = custom_target(
124+
'efm32_stub-bin',
125+
command: [
126+
objcopy,
127+
'-Obinary',
128+
'-j.text',
129+
'@INPUT@',
130+
'@OUTPUT@'
131+
],
132+
input: efm32_stub_elf,
133+
output: 'efm32_stub_bin',
134+
)
135+
108136
efm32_stub = custom_target(
109137
'efm32_stub-hex',
110138
command: [
@@ -113,7 +141,7 @@ efm32_stub = custom_target(
113141
'-e', '/2 "0x%04X, "',
114142
'@INPUT@'
115143
],
116-
input: efm32_stub_elf,
144+
input: efm32_stub_bin,
117145
output: 'efm32.stub',
118146
capture: true,
119147
)
@@ -136,6 +164,19 @@ rp2040_stub_elf = executable(
136164
install: false,
137165
)
138166

167+
rp2040_stub_bin = custom_target(
168+
'rp2040_stub-bin',
169+
command: [
170+
objcopy,
171+
'-Obinary',
172+
'-j.text',
173+
'@INPUT@',
174+
'@OUTPUT@'
175+
],
176+
input: rp2040_stub_elf,
177+
output: 'rp2040_stub_bin',
178+
)
179+
139180
rp2040_stub = custom_target(
140181
'rp_stub-hex',
141182
command: [
@@ -144,7 +185,7 @@ rp2040_stub = custom_target(
144185
'-e', '/2 "0x%04X, "',
145186
'@INPUT@'
146187
],
147-
input: rp2040_stub_elf,
188+
input: rp2040_stub_bin,
148189
output: 'rp.stub',
149190
capture: true,
150191
)

0 commit comments

Comments
 (0)