cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeProgrammer External Loader Partial Page

CRich.4
Associate III

Hello, I have made a custom external flash loader(.stldr) file for my STM32 based board. Reading the content of the external flash via CubeProgrammer works fine. But when programming i run into the following problem: CubeProgrammer tries to write partial pages, which fails.

device setup in Dev_Inf.c:

struct StorageInfo const StorageInfo = {
#endif
"W25Q_BurnerHMI_PT1_loader_v1", // Device Name
NOR_FLASH, // Device Type
0x70000000, // Device Start Address
PAGE_COUNT*MEM_PAGE_SIZE_BYTES, // Device Size in Bytes (8192 pages * 512 bytes)
MEM_PAGE_SIZE_BYTES, // Programming Page Size (512 bytes)
0xFF, // Initial Content of Erased Memory
// Specify Size and Address of Sectors (view example below)
{
{SECTOR_COUNT, MEM_SECTOR_SIZE_BYTES}, // Sector Num (512), Sector Size (8192 bytes)
{0x00000000, 0x00000000}
},
};

 

The image i'm writing has a size of 2097152 bytes (2MiB) and in the UART debug print i can see that CubeProgrammer is splitting the image like this:

Write(Address:0x70000000, Size:0x7D500, buffer:0x240052A0)
partial page: PageNum:0x3EA, OffsetIntoPage:0x0, NumBytes:0x100
Write(Address:0x7007D500, Size:0x7D500, buffer:0x240827A0)
partial page: PageNum:0x3EA, OffsetIntoPage:0x100, NumBytes:0x100
Write(Address:0x700FAA00, Size:0x7D500, buffer:0x240052A0)
partial page: PageNum:0xBBF, OffsetIntoPage:0x0, NumBytes:0x100
Write(Address:0x70177F00, Size:0x7D500, buffer:0x240827A0)
partial page: PageNum:0xBBF, OffsetIntoPage:0x100, NumBytes:0x100
Write(Address:0x701F5400, Size:0x5600, buffer:0x240052A0)
Write(Address:0x701FAA00, Size:0x5600, buffer:0x2400A8A0)

 

0x7D500 is not a multiple of the page size (512).

 

Is there any way to force CubeProgrammer to split the image into multiples of 512 bytes (full pages)?

 

 

10 REPLIES 10

i think i have found the problem in my loader.

I compied the drive from a QSPI project.

and it contained this function:

u32_t page_to_addr(u32_t pageNum, u8_t pageShift) {
return pageNum * MEM_PAGE_SIZE_BYTES + pageShift;
}

 

for single memories the page size is 256, so the offset/shift fits into one byte

but for D-QSPI the page size is 512 bytes and no longer fits into a uint8_t

 

fixed:

u32_t page_to_addr(u32_t pageNum, u16_t pageShift) {
return pageNum * MEM_PAGE_SIZE_BYTES + pageShift;
}