Skip to content

Conversation

@ravibhagavandas
Copy link
Contributor

@ravibhagavandas ravibhagavandas commented Aug 22, 2020

Update Renesas GCC compiler ports

Description

This contains the changes for Renesas GCC compiler ports, authored in PR #89, rebased to latest master branch. Also it fixes the ports as per the proposal in the PR

Test Steps

Demos for Renesas GCC compiler ports fails without the fix mentioned above.

https://github.com/FreeRTOS/FreeRTOS/tree/master/FreeRTOS/Demo/RX200_RX231-RSK_GCC_e2studio_IAR
https://github.com/FreeRTOS/FreeRTOS/tree/master/FreeRTOS/Demo/RX600_RX64M_RSK_GCC_e2studio

Related Issue

#89

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ravibhagavandas
Copy link
Contributor Author

@VanNamDinh @NoMaY-jp

@NoMaY-jp
Copy link
Contributor

NoMaY-jp commented Aug 23, 2020

Hello ravibhagavandas and n9wxu,

Thank you for taking care of Renesas RX MCU projects. (But I'm not an engineer of Renesas Electronics Corporation. I'm one of users of Japanese forum regarding to Renesas MCUs.) I want your advice.

I'm trying to fix build errors of RTOSDemo projects regarding to Renesas RX MCUs and to add more IDEs which can build the projects. But missing evaluation boards at my side bothers me. Do you think that I can post a pull request only with build check passed but without any check using evaluation boards?

If I can post a pull request without evaluation boards, it makes me easier to do such things regarding to fixing build errors and adding more IDEs.

For example, only one line change is enough to fix build error which was already discussed in the following thread.

Compiler error when building FreeRTOS for Renesas RX113 (RX100) Demo
https://forums.freertos.org/t/compiler-error-when-building-freertos-for-renesas-rx113-rx100-demo/9529/5

SOURCE:

FreeRTOSConfig.h

WRONG:

#define configTICK_VECTOR VECT_CMT0_CMI0

FIXED:

#define configTICK_VECTOR _CMT0_CMI0

NOTE:

In my environment, the following error which was mentioned in the following post is not displayed and I can build the both projects. (But 'warning' message and 'information' message are displayed.)

Compiler error when building FreeRTOS for Renesas RX113 (RX100) Demo <-- the same thread as above
https://forums.freertos.org/t/compiler-error-when-building-freertos-for-renesas-rx113-rx100-demo/9529/6

E0552113:Symbol definition is not appropriate

Best regards,
NoMaY

@VanNamDinh
Copy link
Contributor

Hi @ravibhagavandas, thank you so much for your merge.
Hi @NoMaY-jp, I will check build on my environment. Thank you so much for your activities.

@ravibhagavandas
Copy link
Contributor Author

Hello ravibhagavandas and n9wxu,

Thank you for taking care of Renesas RX MCU projects. (But I'm not an engineer of Renesas Electronics Corporation. I'm one of users of Japanese forum regarding to Renesas MCUs.) I want your advice.

I'm trying to fix build errors of RTOSDemo projects regarding to Renesas RX MCUs and to add more IDEs which can build the projects. But missing evaluation boards at my side bothers me. Do you think that I can post a pull request only with build check passed but without any check using evaluation boards?

If I can post a pull request without evaluation boards, it makes me easier to do such things regarding to fixing build errors and adding more IDEs.

For example, only one line change is enough to fix build error which was already discussed in the following thread.

Compiler error when building FreeRTOS for Renesas RX113 (RX100) Demo
https://forums.freertos.org/t/compiler-error-when-building-freertos-for-renesas-rx113-rx100-demo/9529/5

SOURCE:

FreeRTOSConfig.h

WRONG:

#define configTICK_VECTOR VECT_CMT0_CMI0

FIXED:

#define configTICK_VECTOR _CMT0_CMI0

NOTE:

In my environment, the following error which was mentioned in the following post is not displayed and I can build the both projects. (But 'warning' message and 'information' message are displayed.)

Compiler error when building FreeRTOS for Renesas RX113 (RX100) Demo <-- the same thread as above
https://forums.freertos.org/t/compiler-error-when-building-freertos-for-renesas-rx113-rx100-demo/9529/6

E0552113:Symbol definition is not appropriate

Best regards,
NoMaY

We always recommend to run the demo on the evaluation board to make sure it works, if there is a change in the runtime functionality. Looking at the change mentioned above, its only modifying a macro while underlying value remains same so its not a major change. Are there other RX demos which have this issue? If so is it possible to run on one of them?

@alfred2g alfred2g merged commit 1d8df47 into FreeRTOS:master Aug 24, 2020
@NoMaY-jp
Copy link
Contributor

Hello @ravibhagavandas and @VanNamDinh,

Thank you for reply. Regarding to the RX113/RX100 issue, please look at the following search result. I think that you can notice that '#define configTICK_VECTOR VECT_CMT0_CMI0' is for IAR(ICCRX) but somehow this definition is used for Renesas(CC-RX) in case of RX113/RX100. And not only search result but also source codes of port layer show us that '#define configTICK_VECTOR _CMT0_CMI0' has to be used for Renesas(CC-RX) in case of RX113/RX100.

Port layer using IAR(ICCRX)

IAR/RX100/port.c:               #pragma vector = configTICK_VECTOR
IAR/RX600/port.c:               #pragma vector = configTICK_VECTOR
IAR/RXv2/port.c:                #pragma vector = configTICK_VECTOR
IAR/RX700v3_DPFPU/port.c:       FreeRTOS v10.3.1 does not have this port.

Port layer using GCC(GNURX)

GCC/RX100/port.c:               FreeRTOS v10.3.1 does not use configTICK_VECTOR in this port.
GCC/RX200/port.c:               FreeRTOS v10.3.1 does not have this port.
GCC/RX600/port.c:               FreeRTOS v10.3.1 does not use configTICK_VECTOR in this port.
GCC/RX600v2/port.c:             FreeRTOS v10.3.1 does not use configTICK_VECTOR in this port.
GCC/RX700v3_DPFPU/port.c:       FreeRTOS v10.3.1 does not have this port.

Port layer using Renesas(CC-RX)

Renesas/RX100/port.c:           #pragma interrupt ( prvTickISR( vect = _VECT( configTICK_VECTOR ), enable ) )
Renesas/RX200/port.c:           #pragma interrupt ( vTickISR( vect = _VECT( configTICK_VECTOR ), enable ) )
Renesas/RX600/port.c:           #pragma interrupt ( vTickISR( vect = _VECT( configTICK_VECTOR ), enable ) )
Renesas/RX600v2/port.c:         #pragma interrupt ( vTickISR( vect = _VECT( configTICK_VECTOR ), enable ) )
Renesas/RX700v3_DPFPU/port.c:   FreeRTOS v10.3.1 does not have this port.

RTOSDemo using IAR(ICCRX) or GCC(GNURX)

RX100-RSK_IAR/FreeRTOSConfig.h:                             #define configTICK_VECTOR   VECT_CMT0_CMI0          <-- IAR demo only
RX100_RX113-RSK_GCC_e2studio_IAR/src/FreeRTOSConfig.h:      #define configTICK_VECTOR   VECT_CMT0_CMI0          <-- only used in IAR port
RX200_RX231-RSK_GCC_e2studio_IAR/src/FreeRTOSConfig.h:      #define configTICK_VECTOR   VECT_CMT0_CMI0          <-- only used in IAR port
RX600_RX62N-RDK_IAR/FreeRTOSConfig.h:                       #define configTICK_VECTOR   28 /*VECT_CMT0_CMI0*/   <-- IAR demo only
RX600_RX62N-RSK_IAR/FreeRTOSConfig.h:                       #define configTICK_VECTOR   28 /*VECT_CMT0_CMI0*/   <-- IAR demo only
RX600_RX64M_RSK_GCC_e2studio/src/FreeRTOSConfig.h:          #define configTICK_VECTOR   _CMT0_CMI0              <-- GCC demo only but not used in GCC port
RX700_RX71M_RSK_GCC_e2studio_IAR/src/FreeRTOSConfig.h:      #define configTICK_VECTOR   28 /*vect _CMT0_CMI0*/  <--only used in IAR port
RX700_RX72N_EnvisionKit_GCC_e2studio                        FreeRTOS v10.3.1 does not have this demo.
RX700_RX72N_EnvisionKit_IAR_e2studio_EWRX                   FreeRTOS v10.3.1 does not have this demo.

RTOSDemo using Renesas(CC-RX)

