diff options
author | Randall Spangler <rspangler@chromium.org> | 2013-07-02 16:35:39 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-08 11:30:50 -0700 |
commit | b013fd4e9cfb33c2b23e067d597a09830677e526 (patch) | |
tree | 41c910c3ed689739efa5a2f60661678db0f518ef /chip | |
parent | 0e835170b0906ab7225262d7dc94c5e014de6bd4 (diff) | |
download | chrome-ec-b013fd4e9cfb33c2b23e067d597a09830677e526.tar.gz |
pit: Align spi protocol buffers on 32-bit boundary
Flash writes must be done from 32-bit-aligned source buffers. Force
the protcol buffer to be aligned like we do for the lpc interface.
BUG=chrome-os-partner:20571
BRANCH=none
TEST=ectool flashread 0x1f800 0x800 /tmp/foo
ectool flasherase 0x1f800 0x800
ectool flashwrite 0x1f800 /tmp/foo
Change-Id: Icaa3259bcbc36be49345da5e19ad8a0790b73923
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/60892
Diffstat (limited to 'chip')
-rw-r--r-- | chip/stm32/spi.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/chip/stm32/spi.c b/chip/stm32/spi.c index cbe90d4816..bb2bfaafe6 100644 --- a/chip/stm32/spi.c +++ b/chip/stm32/spi.c @@ -80,10 +80,11 @@ static const uint8_t out_preamble[4] = { /* * Our input and output buffers. These must be large enough for our largest - * message, including protocol overhead. + * message, including protocol overhead, and must be 32-bit aligned. */ -static uint8_t out_msg[SPI_MAX_RESPONSE_SIZE + sizeof(out_preamble)]; -static uint8_t in_msg[SPI_MAX_REQUEST_SIZE]; +static uint8_t out_msg[SPI_MAX_RESPONSE_SIZE + sizeof(out_preamble)] + __attribute__((aligned(4))); +static uint8_t in_msg[SPI_MAX_REQUEST_SIZE] __attribute__((aligned(4))); static uint8_t active; static uint8_t enabled; static struct host_cmd_handler_args args; @@ -355,7 +356,6 @@ void spi_event(enum gpio_signal signal) args.version = in_msg[0] - EC_CMD_VERSION0; args.command = in_msg[1]; args.params_size = in_msg[2]; - args.params = in_msg + 3; /* Wait for parameters */ if (wait_for_bytes(rxdma, 3 + args.params_size, @@ -363,10 +363,14 @@ void spi_event(enum gpio_signal signal) goto spi_event_error; /* - * TODO: params are not 32-bit aligned in protocol version 2. - * As a workaround, memmove them to the beginning of the input - * buffer so they are aligned. + * Params are not 32-bit aligned in protocol version 2. As a + * workaround, move them to the beginning of the input buffer + * so they are aligned. */ + if (args.params_size) + memmove(in_msg, in_msg + 3, args.params_size); + + args.params = in_msg; /* Process the command and send the reply */ args.send_response = spi_send_response; |