flash: stm32f1x: Pad odd byte writes early to avoid 16-bit writes
commitc89eb70a20230edfc79153c17c0c4c3f9dc64819
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Fri, 20 Jul 2012 12:44:22 +0000 (20 14:44 +0200)
committerFreddie Chopin <freddie.chopin@gmail.com>
Wed, 1 Aug 2012 21:12:07 +0000 (1 21:12 +0000)
tree4314c94f26520c5a1acb92848a925b33125ed0e3
parentb8862229d01c803142388d8456473b908fee22ea
flash: stm32f1x: Pad odd byte writes early to avoid 16-bit writes

For odd byte counts, stm32x_write() pads the last byte and writes it using
a discrete 16-bit access. The stlink debugger can't issue 16-bit writes so
it fails for odd byte writes.

This patch changes stm32x_write() to pad odd byte writes into a new buffer
and use the normal code path with a single block write. The fallback path,
when working area cannot be allocated, has to use 16-bit writes though
which means that sufficient working area is required for stlink and odd
byte writes.

Change-Id: I4c5dc456300b6e1056f76b0095be8aceee3e954f
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/756
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
Reviewed-by: Freddie Chopin <freddie.chopin@gmail.com>
src/flash/nor/stm32f1x.c