Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package stm32flash for openSUSE:Factory 
checked in at 2023-02-22 15:21:31
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/stm32flash (Old)
 and      /work/SRC/openSUSE:Factory/.stm32flash.new.1706 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "stm32flash"

Wed Feb 22 15:21:31 2023 rev:6 rq:1067059 version:0.7

Changes:
--------
--- /work/SRC/openSUSE:Factory/stm32flash/stm32flash.changes    2021-06-11 
22:31:18.274195764 +0200
+++ /work/SRC/openSUSE:Factory/.stm32flash.new.1706/stm32flash.changes  
2023-02-22 15:21:38.813881821 +0100
@@ -1,0 +2,14 @@
+Mon Feb 13 08:04:29 UTC 2023 - Torsten Gruner <simmpho...@opensuse.org>
+
+- update to 0.7
+  * Fix I2C page-by-page erase (Yann Sionneau)
+  * Fix hex file base address not used, extraneous base padding (Renaud Fivet)
+  * Fix truncated read from stdin (Renaud Fivet)
+  * Fix input buffer flush on Windows (Jan Belohoubek)
+  * More baud rates available, up to 4000000
+  * Allow skipping serial port setup with -b 0
+  * Support STM32L412xx/422xx (Andy Little)
+  * Support STM32G05xxx/061xx (Luca Amati), STM32G0B0/B1/C1xx, STM32G491xx/A1xx
+- drop stm32flash-i2c-tools-headers-clash.patch
+
+-------------------------------------------------------------------

Old:
----
  stm32flash-0.6.tar.gz
  stm32flash-i2c-tools-headers-clash.patch

New:
----
  stm32flash-0.7.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ stm32flash.spec ++++++
--- /var/tmp/diff_new_pack.Xg2ugA/_old  2023-02-22 15:21:39.297884566 +0100
+++ /var/tmp/diff_new_pack.Xg2ugA/_new  2023-02-22 15:21:39.297884566 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package stm32flash
 #
-# Copyright (c) 2021 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,16 +17,13 @@
 
 
 Name:           stm32flash
-Version:        0.6
+Version:        0.7
 Release:        0
 Summary:        Flash Program for the STM32 Bootloader
 License:        GPL-2.0-or-later
 Group:          Hardware/Other
 URL:            https://sourceforge.net/p/stm32flash/wiki/Home
-Source:         
https://download.sourceforge.net/stm32flash/stm32flash-0.6.tar.gz
-# PATCH-FIX-OPENSUSE stm32flash-i2c-tools-headers-clash.patch sbra...@suse.cz 
-- Prevent clash between i2c.h and i2c-dev.h defining the same.
-Patch3:         stm32flash-i2c-tools-headers-clash.patch
-BuildRequires:  i2c-tools
+Source:         
https://download.sourceforge.net/stm32flash/stm32flash-%{version}.tar.gz
 
 %description
 Open source flash program for the STM32 ARM processors using the ST
@@ -49,9 +46,6 @@
 
 %prep
 %setup -q
-%if 0%{?suse_version} < 1315 || 0%{?suse_version} == 1320
-%patch3 -p1
-%endif
 
 %build
 %make_build CFLAGS="-O2 %{optflags}" PREFIX=%{_prefix}

++++++ stm32flash-0.6.tar.gz -> stm32flash-0.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/AUTHORS new/stm32flash-0.7/AUTHORS
--- old/stm32flash-0.6/AUTHORS  2020-11-16 11:06:58.000000000 +0100
+++ new/stm32flash-0.7/AUTHORS  2022-03-27 14:16:36.000000000 +0200
@@ -35,3 +35,7 @@
 Emil Melar
 Paolo Bassi
 Guillaume Revaillot
+Luca Amati
+Yann Sionneau
+Andy Little
+Renaud Fivet
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/ChangeLog new/stm32flash-0.7/ChangeLog
--- old/stm32flash-0.6/ChangeLog        1970-01-01 01:00:00.000000000 +0100
+++ new/stm32flash-0.7/ChangeLog        2022-03-27 14:16:36.000000000 +0200
@@ -0,0 +1,35 @@
+0.7 (2022-03-26)
+
+- Fix I2C page-by-page erase (Yann Sionneau)
+- Fix hex file base address not used, extraneous base padding (Renaud Fivet)
+- Fix truncated read from stdin (Renaud Fivet)
+- Fix input buffer flush on Windows (Jan Belohoubek)
+- More baud rates available, up to 4000000
+- Allow skipping serial port setup with -b 0
+- Support STM32L412xx/422xx (Andy Little)
+- Support STM32G05xxx/061xx (Luca Amati), STM32G0B0/B1/C1xx, STM32G491xx/A1xx
+
+
+0.6 (2021-02-12)
+
+stm32flash 0.6 is a maintenance release with these highlights:
+- Many more devices supported G0/G4/F7/H7/L4 (various contributors)
+- GPIO sequencing reworked (Roman Savrulin)
+- Serial port handling improved (Mickael Gardet)
+- Many code improvements (Antonio Borneo)
+- Only erase needed pages if flashing from file (Tormod Volden)
+
+
+0.5 (2016-02-11)
+
+- support for multiple bank sizes
+- improved serial port support on Windows
+- improved erase functionality
+- improved hex parser
+- many new devices and device info corrections
+
+
+0.4 (2014-10-04)
+- support for programming over I2C (Antonio Borneo)
+- code refactored to make it easier to add other transports (Antonio Borneo)
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/I2C.txt new/stm32flash-0.7/I2C.txt
--- old/stm32flash-0.6/I2C.txt  2016-03-22 22:23:23.000000000 +0100
+++ new/stm32flash-0.7/I2C.txt  2022-03-26 09:58:16.000000000 +0100
@@ -20,8 +20,19 @@
 
 In the market there are several USB-to-I2C dongles; most of them are not
 supported by kernel drivers. Manufacturer provide proprietary userspace
-libraries using not standardized API.
-These API and dongles could be supported in feature versions.
+libraries using not standardized API. Such API and dongles could in
+principle be supported in feature versions of stm32flash.
+
+The open-hardware i2c-tiny-usb device and its reimplementation on the
+STM32, the i2c-star, are fully supported by the Linux kernel.
+- https://www.fischl.de/i2c-mp-usb/
+- https://github.com/daniel-thompson/i2c-star
+
+There is also the I2CDriver which has open-source drivers and
+available design files. Although there is no kernel driver,
+there is a userspace compatibility interface available.
+- https://github.com/jamesbowman/i2cdriver
+- https://github.com/mbenkmann/i2cdriver/tree/master/c/linux
 
 There are currently 3 versions of STM32 bootloader for I2C communications:
 - v1.0 using I2C clock stretching synchronization between host and STM32;