RX100-RSK_Renesas_e2studio/RTOSDemo/FreeRTOSConfig.h:       #define configTICK_VECTOR   VECT_CMT0_CMI0  <-- mistakenly used
RX100_RX113-RSK_Renesas_e2studio/src/FreeRTOSConfig.h:      #define configTICK_VECTOR   VECT_CMT0_CMI0  <-- mistakenly used
RX200_RX210-RSK_Renesas/RTOSDemo/FreeRTOSConfig.h:          #define configTICK_VECTOR   _CMT0_CMI0
RX200_RX231-RSK_Renesas_e2studio/src/FreeRTOSConfig.h:      #define configTICK_VECTOR   _CMT0_CMI0
RX600_RX62N-RDK_Renesas/RTOSDemo/FreeRTOSConfig.h:          #define configTICK_VECTOR   _CMT0_CMI0
RX600_RX62N-RSK_Renesas/RTOSDemo/FreeRTOSConfig.h:          #define configTICK_VECTOR   _CMT0_CMI0
RX600_RX630-RSK_Renesas/RTOSDemo/FreeRTOSConfig.h:          #define configTICK_VECTOR   _CMT0_CMI0
RX600_RX63N-RDK_Renesas/RTOSDemo/FreeRTOSConfig.h:          #define configTICK_VECTOR   _CMT0_CMI0
RX600_RX64M_RSK_Renesas_e2studio/Source/FreeRTOSConfig.h:   #define configTICK_VECTOR   _CMT0_CMI0
RX700_RX71M_RSK_Renesas_e2studio/src/FreeRTOSConfig.h:      #define configTICK_VECTOR   _CMT0_CMI0
RX700_RX72N_EnvisionKit_Renesas_e2studio_CS+                FreeRTOS v10.3.1 does not have this demo.

Source/portable/Renesas/RX100/port.c:

#pragma interrupt ( prvTickISR( vect = _VECT( configTICK_VECTOR ), enable ) )
void prvTickISR( void )
{
    /* Increment the tick, and perform any processing the new tick value
    necessitates. */
    set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY );
    {
        if( xTaskIncrementTick() != pdFALSE )
        {
            taskYIELD();
        }
    }
    set_ipl( configKERNEL_INTERRUPT_PRIORITY );

    #if configUSE_TICKLESS_IDLE == 1
    {
        /* The CPU woke because of a tick. */
        ulTickFlag = pdTRUE;

        /* If this is the first tick since exiting tickless mode then the CMT
        compare match value needs resetting. */
        CMT0.CMCOR = ( uint16_t ) ulMatchValueForOneTick;
    }
    #endif
}

Source/portable/Renesas/{RX200, RX600, RX600v2}/port.c:

#pragma interrupt ( vTickISR( vect = _VECT( configTICK_VECTOR ), enable ) )
void vTickISR( void )
{
    /* Increment the tick, and perform any processing the new tick value
    necessitates. */
    set_ipl( configMAX_SYSCALL_INTERRUPT_PRIORITY );
    {
        if( xTaskIncrementTick() != pdFALSE )
        {
            taskYIELD();
        }
    }
    set_ipl( configKERNEL_INTERRUPT_PRIORITY );
}

Best regards,
NoMaY

@NoMaY-jp
Copy link
Contributor

Hello @VanNamDinh (and @ravibhagavandas and @n9wxu),

Yesterday I understood that GCC/RX200 port was newly added (but no test program was added). Moreover today I notice that the port is wrong.

