When using stlinkV2 you are constantly getting error messages from
'stlink_v1_open' when all goes well and 'stlink_open_usb' is used
instead. This patch fixes this confusing behaviour and makes stlink-sg.c
use logging macros consistently by removing last 'stderr' printout. It
is not needed as 'stlink_v1_open_inner' is verbose enough.
If 'stlink_v1_open_inner' returns NULL then 'stlink_v1_open' prints
to stderr thus there is no need for the former one to print it also.
This removes 'Error: could not open stlink device' being printed
twice.
The SNB part of the FLASH_CR register is four bits wide on F4 devices
and five bits wide on F4_HD devices. F4 devices have a reserved bit
alongside the sector number, so just increase the bitmask to cover all
five bits.
Currently flashing breaks, if flahing sector eight and above before
flashing lower sectors, because the highest bit is never unset.
Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Rather than putting debug printing in #ifdef blocks, use the same
uglylogging framework used by core stlink code.
To support this, the *LOG() macros are moved into the uglylogging.h
header file, and always use the filename as the logging tag.
The indentation of various st-link source files is highly inconsistent.
Reindent all source files to 4 space indentions for consistency.
I went with 4 space indentations, as it was the most common style.
Building on a 32-bit linux system was generating the following:
src/st-info.c: In function ‘print_data’:
src/st-info.c:25:3: warning: format ‘%lx’ expects argument of type \
‘long unsigned int’, but argument 2 has type ‘size_t’ [-Wformat]
src/st-info.c:27:3: warning: format ‘%lx’ expects argument of type \
‘long unsigned int’, but argument 2 has type ‘size_t’ [-Wformat]
src/st-info.c:29:3: warning: format ‘%lx’ expects argument of type \
‘long unsigned int’, but argument 2 has type ‘size_t’ [-Wformat]
Using '%zx' eliminates the warning in a platform agnostic way.
Consider a 128-byte write to the chip. If the last 2 bytes are
considered "empty", then len is adjusted to 126, and run_flash_loader
will only copy 126 bytes to RAM. However, run_flash_loader then
proceeds to round up to 32 words (128 bytes) when flashing, which has
the effect of clobbering those last two "empty" bytes with junk data.
There was a typo in the flash size register address for STM32F2. Change
to correct address. Verified against STM32F207 reference manual
(RM0033 Rev 5 section 33.2), and an STM32F217 chip.
Stlinky can silently fail if its magic bytes are present anywhere else
in the SRAM. This change makes st-term detect all stlinky structures,
warn about multiple occurences and will use the last one detected.
'-n' in st-util will cause it to skip the reset step, and thus allow you
to begin debugging at whatever point the code may currently be at.
Adding this feature required changing the stlink_open functions to
accept a reset flag that tells them whether or not to reset after
connecting. Skipping reset does not seem to have any adverse effects on
stlink usb devices. Unfortunately, I have to stlink v1 devices to test.