stm32l4: Handle failing flash_size read like on other devices.
[fw/openocd] / src / flash / nor / core.c
index 14aa9755158a59efcfa6ffa793ac1db3b01d9b6b..cfc4f19c4be94f32686673e3e1d03575c05fab22 100644 (file)
@@ -16,9 +16,7 @@
  *   GNU General Public License for more details.                          *
  *                                                                         *
  *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -232,6 +230,9 @@ int get_flash_bank_by_addr(struct target *target,
 
        /* cycle through bank list */
        for (c = flash_banks; c; c = c->next) {
+               if (c->target != target)
+                       continue;
+
                int retval;
                retval = c->driver->auto_probe(c);
 
@@ -240,7 +241,7 @@ int get_flash_bank_by_addr(struct target *target,
                        return retval;
                }
                /* check whether address belongs to this flash bank */
-               if ((addr >= c->base) && (addr <= c->base + (c->size - 1)) && target == c->target) {
+               if ((addr >= c->base) && (addr <= c->base + (c->size - 1))) {
                        *result_bank = c;
                        return ERROR_OK;
                }
@@ -595,7 +596,7 @@ int flash_write_unlock(struct target *target, struct image *image,
                if (retval != ERROR_OK)
                        goto done;
                if (c == NULL) {
-                       LOG_WARNING("no flash bank found for address %x", run_address);
+                       LOG_WARNING("no flash bank found for address %" PRIx32, run_address);
                        section++;      /* and skip it */
                        section_offset = 0;
                        continue;
@@ -710,7 +711,7 @@ int flash_write_unlock(struct target *target, struct image *image,
 
                        /* see if we need to pad the section */
                        while (padding[section]--)
-                               (buffer + buffer_size)[size_read++] = 0xff;
+                               (buffer + buffer_size)[size_read++] = c->default_padded_value;
 
                        buffer_size += size_read;
                        section_offset += size_read;