blackmagic/flashstub/code-to-array.pl
Marc Singer e0a8ce5a88 STM32L0x target support.
Target support for stm32l0's and stm32l1's including option bytes and
data EEPROM.  This module will superceed the previous stm32l1 driver.

o Program flash write and erase.
o Options modification and interpretive status.
o Stubs for program flash writes and erases.  Stubs are modestly
  faster than non-stub version.   The stm32l0 will not execute stubs
  when the MCU has crashed.  A monitor option may be used to force
  non-stub flash writes.
o Stubs generated from C++ code and converted to arrays of half-words.
o Writes to data EEPROM supoprted when loading segments.
o EEPROM data monitor command to write words.
o Stubs supported on stm32l1.
2015-03-08 16:17:34 -07:00

25 lines
504 B
Perl
Executable File

#!/usr/bin/perl
#
# Convert the output of objdump to an array of bytes are can include
# into our program.
while (<>) {
if (m/^\s*([0-9a-fA-F]+):\s*([0-9a-fA-F]+)(.*)/) {
my $addr = "0x$1";
my $value = $2;
if (length ($value) == 4) {
print " [$addr/2] = 0x$value, // $_";
}
else {
my $lsb = substr ($value, 4, 4);
my $msb = substr ($value, 0, 4);
print " [$addr/2] = 0x$lsb, // $_";
print " [$addr/2 + 1] = 0x$msb,\n";
}
}
else {
print "// ", $_;
}
}