Help storing data in QSPIFLASH - dfu-util is not writeable error

Maybe I’m missing something simple here, but I can’t seem to get this working at all.

I’m trying to store a large array in QSPIFLASH but when flashing with dfu-util I get the following error:

dfu-util 0.11

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2021 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

dfu-util: Warning: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release
Opening DFU capable USB device...
Device ID 0483:df11
Device DFU version 011a
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 011a
Device returned transfer size 1024
DfuSe interface name: "Internal Flash   "
Downloading element to address = 0x08000000, size = -2012712140
dfu-util: Last page at 0x90087333 is not writeable
make: *** [program-dfu] Error 64

I’m using the DSY_QSPI_DATA macro like so:

#include "per/qspi.h"

const unsigned char DSY_QSPI_DATA birds_wav[] = {
  0x52, 0x49, 0x46, 0x46, 0x2c, 0x73, 0x04, 0x00, 0x57, 0x41, 0x56, 0x45,
  ...
  0x58, 0x58, 0x58, 0x00, 0x69, 0x73, 0x6f, 0x36, 0x6d, 0x70, 0x34, 0x31
};
unsigned int birds_wav_len = 291636;

I can see this defined in the libDaisy/src/per/qspi.h file:

#define DSY_QSPI_DATA       \
    __attribute__((section( \
        ".qspiflash_data"))) /**< used for reading memory in memory_mapped mode. */

I’ve copied the example linker file fromlibDaisy/core/STM32H750IB_flash.lds - I’ve also tried modifying the MEMORY map QSPIFLASH entry to the below as they’re different in the _qspi.lds and _flash.lds linker files; although I’m not sure this makes any difference to the dfu-util error I’m getting.

QSPIFLASH   (RX)  : ORIGIN = 0x90040000, LENGTH = 7936K

I’ve added the custom linker script to my Makefile; again I’m sure the example STM32H750IB_flash.lds should work.

LDSCRIPT = ./STM32H750IB_custom.lds

Compiled okay and we can see the main program in FLASH and the additional data in QSPIFLASH:

Memory region         Used Size  Region Size  %age Used
           FLASH:      104152 B       128 KB     79.46%
         DTCMRAM:          0 GB       128 KB      0.00%
            SRAM:       32144 B       512 KB      6.13%
          RAM_D2:       16704 B       288 KB      5.66%
          RAM_D3:          0 GB        64 KB      0.00%
     BACKUP_SRAM:          12 B         4 KB      0.29%
         ITCMRAM:          0 GB        64 KB      0.00%
           SDRAM:          0 GB        64 MB      0.00%
       QSPIFLASH:      291636 B      7936 KB      3.59%

But then when running the program-dfu task dfu-util is never able to write to QSPIFLASH. It always throws a dfu-util: Last page at 0x90087333 is not writeable

Also dfu-util -l shows this:

Found DFU: [0483:df11] ver=0200, devnum=1, cfg=1, intf=0, path="1-1", alt=1, name="@Option Bytes   /0x5200201C/01*128 e", serial="200364500000"
Found DFU: [0483:df11] ver=0200, devnum=1, cfg=1, intf=0, path="1-1", alt=0, name="@Internal Flash   /0x08000000/16*128Kg", serial="200364500000"

Is this something to do with the program-dfu task in the Makefile? I can see it also passes the memory address to write.

program-dfu:
	dfu-util -a 0 -s $(FLASH_ADDRESS):leave -D $(BUILD_DIR)/$(TARGET_BIN) -d ,0483:$(USBPID)

Then when running this task is passes the FLASH address, so it would make sense it might not be also able to write to QSPIFLASH then too…

dfu-util -a 0 -s 0x08000000:leave -D build/test.bin -d ,0483:df11

Maybe I’m missing something here, but from the docs, libDaisy source code and other posts on the forum, this should work, right???

Can dfu-util flash to multiple memory regions? I would assume so based on the docs and examples from @BHAudio’s great post here: Out of FLASH memory walkthrough with samples

I’m new to all this embedded stuff, but have experience in other languages. I’ve been troubleshooting this for a couple of days, but I’m stumped.

Hopefully someone can help me. Thanks!

I’m pretty sure this is a limitation of the built-in STM32 bootloader - the one that gets activated by the two button sequence. The STM32 isn’t aware of the QSPI chip until QSPI initialization is done by libdaisy.

This might be possible with the Daisy bootloader. Confusing names, but builtin bootloader isn’t the same as Daisy bootloader.

1 Like

Thanks. This is what I’m thinking too. I thought maybe the built-in bootloader may have been a Daisy specific one after seeing both int and ext ones in the libDaisy/core folder.

I think you’re right though. Found another thread on the ST forums; it doesn’t seem like the ST provided bootloader supports external flash writing. - https://community.st.com/t5/stm32cubeprogrammer-mcus/flashing-qspi-using-dfu-mode-in-stm32cubeprogrammer/td-p/268450

Oh well, I learned loads getting this far :rofl: