diff options
author | Tim Newsome <tim@sifive.com> | 2019-11-15 12:50:08 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-15 12:50:08 -0800 |
commit | e944de422eb9813267f9e8977124f0bbe1da1b31 (patch) | |
tree | 81e8f3491fb597e56f6fda4d4eaeb6ff948e051d | |
parent | b7bd3f8d47b1c73d1e250a2476ee11b422494a35 (diff) | |
download | riscv-openocd-e944de422eb9813267f9e8977124f0bbe1da1b31.zip riscv-openocd-e944de422eb9813267f9e8977124f0bbe1da1b31.tar.gz riscv-openocd-e944de422eb9813267f9e8977124f0bbe1da1b31.tar.bz2 |
fespi: Properly support large flash devices (#421)
* 64-bit progbuf memory reads work.
Change-Id: Ia3dbc0ee39a31ed0e5c38bbb3d9e089b2533f399
* 64-bit writes work.
Change-Id: Iae78711d715b6682817bb7cce366b0094bda8b23
* Let targets indicate number of supported data bits.
This is used by the default memory read/write functions when creating an
aligned block.
I'm adding this mainly to ensure I get coverage of the 64-bit progbuf
memory read/write code.
Change-Id: Ie5909fe537c9ec3360a8d2837f84be00a63de77b
* Make mingw32 happy.
Change-Id: Iade8c1fdfc72ccafc82f2f34923577032b668916
* WIP >16MB flashing.
Change-Id: Ibef9244f8573d2fbf19b80e5db7c2d3a10da59b5
* >16MB flashing works on Hi5 Unleashed
But now flashing HiFive1 is broken.
Change-Id: If939c9e21cf793ae727f3335205abd261a998c0c
* Fix off-by-one error on bank size.
Change-Id: I0e6e49db8c1bfddb2c5f67d40f62111246db8dcb
* Fix formatting.
Change-Id: I4211f9328c7d11ea659be9588a81aa2cd59017f9
-rw-r--r-- | contrib/loaders/flash/fespi/riscv32_fespi.inc | 57 | ||||
-rw-r--r-- | contrib/loaders/flash/fespi/riscv64_fespi.inc | 76 | ||||
-rw-r--r-- | contrib/loaders/flash/fespi/riscv_fespi.c | 23 | ||||
-rw-r--r-- | src/flash/nor/fespi.c | 54 | ||||
-rw-r--r-- | src/flash/nor/spi.c | 8 |
5 files changed, 126 insertions, 92 deletions
diff --git a/contrib/loaders/flash/fespi/riscv32_fespi.inc b/contrib/loaders/flash/fespi/riscv32_fespi.inc index 338ae35..44e0448 100644 --- a/contrib/loaders/flash/fespi/riscv32_fespi.inc +++ b/contrib/loaders/flash/fespi/riscv32_fespi.inc @@ -1,5 +1,5 @@ /* Autogenerated with ../../../../src/helper/bin2char.sh */ -0x17,0x01,0x00,0x00,0x13,0x01,0x81,0x2e,0xef,0x00,0x80,0x10,0x73,0x00,0x10,0x00, +0x17,0x01,0x00,0x00,0x13,0x01,0xc1,0x31,0xef,0x00,0x80,0x10,0x73,0x00,0x10,0x00, 0x93,0x07,0x90,0x3e,0x93,0x87,0xf7,0xff,0x63,0x96,0x07,0x00,0x13,0x05,0x10,0x00, 0x67,0x80,0x00,0x00,0x03,0x27,0x45,0x07,0x13,0x77,0x17,0x00,0xe3,0x04,0x07,0xfe, 0x13,0x05,0x00,0x00,0x67,0x80,0x00,0x00,0x93,0x07,0x90,0x3e,0x93,0x87,0xf7,0xff, @@ -16,33 +16,36 @@ 0x13,0x07,0x90,0x3e,0x13,0x07,0xf7,0xff,0xe3,0x0a,0x07,0xfc,0x83,0x27,0xc4,0x04, 0xe3,0xca,0x07,0xfe,0x93,0xf7,0x17,0x00,0xe3,0x98,0x07,0xfc,0x23,0x2c,0x04,0x00, 0x83,0x27,0x04,0x04,0x93,0xe7,0x87,0x00,0x23,0x20,0xf4,0x04,0x6f,0xf0,0xdf,0xf8, -0x13,0x01,0xc1,0xfd,0x23,0x2e,0x81,0x00,0x23,0x2c,0x91,0x00,0x23,0x20,0x11,0x02, +0x13,0x01,0x41,0xfd,0x23,0x22,0x81,0x02,0x23,0x20,0x91,0x02,0x23,0x24,0x11,0x02, 0x13,0x04,0x05,0x00,0x23,0x26,0xb1,0x00,0x23,0x28,0xc1,0x00,0x23,0x20,0xd1,0x00, -0x23,0x22,0xe1,0x00,0xef,0xf0,0xdf,0xed,0x93,0x04,0x05,0x00,0x63,0x12,0x05,0x04, -0x83,0x27,0x04,0x06,0x13,0x05,0x04,0x00,0x93,0xf7,0xe7,0xff,0x23,0x20,0xf4,0x06, -0xef,0xf0,0x1f,0xf1,0x93,0x04,0x05,0x00,0x63,0x1e,0x05,0x00,0x83,0x27,0xc1,0x00, -0x03,0x27,0x01,0x00,0x93,0x87,0xf7,0xff,0xb3,0xf7,0xe7,0x00,0x03,0x27,0x41,0x00, -0x63,0x14,0x07,0x02,0x83,0x27,0x04,0x06,0x93,0xe7,0x17,0x00,0x23,0x20,0xf4,0x06, -0x83,0x20,0x01,0x02,0x03,0x24,0xc1,0x01,0x13,0x85,0x04,0x00,0x83,0x24,0x81,0x01, -0x13,0x01,0x41,0x02,0x67,0x80,0x00,0x00,0x83,0x26,0x41,0x00,0x03,0x27,0x41,0x00, -0x23,0x24,0xd1,0x00,0x83,0x26,0xc1,0x00,0x33,0x07,0xf7,0x00,0x63,0xf6,0xe6,0x00, -0xb3,0x87,0xf6,0x40,0x23,0x24,0xf1,0x00,0x93,0x05,0x60,0x00,0x13,0x05,0x04,0x00, -0xef,0xf0,0x9f,0xe7,0x63,0x1e,0x05,0x0c,0x13,0x05,0x04,0x00,0xef,0xf0,0x5f,0xe4, -0x63,0x18,0x05,0x0c,0x93,0x07,0x20,0x00,0x23,0x2c,0xf4,0x00,0x93,0x05,0x20,0x00, -0x13,0x05,0x04,0x00,0xef,0xf0,0x5f,0xe5,0x63,0x1c,0x05,0x0a,0x83,0x27,0x01,0x00, -0x13,0x05,0x04,0x00,0x93,0xd5,0x07,0x01,0x93,0xf5,0xf5,0x0f,0xef,0xf0,0xdf,0xe3, -0x63,0x10,0x05,0x0a,0x83,0x27,0x01,0x00,0x13,0x05,0x04,0x00,0x93,0xd5,0x87,0x00, -0x93,0xf5,0xf5,0x0f,0xef,0xf0,0x5f,0xe2,0x63,0x14,0x05,0x08,0x83,0x45,0x01,0x00, -0x13,0x05,0x04,0x00,0xef,0xf0,0x5f,0xe1,0x63,0x1c,0x05,0x06,0x03,0x26,0x01,0x01, -0x83,0x27,0x81,0x00,0xb3,0x07,0xf6,0x00,0x23,0x28,0xf1,0x00,0x83,0x27,0x01,0x01, -0x63,0x92,0xc7,0x04,0x13,0x05,0x04,0x00,0xef,0xf0,0x9f,0xdc,0x63,0x1a,0x05,0x04, -0x23,0x2c,0x04,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0x9f,0xe0,0x63,0x12,0x05,0x04, -0x83,0x27,0x01,0x00,0x03,0x27,0x81,0x00,0xb3,0x87,0xe7,0x00,0x23,0x20,0xf1,0x00, -0x83,0x27,0x41,0x00,0xb3,0x87,0xe7,0x40,0x23,0x22,0xf1,0x00,0x93,0x07,0x00,0x00, -0x6f,0xf0,0xdf,0xee,0x83,0x45,0x06,0x00,0x13,0x05,0x04,0x00,0x23,0x2a,0xc1,0x00, -0xef,0xf0,0x9f,0xda,0x03,0x26,0x41,0x01,0x13,0x06,0x16,0x00,0xe3,0x00,0x05,0xfa, -0x93,0x04,0x05,0x00,0x6f,0xf0,0x1f,0xed,0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08, +0x23,0x22,0xe1,0x00,0x23,0x2a,0xf1,0x00,0xef,0xf0,0x9f,0xed,0x93,0x04,0x05,0x00, +0x63,0x16,0x05,0x04,0x83,0x27,0x04,0x06,0x13,0x05,0x04,0x00,0x93,0xf7,0xe7,0xff, +0x23,0x20,0xf4,0x06,0xef,0xf0,0xdf,0xf0,0x93,0x04,0x05,0x00,0x63,0x12,0x05,0x02, +0x83,0x27,0xc1,0x00,0x03,0x27,0x01,0x00,0x93,0x87,0xf7,0xff,0xb3,0xf7,0xe7,0x00, +0x03,0x47,0x41,0x01,0x23,0x2c,0xe1,0x00,0x03,0x27,0x41,0x00,0x63,0x14,0x07,0x02, +0x83,0x27,0x04,0x06,0x93,0xe7,0x17,0x00,0x23,0x20,0xf4,0x06,0x83,0x20,0x81,0x02, +0x03,0x24,0x41,0x02,0x13,0x85,0x04,0x00,0x83,0x24,0x01,0x02,0x13,0x01,0xc1,0x02, +0x67,0x80,0x00,0x00,0x83,0x26,0x41,0x00,0x03,0x27,0x41,0x00,0x23,0x24,0xd1,0x00, +0x83,0x26,0xc1,0x00,0x33,0x07,0xf7,0x00,0x63,0xf6,0xe6,0x00,0xb3,0x87,0xf6,0x40, +0x23,0x24,0xf1,0x00,0x93,0x05,0x60,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0xdf,0xe6, +0x63,0x1e,0x05,0x0c,0x13,0x05,0x04,0x00,0xef,0xf0,0x9f,0xe3,0x63,0x18,0x05,0x0c, +0x83,0x25,0x81,0x01,0x93,0x07,0x20,0x00,0x23,0x2c,0xf4,0x00,0x13,0x05,0x04,0x00, +0xef,0xf0,0x9f,0xe4,0x63,0x1c,0x05,0x0a,0x83,0x27,0x41,0x01,0x93,0xf7,0x07,0x10, +0x63,0x9c,0x07,0x08,0x83,0x27,0x01,0x00,0x13,0x05,0x04,0x00,0x93,0xd5,0x07,0x01, +0x93,0xf5,0xf5,0x0f,0xef,0xf0,0x5f,0xe2,0x63,0x1a,0x05,0x08,0x83,0x27,0x01,0x00, +0x13,0x05,0x04,0x00,0x93,0xd5,0x87,0x00,0x93,0xf5,0xf5,0x0f,0xef,0xf0,0xdf,0xe0, +0x63,0x1e,0x05,0x06,0x83,0x45,0x01,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0xdf,0xdf, +0x63,0x16,0x05,0x06,0x03,0x26,0x01,0x01,0x83,0x27,0x81,0x00,0xb3,0x07,0xf6,0x00, +0x63,0x12,0xf6,0x06,0x13,0x05,0x04,0x00,0x23,0x28,0xc1,0x00,0xef,0xf0,0x5f,0xdb, +0x63,0x16,0x05,0x04,0x23,0x2c,0x04,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0x5f,0xdf, +0x63,0x1e,0x05,0x02,0x83,0x27,0x01,0x00,0x03,0x27,0x81,0x00,0xb3,0x87,0xe7,0x00, +0x23,0x20,0xf1,0x00,0x83,0x27,0x41,0x00,0xb3,0x87,0xe7,0x40,0x23,0x22,0xf1,0x00, +0x93,0x07,0x00,0x00,0x6f,0xf0,0x5f,0xee,0x83,0x27,0x01,0x00,0x13,0x05,0x04,0x00, +0x93,0xd5,0x87,0x01,0xef,0xf0,0x5f,0xd9,0xe3,0x0e,0x05,0xf4,0x93,0x04,0x05,0x00, +0x6f,0xf0,0x1f,0xed,0x83,0x45,0x06,0x00,0x13,0x05,0x04,0x00,0x23,0x2e,0xf1,0x00, +0x23,0x28,0xc1,0x00,0xef,0xf0,0x5f,0xd7,0x03,0x26,0x01,0x01,0x83,0x27,0xc1,0x01, +0x13,0x06,0x16,0x00,0xe3,0x0e,0x05,0xf6,0x6f,0xf0,0x5f,0xfd,0x09,0x53,0x67,0x08, 0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08, 0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08, 0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08, -0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08, +0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08,0x09,0x53,0x67,0x08, diff --git a/contrib/loaders/flash/fespi/riscv64_fespi.inc b/contrib/loaders/flash/fespi/riscv64_fespi.inc index b8b1d40..97a860f 100644 --- a/contrib/loaders/flash/fespi/riscv64_fespi.inc +++ b/contrib/loaders/flash/fespi/riscv64_fespi.inc @@ -1,5 +1,5 @@ /* Autogenerated with ../../../../src/helper/bin2char.sh */ -0x17,0x01,0x00,0x00,0x13,0x01,0x01,0x35,0xef,0x00,0x40,0x12,0x73,0x00,0x10,0x00, +0x17,0x01,0x00,0x00,0x13,0x01,0x81,0x38,0xef,0x00,0x40,0x12,0x73,0x00,0x10,0x00, 0x93,0x07,0x90,0x3e,0x9b,0x87,0xf7,0xff,0x63,0x96,0x07,0x00,0x13,0x05,0x10,0x00, 0x67,0x80,0x00,0x00,0x03,0x27,0x45,0x07,0x13,0x77,0x17,0x00,0xe3,0x04,0x07,0xfe, 0x13,0x05,0x00,0x00,0x67,0x80,0x00,0x00,0x93,0x07,0x90,0x3e,0x9b,0x87,0xf7,0xff, @@ -17,38 +17,42 @@ 0x93,0x07,0x90,0x3e,0x9b,0x87,0xf7,0xff,0xe3,0x8a,0x07,0xfc,0x83,0x26,0xc4,0x04, 0x13,0x96,0x06,0x02,0x1b,0x87,0x06,0x00,0xe3,0x46,0x06,0xfe,0x93,0x77,0x17,0x00, 0xe3,0x94,0x07,0xfc,0x23,0x2c,0x04,0x00,0x83,0x27,0x04,0x04,0x9b,0x87,0x07,0x00, -0x93,0xe7,0x87,0x00,0x23,0x20,0xf4,0x04,0x6f,0xf0,0xdf,0xf7,0x13,0x01,0x01,0xfb, -0x23,0x30,0x81,0x04,0x23,0x3c,0x91,0x02,0x23,0x38,0x21,0x03,0x23,0x34,0x31,0x03, -0x23,0x30,0x41,0x03,0x23,0x3c,0x51,0x01,0x23,0x34,0x11,0x04,0x23,0x38,0x61,0x01, -0x23,0x34,0x71,0x01,0x23,0x30,0x81,0x01,0x13,0x04,0x05,0x00,0x13,0x8a,0x05,0x00, -0x93,0x0a,0x06,0x00,0x13,0x89,0x06,0x00,0x93,0x09,0x07,0x00,0xef,0xf0,0x5f,0xea, -0x93,0x04,0x05,0x00,0x63,0x14,0x05,0x04,0x83,0x27,0x04,0x06,0x13,0x05,0x04,0x00, -0x9b,0x87,0x07,0x00,0x93,0xf7,0xe7,0xff,0x23,0x20,0xf4,0x06,0xef,0xf0,0xdf,0xed, -0x93,0x04,0x05,0x00,0x63,0x1c,0x05,0x00,0x9b,0x07,0xfa,0xff,0xb3,0x77,0xf9,0x00, -0x9b,0x87,0x07,0x00,0x93,0x0b,0x20,0x00,0x63,0x94,0x09,0x04,0x83,0x27,0x04,0x06, -0x9b,0x87,0x07,0x00,0x93,0xe7,0x17,0x00,0x23,0x20,0xf4,0x06,0x83,0x30,0x81,0x04, -0x03,0x34,0x01,0x04,0x03,0x39,0x01,0x03,0x83,0x39,0x81,0x02,0x03,0x3a,0x01,0x02, -0x83,0x3a,0x81,0x01,0x03,0x3b,0x01,0x01,0x83,0x3b,0x81,0x00,0x03,0x3c,0x01,0x00, -0x13,0x85,0x04,0x00,0x83,0x34,0x81,0x03,0x13,0x01,0x01,0x05,0x67,0x80,0x00,0x00, -0x3b,0x87,0xf9,0x00,0x13,0x8b,0x09,0x00,0x63,0x74,0xea,0x00,0x3b,0x0b,0xfa,0x40, -0x93,0x05,0x60,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0x1f,0xe3,0x63,0x1c,0x05,0x0a, -0x13,0x05,0x04,0x00,0xef,0xf0,0xdf,0xdf,0x63,0x16,0x05,0x0a,0x23,0x2c,0x74,0x01, -0x93,0x05,0x20,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0x1f,0xe1,0x63,0x1c,0x05,0x08, -0x9b,0x55,0x09,0x01,0x93,0xf5,0xf5,0x0f,0x13,0x05,0x04,0x00,0xef,0xf0,0xdf,0xdf, -0x63,0x12,0x05,0x08,0x9b,0x55,0x89,0x00,0x93,0xf5,0xf5,0x0f,0x13,0x05,0x04,0x00, -0xef,0xf0,0x9f,0xde,0x63,0x18,0x05,0x06,0x93,0x75,0xf9,0x0f,0x13,0x05,0x04,0x00, -0xef,0xf0,0x9f,0xdd,0x63,0x10,0x05,0x06,0x13,0x0c,0x00,0x00,0x9b,0x07,0x0c,0x00, -0x63,0xee,0x67,0x03,0x13,0x05,0x04,0x00,0xef,0xf0,0x9f,0xd9,0x63,0x14,0x05,0x04, -0x23,0x2c,0x04,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0x1f,0xde,0x63,0x1c,0x05,0x02, -0x93,0x17,0x0b,0x02,0x93,0xd7,0x07,0x02,0xb3,0x8a,0xfa,0x00,0x3b,0x09,0x69,0x01, -0xbb,0x89,0x69,0x41,0x93,0x07,0x00,0x00,0x6f,0xf0,0x1f,0xf0,0xb3,0x87,0x8a,0x01, -0x83,0xc5,0x07,0x00,0x13,0x05,0x04,0x00,0x13,0x0c,0x1c,0x00,0xef,0xf0,0xdf,0xd7, -0xe3,0x06,0x05,0xfa,0x93,0x04,0x05,0x00,0x6f,0xf0,0x5f,0xee,0x00,0x00,0x00,0x00, -0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, -0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, -0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, -0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, -0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, -0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, -0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, -0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x93,0xe7,0x87,0x00,0x23,0x20,0xf4,0x04,0x6f,0xf0,0xdf,0xf7,0x13,0x01,0x01,0xfa, +0x23,0x38,0x81,0x04,0x23,0x34,0x91,0x04,0x23,0x30,0x21,0x05,0x23,0x3c,0x31,0x03, +0x23,0x38,0x41,0x03,0x23,0x34,0x51,0x03,0x23,0x30,0x61,0x03,0x23,0x3c,0x11,0x04, +0x23,0x3c,0x71,0x01,0x23,0x38,0x81,0x01,0x23,0x34,0x91,0x01,0x23,0x30,0xa1,0x01, +0x13,0x04,0x05,0x00,0x93,0x8a,0x05,0x00,0x13,0x0b,0x06,0x00,0x13,0x89,0x06,0x00, +0x13,0x0a,0x07,0x00,0x93,0x89,0x07,0x00,0xef,0xf0,0x9f,0xe9,0x93,0x04,0x05,0x00, +0x63,0x1a,0x05,0x04,0x83,0x27,0x04,0x06,0x13,0x05,0x04,0x00,0x9b,0x87,0x07,0x00, +0x93,0xf7,0xe7,0xff,0x23,0x20,0xf4,0x06,0xef,0xf0,0x1f,0xed,0x93,0x04,0x05,0x00, +0x63,0x12,0x05,0x02,0x9b,0x86,0xfa,0xff,0xb3,0x76,0xd9,0x00,0x93,0xfc,0xf9,0x0f, +0x93,0xf9,0x09,0x10,0x9b,0x86,0x06,0x00,0x13,0x0c,0x20,0x00,0x9b,0x89,0x09,0x00, +0x63,0x18,0x0a,0x04,0x83,0x27,0x04,0x06,0x9b,0x87,0x07,0x00,0x93,0xe7,0x17,0x00, +0x23,0x20,0xf4,0x06,0x83,0x30,0x81,0x05,0x03,0x34,0x01,0x05,0x03,0x39,0x01,0x04, +0x83,0x39,0x81,0x03,0x03,0x3a,0x01,0x03,0x83,0x3a,0x81,0x02,0x03,0x3b,0x01,0x02, +0x83,0x3b,0x81,0x01,0x03,0x3c,0x01,0x01,0x83,0x3c,0x81,0x00,0x03,0x3d,0x01,0x00, +0x13,0x85,0x04,0x00,0x83,0x34,0x81,0x04,0x13,0x01,0x01,0x06,0x67,0x80,0x00,0x00, +0xbb,0x07,0xda,0x00,0x93,0x0b,0x0a,0x00,0x63,0xf4,0xfa,0x00,0xbb,0x8b,0xda,0x40, +0x93,0x05,0x60,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0x1f,0xe1,0x63,0x1a,0x05,0x0a, +0x13,0x05,0x04,0x00,0xef,0xf0,0xdf,0xdd,0x63,0x14,0x05,0x0a,0x23,0x2c,0x84,0x01, +0x93,0x85,0x0c,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0x1f,0xdf,0x63,0x1a,0x05,0x08, +0x63,0x90,0x09,0x08,0x9b,0x55,0x09,0x01,0x93,0xf5,0xf5,0x0f,0x13,0x05,0x04,0x00, +0xef,0xf0,0x9f,0xdd,0x63,0x1e,0x05,0x06,0x9b,0x55,0x89,0x00,0x93,0xf5,0xf5,0x0f, +0x13,0x05,0x04,0x00,0xef,0xf0,0x5f,0xdc,0x63,0x14,0x05,0x06,0x93,0x75,0xf9,0x0f, +0x13,0x05,0x04,0x00,0xef,0xf0,0x5f,0xdb,0x63,0x1c,0x05,0x04,0x13,0x0d,0x00,0x00, +0x9b,0x07,0x0d,0x00,0x63,0xea,0x77,0x05,0x13,0x05,0x04,0x00,0xef,0xf0,0x5f,0xd7, +0x63,0x10,0x05,0x04,0x23,0x2c,0x04,0x00,0x13,0x05,0x04,0x00,0xef,0xf0,0xdf,0xdb, +0x63,0x18,0x05,0x02,0x93,0x97,0x0b,0x02,0x93,0xd7,0x07,0x02,0x33,0x0b,0xfb,0x00, +0x3b,0x09,0x79,0x01,0x3b,0x0a,0x7a,0x41,0x93,0x06,0x00,0x00,0x6f,0xf0,0x5f,0xef, +0x9b,0x55,0x89,0x01,0x13,0x05,0x04,0x00,0xef,0xf0,0x1f,0xd6,0xe3,0x0c,0x05,0xf6, +0x93,0x04,0x05,0x00,0x6f,0xf0,0x1f,0xee,0xb3,0x07,0xab,0x01,0x83,0xc5,0x07,0x00, +0x13,0x05,0x04,0x00,0x13,0x0d,0x1d,0x00,0xef,0xf0,0x1f,0xd4,0xe3,0x0a,0x05,0xf8, +0x6f,0xf0,0x1f,0xfe,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00,0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, +0x09,0x53,0x67,0x08,0x00,0x00,0x00,0x00, diff --git a/contrib/loaders/flash/fespi/riscv_fespi.c b/contrib/loaders/flash/fespi/riscv_fespi.c index 01d27fe..b616433 100644 --- a/contrib/loaders/flash/fespi/riscv_fespi.c +++ b/contrib/loaders/flash/fespi/riscv_fespi.c @@ -101,11 +101,18 @@ static void fespi_disable_hw_mode(volatile uint32_t *ctrl_base); static void fespi_enable_hw_mode(volatile uint32_t *ctrl_base); static int fespi_wip(volatile uint32_t *ctrl_base); static int fespi_write_buffer(volatile uint32_t *ctrl_base, - const uint8_t *buffer, unsigned offset, unsigned len); + const uint8_t *buffer, unsigned offset, unsigned len, + uint32_t flash_info); /* Can set bits 3:0 in result. */ +/* flash_info contains: + * bits 7:0 -- pprog_cmd + * bit 8 -- 0 means send 3 bytes after pprog_cmd, 1 means send 4 bytes + * after pprog_cmd + */ int flash_fespi(volatile uint32_t *ctrl_base, uint32_t page_size, - const uint8_t *buffer, unsigned offset, uint32_t count) + const uint8_t *buffer, unsigned offset, uint32_t count, + uint32_t flash_info) { int result; @@ -135,7 +142,7 @@ int flash_fespi(volatile uint32_t *ctrl_base, uint32_t page_size, else cur_count = count; - result = fespi_write_buffer(ctrl_base, buffer, offset, cur_count); + result = fespi_write_buffer(ctrl_base, buffer, offset, cur_count, flash_info); if (result != ERROR_OK) { result |= ERROR_STACK(0x3); goto err; @@ -264,7 +271,8 @@ static int fespi_wip(volatile uint32_t *ctrl_base) /* Can set bits 23:20 in result. */ static int fespi_write_buffer(volatile uint32_t *ctrl_base, - const uint8_t *buffer, unsigned offset, unsigned len) + const uint8_t *buffer, unsigned offset, unsigned len, + uint32_t flash_info) { int result = fespi_tx(ctrl_base, SPIFLASH_WRITE_ENABLE); if (result != ERROR_OK) @@ -275,10 +283,15 @@ static int fespi_write_buffer(volatile uint32_t *ctrl_base, fespi_write_reg(ctrl_base, FESPI_REG_CSMODE, FESPI_CSMODE_HOLD); - result = fespi_tx(ctrl_base, SPIFLASH_PAGE_PROGRAM); + result = fespi_tx(ctrl_base, flash_info & 0xff); if (result != ERROR_OK) return result | ERROR_STACK(0x300000); + if (flash_info & 0x100) { + result = fespi_tx(ctrl_base, offset >> 24); + if (result != ERROR_OK) + return result | ERROR_STACK(0x400000); + } result = fespi_tx(ctrl_base, offset >> 16); if (result != ERROR_OK) return result | ERROR_STACK(0x400000); diff --git a/src/flash/nor/fespi.c b/src/flash/nor/fespi.c index 99c786a..76c05b8 100644 --- a/src/flash/nor/fespi.c +++ b/src/flash/nor/fespi.c @@ -336,6 +336,11 @@ static int fespi_erase_sector(struct flash_bank *bank, int sector) if (retval != ERROR_OK) return retval; sector = bank->sectors[sector].offset; + if (bank->size > 0x1000000) { + retval = fespi_tx(bank, sector >> 24); + if (retval != ERROR_OK) + return retval; + } retval = fespi_tx(bank, sector >> 16); if (retval != ERROR_OK) return retval; @@ -436,32 +441,38 @@ static int fespi_protect(struct flash_bank *bank, int set, static int slow_fespi_write_buffer(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t len) { + struct fespi_flash_bank *fespi_info = bank->driver_priv; uint32_t ii; - if (offset & 0xFF000000) { - LOG_ERROR("FESPI interface does not support greater than 3B addressing, can't write to offset 0x%x", - offset); - return ERROR_FAIL; - } - /* TODO!!! assert that len < page size */ - fespi_tx(bank, SPIFLASH_WRITE_ENABLE); - fespi_txwm_wait(bank); + if (fespi_tx(bank, SPIFLASH_WRITE_ENABLE) != ERROR_OK) + return ERROR_FAIL; + if (fespi_txwm_wait(bank) != ERROR_OK) + return ERROR_FAIL; if (fespi_write_reg(bank, FESPI_REG_CSMODE, FESPI_CSMODE_HOLD) != ERROR_OK) return ERROR_FAIL; - fespi_tx(bank, SPIFLASH_PAGE_PROGRAM); + if (fespi_tx(bank, fespi_info->dev->pprog_cmd) != ERROR_OK) + return ERROR_FAIL; - fespi_tx(bank, offset >> 16); - fespi_tx(bank, offset >> 8); - fespi_tx(bank, offset); + if (bank->size > 0x1000000 && fespi_tx(bank, offset >> 24) != ERROR_OK) + return ERROR_FAIL; + if (fespi_tx(bank, offset >> 16) != ERROR_OK) + return ERROR_FAIL; + if (fespi_tx(bank, offset >> 8) != ERROR_OK) + return ERROR_FAIL; + if (fespi_tx(bank, offset) != ERROR_OK) + return ERROR_FAIL; - for (ii = 0; ii < len; ii++) - fespi_tx(bank, buffer[ii]); + for (ii = 0; ii < len; ii++) { + if (fespi_tx(bank, buffer[ii]) != ERROR_OK) + return ERROR_FAIL; + } - fespi_txwm_wait(bank); + if (fespi_txwm_wait(bank) != ERROR_OK) + return ERROR_FAIL; if (fespi_write_reg(bank, FESPI_REG_CSMODE, FESPI_CSMODE_AUTO) != ERROR_OK) return ERROR_FAIL; @@ -488,7 +499,8 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer, int sector; int retval = ERROR_OK; - LOG_DEBUG("offset=0x%08" PRIx32 " count=0x%08" PRIx32, offset, count); + LOG_DEBUG("bank->size=0x%x offset=0x%08" PRIx32 " count=0x%08" PRIx32, + bank->size, offset, count); if (target->state != TARGET_HALTED) { LOG_ERROR("Target not halted"); @@ -561,12 +573,13 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer, fespi_info->dev->pagesize : SPIFLASH_DEF_PAGESIZE; if (algorithm_wa) { - struct reg_param reg_params[5]; + struct reg_param reg_params[6]; init_reg_param(®_params[0], "a0", xlen, PARAM_IN_OUT); init_reg_param(®_params[1], "a1", xlen, PARAM_OUT); init_reg_param(®_params[2], "a2", xlen, PARAM_OUT); init_reg_param(®_params[3], "a3", xlen, PARAM_OUT); init_reg_param(®_params[4], "a4", xlen, PARAM_OUT); + init_reg_param(®_params[5], "a5", xlen, PARAM_OUT); while (count > 0) { cur_count = MIN(count, data_wa_size); @@ -575,6 +588,8 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer, buf_set_u64(reg_params[2].value, 0, xlen, data_wa->address); buf_set_u64(reg_params[3].value, 0, xlen, offset); buf_set_u64(reg_params[4].value, 0, xlen, cur_count); + buf_set_u64(reg_params[5].value, 0, xlen, + fespi_info->dev->pprog_cmd | (bank->size > 0x1000000 ? 0x100 : 0)); retval = target_write_buffer(target, data_wa->address, cur_count, buffer); @@ -589,7 +604,8 @@ static int fespi_write(struct flash_bank *bank, const uint8_t *buffer, ", count=0x%" PRIx32 "), buffer=%02x %02x %02x %02x %02x %02x ..." PRIx32, fespi_info->ctrl_base, page_size, data_wa->address, offset, cur_count, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]); - retval = target_run_algorithm(target, 0, NULL, 5, reg_params, + retval = target_run_algorithm(target, 0, NULL, + ARRAY_SIZE(reg_params), reg_params, algorithm_wa->address, 0, cur_count * 2, NULL); if (retval != ERROR_OK) { LOG_ERROR("Failed to execute algorithm at " TARGET_ADDR_FMT ": %d", @@ -790,8 +806,6 @@ static int fespi_probe(struct flash_bank *bank) if (bank->size <= (1UL << 16)) LOG_WARNING("device needs 2-byte addresses - not implemented"); - if (bank->size > (1UL << 24)) - LOG_WARNING("device needs paging or 4-byte addresses - not implemented"); /* if no sectors, treat whole bank as single sector */ sectorsize = fespi_info->dev->sectorsize ? diff --git a/src/flash/nor/spi.c b/src/flash/nor/spi.c index 84eb08a..af72ffc 100644 --- a/src/flash/nor/spi.c +++ b/src/flash/nor/spi.c @@ -124,10 +124,10 @@ const struct flash_device flash_devices[] = { FLASH_ID("issi is25lp064", 0x03, 0x00, 0x02, 0xd8, 0xc7, 0x0017609d, 0x100, 0x10000, 0x800000), FLASH_ID("issi is25lp128d", 0x03, 0xeb, 0x02, 0xd8, 0xc7, 0x0018609d, 0x100, 0x10000, 0x1000000), FLASH_ID("issi is25wp128d", 0x03, 0xeb, 0x02, 0xd8, 0xc7, 0x0018709d, 0x100, 0x10000, 0x1000000), - FLASH_ID("issi is25lp256d", 0x13, 0xec, 0x12, 0xd8, 0xc7, 0x0019609d, 0x100, 0x10000, 0x2000000), - FLASH_ID("issi is25wp256d", 0x13, 0xec, 0x12, 0xd8, 0xc7, 0x0019709d, 0x100, 0x10000, 0x2000000), - FLASH_ID("issi is25lp512m", 0x13, 0xec, 0x12, 0xd8, 0xc7, 0x001a609d, 0x100, 0x10000, 0x4000000), - FLASH_ID("issi is25wp512m", 0x13, 0xec, 0x12, 0xd8, 0xc7, 0x001a709d, 0x100, 0x10000, 0x4000000), + FLASH_ID("issi is25lp256d", 0x13, 0xec, 0x12, 0xdc, 0xc7, 0x0019609d, 0x100, 0x10000, 0x2000000), + FLASH_ID("issi is25wp256d", 0x13, 0xec, 0x12, 0xdc, 0xc7, 0x0019709d, 0x100, 0x10000, 0x2000000), + FLASH_ID("issi is25lp512m", 0x13, 0xec, 0x12, 0xdc, 0xc7, 0x001a609d, 0x100, 0x10000, 0x4000000), + FLASH_ID("issi is25wp512m", 0x13, 0xec, 0x12, 0xdc, 0xc7, 0x001a709d, 0x100, 0x10000, 0x4000000), /* FRAM, no erase commands, no write page or sectors */ FRAM_ID("fu mb85rs16n", 0x03, 0, 0x02, 0x00010104, 0x800), |