cancel
Showing results for 
Search instead for 
Did you mean: 

Fail to load image from External Flash - STM32F429BIT6 / W25Q64 (8MB, 23-bit address)

hbZhao
Associate III

Hello all,

 

I am developing with a STM32F429bit6 by STM32CUBEIDE v1.15.1 and TouchGfx v4.23.2. The LCD display works well. The screen layout is portrait.

However, when I moved the images to the SPI flash (w25q64), the display was crashed.

hbZhao_2-1716836812756.png

 

The changes are as below:

  • Change the ld file to store the images and fonts:

 

hbZhao_0-1716836936100.png

 

  • Enable External Data reader

hbZhao_0-1716836645537.png

  • add spi flash driver and implement the virtual function

 

 

void DataReader_WaitForReceiveDone() {
    return;
}

void DataReader_ReadData(uint32_t address24, uint8_t *buffer, uint32_t length) {
    W25Q_Read(address24, 0, length, buffer);
}

void DataReader_StartDMAReadData(uint32_t address24, uint8_t *buffer, uint32_t length) {
    W25Q_Read(address24, 0, length, buffer);
}

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Couple of thoughts.

The page size is 256-bytes, make sure it writes suitably aligned blocks (address and length), so they don't span across boundaries. Wait for completion of PAGE WRITE

Make sure to mask the address passed to the memory. The memory has a zero-basis, it doesn't under stand anything about 0x90000000, that's an STM32 side decode range

ie

.Address = Addr & 0x0FFFFFFF; // 28-bit address

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

5 REPLIES 5

Validate the data readable on the STM32 side matches the data on the PC side.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
hbZhao
Associate III

Hello Telsa,

 

Thanks for your replay. When I verified the flash by the STM32CubeProgrammer, I got the the data dismatched.

Data mismatch found at address 0x90004400 (byte = 0xF8 instead of 0x8C)

But the data value (0x8C) in the flash is correct.

hbZhao_0-1716857028934.png

The below is the verify code in the Loader_Src.c

uint64_t Verify(uint32_t MemoryAddr, uint32_t RAMBufferAddr, uint32_t Size, uint32_t missalignement) {
    __set_PRIMASK(0); // enable interrupts

    uint32_t VerifiedData = 0, InitVal = 0;
    uint64_t checksum;
    Size *= 4;

    uint8_t  Buffer[2];
    uint32_t posBuf;

    checksum = CheckSum((uint32_t)MemoryAddr + (missalignement & 0xf), Size - ((missalignement >> 16) & 0xF), InitVal);

    while (Size > VerifiedData) {
        flash_ReadMemory(MemoryAddr + VerifiedData, 2, Buffer);

        posBuf = 0;
        while ((Size > VerifiedData) && (posBuf < 1024)) {
            if (Buffer[posBuf] != *((uint8_t *)RAMBufferAddr + VerifiedData)) {
                __set_PRIMASK(1); // disable interrupts
                return ((checksum << 32) + MemoryAddr + VerifiedData);
            }
            posBuf++;
            VerifiedData++;
        }
    }
    __set_PRIMASK(1); // disable interrupts
    return (checksum << 32);
}

 

 

The suggestion was to validate content at the application level.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

I have moved the function to an application. And it can run successfully. However, when I tested it as a stldr, it failed to verify with a bigger size file (500K).

The error message is Error: Data mismatch found at address 0x90000A00 (byte = 0xA8 instead of 0x01)

I compared the file with the memory as below. The wrong section address is from 0x9000_0A00 to 0x9005_F5FF.

hbZhao_0-1717105474898.png

hbZhao_2-1717105696115.png

The first error data is 0x8F5BB4A8, which can be found in the bin file while the address is 0x9006_2800 rather than 0x9000_0A00.

hbZhao_3-1717105946346.png

So it seems some blocks data were wrotten to wrong place. Howerver, accroding to the serial port output, there is not error or wrong operations during downloanding. May I know how can fix it? Thanks.

[2024-05-30 16:28:52.269]# RECV ASCII>
Init app...

[2024-05-30 16:29:02.764]# RECV ASCII>
Init app...

[2024-05-30 16:29:02.873]# RECV ASCII>
Write: 90000000(66816)

[2024-05-30 16:29:06.028]# RECV ASCII>
Write: 90010500(66816)

[2024-05-30 16:29:09.162]# RECV ASCII>
Write: 90020A00(66816)

[2024-05-30 16:29:12.328]# RECV ASCII>
Write: 90030F00(66816)

[2024-05-30 16:29:15.469]# RECV ASCII>
Write: 90041400(66816)

[2024-05-30 16:29:18.601]# RECV ASCII>
Write: 90051900(66816)

[2024-05-30 16:29:21.754]# RECV ASCII>
Write: 90061E00(61696)

[2024-05-30 16:29:24.658]# RECV ASCII>
Write: 90070F00(61696)

[2024-05-30 16:29:52.109]# RECV ASCII>
Init app...

[2024-05-30 16:29:52.231]# RECV ASCII>
Read: 90000000(133632)

[2024-05-30 16:29:53.167]# RECV ASCII>
Init app...

[2024-05-30 16:29:53.275]# RECV ASCII>
Read: 90020A00(133632)

[2024-05-30 16:29:54.210]# RECV ASCII>
Init app...

[2024-05-30 16:29:54.320]# RECV ASCII>
Read: 90041400(133632)

[2024-05-30 16:29:55.251]# RECV ASCII>
Init app...

[2024-05-30 16:29:55.390]# RECV ASCII>
Read: 90061E00(123392)

 

 

 

Couple of thoughts.

The page size is 256-bytes, make sure it writes suitably aligned blocks (address and length), so they don't span across boundaries. Wait for completion of PAGE WRITE

Make sure to mask the address passed to the memory. The memory has a zero-basis, it doesn't under stand anything about 0x90000000, that's an STM32 side decode range

ie

.Address = Addr & 0x0FFFFFFF; // 28-bit address

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..