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.