Created
August 27, 2019 18:34
-
-
Save ivand58/b6ba95a44e0e894149f85bf3c3cfb13d to your computer and use it in GitHub Desktop.
A hexdump with Extended Linear Address record for images > 64kB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$FF variable hex.empty \ needs to be variable, some flash is zero when empty | |
: hexd64k ( n -- ) | |
\ STM32F103x8: Complete image with Dictionary: $FFFF $0000 | |
dup | |
$FFFF + swap | |
do | |
\ Check if this line is entirely empty: | |
0 \ Not worthy to print | |
i #16 + i do \ Scan data | |
i c@ hex.empty @ <> or \ Set flag if there is a non-empty byte | |
loop | |
if | |
." :10" i $FFFF and h.4 ." 00" \ Write record-intro with 4 digits. | |
$10 \ Begin checksum | |
i + \ Sum the address bytes | |
i 8 rshift + \ separately into the checksum | |
i #16 + i do | |
i c@ h.2 \ Print data with 2 digits | |
i c@ + \ Sum it up for Checksum | |
loop | |
negate h.2 \ Write Checksum | |
cr | |
then | |
#16 +loop | |
; | |
: exadr ( u -- ) | |
\ STM32F103xB: 128 KB needs an Extended Linear Address | |
." :02000004" | |
dup h.4 | |
dup 8 rshift + 2 + 4 + negate 255 and | |
h.2 | |
cr | |
; | |
: hexdump ( -- ) \ dumps entire flash as Intel hex | |
flash-kb 64 / \ how many pages, each 64k | |
cr | |
0 do | |
i exadr | |
i 16 lshift \ page>addr | |
hexd64k | |
loop | |
." :00000001FF" cr | |
; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment