Adding an image to the LCD display in bootloader mode

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Adding an image to the LCD display in bootloader mode

344件の閲覧回数
EmbeddedTech
Contributor III

Hi @kerryzhou 

I need to add a bitmap image in the bootloader code to show in the display so that the display is not blank for the initial 5 secs while checking for bootloader or application entry. Since my display size is 1024x600, I need to allocate more than 1MB for the GUI buffer. So, I want to use SDRAM to store the display buffer. When I try to add the above changes, the code does not jump to main application after 5 secs. 

Currently I am using the ota bootloader for IAR based on the below knowledge base,

RT1060 OTA bootloader ISP and swap rollback usage - NXP Community

Can I allocate sdram region,

define symbol m_guidata_start = 0x80000000;
define symbol m_guidata_end = 0x802FFFFF;

and place the ,

define block ApplicationRam { readwrite, block CodeRelocateRam, block CSTACK, block HEAP }; in sdram region.

while doing so, should I update the memory_map in the bootloader code?

Your help on this is highly appreciated.

Thanks.

0 件の賞賛
返信
5 返答(返信)

306件の閲覧回数
Sam_Gao
NXP Employee
NXP Employee

Hi,

Please try with below comments.

1. Define SDRAM Region in Linker Script: Add the following to your linker script to define the SDRAM region and place the GUI buffer there:

  

MEMORY
{
    FLASH (rx) : ORIGIN = 0x60000000, LENGTH = 0x200000 /* 2MB */
    SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x20000 /* 128KB */
    SDRAM (rwx) : ORIGIN = 0x80000000, LENGTH = 0x100000 /* 1MB */
}

SECTIONS
{
    .text :
    {
        *(.text*)
    } > FLASH

    .data :
    {
        *(.data*)
    } > SRAM AT > FLASH

    .bss :
    {
        *(.bss*)
    } > SRAM

    .guidata :
    {
        *(.guidata*)
    } > SDRAM

    .ApplicationRam :
    {
        *(.ApplicationRam*)
    } > SDRAM
}

2. Initialize SDRAM in Bootloader: Ensure your bootloader initializes the SDRAM before using it:

void SDRAM_Init(void) {
    // Configure SDRAM controller
    // Example: Set timing parameters, refresh rate, etc.

    // Initialize SDRAM
    // Example: Perform precharge, refresh operations
}

int main(void) {
    SDRAM_Init();

    // Load and display bitmap
    DisplayBitmap((uint8_t *)0x80000000);

    // Check for bootloader or application entry
    if (CheckForBootloaderEntry()) {
        BootloaderEntry();
    } else {
        JumpToApplication();
    }

    while (1) {
        // Main loop
    }
}

3. Load and Display bitmap picture, define functions to load and display the bitmap for reference.

extern uint8_t _m_guidata_start;
extern uint8_t _m_guidata_end;

#define GUIDATA_SIZE (0x2FFFFF - 0x80000000)

void DisplayBitmap(uint8_t *bitmap) {
    // Load bitmap data to SDRAM
    LoadBitmapToSDRAM((const uint8_t *)FLASH_BITMAP_ADDRESS, (uint8_t *)0x80000000, GUIDATA_SIZE);

    // Display bitmap
    // Example: Call display driver function to show bitmap
}

void LoadBitmapToSDRAM(const uint8_t *source, uint8_t *dest, size_t size) {
    memcpy(dest, source, size);
}

4. Jump to application, for examples (after 3-5 seconds to jump)

void JumpToApplication(void) {
    uint32_t *app_vector_table = (uint32_t *)APP_START_ADDRESS;
    SCB->VTOR = APP_START_ADDRESS;
    __set_MSP(app_vector_table[0]);
    void (*app_reset_handler)(void) = (void (*)(void))app_vector_table[1];
    app_reset_handler();
}

 

 

 

0 件の賞賛
返信

273件の閲覧回数
EmbeddedTech
Contributor III

Hi @Sam_Gao ,

In the bootloader_init() function, while fetching the application address,

g_bootloaderContext.activePeripheral = get_active_peripheral(); 

 

get_user_application_entry(&applicationAddress, &stackPointer);

 

if (g_bootloaderContext.imageStart != 0xffffffffu)
{
uint32_t *appVectorTable = (uint32_t *)g_bootloaderContext.imageStart;
*appEntry = appVectorTable[kInitialPC];
*appStack = appVectorTable[kInitialSP];
}
else
{
*appEntry = 0xffffffffu;
*appStack = 0xffffffffu;
}

g_bootloaderContext.imageStart is 0xffffffff so it is not jumping to the application code.

I have attached the linker file for both the ota_bootloader and application code.

Also, in bootloader_config.h I have changed as below,

#define BL_APP_VECTOR_TABLE_ADDRESS (0x60200000u)

Is there anything more which I should change for the ota_bootloader code for IAR?

Thanks.

 

 

0 件の賞賛
返信

224件の閲覧回数
Sam_Gao
NXP Employee
NXP Employee

I am not sure about how to enable some key parmeters via IAR IDE, but it is strange that it seems wrong with appVectorTable and you defined. Please help continue debug to check more with trace log.

0 件の賞賛
返信

142件の閲覧回数
EmbeddedTech
Contributor III

Hi @Sam_Gao ,

I managed to get the bitmap being displayed in bootloader mode and able to jump to application after 5 secs. But it is not consistent. Sometimes after bootloader mode the screen gradually turns white, and the debugger shows error message 'Could not stop CPU (possibly it is in sleep mode)'. Can you please help to find the root cause of this issue.

Thanks.

 

0 件の賞賛
返信

90件の閲覧回数
Sam_Gao
NXP Employee
NXP Employee

I am not sure the root casue from sw or hw, maybe there are other issues if it is not consistent, it is hard to give clear recommendations currently.

0 件の賞賛
返信