FRDM-K82F error when flashing large program to QSPI

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-K82F error when flashing large program to QSPI

1,359 Views
jozefl
Contributor II


I have a program which is 42880 bytes large when built at Os in KDS3, however when I try to flash it to QSPI using blhost from the K80 bootloader tools, I get the following error:

Boot Section 0x00000000:

  ERAS | adr=0x00000000 | cnt=0x00000800 | flg=0x0000

  LOAD | adr=0x20000000 | len=0x00000200 | crc=0x0719eed2 | flg=0x0000

  ENA  | adr=0x20000000 | cnt=0x00000004 | flg=0x0100

  ERAS | adr=0x68000000 | cnt=0x00008000 | flg=0x0000

  LOAD | adr=0x68000000 | len=0x00000200 | crc=0x0719eed2 | flg=0x0000

  LOAD | adr=0x00000000 | len=0x000003c0 | crc=0xe83ccd71 | flg=0x0000

  LOAD | adr=0x00000400 | len=0x00000010 | crc=0x0e6bd07a | flg=0x0000

  LOAD | adr=0x68001000 | len=0x00009e88 | crc=0x5aad77e1 | flg=0x0000

Inject command 'receive-sb-file'

Preparing to send 42880 (0xa780) bytes to the target.

Successful generic response to command 'receive-sb-file'

usb hid detected receiver data abort

Data phase write aborted by status 0x2712 kStatus_AbortDataPhase

Response status = 403 (0x193) QSPI Flash Command Failure.

Wrote 31200 of 42880 bytes.

I have a different program which is 25952 bytes when built at Os and flashing it using blhost completes successfully and the program runs correctly.

If I build that same program at -O0 then the program is larger than 31200 bytes and I get the same error as before:

Boot Section 0x00000000:

  ERAS | adr=0x00000000 | cnt=0x00000800 | flg=0x0000

  LOAD | adr=0x20000000 | len=0x00000200 | crc=0x0719eed2 | flg=0x0000

  ENA  | adr=0x20000000 | cnt=0x00000004 | flg=0x0100

  ERAS | adr=0x68000000 | cnt=0x00008000 | flg=0x0000

  LOAD | adr=0x68000000 | len=0x00000200 | crc=0x0719eed2 | flg=0x0000

  LOAD | adr=0x00000000 | len=0x000003c0 | crc=0xe812f756 | flg=0x0000

  LOAD | adr=0x00000400 | len=0x00000010 | crc=0x0e6bd07a | flg=0x0000

  LOAD | adr=0x68001000 | len=0x00007d84 | crc=0xb93b887a | flg=0x0000

Inject command 'receive-sb-file'

Preparing to send 34432 (0x8680) bytes to the target.

Successful generic response to command 'receive-sb-file'

usb hid detected receiver data abort

Data phase write aborted by status 0x2712 kStatus_AbortDataPhase

Response status = 403 (0x193) QSPI Flash Command Failure.

Wrote 31200 of 34432 bytes.

Why am I getting this error and how can I fix it? As far as I'm aware the QSPI memory is much larger than 30kB, in the linker script ~1MB is allocated for the text section in QSPI and the web page for the FRDM-K82F says they are 4MB each.

Labels (1)
Tags (2)
0 Kudos
Reply
3 Replies

887 Views
isaacavila
NXP Employee
NXP Employee

Hello Jozefl,

Could you please be so kind to attach your images? (The one bigger than 30kB and the one that can be programmed correctly).

Best Regards,

Isaac

0 Kudos
Reply

887 Views
konradgräfe
Contributor III

I have the same problem on the TWR-KL82Z72M, except that the "cut-off size" seems to vary depending on the actual image. I attached my images to this post. 

First, hello_world_qspi_small.sb, which is basically the demo application from the SDK, is working:

hello_world_qspi> blhost -V -p COM5 receive-sb-file hello_world_qspi_small.sb
Ping responded in 1 attempt(s)
Framing protocol version = 0x50010200, options = 0x0
Inject command 'receive-sb-file'
Preparing to send 11776 (0x2e00) bytes to the target.
Successful generic response to command 'receive-sb-file'
(1/1)100% Completed!
Successful generic response to command 'receive-sb-file'
 - took 3.421 seconds
Response status = 0 (0x0) Success.
Wrote 11776 of 11776 bytes.

Second, hello_world_qspi_large.sb, which is the same but extended by a very large constant array, is not working:

hello_world_qspi> blhost -V -p COM5 receive-sb-file hello_world_qspi_large.sb
Ping responded in 1 attempt(s)
Framing protocol version = 0x50010200, options = 0x0
Inject command 'receive-sb-file'
Preparing to send 44640 (0xae60) bytes to the target.
Successful generic response to command 'receive-sb-file'
(1/1)97%Data phase write aborted by status 0x2712 kStatus_AbortDataPhase
Possible JUMP or RESET command received.
 - took 11.676 seconds
Response status = 403 (0x193) QSPI Flash Command Failure.
Wrote 43648 of 44640 bytes.

If I increase the size of the constant array, more bytes will be transferred, before it gets aborted.

I am running blhost from a Cygwin shell on a Windows host but I have the same issue with the KinetisFlashTool (with less output) so I guess that shouldn't matter.

0 Kudos
Reply

887 Views
konradgräfe
Contributor III

In my case the QSPI config block delivered with the SDK was wrong: the QSPI flashes don't have 4MiB each but 8MiB:

diff --git a/qspi_config_block_generator.c b/qspi_config_block_generator.c
index 7e7da1a..1169621 100644
--- a/qspi_config_block_generator.c
+++ b/qspi_config_block_generator.c
@@ -183,8 +183,8 @@ int main(void)
 const qspi_config_t qspi_config_block = {
 .tag = kQspiConfigTag,
 .version = {.version = kQspiVersionTag},
- .sflash_A1_size = 0x400000, // 4MB
- .sflash_B1_size = 0x400000, // 4MB
+ .sflash_A1_size = 0x800000, // 8MB
+ .sflash_B1_size = 0x800000, // 8MB
 .sclk_freq = kQspiSerialClockFreq_Mid, // Mid frequency
 .sflash_type = kQspiFlashPad_Quad, // SPI Flash devices work under quad-pad mode
 .sflash_port = kQspiPort_EnableBothPorts, // Both QSPI0A and QSPI0B are enabled.‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

My images are far away from those 4MiB, but with this change it is indeed working for me.

0 Kudos
Reply