The port should be for RX200 group MCUs using RXv1 CPU core but without FPU. RXv1 CPU core has only one accumulator. (On the other hand, RXv2 and RXv3 CPU cores has two accumulators.) Nevertheless the port attempts to save/restore FPSW(FPU's PSW) and two accumulators(using RXv2 CPU core instructions)! (Please compare GCC/RX200/port.c and Renesas/RX200/port.c.)

GCC/RX200/port.c

WRONG:

L166:

    pxTopOfStack--;
    *pxTopOfStack = portINITIAL_FPSW;
    pxTopOfStack--;
    *pxTopOfStack = 0x11111111; /* Accumulator 0. */
    pxTopOfStack--;
    *pxTopOfStack = 0x22222222; /* Accumulator 0. */
    pxTopOfStack--;
    *pxTopOfStack = 0x33333333; /* Accumulator 0. */
    pxTopOfStack--;
    *pxTopOfStack = 0x44444444; /* Accumulator 1. */
    pxTopOfStack--;
    *pxTopOfStack = 0x55555555; /* Accumulator 1. */
    pxTopOfStack--;
    *pxTopOfStack = 0x66666666; /* Accumulator 1. */

L238:

        /* Restore the registers from the stack of the task pointed to by
        pxCurrentTCB. */
        "POP        R15                     \n" \

        /* Accumulator low 32 bits. */
        "MVTACLO    R15, A0                 \n" \
        "POP        R15                     \n" \

        /* Accumulator high 32 bits. */
        "MVTACHI    R15, A0                 \n" \
        "POP        R15                     \n" \

        /* Accumulator guard. */
        "MVTACGU    R15, A0                 \n" \
        "POP        R15                     \n" \

        /* Accumulator low 32 bits. */
        "MVTACLO    R15, A1                 \n" \
        "POP        R15                     \n" \

        /* Accumulator high 32 bits. */
        "MVTACHI    R15, A1                 \n" \
        "POP        R15                     \n" \

        /* Accumulator guard. */
        "MVTACGU    R15, A1                 \n" \
        "POP        R15                     \n" \

        /* Floating point status word. */
        "MVTC       R15, FPSW               \n" \

L314:

        /* Save the FPSW and accumulator. */
        "MVFC       FPSW, R15                   \n" \
        "PUSH.L     R15                         \n" \
        "MVFACGU    #0, A1, R15                 \n" \
        "PUSH.L     R15                         \n" \
        "MVFACHI    #0, A1, R15                 \n" \
        "PUSH.L     R15                         \n" \
        /* Low order word. */
        "MVFACLO    #0, A1, R15                 \n" \
        "PUSH.L     R15                         \n" \
        "MVFACGU    #0, A0, R15                 \n" \
        "PUSH.L     R15                         \n" \
        "MVFACHI    #0, A0, R15                 \n" \
        "PUSH.L     R15                         \n" \
        /* Low order word. */
        "MVFACLO    #0, A0, R15                 \n" \
        "PUSH.L     R15                         \n" \

L353:

        /* Restore the context of the new task.  The PSW (Program Status Word) and
        PC will be popped by the RTE instruction. */
        "POP        R15                         \n" \

        /* Accumulator low 32 bits. */
        "MVTACLO    R15, A0                     \n" \
        "POP        R15                         \n" \

        /* Accumulator high 32 bits. */
        "MVTACHI    R15, A0                     \n" \
        "POP        R15                         \n" \

        /* Accumulator guard. */
        "MVTACGU    R15, A0                     \n" \
        "POP        R15                         \n" \

        /* Accumulator low 32 bits. */
        "MVTACLO    R15, A1                     \n" \
        "POP        R15                         \n" \

        /* Accumulator high 32 bits. */
        "MVTACHI    R15, A1                     \n" \
        "POP        R15                         \n" \

        /* Accumulator guard. */
        "MVTACGU    R15, A1                     \n" \
        "POP        R15                         \n" \
        "MVTC       R15, FPSW                   \n" \

CORRECT(probably correct but not tested):

    pxTopOfStack--;
    *pxTopOfStack = 0x12345678; /* Accumulator. */
    pxTopOfStack--;
    *pxTopOfStack = 0x87654321; /* Accumulator. */

`

        /* Restore the registers from the stack of the task pointed to by
        pxCurrentTCB. */
        "POP        R15                     \n" \

        /* Accumulator low 32 bits. */
        "MVTACLO    R15                     \n" \
        "POP        R15                     \n" \

        /* Accumulator high 32 bits. */
        "MVTACHI    R15                     \n" \

`

        /* Save the accumulator. */
        "MVFACHI    R15                         \n" \
        "PUSH.L     R15                         \n" \
        /* Middle order word. */
        "MVFACMI    R15                         \n" \
        /* Shifted left as it is restored to the low order word. */
        "SHLL       #16, R15                    \n" \
        "PUSH.L     R15                         \n" \

`

        /* Restore the context of the new task.  The PSW (Program Status Word) and
        PC will be popped by the RTE instruction. */
        "POP        R15                         \n" \

        /* Accumulator low 32 bits. */
        "MVTACLO    R15                         \n" \
        "POP        R15                         \n" \

        /* Accumulator high 32 bits. */
        "MVTACHI    R15                         \n" \

On the other hand, Renesas/RX200 port is as follows.

Renesas/RX200/port.c

L148:

    pxTopOfStack--;
    *pxTopOfStack = 0x12345678; /* Accumulator. */
    pxTopOfStack--;
    *pxTopOfStack = 0x87654321; /* Accumulator. */

L203:

    /* Restore the registers from the stack of the task pointed to by
    pxCurrentTCB. */
    POP     R15
    MVTACLO R15         /* Accumulator low 32 bits. */
    POP     R15
    MVTACHI R15         /* Accumulator high 32 bits. */

L271:

    /* Save the accumulator. */
    MVFACHI R15
    PUSH.L  R15
    MVFACMI R15 ; Middle order word.
    SHLL    #16, R15 ; Shifted left as it is restored to the low order word.
    PUSH.L  R15

L299:

    /* Restore the context of the new task.  The PSW (Program Status Word) and
    PC will be popped by the RTE instruction. */
    POP     R15
    MVTACLO R15
    POP     R15
    MVTACHI R15

Best regards,
NoMaY

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants