|
@@ -33,12 +33,10 @@ if [ -z "$1" ]; then PROGMEM=progmem1; fi
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
echo "progmem.sh started" >&2
|
|
@@ -61,71 +59,56 @@ if [ -e $PROGMEM.txt ]; then rm $PROGMEM.txt; fi
|
|
|
|
|
|
echo " progmem.sh (2) - listing symbol table of section '.text'" >&2
|
|
|
|
|
|
-$OBJDUMP -t -j ".text" $INOELF | tail -n +5 | grep -E "^[0-9a-f]{8} [gl] O" | cut -c1-9,28-36,37- | sed "/^$/d" | sort >> text.sym
|
|
|
+
|
|
|
+$OBJDUMP -t -j ".text" $INOELF | tail -n +5 | grep -E "^[0-9a-f]{8} [gl] [O ]" | cut -c1-9,28-36,37- | sed "/^$/d" | sort > text.sym
|
|
|
|
|
|
|
|
|
-echo " progmem.sh (3) - listing symbol table of section '.$PROGMEM'" >&2
|
|
|
-
|
|
|
-ls "$OBJDIR"/*.o | while read fn; do
|
|
|
- echo " processing $fn" >&2
|
|
|
-
|
|
|
- $OBJDUMP -t -j ".$PROGMEM" $fn 2>/dev/null | tail -n +5 | cut -c1-9,28-36,37- | sed "/^$/d" | sort >> $PROGMEM.sym
|
|
|
-done
|
|
|
-
|
|
|
-
|
|
|
-echo " progmem.sh (4) - filtering $PROGMEM symbols" >&2
|
|
|
-
|
|
|
-progmem=$(cut -c19- $PROGMEM.sym)
|
|
|
-progmem=$(echo $progmem | sed "s/ /\\\b\\\|\\\b/g")
|
|
|
-progmem='\b'$progmem'\b'
|
|
|
-
|
|
|
-cat text.sym | grep $progmem > $PROGMEM.sym
|
|
|
-
|
|
|
-
|
|
|
-echo " progmem.sh (5) - calculating start and stop address" >&2
|
|
|
+echo " progmem.sh (3) - calculating start and end address" >&2
|
|
|
|
|
|
-PROGMEM_BEG=$(head -n1 $PROGMEM.sym | while read offs size name; do echo "0x"$offs; done)
|
|
|
+PROGMEM_BEG=$(cat text.sym | grep "__loc_pri_start" | while read offs size name; do echo "0x"$offs; done)
|
|
|
|
|
|
-PROGMEM_END=$(tail -n1 $PROGMEM.sym | while read offs size name; do printf "0x%x" $((0x$offs + 0x$size)); done)
|
|
|
+PROGMEM_END=$(cat text.sym | grep "__loc_pri_end" | while read offs size name; do echo "0x"$offs; done)
|
|
|
echo " START address = "$PROGMEM_BEG >&2
|
|
|
echo " STOP address = "$PROGMEM_END >&2
|
|
|
|
|
|
-
|
|
|
-echo " progmem.sh (6) - extracting string data from elf" >&2
|
|
|
-
|
|
|
-$OBJDUMP -d -j ".text" -w -z --start-address=$PROGMEM_BEG --stop-address=$PROGMEM_END $INOELF | cut -c1-57 > $PROGMEM.lss
|
|
|
+
|
|
|
+echo " progmem.sh (4) - extracting string data from elf" >&2
|
|
|
+
|
|
|
+$OBJDUMP -D -j ".text" -w -z --start-address=$PROGMEM_BEG --stop-address=$PROGMEM_END $INOELF |\
|
|
|
+ tail -n +7 | sed "s/ \t.*$//" > $PROGMEM.lss
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-cat $PROGMEM.lss | tail -n +7 | sed -E 's/^$/|/;s/^........:\t/ /;s/<//g;s/>:/ /g;s/[ \t]*$//' |\
|
|
|
- tr -d '\n' | sed "s/[|]/\n/g" | grep $progmem > $PROGMEM.hex
|
|
|
+cat $PROGMEM.lss | sed -E 's/^$/|/;s/^ ....:\t//;s/[ ]*$/ /' | tr -d '\n' | tr '|' '\n' |\
|
|
|
+ sed "s/^ //;s/<//;s/>:/ /;s/00 [1-9a-f][1-9a-f] $/00 /; s/ $//" > $PROGMEM.hex
|
|
|
|
|
|
-
|
|
|
-echo " progmem.sh (7) - preparing string data" >&2
|
|
|
+
|
|
|
+echo " progmem.sh (5) - preparing string data" >&2
|
|
|
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
|
|
|
-cat $PROGMEM.hex | sed 's/ /\t/;s/ /\t /;s/ /\\x/g;s/\t/ /g' > $PROGMEM.chr
|
|
|
+cat $PROGMEM.hex | sed 's/ /\t/;s/ /\t /;s/ /\\x/g;s/\t/ /g' > $PROGMEM.chr
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-echo " progmem.sh (8) - converting string data" >&2
|
|
|
+
|
|
|
+
|
|
|
+echo " progmem.sh (6) - converting string data" >&2
|
|
|
+(\
|
|
|
+echo "/bin\/echo -e \\"; \
|
|
|
cat $PROGMEM.chr | \
|
|
|
sed 's/ \\xff\\xff/ /;' | \
|
|
|
sed 's/\\x22/\\\\\\x22/g;' | \
|
|
|
sed 's/\\x1b/\\\\\\x1b/g;' | \
|
|
|
sed 's/\\x01/\\\\\\x01/g;' | \
|
|
|
sed 's/\\xf8/\\\\\\xf8/g;' | \
|
|
|
- sed 's/\\x00$//;s/^/\/bin\/echo -e "/;s/$/"/' | sh > $PROGMEM.var
|
|
|
+ sed 's/\\x00$/\n/;s/^/\"/;s/$/\"\\/'; \
|
|
|
+) | sh > $PROGMEM.var
|
|
|
|
|
|
|
|
|
-
|
|
|
+cat $PROGMEM.var | sed 's/\r/\n/g' | sed -E 's/^[0-9a-f]{8} [^ ]* //' >$PROGMEM.txt
|
|
|
|
|
|
echo "progmem.sh finished" >&2
|
|
|
|