在RT-Thread使用-----TouchGfx(7)----移动Touchgfx文件到外部flash中,我们将屏幕的图片文件存储到了外部的SPI flash中,GFX通过文件系统对flash中的文件进行访问,进行显示内容的更新。如此操作我们屏幕每次更新时都需要进行外部FLASH的读取操作,并且需要提供缓冲区用来进行屏幕内容的缓冲。本章节中我们直接将显示内容存储到SRAM中,在启动GFX前将文件信息拷贝到SRAM中,GFX便可以每次直接寻址SRAM减少读取文件等操作时间。
首先进行链接文件的修改。在.ld文件中增加ExtFlashSection,FontFlashSection,FontSearchFlashSection,TextFlashSection。并将这4个section存储到SDRAM中。
/*
* linker script for STM32F429IG with GNU ld
*/
/* Program Entry, set to mark it as "used" and avoid gc */
MEMORY
{
ROM (rx) : ORIGIN =0x08000000,LENGTH =1024k
RAM (rw) : ORIGIN =0x20000000,LENGTH =192k
SPIFLASH (rwx) : ORIGIN =0x9A000000,LENGTH =32768k
SDRAM_GFX_PIC (rwx) : ORIGIN =0xC0000000,LENGTH =20480k
}
ENTRY(Reset_Handler)
_system_stack_size = 0x400;
SECTIONS
{
ExtFlashSection :
{
KEEP(*(ExtFlashSection.*))
. = ALIGN(4);
} > SDRAM_GFX_PIC
FontFlashSection :
{
KEEP(*(FontFlashSection.*))
. = ALIGN(4);
} > SDRAM_GFX_PIC
FontSearchFlashSection :
{
KEEP(*(FontSearchFlashSection.*))
. = ALIGN(4);
} > SDRAM_GFX_PIC
TextFlashSection :
{
KEEP(*(TextFlashSection.*))
. = ALIGN(4);
} > SDRAM_GFX_PIC
.text :
{
. = ALIGN(4);
_stext = .;
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
*(.text) /* remaining code */
*(.text.*) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
*(.gnu.linkonce.t*)
/* section information for finsh shell */
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
/* section information for utest */
. = ALIGN(4);
__rt_utest_tc_tab_start = .;
KEEP(*(UtestTcTab))
__rt_utest_tc_tab_end = .;
/* section information for at server */
. = ALIGN(4);
__rtatcmdtab_start = .;
KEEP(*(RtAtCmdTab))
__rtatcmdtab_end = .;
. = ALIGN(4);
/* section information for initial. */
. = ALIGN(4);
__rt_init_start = .;
KEEP(*(SORT(.rti_fn*)))
__rt_init_end = .;
. = ALIGN(4);
PROVIDE(__ctors_start__ = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE(__ctors_end__ = .);
. = ALIGN(4);
_etext = .;
} > ROM = 0
/* .ARM.exidx is sorted, so has to go in its own output section. */
__exidx_start = .;
.ARM.exidx :
{
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
/* This is used by the startup in order to initialize the .data secion */
_sidata = .;
} > ROM
__exidx_end = .;
/* .data section which is used for initialized data */
.data : AT (_sidata)
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_sdata = . ;
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
PROVIDE(__dtors_start__ = .);
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
PROVIDE(__dtors_end__ = .);
. = ALIGN(4);
/* This is used by the startup in order to initialize the .data secion */
_edata = . ;
} >RAM
.stack :
{
. = ALIGN(4);
_sstack = .;
. = . + _system_stack_size;
. = ALIGN(4);
_estack = .;
} >RAM
__bss_start = .;
.bss :
{
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_sbss = .;
*(.bss)
*(.bss.*)
*(COMMON)
. = ALIGN(4);
/* This is used by the startup in order to initialize the .bss secion */
_ebss = . ;
*(.bss.init)
} > RAM
__bss_end = .;
_end = .;
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
* Symbols in the DWARF debugging sections are relative to the beginning
* of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
}
恢复TouchGFXHAL文件为默认
启动阶段不进行bitmap操作
void TouchGFXHAL::initialize()
{
// Calling parent implementation of initialize().
//
// To overwrite the generated implementation, omit call to parent function
// and implemented needed functionality here.
// Please note, HAL::initialize() must be called to initialize the framework.
TouchGFXGeneratedHAL::initialize();
// uint16_t* cacheStartAddr =(uint16_t *)TOUCHGFX_BUFFER_ADDR;
// uint32_t cacheSize = TOUCHGFX_BUFFER_SIZE;
//
// Bitmap::removeCache();
// Bitmap::setCache(cacheStartAddr,cacheSize,1024);
// Bitmap::cacheAll();
}
blocpcopy恢复到默认
//#include "dfs_posix.h"
bool TouchGFXHAL::blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes)
{
// uint32_t dataOffset = (uint32_t) src;
// if (dataOffset >= 0x9A000000 && dataOffset < 0xA0000000)
// {
// int fd;
// struct statfs buffer;
// if (dfs_statfs("/w25qxx", &buffer) == RT_EOK)
// {
// fd = open("/w25qxx/images.bin", O_RDONLY, 0);
// if (fd < 0)
// {
// rt_kprintf("open file for read failed\n");
// return false;
// }
// dataOffset = dataOffset - 0x9A000000;
// lseek(fd, dataOffset, SEEK_SET);
// // for copying data from there.
// read(fd, (uint8_t *) dest, numBytes);
// close(fd);
// return true;
// }
// else
// {
// return false;
// }
// }
// else
// {
// // For all other addresses, just use the default implementation.
// // This is important, as blockCopy is also used for other things in the core framework.
return TouchGFXGeneratedHAL::blockCopy(dest, src, numBytes);
// }
}
GFX初始化阶段将image拷贝到SRAM
#include "dfs_posix.h"
rt_int8_t copyimage2ram()
{
int fd;
struct statfs buffer;
struct stat *buf;
if (dfs_statfs("/w25qxx", &buffer) == RT_EOK)
{
fd = open("/w25qxx/images.bin", O_RDONLY, 0);
if (fd < 0)
{
rt_kprintf("open file for read failed\n");
return 1;
}
if(stat("/w25qxx/images.bin",buf) == RT_EOK)
{
read(fd, (uint8_t *)0xC0000000, buf->st_size);
close(fd);
return 0;
}
}
return 1;
}
点击工程属性进行设置
arm-none-eabi-objcopy -O binary -j ExtFlashSection -j FontFlashSection -j FontSearchFlashSection -j TextFlashSection "${BuildArtifactFileBaseName}.elf" "images.bin"
编译文件,通过FTP将bin文件传输到SPI flash系统