Skip to content

Commit 1298a1a

Browse files
committed
[ot] hw/opentitan: ot_spi_device: fix address parsing in read SFDP
The bytes are received over the wire and stored in the buffer most-significant byte first (big-endian), so the dummy byte is the last byte not the first. Signed-off-by: Alice Ziuziakowska <[email protected]>
1 parent 55d5bb4 commit 1298a1a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

hw/opentitan/ot_spi_device.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,8 +1117,7 @@ static void ot_spi_device_flash_exec_read_sfdp(OtSPIDeviceState *s)
11171117
{
11181118
SpiDeviceFlash *f = &s->flash;
11191119

1120-
unsigned address = ldl_be_p(f->src);
1121-
address &= (1u << 24u) - 1u; /* discard dummy byte */
1120+
unsigned address = ldl_be_p(f->src) >> 8u; /* discard dummy byte */
11221121
f->pos = address % SPI_SRAM_SFDP_SIZE;
11231122
f->len = SPI_SRAM_SFDP_SIZE;
11241123
f->src = &((uint8_t *)s->sram)[SPI_SRAM_SFDP_OFFSET];

0 commit comments

Comments
 (0)