cancel
Showing results for 
Search instead for 
Did you mean: 

I can't save images on external Flash Memory correctly

LCris.1
Associate II

Hi,

I have a custom board with STM32H7A3 using FMC, LLTC and other modules. I started to develop the firmware to change some images in a display. I made one project on TouchGFX with multiple images and fonts. I verify the BitmapDatabase.cpp and the all images files generated. For each image file generated for example:

LOCATION_PRAGMA("ExtFlashSection")
KEEP extern const unsigned char image_attention_all[] LOCATION_ATTRIBUTE("ExtFlashSection") = { // 223x265 RGB888 pixels.
    0x0b, 0xba, 0xf7, 0x0b, 0xba, 0xf7, 0x0b, 0xba, 0xf7, 0x0b, 0xba, 0xf7,
...
...}

In my application.ld file I put that configurations that I view on https://support.touchgfx.com/4.18/docs/development/scenarios/using-non-memory-mapped-flash

/* Specify the memory areas */
MEMORY
{
DTCMRAM (xrw)      : ORIGIN = 0x20000000, LENGTH = 128K
RAM (xrw)      : ORIGIN = 0x24000000, LENGTH = 1024K
ITCMRAM (xrw)      : ORIGIN = 0x00000000, LENGTH = 64K
FLASH1 (rx)      : ORIGIN = 0x8000000, LENGTH = 512K
FLASH2 (rx)      : ORIGIN = 0x8100000, LENGTH = 512K
NOR1 (rx)      : ORIGIN = 0x60000000, LENGTH = 64M          /*External NOR Memory*/
SRAM (xrw)     : ORIGIN = 0x62000000, LENGTH = 4M          /*External SRAM Memory*/
}

.ARM.attributes 0 : { *(.ARM.attributes) }
	ExtFlashSection :
	{
		*(ExtFlashSection ExtFlashSection.*)
		*(.gnu.linkonce.r.*)
        . = ALIGN(0x4);
	} >NOR1
 
  FontFlashSection :
	{
		*(FontFlashSection FontFlashSection.*)
		*(.gnu.linkonce.r.*)
        . = ALIGN(0x4);
	} >NOR1
 
  TextFlashSection :
	{
		*(TextFlashSection TextFlashSection.*)
		*(.gnu.linkonce.r.*)
        . = ALIGN(0x4);
	} >NOR1

When I try to build the program I have section output from compiler:

0693W00000KZdXTQA1.pngWhat I'm doing wrong?

I only can write some program inside NOR1 when I change part of linker like:

 /*Original data without write anything on NOR
 /* Constant data goes into FLASH 
  .rodata :
  {
    . = ALIGN(4);
    *(.rodata)         /* .rodata sections (constants, strings, etc.) 
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) 
    . = ALIGN(4);
  } >FLASH1
*/
 
  /* Constant data goes into FLASH */
  .rodata :
  {
    . = ALIGN(4);
    *(.rodata)         /* .rodata sections (constants, strings, etc.) */
    *(.rodata*)        /* .rodata* sections (constants, strings, etc.) */
    . = ALIGN(4);
  } >NOR1

0693W00000KZddqQAD.pngWhat am I doing wrong? How can I have a sure that I write all images files in External Flash?

Best regards,

Luis Cristovao

1 ACCEPTED SOLUTION

Accepted Solutions
MM..1
Chief III

Your one image have around 170kB and isnt on any area linked, then error is in your makefile.

View solution in original post

9 REPLIES 9
MM..1
Chief III

Are youy sure, that build is over images cpp files ?

And i see one problem

NOR1 (rx)      : ORIGIN = 0x60000000, LENGTH = 64M          /*External NOR Memory*/
SRAM (xrw)     : ORIGIN = 0x62000000, LENGTH = 4M          /*External SRAM Memory*/

64M ends override SRAM section +32M

LCris.1
Associate II

Thanks for your reply MM..1

This morning I verify that SRAM need to be ORIGIN=0x64000000.

I think that I have the correct setting to build the project. I use Visual Studio Code with arm-none-eabi-gcc MakeFile . I add all images files (.cpp) generated by TouchGFX to my CmakeList.

