This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

EMIF writing error with FreeRTOS on RM48

Other Parts Discussed in Thread: RM48L950, HALCOGEN

Hello.

I have a problem to use EMIF with FreeRTOS on RM48. There is a 'dummy write pulses' problem in RM48, it is reported in errata already. It is avoided by using MPU configuration. But the problem is occured again when I use FreeRTOS, because the FreeRTOS changes the MPU configuration. Is there any solution for this issue?

Best Regards,

Wonjae Kim.

  • Hi Kim,

    From looking at the FreeRTOS source I can see that it uses MPU regions 0 - 4 for it's own purpose and regions 5 - 7 are user configurable on per Task basis:

    /* Default MPU regions */
    #define portUNPRIVILEGED_FLASH_REGION			( 0UL )
    #define portPRIVILEGED_FLASH_REGION				( 1UL )
    #define portPRIVILEGED_RAM_REGION				( 2UL )
    #define portGENERAL_PERIPHERALS_REGION			( 3UL )
    #define portSTACK_REGION						( 4UL )
    #define portFIRST_CONFIGURABLE_REGION	    	( 5UL )
    #define portLAST_CONFIGURABLE_REGION			( 7UL )
    #define portNUM_CONFIGURABLE_REGIONS			( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 )
    #define portTOTAL_NUM_REGIONS					( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */

    (portmacro.h)

    The RM 48 MCU has got 12 regions, from which are the first 8 used by FreeRTOS. So if you use one of the last 4 regions for the EMIF access, then these shouldn't be overwritten by FreeRTOS.

    Another solution would be to define each Task in which you will access the EMIF as a restricted one and provide a MPU region for the EMIF access with it:

    static const xTaskParameters xTaskParamters1={
    		vTask1,				  /* Function that implements the task */
    		(const signed char *)"Blinky",/* Just a text name for the task to assist debugging */
    		configMINIMAL_STACK_SIZE,     /* Stack size */
    		NULL,                         /* Parametrs to be passed to the task function */
    		1,                            /* Task Priority. set the portPRIVILEGE_BIT (1|portPRIVILEGE_BIT) if the task should run in a privileged state*/
    		stackbuffer,                  /* Buffer to be used as the task stack */
    		/* xRegions - Allocate up to three separate memory regions for access by the task, with appropriate access permissions.*/
    		/* No region is set in this example. */
    		{						/*  Base address					Length	Parameters                            */
    			{0,0,0},            /* { cReadWriteArray,				32,		portMPU_REGION_READ_WRITE },          */
    			{0,0,0},            /* { cReadOnlyArray,			   	32,		portMPU_REGION_READ_ONLY },           */
    			{0,0,0}             /* { cPrivilegedOnlyAccessArray,	128,	portMPU_REGION_PRIVILEGED_READ_WRITE }*/
    		}
    };

    (example_freeRTOSRestrictedTask.c)

    Best Regards,
    Christian

  • Hello Christian,

    It is different your code and my code. I did make a project using HALCoGen 4.02 for RM48L950_FREERTOS. This is my code in 'portmacro.h'.

    /* Default MPU regions */
    #define portUNPRIVILEGED_FLASH_REGION		    ( 0UL )
    #define portPRIVILEGED_FLASH_REGION			    ( 1UL )
    #define portPRIVILEGED_RAM_REGION			    ( 2UL )
    #define portGENERAL_PERIPHERALS_REGION		    ( 3UL )
    #define portSTACK_REGION					    ( 4UL - 1UL )
    #define portFIRST_CONFIGURABLE_REGION	        ( 5UL - 1UL )
    #define portLAST_CONFIGURABLE_REGION		    ( portMPU_TOTAL_REGIONS - 2 )
    #define portPRIVILEGED_SYSTEM_REGION            ( portMPU_TOTAL_REGIONS - 1 )
    #define portNUM_CONFIGURABLE_REGIONS		    ( ( portLAST_CONFIGURABLE_REGION - portFIRST_CONFIGURABLE_REGION ) + 1 )
    #define portTOTAL_NUM_REGIONS				    ( portNUM_CONFIGURABLE_REGIONS + 1 ) /* Plus one to make space for the stack region. */
    


    Although there is a diffrence, I tried to change the region number as 9 or 11, but it is not cleared. Could you give me more tip?

    Best Regards,

    Wonjae Kim.

  • Hi Kim,

    I copied it from the HALCoGen 4.01.00 source, its seems that this has changed in HCG 4.02.00.
    However it looks like a bug to me as the following two entries would use the same MPU region:

    #define portGENERAL_PERIPHERALS_REGION ( 3UL )
    #define portSTACK_REGION ( 4UL - 1UL )

    I will submit a bug report on this.

    Best Regards,
    Christian
  • Hello, Christian.

    I also think those two defines have a problem.. On the other hand, How can I revise the MPU region configuration?

    Best Regards,

    Wonjae

  • Hi Kim,

    First of all, please take in consideration that the FreeRTOS isn't made for safety applications. There are several safety certified or certify able RTOS available from third parties, SafeRTOS is one of them you can find a more complete list on our web page:

    You can either use the xTaskCreateRestricted API or configure one of the remaining (not used by FreeRTOS) MPU regions for your purpose. An example how to use the xTaskCreateRestricted API can be found in the example_freeRTOSRestrictedTask.c as part of HALCoGen.

    Best Regards,
    Christian