The controller doesn't clear them automatically when the operation
finishes, so to avoid getting errors we need to clear them manually
before we request another operation.
Per ST doc DM00035129.pdf "DocID022063 Rev 5", the STM32F415xx data sheet,
table 40 on page 110 of the PDF, 32-bit program operation is only possible
above 2.7 Volts.
In order to support programming on devices running at lower voltages, this
commit adds an 8-bit programming mode and the necessary tests to enable it
when the reported voltage is below 2.7 Volts.
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.