What do you mean build is over images cpp files? Sorry because I never worked before with this type of architecture, I only worked before with microcontrollers PIC32.

Best regards, Luis

Thanks for your reply MM..1

This morning I verify that SRAM need to be ORIGIN=0x64000000.

I think that I have the correct setting to build the project. I use Visual Studio Code with arm-none-eabi-gcc MakeFile . I add all images files (.cpp) generated by TouchGFX to my CmakeList.

What do you mean build is over images cpp files? Sorry because I never worked before with this type of architecture, I only worked before with microcontrollers PIC32.

Best regards, Luis

MM..1
Chief III

Your one image have around 170kB and isnt on any area linked, then error is in your makefile.

What type of error? Can be anything with flags that I used?

I have this code CMakeList.txt:

cmake_minimum_required(VERSION 3.10)
 
# This is due to cross-compiling C/C++
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
 
project(project C CXX ASM)
 
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
 
set(FREERTOS_ENABLE 1)
set(FREERTOS_HEAP_TYPE 4)
set(CMSIS_RTOS_VERSION 2)
 
add_executable(project_target_elf
    TouchGFX/App/app_touchgfx.c
    TouchGFX/generated/gui_generated/src/containers/Safe_ModeBase.cpp
    TouchGFX/generated/gui_generated/src/containers/Normal_ModeBase.cpp
    TouchGFX/generated/gui_generated/src/containers/Attention_ModeBase.cpp
    TouchGFX/generated/gui_generated/src/containers/TopBarBase.cpp
    TouchGFX/generated/gui_generated/src/mainscrenn_screen/MainScrennViewBase.cpp
    TouchGFX/generated/gui_generated/src/common/FrontendApplicationBase.cpp
    TouchGFX/gui/src/containers/Attention_Mode.cpp
    TouchGFX/gui/src/containers/Normal_Mode.cpp
    TouchGFX/gui/src/containers/TopBar.cpp
    TouchGFX/gui/src/containers/Safe_Mode.cpp
    TouchGFX/target/generated/STM32DMA.cpp
    TouchGFX/target/generated/OSWrappers.cpp
    TouchGFX/target/generated/TouchGFXConfiguration.cpp
    TouchGFX/target/generated/TouchGFXGeneratedHAL.cpp
    TouchGFX/target/TouchGFXHAL.cpp
    TouchGFX/target/STM32TouchController.cpp
    TouchGFX/target/TouchGFXGPIO.cpp
    TouchGFX/target/generated/STM32DMA.cpp
    TouchGFX/target/generated/OSWrappers.cpp
    TouchGFX/target/TouchGFXGPIO.cpp
    TouchGFX/gui/src/mainscrenn_screen/MainScrennView.cpp
    TouchGFX/gui/src/mainscrenn_screen/MainScrennPresenter.cpp
    TouchGFX/gui/src/common/FrontendApplication.cpp
    TouchGFX/gui/src/model/Model.cpp
    TouchGFX/generated/images/src/image_Attention.cpp
    TouchGFX/generated/images/src/image_Attention_all.cpp
    Core/Src/main.c
    Core/Src/stm32h7xx_it.c
    Core/Src/stm32h7xx_hal_msp.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hsem.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_exti.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_fdcan.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_fmc.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_nor.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sram.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ltdc.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ltdc_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c
    Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c
    Core/Src/system_stm32h7xx.c   
    Core/Src/freertos.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/croutine.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/event_groups.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/list.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/queue.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/stream_buffer.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/tasks.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/timers.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/CMSIS_RTOS_V2/cmsis_os2.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/portable/MemMang/heap_4.c
    ../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/portable/GCC/ARM_CM4F/port.c
    Core/Src/stm32h7xx_hal_timebase_tim.c
    target/startup/startup_stm32h7a3xx.s
)
 