@@ -56,6 +67,8 @@
 About bootloader v1.0
 ==========================================================================
 
+(Used on F0, F3 and F4 up to STM32F401xB(C) devices)
+
 Version v1.0 can have issues with some I2C controllers due to use of clock
 stretching during commands that require long operations, like flash erase
 and programming.
@@ -79,7 +92,8 @@
 
 In my case I'm using the I2C controller integrated in the VGA port of my
 laptop HP EliteBook 8460p. I built the 0.25$ VGA-to-I2C adapter reported in
-       http://www.paintyourdragon.com/?p=43
+https://web.archive.org/web/20160506154718/http://www.paintyourdragon.com/?p=43
+
 To change the timeout of the I2C controller I had to modify the kernel file
        drivers/gpu/drm/radeon/radeon_i2c.c
 line 969
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/Makefile.in 
new/stm32flash-0.7/Makefile.in
--- old/stm32flash-0.6/Makefile.in      2021-02-12 20:43:31.000000000 +0100
+++ new/stm32flash-0.7/Makefile.in      2022-03-27 14:22:36.000000000 +0200
@@ -208,9 +208,9 @@
 CTAGS = ctags
 CSCOPE = cscope
 DIST_SUBDIRS = $(SUBDIRS)
-am__DIST_COMMON = $(srcdir)/Makefile.in AUTHORS INSTALL TODO ar-lib \
-       compile config.guess config.sub depcomp install-sh ltmain.sh \
-       missing
+am__DIST_COMMON = $(srcdir)/Makefile.in AUTHORS ChangeLog INSTALL TODO \
+       ar-lib compile config.guess config.sub depcomp install-sh \
+       ltmain.sh missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/configure new/stm32flash-0.7/configure
--- old/stm32flash-0.6/configure        2021-02-12 20:43:31.000000000 +0100
+++ new/stm32flash-0.7/configure        2022-03-27 14:22:36.000000000 +0200
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for stm32flash 0.6.
+# Generated by GNU Autoconf 2.69 for stm32flash 0.7.
 #
 #
 # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -587,8 +587,8 @@
 # Identity of this package.
 PACKAGE_NAME='stm32flash'
 PACKAGE_TARNAME='stm32flash'
-PACKAGE_VERSION='0.6'
-PACKAGE_STRING='stm32flash 0.6'
+PACKAGE_VERSION='0.7'
+PACKAGE_STRING='stm32flash 0.7'
 PACKAGE_BUGREPORT=''
 PACKAGE_URL=''
 
