hardfault on imxrt1062 with azure rtos

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

hardfault on imxrt1062 with azure rtos

379 次查看
morganRo
Contributor II

Hello everybody,

I will try to explain my issue.

I use for our project an imxrt1062 custom board with the same components on dev board (SDRAM, hyperflash), running on azure rtos with ThreadX and GuiX and a 1024*600 touch screen.

I used guix washing mashine example to start my project with the same configuration for semc, hyperflash and sdram and then adapt for my screen.

I configured sdram of 32MB with 16MB in non cacheable for pictures.

 

Here is my MPU config :

/* Region 0 setting: Instruction access disabled, No data access permission. */
    MPU->RBAR = ARM_MPU_RBAR(0, 0x00000000U);
    MPU->RASR = ARM_MPU_RASR(1, ARM_MPU_AP_NONE, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_4GB);

    /* Region 1 setting: Memory with Device type, not shareable, non-cacheable. */
    MPU->RBAR = ARM_MPU_RBAR(1, 0x80000000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_512MB);

    /* Region 2 setting: Memory with Device type, not shareable,  non-cacheable. */
    MPU->RBAR = ARM_MPU_RBAR(2, 0x60000000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_512MB);

#if defined(XIP_EXTERNAL_FLASH) && (XIP_EXTERNAL_FLASH == 1)
    /* Region 3 setting: Memory with Normal type, not shareable, outer/inner write back. */
    MPU->RBAR = ARM_MPU_RBAR(3, 0x60000000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_RO, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_64MB);
#endif

    /* Region 4 setting: Memory with Device type, not shareable, non-cacheable. */
    MPU->RBAR = ARM_MPU_RBAR(4, 0x00000000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 2, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_1GB);

    /* Region 5 setting: Memory with Normal type, not shareable, outer/inner write back */
    MPU->RBAR = ARM_MPU_RBAR(5, 0x00000000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);

    /* Region 6 setting: Memory with Normal type, not shareable, outer/inner write back */
    MPU->RBAR = ARM_MPU_RBAR(6, 0x20000000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_128KB);

    /* Region 7 setting: Memory with Normal type, not shareable, outer/inner write back */
    MPU->RBAR = ARM_MPU_RBAR(7, 0x20200000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_512KB);

    /* Region 8 setting: Memory with Normal type, not shareable, outer/inner write back */
    MPU->RBAR = ARM_MPU_RBAR(8, 0x20280000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_256KB);

    /* Region 9 setting: Memory with Normal type, not shareable, outer/inner write back */
    MPU->RBAR = ARM_MPU_RBAR(9, 0x80000000U);
    MPU->RASR = ARM_MPU_RASR(0, ARM_MPU_AP_FULL, 0, 0, 1, 1, 0, ARM_MPU_REGION_SIZE_16MB);
    /* Region 9 setting: Memory with Normal type, not shareable, outer/inner write back */
	MPU->RBAR = ARM_MPU_RBAR(10, 0x81000000U);
	MPU->RASR = ARM_MPU_RASR(1, ARM_MPU_AP_FULL, 1, 0, 0, 0, 0, ARM_MPU_REGION_SIZE_16MB);

I use guix timer for refresh data, actually I'm just using basing send can frame to check :

/* Define main entry point.  */
int main(VOID)
{
    /* Init board hardware. */
    BOARD_ConfigMPU();
    BOARD_InitBootPins();
    BOARD_InitBootClocks();

    RUN_Init();

    CLOCK_InitSysPfd(kCLOCK_Pfd2, 29);
    /* Set semc clock to 163.86 MHz */
    CLOCK_SetMux(kCLOCK_SemcMux, 1);
    CLOCK_SetDiv(kCLOCK_SemcDiv, 1);

    HAL_SEMC_InitSEMC();

    /* perform LCD initialization */
    gx_lcd_board_setup();

    /* Enter the ThreadX kernel.  */
    tx_kernel_enter();

    return 0;
}

/******************************************************************************************/
/* Define memory allocator function.                                                     */
/******************************************************************************************/
VOID *memory_allocate(ULONG size)
{
    VOID *memptr;

    if (tx_byte_allocate(&memory_pool, &memptr, size, TX_NO_WAIT) == TX_SUCCESS)
    {
        return memptr;
    }
    return NULL;
}

/******************************************************************************************/
/* Define memory de-allocator function.                                                   */
/******************************************************************************************/
void memory_free(VOID *mem)
{
    tx_byte_release(mem);
}

/* Define what the initial system looks like.  */

void tx_application_define(void *first_unused_memory)
{
    /* create byte pool. */
    tx_byte_pool_create(&memory_pool, "scratchpad", scratchpad, BUFFER_SIZE);

    RUN_WDT_Refresh();

    guix_startup();
}

void guix_startup(void)
{
    /* Initialize GUIX. */
    gx_system_initialize();

    /* install our memory allocator and de-allocator */
    gx_system_memory_allocator_set(memory_allocate, memory_free);

    /* Instantiate24 bpp 8:8:8 format display driver */
    gx_studio_display_configure(CUID, gx_display_driver_imxrt10xx_24xrgb_setup, LANGUAGE_ENGLISH,
                                CUID_THEME_1, &root);

    gx_canvas_hardware_layer_bind(root->gx_window_root_canvas, 0);

    /* Create the main screen and attach it to root window. */
    gx_studio_named_widget_create("windowCatheterMode", (GX_WIDGET *)root, GX_NULL);

    /* window on Microcatheter moving mode. */
    gx_studio_named_widget_create("windowMicroCatheterMode", GX_NULL, GX_NULL);

    /* window on boot mode. */
    gx_studio_named_widget_create("windowBootScreen", GX_NULL, GX_NULL);

    /* window on Emergency mode. */
    gx_studio_named_widget_create("windowEmergencyStop", GX_NULL, GX_NULL);

    /* window on Track change mode. */
    gx_studio_named_widget_create("windowTrackChange", GX_NULL, GX_NULL);

    /* Show the root window to make it and main screen visible.  */
    gx_widget_show(root);

    /* Let GUIX run */
    gx_system_start();
}

UINT eventWindowCatheter(GX_WINDOW *widget, GX_EVENT *event_ptr)
{
	switch (event_ptr->gx_event_type) 
    {
		case GX_EVENT_SHOW:
            RUN_Windows_SetWidget(widget);
            /* Init widget */
			RUN_Timer_Init();
            gx_system_timer_start((GX_WIDGET *)widget, CLOCK_TIMER, 1, 1);
            			/* *** */
			gx_window_event_process(widget, event_ptr);
			break;
		case GX_EVENT_TIMER:
			RUN_Windows_SetWidget(widget);
			RUN_CAN();
			//RUN_Timer_Scheduler();
			gx_window_event_process(widget, event_ptr);
			break;

		default:
			gx_window_event_process(widget, event_ptr);
	}
	return 0;
}

 

I don't what i'm doing wrong, bad memory configuration, bad azure configuration?

 

Someone can help me?

 

Thanks

Morgan

 

0 项奖励
回复
0 回复数