target_include_directories(project_target_elf
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/Middlewares/ST/touchgfx
        ${CMAKE_CURRENT_SOURCE_DIR}/Middlewares/ST/touchgfx/framework/include
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/App/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/target/generated/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/target/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/gui/include
        ${CMAKE_CURRENT_SOURCE_DIR}/Core/Inc/
        ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Inc/
        ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy/
        ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32H7xx/Include/
        ${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Include/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/gui_generated/include/gui_generated/containers
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/gui_generated/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/gui_generated/include/gui_generated/mainscrenn_screen
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/gui_generated/images/include
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/fonts/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/gui_generated/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/images/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/texts/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/generated/videos/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/TouchGFX/gui/include/
        ${CMAKE_CURRENT_SOURCE_DIR}/../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/CMSIS_RTOS_V2
        ${CMAKE_CURRENT_SOURCE_DIR}/../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/include
        ${CMAKE_CURRENT_SOURCE_DIR}/../../../../submodules/stm/stm32h7/Middlewares/Third_Party/stm32_mw_freertos/Source/portable/GCC/ARM_CM4F
)
 
set_target_properties(project_target_elf PROPERTIES OUTPUT_NAME "project_target")
set_target_properties(project_target_elf PROPERTIES SUFFIX ".elf")
 
 
target_compile_options(project_target_elf
    PRIVATE
        -Wextra
        -Wall
        -pedantic
        -Wno-unused
        -Werror=implicit-function-declaration
)
 
 
add_subdirectory(../../../../submodules/asglobal/c/ deps/asglobal/)
add_subdirectory(../../../../submodules/stm/stm32h7 deps/vendor/stm)
 
target_include_directories(stm32h7xx_hal_driver
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/Core/Inc/
)
 
target_include_directories(stm32_mw_freertos
    PRIVATE
        ${CMAKE_CURRENT_SOURCE_DIR}/Core/Inc/
        ${CMAKE_CURRENT_SOURCE_DIR}/tracealyzer/Inc/   
)
 
target_compile_definitions(project_target_elf
    PRIVATE
        -DMCPU
        -DUSE_HAL_DRIVER
)
 
target_link_options(project_target_elf
    PUBLIC
        -Wl,-Map=${CMAKE_CURRENT_SOURCE_DIR}/target/mapfile.txt
        -T${CMAKE_CURRENT_SOURCE_DIR}/target/application.ld
)
 
add_custom_command(
    OUTPUT project_target.hex
    COMMAND arm-none-eabi-objcopy -O ihex project_target.elf project_target.hex
    DEPENDS project_target_elf
    COMMENT "Creating hex file"
    VERBATIM
)
 
add_custom_command(
    OUTPUT project_target.bin
    COMMAND arm-none-eabi-objcopy -O binary project_target.elf project_target.bin
    DEPENDS project_target_elf
    COMMENT "Creating binary file"
    VERBATIM
)
 
add_custom_target(project_target ALL
    COMMAND arm-none-eabi-size project_target.elf
    DEPENDS project_target_elf
    DEPENDS project_target.hex
    DEPENDS project_target.bin
)

And the Cmake file have:

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR arm)
 
set(CMAKE_C_COMPILER "arm-none-eabi-gcc.exe")
 
set(CMAKE_C_FLAGS 
    "-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -DSTM32H7A3xx -DSTM32H7A3xx -fmessage-length=0 -ffunction-sections"
)
 
set(CMAKE_CXX_FLAGS 
    "-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 -DSTM32H7A3xx -DSTM32H7A3xx -fmessage-length=0 -ffunction-sections"
)
 
set(CMAKE_EXE_LINKER_FLAGS
    "-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-d16 --specs=nosys.specs -specs=nano.specs -Wl,--print-memory-usage -Wl,--gc-sections -Wl,--unresolved-symbols=ignore-in-object-files"
)
 
 
set(CMAKE_C_FLAGS_DEBUG "-O0 -g3")
set(CMAKE_C_FLAGS_RELEASE "-O3 -g0")
 
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

Thanks for your help.

here miss BitmapDatabase.cpp maybe more

i dont help you i preffer IDE or KEIL

I tried before with BitmapDatabase.cpp and the size of program don't change. Thanks for your help, I try to search more about it.

Thanks MM1, I solved my problem looking to the problem with other ideas.

The problem that I don't have any compiler to build .cpp files.

set(CMAKE_C_COMPILER "arm-none-eabi-gcc.exe")
set(CMAKE_CXX_COMPILER "arm-none-eabi-g++.exe")

Thanks a lot for your help :grinning_face:

My first linetip ... Are you sure, that build is over images cpp files ?

Marks some as Best reply for mark thread as solved...