@@ -1327,7 +1327,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures stm32flash 0.6 to adapt to many kinds of systems.
+\`configure' configures stm32flash 0.7 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1398,7 +1398,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of stm32flash 0.6:";;
+     short | recursive ) echo "Configuration of stm32flash 0.7:";;
    esac
   cat <<\_ACEOF
 
@@ -1510,7 +1510,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-stm32flash configure 0.6
+stm32flash configure 0.7
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1788,7 +1788,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by stm32flash $as_me 0.6, which was
+It was created by stm32flash $as_me 0.7, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2653,7 +2653,7 @@
 
 # Define the identity of the package.
  PACKAGE='stm32flash'
- VERSION='0.6'
+ VERSION='0.7'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -12764,7 +12764,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by stm32flash $as_me 0.6, which was
+This file was extended by stm32flash $as_me 0.7, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -12821,7 +12821,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; 
s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-stm32flash config.status 0.6
+stm32flash config.status 0.7
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/configure.ac 
new/stm32flash-0.7/configure.ac
--- old/stm32flash-0.6/configure.ac     2021-02-12 20:41:50.000000000 +0100
+++ new/stm32flash-0.7/configure.ac     2022-03-27 14:16:36.000000000 +0200
@@ -2,7 +2,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ([2.68])
-AC_INIT([stm32flash], [0.6], [])
+AC_INIT([stm32flash], [0.7], [])
 
 # Checks for programs.
 AM_INIT_AUTOMAKE([foreign -Wall])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/dev_table.c 
new/stm32flash-0.7/dev_table.c
--- old/stm32flash-0.6/dev_table.c      2021-01-24 09:02:51.000000000 +0100
+++ new/stm32flash-0.7/dev_table.c      2021-12-20 22:04:53.000000000 +0100
@@ -96,18 +96,23 @@
        {0x421, "STM32F446xx"                     , 0x20003000, 0x20020000, 
0x08000000, 0x08080000,  1, f2f4  , 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 
0x1FFF7800, 0},
        {0x434, "STM32F469xx/479xx"               , 0x20003000, 0x20060000, 
0x08000000, 0x08200000,  1, f4db  , 0x1FFEC000, 0x1FFFC00F, 0x1FFF0000, 
0x1FFF7800, 0},
        {0x463, "STM32F413xx/423xx"               , 0x20003000, 0x20050000, 
0x08000000, 0x08180000,  1, f2f4  , 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 
0x1FFF7800, 0},
+       /* F7 */
+       {0x452, "STM32F72xxx/73xxx"               , 0x20004000, 0x20040000, 
0x08000000, 0x08080000,  1, f2f4  , 0x1FFF0000, 0x1FFF001F, 0x1FF00000, 
0x1FF0EDC0, 0},
+       {0x449, "STM32F74xxx/75xxx"               , 0x20004000, 0x20050000, 
0x08000000, 0x08100000,  1, f7    , 0x1FFF0000, 0x1FFF001F, 0x1FF00000, 
0x1FF0EDC0, 0},
+       {0x451, "STM32F76xxx/77xxx"               , 0x20004000, 0x20080000, 
0x08000000, 0x08200000,  1, f7    , 0x1FFF0000, 0x1FFF001F, 0x1FF00000, 
0x1FF0EDC0, 0},
        /* G0 */
        {0x466, "STM32G03xxx/04xxx"               , 0x20001000, 0x20002000, 
0x08000000, 0x08010000,  1, p_2k  , 0x1FFF7800, 0x1FFF787F, 0x1FFF0000, 
0x1FFF2000, 0},
        {0x460, "STM32G07xxx/08xxx"               , 0x20002700, 0x20009000, 
0x08000000, 0x08020000,  1, p_2k  , 0x1FFF7800, 0x1FFF787F, 0x1FFF0000, 
0x1FFF7000, 0},
+       {0x467, "STM32G0B0/B1/C1xx"               , 0x20004000, 0x20020000, 
0x08000000, 0x08080000,  1, p_2k  , 0x1FFF7800, 0x1FFF787F, 0x1FFF0000, 
0x1FFF7000, 0},
+       {0x456, "STM32G05xxx/061xx"               , 0x20001000, 0x20004800, 
0x08000000, 0x08010000,  1, p_2k  , 0x1FFF7800, 0x1FFF787F, 0x1FFF0000, 
0x1FFF2000, 0},
        /* G4 */
        {0x468, "STM32G431xx/441xx"               , 0x20004000, 0x20005800, 
0x08000000, 0x08020000,  1, p_2k  , 0x1FFF7800, 0x1FFF782F, 0x1FFF0000, 
0x1FFF7000, 0},
        {0x469, "STM32G47xxx/48xxx"               , 0x20004000, 0x20018000, 
0x08000000, 0x08080000,  1, p_2k  , 0x1FFF7800, 0x1FFF782F, 0x1FFF0000, 
0x1FFF7000, 0},
-       /* F7 */
-       {0x452, "STM32F72xxx/73xxx"               , 0x20004000, 0x20040000, 
0x08000000, 0x08080000,  1, f2f4  , 0x1FFF0000, 0x1FFF001F, 0x1FF00000, 
0x1FF0EDC0, 0},
-       {0x449, "STM32F74xxx/75xxx"               , 0x20004000, 0x20050000, 
0x08000000, 0x08100000,  1, f7    , 0x1FFF0000, 0x1FFF001F, 0x1FF00000, 
0x1FF0EDC0, 0},
-       {0x451, "STM32F76xxx/77xxx"               , 0x20004000, 0x20080000, 
0x08000000, 0x08200000,  1, f7    , 0x1FFF0000, 0x1FFF001F, 0x1FF00000, 
0x1FF0EDC0, 0},
+       {0x479, "STM32G491xx/A1xx"                , 0x20004000, 0x2001C000, 
0x08000000, 0x08080000,  1, p_2k  , 0x1FFF7800, 0x1FFF782F, 0x1FFF0000, 
0x1FFF7000, 0},
        /* H7 */
+/*     {0x483, "STM32H72xxx/73xxx"               , 0x20004100, 0x20020000, 
0x80000000, x         ,  x, x     , x         , x         , 0x1FF00000, 
0x1FF1E800, 0}, */
        {0x450, "STM32H74xxx/75xxx"               , 0x20004100, 0x20020000, 
0x08000000, 0x08200000,  1, p_128k, 0         , 0         , 0x1FF00000, 
0x1FF1E800, 0},
+/*     {0x480, "STM32H7A3xx/B3xx"                , 0x20004100, 0x20020000, 
0x08000000, x         ,  x, x     , x         , x         , 0x1FF00000, 
0x1FF14000, 0}, */
        /* L0 */
        {0x457, "STM32L01xxx/02xxx"               , 0x20000800, 0x20000800, 
0x08000000, 0x08004000, 32, p_128 , 0x1FF80000, 0x1FF8001F, 0x1FF00000, 
0x1FF01000, F_NO_ME},
        {0x425, "STM32L031xx/041xx"               , 0x20001000, 0x20002000, 
0x08000000, 0x08008000, 32, p_128 , 0x1FF80000, 0x1FF8001F, 0x1FF00000, 
0x1FF01000, F_NO_ME},
@@ -120,11 +125,20 @@
        {0x436, "STM32L1xxxD"                     , 0x20001000, 0x2000C000, 
0x08000000, 0x08060000, 16, p_256 , 0x1FF80000, 0x1FF8009F, 0x1FF00000, 
0x1FF02000, F_NO_ME},
        {0x437, "STM32L1xxxE"                     , 0x20001000, 0x20014000, 
0x08000000, 0x08080000, 16, p_256 , 0x1FF80000, 0x1FF8009F, 0x1FF00000, 
0x1FF02000, F_NO_ME},
        /* L4 */
+       {0x464, "STM32L412xx/422xx"               , 0x20003100, 0x20008000, 
0x08000000, 0x08020000,  1, p_2k  , 0x1FFF7800, 0x1FFF780F, 0x1FFF0000, 
0x1FFF7000, 0},
        {0x435, "STM32L43xxx/44xxx"               , 0x20003100, 0x2000C000, 
0x08000000, 0x08040000,  1, p_2k  , 0x1FFF7800, 0x1FFF780F, 0x1FFF0000, 
0x1FFF7000, 0},
        {0x462, "STM32L45xxx/46xxx"               , 0x20003100, 0x20020000, 
0x08000000, 0x08080000,  1, p_2k  , 0x1FFF7800, 0x1FFF780F, 0x1FFF0000, 
0x1FFF7000, F_PEMPTY},
        {0x415, "STM32L47xxx/48xxx"               , 0x20003100, 0x20018000, 
0x08000000, 0x08100000,  1, p_2k  , 0x1FFF7800, 0x1FFFF80F, 0x1FFF0000, 
0x1FFF7000, 0},
        {0x461, "STM32L496xx/4A6xx"               , 0x20003100, 0x20040000, 
0x08000000, 0x08100000,  1, p_2k  , 0x1FFF7800, 0x1FFFF80F, 0x1FFF0000, 
0x1FFF7000, 0},
        {0x470, "STM32L4Rxx/4Sxx"                 , 0x20003200, 0x200A0000, 
0x08000000, 0x08100000,  1, p_2k  , 0x1FFF7800, 0x1FFFF80F, 0x1FFF0000, 
0x1FFF7000, 0},
+/*     {0x471, "STM32L4P5xx/Q5xx"                , 0x20004000, 0x20050000, 
0x08000000, x         ,  x, x     , x         , x         , 0x1FFF0000, 
0x1FFF7000, 0}, */
+       /* L5 */
+/*     {0x472, "STM32L552xx/562xx"               , 0x20004000, 0x20040000, 
0x08000000, x         ,  x, x     , x         , x         , 0x0BF90000, 
0x0BF98000, 0}, */
+       /* WB */
+/*     {0x495, "STM32WB10xx/15xx"                , 0x20005000, 0x20040000, 
0x08000000, x         ,  x, x     , x         , x         , 0x1FFF0000, 
0x1FFF7000, 0}, */
+/*     {0x494, "STM32WB30(5)xx/50(5)xx"          , 0x20004000, 0x2000C000, 
0x08000000, x         ,  x, x     , x         , x         , 0x1FFF0000, 
0x1FFF7000, 0}, */
+       /* WL */
+/*     {0x497, "STM32WLE5xx/WL55xx"              , 0x20002000, 0x20010000, 
0x08000000, x         ,  x, x     , x         , x         , 0x1FFF0000, 
0x1FFF4000, 0}, */
        /* These are not (yet) in AN2606: */
        {0x641, "Medium_Density PL"               , 0x20000200, 0x20005000, 
0x08000000, 0x08020000,  4, p_1k  , 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 
0x1FFFF800, 0},
        {0x9a8, "STM32W-128K"                     , 0x20000200, 0x20002000, 
0x08000000, 0x08020000,  4, p_1k  , 0x08040800, 0x0804080F, 0x08040000, 
0x08040800, 0},
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/i2c.c new/stm32flash-0.7/i2c.c
--- old/stm32flash-0.6/i2c.c    2018-03-22 00:44:58.000000000 +0100
+++ new/stm32flash-0.7/i2c.c    2021-12-20 22:13:05.000000000 +0100
@@ -204,7 +204,7 @@
 
 struct port_interface port_i2c = {
        .name   = "i2c",
-       .flags  = PORT_STRETCH_W,
+       .flags  = PORT_STRETCH_W | PORT_NPAG_CSUM,
        .open   = i2c_open,
        .close  = i2c_close,
        .flush  = i2c_flush,
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/main.c new/stm32flash-0.7/main.c
--- old/stm32flash-0.6/main.c   2021-02-12 20:41:50.000000000 +0100
+++ new/stm32flash-0.7/main.c   2022-03-27 14:16:36.000000000 +0200
@@ -4,6 +4,7 @@
   Copyright 2011 Steve Markgraf <st...@steve-m.de>
   Copyright 2012-2016 Tormod Volden <debian.tor...@gmail.com>
   Copyright 2013-2016 Antonio Borneo <borneo.anto...@gmail.com>
+  Copyright 2021 Renaud Fivet <renaud.fi...@gmail.com>
 
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
@@ -43,7 +44,7 @@
 #include <windows.h>
 #endif
 
-#define VERSION "0.6"
+#define VERSION "0.7"
 
 /* device globals */
 stm32_t                *stm            = NULL;
@@ -296,8 +297,16 @@
                fprintf(diag, "Using Parser : %s\n", parser->name);
 
                /* We may know from the file how much data there is */
-               if (!use_stdinout && !readwrite_len)
-                       readwrite_len = parser->size(p_st);
+               if (!use_stdinout) {
+                       if (!start_addr)
+                               start_addr = parser->base(p_st);
+                       if (start_addr)
+                               fprintf(diag, "Location     : %#08x\n", 
start_addr);
+
+                       if (!readwrite_len)
+                               readwrite_len = parser->size(p_st);
+                       fprintf(diag, "Size         : %u\n", readwrite_len);
+               }
        } else {
                parser = &PARSER_BINARY;
                p_st = parser->init();
@@ -550,6 +559,7 @@
                        uint32_t left   = end - addr;
                        len             = max_wlen > left ? left : max_wlen;
                        len             = len > size - offset ? size - offset : 
len;
+                       unsigned int reqlen = len ;
 
                        if (parser->read(p_st, buffer, &len) != PARSER_ERR_OK)
                                goto close;
@@ -614,6 +624,8 @@
                        );
                        fflush(diag);
 
+                       if( len < reqlen)       /* Last read already reached 
EOF */
+                               break ;
                }
 
                fprintf(diag,   "Done.\n");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/parsers/binary.c 
new/stm32flash-0.7/parsers/binary.c
--- old/stm32flash-0.6/parsers/binary.c 2018-03-22 00:44:58.000000000 +0100
+++ new/stm32flash-0.7/parsers/binary.c 2021-12-20 22:04:53.000000000 +0100
@@ -84,6 +84,10 @@
        return PARSER_ERR_OK;
 }
 
+unsigned int binary_base(void *storage) {
+       return 0;
+}
+
 unsigned int binary_size(void *storage) {
        binary_t *st = storage;
        return st->stat.st_size;
@@ -99,12 +103,11 @@
        ssize_t r;
        while(left > 0) {
                r = read(st->fd, d, left);
-               /* If there is no data to read at all, return OK, but with zero 
read */
-               if (r == 0 && left == *len) {
-                       *len = 0;
-                       return PARSER_ERR_OK;
-               }
-               if (r <= 0) return PARSER_ERR_SYSTEM;
+               if (r == 0)
+                       break ;
+               else if ( r < 0)
+                       return PARSER_ERR_SYSTEM;
+
                left -= r;
                d += r;
        }
@@ -137,6 +140,7 @@
        binary_init,
        binary_open,
        binary_close,
+       binary_base,
        binary_size,
        binary_read,
        binary_write
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/parsers/hex.c 
new/stm32flash-0.7/parsers/hex.c
--- old/stm32flash-0.6/parsers/hex.c    2018-03-22 00:44:58.000000000 +0100
+++ new/stm32flash-0.7/parsers/hex.c    2021-12-20 22:04:53.000000000 +0100
@@ -85,6 +85,11 @@
                        switch(type) {
                                /* data record */
                                case 0:
+                                       if (st->data_len == 0) {
+                                               st->base |= address;
+                                               last_address = address;
+                                       }
+
                                        c = address - last_address;
                                        st->data = realloc(st->data, 
st->data_len + c + reclen);
 
@@ -198,6 +203,11 @@
        return PARSER_ERR_OK;
 }
 
+unsigned int hex_base(void *storage) {
+       hex_t *st = storage;
+       return st->base;
+}
+
 unsigned int hex_size(void *storage) {
        hex_t *st = storage;
        return st->data_len;
@@ -224,6 +234,7 @@
        hex_init,
        hex_open,
        hex_close,
+       hex_base,
        hex_size,
        hex_read,
        hex_write
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/parsers/parser.h 
new/stm32flash-0.7/parsers/parser.h
--- old/stm32flash-0.6/parsers/parser.h 2014-01-05 23:25:26.000000000 +0100
+++ new/stm32flash-0.7/parsers/parser.h 2021-12-20 22:04:53.000000000 +0100
@@ -35,6 +35,7 @@
        void*        (*init )();                                                
        /* initialise the parser */
        parser_err_t (*open )(void *storage, const char *filename, const char 
write);   /* open the file for read|write */
        parser_err_t (*close)(void *storage);                                   
        /* close and free the parser */
+       unsigned int (*base )(void *storage);                                   
        /* get the base address */
        unsigned int (*size )(void *storage);                                   
        /* get the total data size */
        parser_err_t (*read )(void *storage, void *data, unsigned int *len);    
        /* read a block of data */
        parser_err_t (*write)(void *storage, void *data, unsigned int len);     
        /* write a block of data */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/port.c new/stm32flash-0.7/port.c
--- old/stm32flash-0.6/port.c   2019-07-30 22:57:56.000000000 +0200
+++ new/stm32flash-0.7/port.c   2021-12-20 21:56:49.000000000 +0100
@@ -45,6 +45,8 @@
                        continue;
                if (ret == PORT_ERR_OK)
                        break;
+               if (ret == PORT_ERR_BAUD)
+                       fprintf(stderr, "Unsupported baud rate\n");
                fprintf(stderr, "Error probing interface \"%s\"\n",
                        (*port)->name);
        }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/port.h new/stm32flash-0.7/port.h
--- old/stm32flash-0.6/port.h   2017-04-17 19:00:32.000000000 +0200
+++ new/stm32flash-0.7/port.h   2021-12-20 22:13:05.000000000 +0100
@@ -25,6 +25,7 @@
        PORT_ERR_OK = 0,
        PORT_ERR_NODEV,         /* No such device */
        PORT_ERR_TIMEDOUT,      /* Operation timed out */
+       PORT_ERR_BAUD,          /* Unsupported baud rate */
        PORT_ERR_UNKNOWN,
 } port_err_t;
 
@@ -34,6 +35,7 @@
 #define PORT_CMD_INIT  (1 << 2)        /* use INIT cmd to autodetect speed */
 #define PORT_RETRY     (1 << 3)        /* allowed read() retry after timeout */
 #define PORT_STRETCH_W (1 << 4)        /* warning for no-stretching commands */
+#define PORT_NPAG_CSUM (1 << 5)        /* checksum after number of pages to 
erase */
 
 /* all options and flags used to open and configure an interface */
 struct port_options {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/serial.h new/stm32flash-0.7/serial.h
--- old/stm32flash-0.6/serial.h 2016-03-22 22:23:23.000000000 +0100
+++ new/stm32flash-0.7/serial.h 2022-03-26 09:58:16.000000000 +0100
@@ -46,8 +46,10 @@
        SERIAL_BAUD_2400,
        SERIAL_BAUD_4800,
        SERIAL_BAUD_9600,
+       SERIAL_BAUD_14400,
        SERIAL_BAUD_19200,
        SERIAL_BAUD_38400,
+       SERIAL_BAUD_56000,
        SERIAL_BAUD_57600,
        SERIAL_BAUD_115200,
        SERIAL_BAUD_128000,
@@ -58,10 +60,16 @@
        SERIAL_BAUD_576000,
        SERIAL_BAUD_921600,
        SERIAL_BAUD_1000000,
+       SERIAL_BAUD_1152000,
        SERIAL_BAUD_1500000,
        SERIAL_BAUD_2000000,
+       SERIAL_BAUD_2500000,
+       SERIAL_BAUD_3000000,
+       SERIAL_BAUD_3500000,
+       SERIAL_BAUD_4000000,
 
-       SERIAL_BAUD_INVALID
+       SERIAL_BAUD_INVALID,
+       SERIAL_BAUD_KEEP
 } serial_baud_t;
 
 typedef enum {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/serial_common.c 
new/stm32flash-0.7/serial_common.c
--- old/stm32flash-0.6/serial_common.c  2014-01-05 23:25:26.000000000 +0100
+++ new/stm32flash-0.7/serial_common.c  2022-03-26 09:58:16.000000000 +0100
@@ -21,13 +21,16 @@
 
 serial_baud_t serial_get_baud(const unsigned int baud) {
        switch(baud) {
+               case      0: return SERIAL_BAUD_KEEP  ;
                case   1200: return SERIAL_BAUD_1200  ;
                case   1800: return SERIAL_BAUD_1800  ;
                case   2400: return SERIAL_BAUD_2400  ;
                case   4800: return SERIAL_BAUD_4800  ;
                case   9600: return SERIAL_BAUD_9600  ;
+               case  14400: return SERIAL_BAUD_14400 ;
                case  19200: return SERIAL_BAUD_19200 ;
                case  38400: return SERIAL_BAUD_38400 ;
+               case  56000: return SERIAL_BAUD_56000 ;
                case  57600: return SERIAL_BAUD_57600 ;
                case 115200: return SERIAL_BAUD_115200;
                case 128000: return SERIAL_BAUD_128000;
@@ -38,8 +41,13 @@
                case 576000: return SERIAL_BAUD_576000;
                case 921600: return SERIAL_BAUD_921600;
                case 1000000: return SERIAL_BAUD_1000000;
+               case 1152000: return SERIAL_BAUD_1152000;
                case 1500000: return SERIAL_BAUD_1500000;
                case 2000000: return SERIAL_BAUD_2000000;
+               case 2500000: return SERIAL_BAUD_2500000;
+               case 3000000: return SERIAL_BAUD_3000000;
+               case 3500000: return SERIAL_BAUD_3500000;
+               case 4000000: return SERIAL_BAUD_4000000;
 
                default:
                        return SERIAL_BAUD_INVALID;
@@ -53,8 +61,10 @@
                case SERIAL_BAUD_2400  : return 2400  ;
                case SERIAL_BAUD_4800  : return 4800  ;
                case SERIAL_BAUD_9600  : return 9600  ;
+               case SERIAL_BAUD_14400 : return 14400 ;
                case SERIAL_BAUD_19200 : return 19200 ;
                case SERIAL_BAUD_38400 : return 38400 ;
+               case SERIAL_BAUD_56000 : return 56000 ;
                case SERIAL_BAUD_57600 : return 57600 ;
                case SERIAL_BAUD_115200: return 115200;
                case SERIAL_BAUD_128000: return 128000;
@@ -65,8 +75,13 @@
                case SERIAL_BAUD_576000: return 576000;
                case SERIAL_BAUD_921600: return 921600;
                case SERIAL_BAUD_1000000: return 1000000;
+               case SERIAL_BAUD_1152000: return 1152000;
                case SERIAL_BAUD_1500000: return 1500000;
                case SERIAL_BAUD_2000000: return 2000000;
+               case SERIAL_BAUD_2500000: return 2500000;
+               case SERIAL_BAUD_3000000: return 3000000;
+               case SERIAL_BAUD_3500000: return 3500000;
+               case SERIAL_BAUD_4000000: return 4000000;
 
                case SERIAL_BAUD_INVALID:
                default:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/serial_posix.c 
new/stm32flash-0.7/serial_posix.c
--- old/stm32flash-0.6/serial_posix.c   2021-01-31 12:49:51.000000000 +0100
+++ new/stm32flash-0.7/serial_posix.c   2022-03-27 14:16:25.000000000 +0200
@@ -29,6 +29,11 @@
 #include <stdio.h>
 #include <sys/file.h>
 
+/* To detect BSD for baud rate encoding */
+#if defined(__unix__) || defined(__UNIX__) || (defined(__APPLE__) && 
defined(__MACH__))
+#  include <sys/param.h>
+#endif
+
 #include "serial.h"
 #include "port.h"
 
@@ -105,6 +110,20 @@
                case SERIAL_BAUD_57600:   port_baud = B57600; break;
                case SERIAL_BAUD_115200:  port_baud = B115200; break;
                case SERIAL_BAUD_230400:  port_baud = B230400; break;
+#ifdef BSD
+               case SERIAL_BAUD_460800:  port_baud = 460800; break;
+               case SERIAL_BAUD_500000:  port_baud = 500000; break;
+               case SERIAL_BAUD_576000:  port_baud = 576000; break;
+               case SERIAL_BAUD_921600:  port_baud = 921600; break;
+               case SERIAL_BAUD_1000000: port_baud = 1000000; break;
+               case SERIAL_BAUD_1152000: port_baud = 1152000; break;
+               case SERIAL_BAUD_1500000: port_baud = 1500000; break;
+               case SERIAL_BAUD_2000000: port_baud = 2000000; break;
+               case SERIAL_BAUD_2500000: port_baud = 2500000; break;
+               case SERIAL_BAUD_3000000: port_baud = 3000000; break;
+               case SERIAL_BAUD_3500000: port_baud = 3500000; break;
+               case SERIAL_BAUD_4000000: port_baud = 4000000; break;
+#else
 #ifdef B460800
                case SERIAL_BAUD_460800:  port_baud = B460800; break;
 #endif /* B460800 */
@@ -120,16 +139,32 @@
 #ifdef B1000000
                case SERIAL_BAUD_1000000: port_baud = B1000000; break;
 #endif /* B1000000 */
+#ifdef B1152000
+               case SERIAL_BAUD_1152000: port_baud = B1152000; break;
+#endif /* B1152000 */
 #ifdef B1500000
                case SERIAL_BAUD_1500000: port_baud = B1500000; break;
 #endif /* B1500000 */
 #ifdef B2000000
                case SERIAL_BAUD_2000000: port_baud = B2000000; break;
 #endif /* B2000000 */
+#ifdef B2500000
+               case SERIAL_BAUD_2500000: port_baud = B2500000; break;
+#endif /* B2500000 */
+#ifdef B3000000
+               case SERIAL_BAUD_3000000: port_baud = B3000000; break;
+#endif /* B3000000 */
+#ifdef B3500000
+               case SERIAL_BAUD_3500000: port_baud = B3500000; break;
+#endif /* B3500000 */
+#ifdef B4000000
+               case SERIAL_BAUD_4000000: port_baud = B4000000; break;
+#endif /* B4000000 */
+#endif /* BSD */
 
                case SERIAL_BAUD_INVALID:
                default:
-                       return PORT_ERR_UNKNOWN;
+                       return PORT_ERR_BAUD;
        }
 
        switch (bits) {
@@ -181,8 +216,12 @@
        h->newtio.c_oflag &= ~(OPOST | ONLCR);
 
        /* setup the new settings */
-       cfsetispeed(&h->newtio, port_baud);
-       cfsetospeed(&h->newtio, port_baud);
+       if (cfsetispeed(&h->newtio, port_baud) ||
+           cfsetospeed(&h->newtio, port_baud)) {
+               fprintf(stderr, "Failed to specify baud rate\n");
+               return PORT_ERR_BAUD;
+       }
+
        h->newtio.c_cflag |=
                port_parity     |
                port_bits       |
@@ -197,16 +236,27 @@
 
        /* set the settings */
        serial_flush(h);
-       if (tcsetattr(h->fd, TCSANOW, &h->newtio) != 0)
+       if (tcsetattr(h->fd, TCSANOW, &h->newtio) != 0) {
+               fprintf(stderr, "Error: Failed to apply settings\n");
                return PORT_ERR_UNKNOWN;
+       }
 
        /* confirm they were set */
        tcgetattr(h->fd, &settings);
+
+       if (cfgetispeed(&settings) != port_baud ||
+           cfgetospeed(&settings) != port_baud) {
+               fprintf(stderr, "Failed to set baud rate\n");
+               return PORT_ERR_BAUD;
+       }
+
        if (settings.c_iflag != h->newtio.c_iflag ||
            settings.c_oflag != h->newtio.c_oflag ||
            settings.c_cflag != h->newtio.c_cflag ||
-           settings.c_lflag != h->newtio.c_lflag)
+           settings.c_lflag != h->newtio.c_lflag) {
+               fprintf(stderr, "Failed to set terminal flags\n");
                return PORT_ERR_UNKNOWN;
+       }
 
        snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d",
                 serial_get_baud_int(baud),
@@ -220,6 +270,16 @@
                                    struct port_options *ops)
 {
        serial_t *h;
+       port_err_t ret;
+
+       /* user takes care of all port setup */
+       if (ops->baudRate == SERIAL_BAUD_KEEP) {
+               h = serial_open(ops->device);
+               if (h == NULL)
+                       return PORT_ERR_UNKNOWN;
+               port->private = h;
+               return PORT_ERR_OK;
+       }
 
        /* 1. check options */
        if (ops->baudRate == SERIAL_BAUD_INVALID)
@@ -241,13 +301,13 @@
                fprintf(stderr, "Warning: Not a tty: %s\n", ops->device);
 
        /* 4. set options */
-       if (serial_setup(h, ops->baudRate,
-                        serial_get_bits(ops->serial_mode),
-                        serial_get_parity(ops->serial_mode),
-                        serial_get_stopbit(ops->serial_mode)
-                       ) != PORT_ERR_OK) {
+       ret = serial_setup(h, ops->baudRate,
+                          serial_get_bits(ops->serial_mode),
+                          serial_get_parity(ops->serial_mode),
+                          serial_get_stopbit(ops->serial_mode));
+       if (ret != PORT_ERR_OK) {
                serial_close(h);
-               return PORT_ERR_UNKNOWN;
+               return ret;
        }
 
        port->private = h;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/serial_w32.c 
new/stm32flash-0.7/serial_w32.c
--- old/stm32flash-0.6/serial_w32.c     2018-03-22 00:44:58.000000000 +0100
+++ new/stm32flash-0.7/serial_w32.c     2022-03-26 09:58:16.000000000 +0100
@@ -84,15 +84,14 @@
        GetCommState(h->fd, &h->oldtio); /* Retrieve port parameters */
        GetCommState(h->fd, &h->newtio); /* Retrieve port parameters */
 
-       /* PurgeComm(h->fd, PURGE_RXABORT | PURGE_TXCLEAR | PURGE_TXABORT | 
PURGE_TXCLEAR); */
+       /* PurgeComm(h->fd, PURGE_RXABORT | PURGE_RXCLEAR | PURGE_TXABORT | 
PURGE_TXCLEAR); */
 
        return h;
 }
 
 static void serial_flush(const serial_t __unused *h)
 {
-       /* We shouldn't need to flush in non-overlapping (blocking) mode */
-       /* tcflush(h->fd, TCIFLUSH); */
+       PurgeComm(h->fd, PURGE_RXCLEAR);
 }
 
 static void serial_close(serial_t *h)
@@ -111,12 +110,13 @@
 {
        switch (baud) {
                case SERIAL_BAUD_1200:    h->newtio.BaudRate = CBR_1200; break;
-               /* case SERIAL_BAUD_1800: h->newtio.BaudRate = CBR_1800; break; 
*/
                case SERIAL_BAUD_2400:    h->newtio.BaudRate = CBR_2400; break;
                case SERIAL_BAUD_4800:    h->newtio.BaudRate = CBR_4800; break;
                case SERIAL_BAUD_9600:    h->newtio.BaudRate = CBR_9600; break;
+               case SERIAL_BAUD_14400:   h->newtio.BaudRate = CBR_14400; break;
                case SERIAL_BAUD_19200:   h->newtio.BaudRate = CBR_19200; break;
                case SERIAL_BAUD_38400:   h->newtio.BaudRate = CBR_38400; break;
+               case SERIAL_BAUD_56000:   h->newtio.BaudRate = CBR_56000; break;
                case SERIAL_BAUD_57600:   h->newtio.BaudRate = CBR_57600; break;
                case SERIAL_BAUD_115200:  h->newtio.BaudRate = CBR_115200; 
break;
                case SERIAL_BAUD_128000:  h->newtio.BaudRate = CBR_128000; 
break;
@@ -128,12 +128,17 @@
                case SERIAL_BAUD_576000:  h->newtio.BaudRate = 576000; break;
                case SERIAL_BAUD_921600:  h->newtio.BaudRate = 921600; break;
                case SERIAL_BAUD_1000000: h->newtio.BaudRate = 1000000; break;
+               case SERIAL_BAUD_1152000: h->newtio.BaudRate = 1152000; break;
                case SERIAL_BAUD_1500000: h->newtio.BaudRate = 1500000; break;
                case SERIAL_BAUD_2000000: h->newtio.BaudRate = 2000000; break;
-               case SERIAL_BAUD_INVALID:
+               case SERIAL_BAUD_2500000: h->newtio.BaudRate = 2500000; break;
+               case SERIAL_BAUD_3000000: h->newtio.BaudRate = 3000000; break;
+               case SERIAL_BAUD_3500000: h->newtio.BaudRate = 3500000; break;
+               case SERIAL_BAUD_4000000: h->newtio.BaudRate = 4000000; break;
 
+               case SERIAL_BAUD_INVALID:
                default:
-                       return PORT_ERR_UNKNOWN;
+                       return PORT_ERR_BAUD;
        }
 
        switch (bits) {
@@ -194,6 +199,16 @@
                                  struct port_options *ops)
 {
        serial_t *h;
+       port_err_t ret;
+
+       /* user takes care of all port setup */
+       if (ops->baudRate == SERIAL_BAUD_KEEP) {
+               h = serial_open(ops->device);
+               if (h == NULL)
+                       return PORT_ERR_UNKNOWN;
+               port->private = h;
+               return PORT_ERR_OK;
+       }
 
        /* 1. check device name match */
        if (!(!strncmp(ops->device, "COM", 3) && isdigit(ops->device[3]))
@@ -203,7 +218,7 @@
 
        /* 2. check options */
        if (ops->baudRate == SERIAL_BAUD_INVALID)
-               return PORT_ERR_UNKNOWN;
+               return PORT_ERR_BAUD;
        if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID)
                return PORT_ERR_UNKNOWN;
        if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID)
@@ -217,13 +232,13 @@
                return PORT_ERR_UNKNOWN;
 
        /* 4. set options */
-       if (serial_setup(h, ops->baudRate,
-           serial_get_bits(ops->serial_mode),
-           serial_get_parity(ops->serial_mode),
-           serial_get_stopbit(ops->serial_mode)
-          ) != PORT_ERR_OK) {
+       ret = serial_setup(h, ops->baudRate,
+                          serial_get_bits(ops->serial_mode),
+                          serial_get_parity(ops->serial_mode),
+                          serial_get_stopbit(ops->serial_mode));
+       if (ret != PORT_ERR_OK) {
                serial_close(h);
-               return PORT_ERR_UNKNOWN;
+               return ret;
        }
 
        port->private = h;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/stm32.c new/stm32flash-0.7/stm32.c
--- old/stm32flash-0.6/stm32.c  2021-02-01 20:31:53.000000000 +0100
+++ new/stm32flash-0.7/stm32.c  2022-03-26 09:32:06.000000000 +0100
@@ -176,11 +176,14 @@
 
 static void stm32_warn_stretching(const char *f)
 {
-       fprintf(stderr, "Attention !!!\n");
-       fprintf(stderr, "\tThis %s error could be caused by your I2C\n", f);
-       fprintf(stderr, "\tcontroller not accepting \"clock stretching\"\n");
-       fprintf(stderr, "\tas required by bootloader.\n");
-       fprintf(stderr, "\tCheck \"I2C.txt\" in stm32flash source code.\n");
+       fprintf(stderr, "Attention !\n");
+       fprintf(stderr, "\tThe %s operation was possibly executed, however a 
driver\n", f);
+       fprintf(stderr, "\ttimeout might have occured while waiting for 
acknowledgment\n");
+       fprintf(stderr, "\tof finished operation.\n");
+       fprintf(stderr, "\tThis can be caused by your I2C controller not 
accepting\n");
+       fprintf(stderr, "\t\"clock stretching\" as required by the 
bootloader,\n");
+       fprintf(stderr, "\tor timing out too early.\n");
+       fprintf(stderr, "\tPlease see \"I2C.txt\" in the stm32flash source 
code.\n");
 }
 
 static stm32_err_t stm32_get_ack_timeout(const stm32_t *stm, time_t timeout)
@@ -391,13 +394,17 @@
         */
        p_err = port->write(port, &cmd, 1);
        if (p_err != PORT_ERR_OK) {
-               fprintf(stderr, "Failed to send init to device\n");
+               fprintf(stderr, "Failed to resend init to device\n");
                return STM32_ERR_UNKNOWN;
        }
        p_err = port->read(port, &byte, 1);
        if (p_err == PORT_ERR_OK && byte == STM32_NACK)
                return STM32_ERR_OK;
-       fprintf(stderr, "Failed to init device.\n");
+       if (p_err == PORT_ERR_TIMEDOUT) {
+               fprintf(stderr, "Failed to init device, timeout.\n");
+               return STM32_ERR_UNKNOWN;
+       }
+       fprintf(stderr, "Failed to init device after retry.\n");
        return STM32_ERR_UNKNOWN;
 }
 
@@ -431,6 +438,14 @@
        len = (port->flags & PORT_GVR_ETX) ? 3 : 1;
        if (port->read(port, buf, len) != PORT_ERR_OK)
                return NULL;
+
+       /* STM32L412xx/422xx bootloader V13.1 sends an extra ACK after init */
+       if ((port->flags & PORT_GVR_ETX) && buf[0] == STM32_ACK && buf[1] == 
0x31) {
+               buf[0] = buf[1];
+               buf[1] = buf[2];
+               port->read(port, &buf[2], 1);
+       }
+
        stm->version = buf[0];
        stm->option1 = (port->flags & PORT_GVR_ETX) ? buf[1] : 0;
        stm->option2 = (port->flags & PORT_GVR_ETX) ? buf[2] : 0;
@@ -797,7 +812,7 @@
                return STM32_ERR_OK;
        }
 
-       /* extended erase */
+       /* extended erase (0x44 or 0x45) */
        buf[0] = 0xFF;  /* 0xFFFF the magic number for mass erase */
        buf[1] = 0xFF;
        buf[2] = 0x00;  /* checksum */
@@ -831,7 +846,7 @@
        /* 0x44 is Extended Erase, a 2 byte based protocol and needs to be 
handled differently. */
        /* 0x45 is clock no-stretching version of Extended Erase for I2C port. 
*/
        if (stm32_send_command(stm, stm->cmd->er) != STM32_ERR_OK) {
-               fprintf(stderr, "Can't initiate chip mass erase!\n");
+               fprintf(stderr, "Can't initiate chip page erase!\n");
                return STM32_ERR_UNKNOWN;
        }
 
@@ -843,6 +858,25 @@
 
                buf[i++] = pages - 1;
                cs ^= (pages-1);
+               /* For I2C send a checksum after the number of pages (AN4221) */
+               if (port->flags & PORT_NPAG_CSUM) {
+                       buf[i++] = cs;
+                       p_err = port->write(port, buf, i);
+                       if (p_err != PORT_ERR_OK) {
+                               fprintf(stderr, "Erase failed sending number of 
pages.");
+                               free(buf);
+                               return STM32_ERR_UNKNOWN;
+                       }
+                       s_err = stm32_get_ack(stm);
+                       if (s_err != STM32_ERR_OK) {
+                               fprintf(stderr, "Erase failed, no ack after 
number of pages.");
+                               free(buf);
+                               return STM32_ERR_UNKNOWN;
+                       }
+                       cs = 0;
+                       i = 0;
+               }
+
                for (pg_num = spage; pg_num < (pages + spage); pg_num++) {
                        buf[i++] = pg_num;
                        cs ^= pg_num;
@@ -851,11 +885,12 @@
                p_err = port->write(port, buf, i);
                free(buf);
                if (p_err != PORT_ERR_OK) {
-                       fprintf(stderr, "Erase failed.\n");
+                       fprintf(stderr, "Erase failed sending list of 
pages.\n");
                        return STM32_ERR_UNKNOWN;
                }
                s_err = stm32_get_ack_timeout(stm, pages * 
STM32_PAGEERASE_TIMEOUT);
                if (s_err != STM32_ERR_OK) {
+                       fprintf(stderr, "Erase failed.\n");
                        if (port->flags & PORT_STRETCH_W)
                                stm32_warn_stretching("erase");
                        return STM32_ERR_UNKNOWN;
@@ -863,7 +898,7 @@
                return STM32_ERR_OK;
        }
 
-       /* extended erase */
+       /* extended erase (0x44 or 0x45) */
        buf = malloc(2 + 2 * pages + 1);
        if (!buf)
                return STM32_ERR_UNKNOWN;
@@ -876,6 +911,24 @@
        buf[i++] = pg_byte;
        cs ^= pg_byte;
 
+       if (port->flags & PORT_NPAG_CSUM) {
+               buf[i++] = cs;
+               p_err = port->write(port, buf, i);
+               if (p_err != PORT_ERR_OK) {
+                       fprintf(stderr, "Extended erase failed sending number 
of pages.");
+                       free(buf);
+                       return STM32_ERR_UNKNOWN;
+               }
+               s_err = stm32_get_ack(stm);
+               if (s_err != STM32_ERR_OK) {
+                       fprintf(stderr, "Extended erase failed, no ack after 
number of pages.");
+                       free(buf);
+                       return STM32_ERR_UNKNOWN;
+               }
+               cs = 0;
+               i = 0;
+       }
+
        for (pg_num = spage; pg_num < spage + pages; pg_num++) {
                pg_byte = pg_num >> 8;
                cs ^= pg_byte;
@@ -888,13 +941,13 @@
        p_err = port->write(port, buf, i);
        free(buf);
        if (p_err != PORT_ERR_OK) {
-               fprintf(stderr, "Page-by-page erase error.\n");
+               fprintf(stderr, "Extended erase failed sending list of 
pages.\n");
                return STM32_ERR_UNKNOWN;
        }
 
        s_err = stm32_get_ack_timeout(stm, pages * STM32_PAGEERASE_TIMEOUT);
        if (s_err != STM32_ERR_OK) {
-               fprintf(stderr, "Page-by-page erase failed. Check the maximum 
pages your device supports.\n");
+               fprintf(stderr, "Extended erase failed. Check the maximum pages 
your device supports.\n");
                if ((port->flags & PORT_STRETCH_W)
                    && stm->cmd->er != STM32_CMD_EE_NS)
                        stm32_warn_stretching("erase");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stm32flash-0.6/stm32flash.1 
new/stm32flash-0.7/stm32flash.1
--- old/stm32flash-0.6/stm32flash.1     2021-02-12 20:41:50.000000000 +0100
+++ new/stm32flash-0.7/stm32flash.1     2022-03-27 14:16:36.000000000 +0200
@@ -1,4 +1,4 @@
-.TH "STM32FLASH" "1" "February 2021" stm32flash "User command"
+.TH "STM32FLASH" "1" "March 2022" stm32flash "User command"
 .SH NAME
 stm32flash \- flashing utility for STM32 through UART or I2C
 .SH SYNOPSIS

Reply via email to