# Compilation/Linker Issues in Running the Demo Example for FreeRTOS/Demo/RL78\_RL78G13\_Promo\_Board\_IAR directory

**URL:** <https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218>\
**Category:** Renesas\
**Created:** [March 11, 2020, 10:30am UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218 "2020-03-11T10:30:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anmol.arora1919](https://avatars.discourse-cdn.com/v4/letter/a/6f9a4e/32.png) [@anmol.arora1919](https://forums.freertos.org/u/anmol.arora1919)\
**Post date:** [March 11, 2020, 10:30am UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/1 "2020-03-11T10:30:59Z")

</div>

Hello All,

I am also stuck in porting the FreeRTOS on RL78 Renesas MCU. I am using IAR version 4.2 and FreeRTOS 10.3.1 . Initially my demo code was for R5F100LEA(RL78\_RL78G13\_Promo\_Board\_IAR). I had the below lines which were giving the error in in “ **port87.asm** ” file.

COMMON INTVEC:CODE:ROOT(1)  
ORG configTICK\_VECTOR  
DW vPortTickISR

COMMON INTVEC:CODE:ROOT(1)  
ORG 126  
DW vPortYield

Afterwards I have changed the above instructions to the below.

ASEGN `.intvec`:CODE:ROOT,56  
DATA16  
DC16 vPortTickISR

ASEGN `.intvec`:CODE:ROOT,126  
DATA16  
DC16 vPortYield

Now again errors are coming mentioned below.

Error[Li005]: no definition for “vRegTestError” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\RegTest.o]  
Error[Li005]: no definition for “usCriticalNesting” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\portasm.o]  
Error[Li005]: no definition for “pxCurrentTCB” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\portasm.o]  
Error[Li005]: no definition for “xTaskIncrementTick” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\portasm.o]  
Error[Li005]: no definition for “vTaskSwitchContext” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\portasm.o]  
Error[Li005]: no definition for “\_vRegTest1” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\main.o]  
Error[Li005]: no definition for “\_vRegTest2” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\main.o]  
Error[Li005]: no definition for “\_vPortStartFirstTask” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\port.o]  
Error[Li005]: no definition for “\_vTaskDelayUntil” [referenced from C:\Users\Anmol Arora\FreeRTOSv10.3.1\FreeRTOSv10.3.1\FreeRTOS\Demo\  
RL78\_RL78G13\_Promo\_Board\_IAR\Debug\Obj\blocktim.o]  
Error[Lp011]: section placement failed  
unable to complete “place at” directives with a total estimated minimum size of 0x7c bytes in \<[0x4-0x37]\> (total space 0x34).  
Error[Lp015]: section placement failure: overcommitted content in [0x4-0x37]  
Error while running Linker

The above errors are saying that the mentioned variables(vRegTestError) are undefined portasm.o . When I am opening this file “portasm.o”, its not written in C, its an output of compiler file. Please tell how can I remove these errors.

Best Regards  
Anmol Arora

---

<div class="post-metadata">

**Author:** ![rtel](https://d3iykfbgfh8zhg.cloudfront.net/user_avatar/forums.freertos.org/rtel/32/31_2.png) [@rtel](https://forums.freertos.org/u/rtel)\
**Post date:** [March 11, 2020, 3:06pm UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/2 "2020-03-11T15:06:57Z")

</div>

I think there is an incompatibility in the output format used by the IAR compiler since the RL78 port was created. You have already fixed up one piece of assembly, and I think there are addition changes required.

I would however recommend you spend some time learning how the C compilation process works. The linker (after compilation) is telling you there is an object file generate from a source file that contains a reference it can’t find. The compiler generates the object .o files from the source files, and in the case of portasm.o the source file is [an assembly file](https://github.com/FreeRTOS/FreeRTOS-Kernel/blob/master/portable/IAR/RL78/portasm.s87), not a C file. Likewise regtest [is also an assembly file](https://github.com/FreeRTOS/FreeRTOS/blob/master/FreeRTOS/Demo/RL78_multiple_IAR/RegTest.s87). So it looks like the method of importing and exporting symbols from assembly files is different with your version of the compiler.

---

<div class="post-metadata">

**Author:** ![NoMaY-jp](https://avatars.discourse-cdn.com/v4/letter/n/439d5e/32.png) [@NoMaY-jp](https://forums.freertos.org/u/NoMaY-jp)\
**Post date:** [July 28, 2020, 11:37pm UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/3 "2020-07-28T23:37:22Z")

</div>

Hello,

the issues seem to be famous because many threads are found as followings. But unfortunately every thread doesn’t show all steps to succeed building the project. So, I’d like to try to fix the issues and post the result regardless of success or fail. If it is succeeded then I’d like to post a pull request. (As of today, nobody posted a pull request regarding to the issues.)

[https://www.freertos.org/FreeRTOS\_Support\_Forum\_Archive/March\_2016/freertos\_Unable\_to\_compile\_FreeRTOSV9.0.0rc1\_with\_IAR\_2.20\_5fbce14dj.html](https://www.freertos.org/FreeRTOS_Support_Forum_Archive/March_2016/freertos_Unable_to_compile_FreeRTOSV9.0.0rc1_with_IAR_2.20_5fbce14dj.html)

[http://www.openrtos.net/FreeRTOS\_Support\_Forum\_Archive/November\_2016/freertos\_Assembler\_Build\_Errors\_in\_FreeRTOS\_Demo\_using\_RL78\_IAR\_EW\_v7.4\_15bfb02dj.html](http://www.openrtos.net/FreeRTOS_Support_Forum_Archive/November_2016/freertos_Assembler_Build_Errors_in_FreeRTOS_Demo_using_RL78_IAR_EW_v7.4_15bfb02dj.html)

[https://sourceforge.net/p/freertos/bugs/172/](https://sourceforge.net/p/freertos/bugs/172/)

[https://renesasrulz.com/rl78/f/the-rl78-forum/6145/freertos-compilation-in-iar-for-rl78](https://renesasrulz.com/rl78/f/the-rl78-forum/6145/freertos-compilation-in-iar-for-rl78)

[https://renesasrulz.com/rl78/f/the-rl78-forum/7122/freertos-on-rl78-g14-with-iar-2-21-1-demo](https://renesasrulz.com/rl78/f/the-rl78-forum/7122/freertos-on-rl78-g14-with-iar-2-21-1-demo)

[https://renesasrulz.com/rl78/f/the-rl78-forum/8967/freertos-demo-on-rl78-with-iar-2-21-1-is-not-compiling](https://renesasrulz.com/rl78/f/the-rl78-forum/8967/freertos-demo-on-rl78-with-iar-2-21-1-is-not-compiling)

[https://renesasrulz.com/rl78/f/the-rl78-forum/9585/freertos-porting-on-iar-3-10](https://renesasrulz.com/rl78/f/the-rl78-forum/9585/freertos-porting-on-iar-3-10)

Best regards,  
NoMaY

---

<div class="post-metadata">

**Author:** ![NoMaY-jp](https://avatars.discourse-cdn.com/v4/letter/n/439d5e/32.png) [@NoMaY-jp](https://forums.freertos.org/u/NoMaY-jp)\
**Post date:** [July 30, 2020, 12:30am UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/4 "2020-07-30T00:30:01Z")

</div>

Hello,

Now I understand that it is wrong to use ‘ASEGN .intvec:CODE:ROOT,XX\<newline\>DATA16’ instead of ‘COMMON INTVEC:CODE:ROOT(1)\<newline\>ORG XX’ if the segment is the interrupt vector table area. And I understand that it is correct to define one more label such as \_\_\_interrupt\_0xXX: at the start address of ISR.

This is original code: (configTICK\_VECTOR is 0x38.)

```
; Install the interrupt handlers

    COMMON INTVEC:CODE:ROOT(1)
    ORG configTICK_VECTOR
    DW vPortTickISR

```

The following modification is wrong:

```
; Install the interrupt handlers

    ASEGN .intvec:CODE:ROOT,0x38
    DATA16
    DC16 _vPortTickISR

```

Above code causes the following linker errors because the interrupt vector table is already placed at address 0x4-0x7F but above new absolute segment starts at address 0x38 therefore these two areas overlap:

```
Error[Lp011]: section placement failed 
    unable to complete "place at" directives with a total estimated minimum size of 0x7c bytes in <[0x4-0x37]> (total space 0x34). 
Error[Lp015]: section placement failure: overcommitted content in [0x4-0x37] 

```

The following modification is correct:

```
PUBLIC _vPortTickISR
PUBLIC ___interrupt_0x38 <---- HERE

```

’

```
 RSEG CODE:CODE
_vPortTickISR:
___interrupt_0x38: <---- HERE
portSAVE_CONTEXT ; Save the context of the current task.
call _xTaskIncrementTick ; Call the timer tick function.
cmpw ax, #0x00
skz
call _vTaskSwitchContext ; Call the scheduler to select the next task.
portRESTORE_CONTEXT ; Restore the context of the next task to run.
reti

```

’

```
; Install the interrupt handlers

; Nothing to do. <---- HERE

```

MAP file shows that \_\_\_interrupt\_0xXXs are pre-difined weak code labels and \_\_\_interrupt\_tab\_0xXXs are pre-difined global data labels:

```
___interrupt_0x00 0x4839 Code Gb cstartup.o [3]
___interrupt_0x04 0x48e1 0x13 Code Wk default_handler.o [3]
...
___interrupt_0x36 0x48e1 0x13 Code Wk default_handler.o [3]
___interrupt_0x38 0x49f2 Code Gb portasm.o [1]
___interrupt_0x3A 0x48e1 0x13 Code Wk default_handler.o [3]
...
___interrupt_0x7C 0x48e1 0x13 Code Wk default_handler.o [3]
___interrupt_0x7E 0x49aa Code Gb portasm.o [1]
___interrupt_tab_0x00 0x0 Data Gb interrupt_vector.o [3]
___interrupt_tab_0x04 0x4 Data Gb interrupt_vector.o [3]
...
___interrupt_tab_0x36 0x36 Data Gb interrupt_vector.o [3]
___interrupt_tab_0x38 0x38 Data Gb interrupt_vector.o [3]
___interrupt_tab_0x3A 0x3a Data Gb interrupt_vector.o [3]
...
___interrupt_tab_0x7C 0x7c Data Gb interrupt_vector.o [3]
___interrupt_tab_0x7E 0x7e Data Gb interrupt_vector.o [3]

```

Now I can build the project on my desktop with other modifications and I’m thinking how to check the modification because I don’t have RL78/G13 Promotion Board.

Other modifications:

Source/portable/IAR/RL78/{portasm.s87, ISR\_Support.h}

- Define \_\_\_interrupt\_0x7E: at the start address of \_\_vPortYield:.
- Add ‘\_’ at the beginning of PUBLIC symbols and EXTERN symbols.

Demo/RL78\_RL78G13\_Promo\_Board\_IAR/RegTest.s87

- Add ‘\_’ at the beginning of PUBLIC symbols and EXTERN symbols.

Demo/RL78\_RL78G13\_Promo\_Board\_IAR/FreeRTOSConfig.h

- Change the following definision. (Probably one of demo common source file was changed after this demo was created.)  
`#define INCLUDE_vTaskDelayUntil 0 ----> 1`

Best regards,  
NoMaY

---

<div class="post-metadata">

**Author:** ![NoMaY-jp](https://avatars.discourse-cdn.com/v4/letter/n/439d5e/32.png) [@NoMaY-jp](https://forums.freertos.org/u/NoMaY-jp)\
**Post date:** [August 2, 2020, 9:00pm UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/5 "2020-08-02T21:00:19Z")

</div>

Hello,

Now I understand that the following method is no longer available due to the incompatible change of ioreg definition header files because (at least the latest version of EWRL78) ICCRL78’s header files have neither ‘#define RTCEN XXXX’ nor ‘#define TMKAEN XXXX’. So, I’ll consider something to fix it.

port.c

```
static void prvSetupTimerInterrupt( void )
{
    const uint16_t usClockHz = 15000UL; /* Internal clock. */
    const uint16_t usCompareMatch = ( usClockHz / configTICK_RATE_HZ ) + 1UL;

    /* Use the internal 15K clock. */
    OSMC = ( uint8_t ) 0x16;

    #ifdef RTCEN <---- HERE
        {
            /* Supply the interval timer clock. */
            RTCEN = ( uint8_t ) 1U;

            /* Disable INTIT interrupt. */
            ITMK = ( uint8_t ) 1;

            /* Disable ITMC operation. */
            ITMC = ( uint8_t ) 0x0000;

            /* Clear INIT interrupt. */
            ITIF = ( uint8_t ) 0;

            /* Set interval and enable interrupt operation. */
            ITMC = usCompareMatch | 0x8000U;

            /* Enable INTIT interrupt. */
            ITMK = ( uint8_t ) 0;
        }
    #endif /* ifdef RTCEN */

    #ifdef TMKAEN <---- HERE
        {
            /* Supply the interval timer clock. */
            TMKAEN = ( uint8_t ) 1U;

            /* Disable INTIT interrupt. */
            TMKAMK = ( uint8_t ) 1;

            /* Disable ITMC operation. */
            ITMC = ( uint8_t ) 0x0000;

            /* Clear INIT interrupt. */
            TMKAIF = ( uint8_t ) 0;

            /* Set interval and enable interrupt operation. */
            ITMC = usCompareMatch | 0x8000U;

            /* Enable INTIT interrupt. */
            TMKAMK = ( uint8_t ) 0;
        }
    #endif /* ifdef TMKAEN */
}

```

By the way, the avobe code seems to be the following code. (mistake of +/-, not so important.)

WRONG:

` const uint16_t usCompareMatch = ( usClockHz / configTICK_RATE_HZ ) + 1UL;`

CORRECT:

` const uint16_t usCompareMatch = ( usClockHz / configTICK_RATE_HZ ) - 1UL;`

---

<div class="post-metadata">

**Author:** ![NoMaY-jp](https://avatars.discourse-cdn.com/v4/letter/n/439d5e/32.png) [@NoMaY-jp](https://forums.freertos.org/u/NoMaY-jp)\
**Post date:** [August 6, 2020, 3:32pm UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/6 "2020-08-06T15:32:05Z")

</div>

Hello,

Now I understand that RL78\_RL78G13\_Promo\_Board\_IAR’s RegTest.s87 is no longer correct maybe due to the change of assembly language syntax of ‘Bcond’ instructions. At least the latest version of EWRL78, ‘Bcond’ instructions need -2 offset as follows.

No longer correct:

```
MOVW AX, BC
CMPW AX, #0x3344
BZ +5 <---- HERE
BR vRegTestError   
MOVW AX, DE
CMPW AX, #0x5566
BZ +5 <---- HERE
BR vRegTestError   
MOVW AX, HL  
CMPW AX, #0x7788
BZ +5 <---- HERE
BR vRegTestError
MOV A, CS
CMP A, #0x01
BZ +5 <---- HERE
BR vRegTestError

```

Correct:

```
MOVW AX, BC
CMPW AX, #0x3344
BZ +5-2 <---- HERE
BR _vRegTestError  
MOVW AX, DE
CMPW AX, #0x5566
BZ +5-2 <---- HERE
BR _vRegTestError  
MOVW AX, HL  
CMPW AX, #0x7788
BZ +5-2 <---- HERE
BR _vRegTestError
MOV A, CS
CMP A, #0x01
BZ +5-2 <---- HERE
BR _vRegTestError
```

---

<div class="post-metadata">

**Author:** ![NoMaY-jp](https://avatars.discourse-cdn.com/v4/letter/n/439d5e/32.png) [@NoMaY-jp](https://forums.freertos.org/u/NoMaY-jp)\
**Post date:** [August 10, 2020, 7:26pm UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/7 "2020-08-10T19:26:27Z")

</div>

Hello,

Now I understand that the 16bit ticks mode needs the following definition (at least the latest version of EWRL78) for RTOSDemo working. (This definition had been known already for CC-RL and GNURL78 in the Japanese user forum for Renesas development tools.) Maybe only early versions of EWRL78 were able to build RTODemo working without this definition. Fortunately another RTOSDemo (in the RL78\_multiple\_IAR directory) which is built by the latest EWRL78 now becomes working with RL78/G14 Fast Prototyping Board on my desktop. I think that all updated source files will be posted in a week.

FreeRTOSConfig.h

```
#if (configUSE_16_BIT_TICKS == 1)
#define pdMS_TO_TICKS( xTimeInMs ) ( ( TickType_t ) ( ( ( uint32_t ) ( xTimeInMs ) * ( uint32_t ) configTICK_RATE_HZ ) / ( uint32_t ) 1000 ) )
#endif 

```

By the way, the past issue of RTCEN and TMKAEN is fixed as follows:

port.c

```
#if INTIT_vect == 0x38
    {
        ...omit...
    }
#endif /* if INTIT_vect == 0x38 */

#if INTIT_vect == 0x3C
    {
        ...omit...
    }
#endif /* if INTIT_vect == 0x3C */

```

portasm.s87

```
#if INTIT_vect == 0x38

    #define ___interrupt_TICK_VECTOR___ interrupt_0x38

#endif

#if INTIT_vect == 0x3C

    #define ___interrupt_TICK_VECTOR___ interrupt_0x3C

#endif

#ifndef ___interrupt_TICK_VECTOR

    #error Neither vector 0x38 nor vector 0x3C is available for the tick interrupt.

#endif

```

`

`PUBLIC ___interrupt_TICK_VECTOR`

`

```
_vPortTickISR:
___interrupt_TICK_VECTOR:
```

---

<div class="post-metadata">

**Author:** ![NoMaY-jp](https://avatars.discourse-cdn.com/v4/letter/n/439d5e/32.png) [@NoMaY-jp](https://forums.freertos.org/u/NoMaY-jp)\
**Post date:** [August 15, 2020, 11:10am UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/8 "2020-08-15T11:10:31Z")

</div>

Hello,

One more incompatibility between versions of EWRL78 which breaks RTOSDemo programs is found. IAR changed ABI to comply with Renesas RL78 ABI in the past. This included a change of rule regarding to an argument of a FAR data pointer as follows (roughly and not exactly).

Older version: (The source code of the RTOSDemo programs (port layer) show the following.)

- A FAR data pointer is passed using 4 bytes of stack.

Newer version: (The help document of CC-RL shows the following.)

- A FAR data pointer is passed using A and DE registers.

Therefore port.c has to be modified like the following proposal.

port.c

Original: (no longer correct)

```
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
{
uint32_t *pulLocal;

    /* With large code and large data sizeof( StackType_t ) == 2, and
    sizeof( StackType_t * ) == 4. With small code and small data
    sizeof( StackType_t ) == 2 and sizeof( StackType_t * ) == 2. */

    #if __DATA_MODEL__ == __DATA_MODEL_FAR__
    {
        /* Parameters are passed in on the stack, and written using a 32-bit value
        hence a space is left for the second two bytes. */
        pxTopOfStack--;

        /* Write in the parameter value. */
        pulLocal = ( uint32_t * ) pxTopOfStack;
        *pulLocal = ( uint32_t ) pvParameters;
        pxTopOfStack--;

        /* The return address, leaving space for the first two bytes of the
        32-bit value. See the comments above the prvTaskExitError() prototype
        at the top of this file. */
        pxTopOfStack--;
        pulLocal = ( uint32_t * ) pxTopOfStack;
        *pulLocal = ( uint32_t ) prvTaskExitError;
        pxTopOfStack--;

        /* The start address / PSW value is also written in as a 32-bit value,
        so leave a space for the second two bytes. */
        pxTopOfStack--;

        /* Task function start address combined with the PSW. */
        pulLocal = ( uint32_t * ) pxTopOfStack;
        *pulLocal = ( ( ( uint32_t ) pxCode ) | ( portPSW << 24UL ) );
        pxTopOfStack--;

        /* An initial value for the AX register. */
        *pxTopOfStack = ( StackType_t ) 0x1111;
        pxTopOfStack--;
    }
    #else
    {
        /* The return address, leaving space for the first two bytes of the
        32-bit value. See the comments above the prvTaskExitError() prototype
        at the top of this file. */
        pxTopOfStack--;
        pulLocal = ( uint32_t * ) pxTopOfStack;
        *pulLocal = ( uint32_t ) prvTaskExitError;
        pxTopOfStack--;

        /* Task function. Again as it is written as a 32-bit value a space is
        left on the stack for the second two bytes. */
        pxTopOfStack--;

        /* Task function start address combined with the PSW. */
        pulLocal = ( uint32_t * ) pxTopOfStack;
        *pulLocal = ( ( ( uint32_t ) pxCode ) | ( portPSW << 24UL ) );
        pxTopOfStack--;

        /* The parameter is passed in AX. */
        *pxTopOfStack = ( StackType_t ) pvParameters;
        pxTopOfStack--;
    }
    #endif

    /* An initial value for the HL register. */
    *pxTopOfStack = ( StackType_t ) 0x2222;
    pxTopOfStack--;

    /* CS and ES registers. */
    *pxTopOfStack = ( StackType_t ) 0x0F00;
    pxTopOfStack--;

    /* The remaining general purpose registers DE and BC */
    *pxTopOfStack = ( StackType_t ) 0xDEDE;
    pxTopOfStack--;
    *pxTopOfStack = ( StackType_t ) 0xBCBC;
    pxTopOfStack--;

    /* Finally the critical section nesting count is set to zero when the task
    first starts. */
    *pxTopOfStack = ( StackType_t ) portNO_CRITICAL_SECTION_NESTING;

```

Proposal: (this will be included in a zip file which will be posted)

```
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
{
uint32_t *pulLocal;

    /* With large code and large data sizeof( StackType_t ) == 2, and
    sizeof( StackType_t * ) == 4. With small code and small data
    sizeof( StackType_t ) == 2 and sizeof( StackType_t * ) == 2. */

    /* The return address, leaving space for the first two bytes of the
    32-bit value. See the comments above the prvTaskExitError() prototype
    at the top of this file. */
    pxTopOfStack--;
    pulLocal = ( uint32_t * ) pxTopOfStack;
    *pulLocal = ( uint32_t ) prvTaskExitError;
    pxTopOfStack--;

    /* The start address / PSW value is also written in as a 32-bit value,
    so leave a space for the second two bytes. */
    pxTopOfStack--;

    /* Task function start address combined with the PSW. */
    pulLocal = ( uint32_t * ) pxTopOfStack;
    *pulLocal = ( ( ( uint32_t ) pxCode ) | ( portPSW << 24UL ) );
    pxTopOfStack--;

    #if __DATA_MODEL__ == __DATA_MODEL_FAR__
    {
        /* The lower 8-bit value of upper 16-bit value of parameter is
        passed in A. X is zero. */
        *pxTopOfStack = ( StackType_t ) ( ( ( ( uint32_t ) pvParameters ) >> 8 ) & 0xFF00 );
        pxTopOfStack--;

        /* An initial value for the HL register. */
        *pxTopOfStack = ( StackType_t ) 0x2222;
        pxTopOfStack--;

        /* CS and ES registers. */
        *pxTopOfStack = ( StackType_t ) 0x0F00;
        pxTopOfStack--;

        /* The lower 16-bit value of parameter is passed in DE. */
        *pxTopOfStack = ( StackType_t ) ( ( ( uint32_t ) pvParameters ) & 0xFFFF );
        pxTopOfStack--;

        /* The remaining general purpose registers BC. */
        *pxTopOfStack = ( StackType_t ) 0xBCBC;
        pxTopOfStack--;
    }
    #else
    {
        /* The parameter is passed in AX. */
        *pxTopOfStack = ( StackType_t ) pvParameters;
        pxTopOfStack--;

        /* An initial value for the HL register. */
        *pxTopOfStack = ( StackType_t ) 0x2222;
        pxTopOfStack--;

        /* CS and ES registers. */
        *pxTopOfStack = ( StackType_t ) 0x0F00;
        pxTopOfStack--;

        /* The remaining general purpose registers DE and BC. */
        *pxTopOfStack = ( StackType_t ) 0xDEDE;
        pxTopOfStack--;
        *pxTopOfStack = ( StackType_t ) 0xBCBC;
        pxTopOfStack--;
    }
    #endif

    /* Finally the critical section nesting count is set to zero when the task
    first starts. */
    *pxTopOfStack = ( StackType_t ) portNO_CRITICAL_SECTION_NESTING;
```

---

<div class="post-metadata">

**Author:** ![NoMaY-jp](https://avatars.discourse-cdn.com/v4/letter/n/439d5e/32.png) [@NoMaY-jp](https://forums.freertos.org/u/NoMaY-jp)\
**Post date:** [August 16, 2020, 7:32pm UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/9 "2020-08-16T19:32:21Z")

</div>

Hello,

There seems to be a small mistake in the combination of Demo/RL78\_multiple\_IAR and YRDKRL78G14 as follows. Not only YRPBRL78G13 for Demo/RL78\_RL78G13\_Promo\_Board\_IAR but also all boards including YRDKRL78G14 for Demo/RL78\_multiple\_IAR are not available for me. But RTOSDemo programs running on RL78/G13 and RL78/G14 can be debugged using e2 studio and Renesas RL78 Simulator which can simulate almost all on-chip peripheral registers and peripherals behavior. Moreover e2 studio’s Visual Expression view can show blinking of LED graphically as follows. 3sec of simulation needs real 20sec ~ 40sec on my PC using 1.8GHz AMD E2-9000 CPU.

Demo/RL78\_multiple\_IAR/demo\_specific\_io.h

WRONG:

```
#ifdef YRPBRL78G13
    #include "ior5f100le.h"
    #include "ior5f100le_ext.h"
    #define LED_BIT ( P7_bit.no7 )
    #define LED_INIT() P7 &= 0x7F; PM7 &= 0x7F
#endif /* YRPBRL78G13 */

#ifdef YRDKRL78G14
    #include "ior5f104pj.h"
    #include "ior5f104pj_ext.h"
    #define LED_BIT ( P4_bit.no1 )
    #define LED_INIT() LED_BIT = 0 <---- HERE
#endif /* YRDKRL78G14 */

#ifdef RSKRL78G1C
    #include "ior5f10jgc.h"
    #include "ior5f10jgc_ext.h"
    #define LED_BIT ( P0_bit.no1 )
    #define LED_INIT() P0 &= 0xFD; PM0 &= 0xFD
#endif /* RSKRL78G1C */

... omit ...

```

CORRECT:

```
#ifdef YRPBRL78G13
    ... omit ...
#endif /* YRPBRL78G13 */

#ifdef YRDKRL78G14
    #include "ior5f104pj.h"
    #include "ior5f104pj_ext.h"
    #define LED_BIT ( P4_bit.no1 )
    #define LED_INIT() P4 &= 0xFD; PM4 &= 0xFD <---- HERE
#endif /* YRDKRL78G14 */

#ifdef RSKRL78G1C
    ... omit ...
#endif /* RSKRL78G1C */

... omit ...

```

Screen copies of e2 studio and Visual Expression view (\*.s87 are renamed to \*.s to be built using e2 studio)

LED ON

 ![e2studio_freertos_build_issues_21](https://d2v6vdsk2p900z.cloudfront.net/original/1X/60f15de03174d266d3ef2c8409d1fcaa4c653165.png)

LED OFF

 ![e2studio_freertos_build_issues_22](https://d2v6vdsk2p900z.cloudfront.net/original/1X/bd82b5a46dd63601858a23a04897435a0a34b4bb.png)

---

<div class="post-metadata">

**Author:** ![NoMaY-jp](https://avatars.discourse-cdn.com/v4/letter/n/439d5e/32.png) [@NoMaY-jp](https://forums.freertos.org/u/NoMaY-jp)\
**Post date:** [August 18, 2020, 6:00pm UTC](https://forums.freertos.org/t/compilation-linker-issues-in-running-the-demo-example-for-freertos-demo-rl78-rl78g13-promo-board-iar-directory/9218/10 "2020-08-18T18:00:29Z")

</div>

Hello,

Files in the following zip file fix the build error problems which are caused by recent EWRL78.

[FreeRTOSv10.3.1.EWRL78.Fixed.20200817.zip](https://forums.freertos.org/uploads/short-url/kvTXCXffhhrYsaIloT0fxndrolI.zip) (639.2 KB)

This zip file includes all files which are necessary to build the following RTOSDemo projects and the following environments and project settings and hardware/simulator are used to confirm.

FreeRTOS/Demo/RL78\_RL78G13\_Promo\_Board\_IAR  
FreeRTOS/Demo/RL78\_multiple\_IAR

**IDE and Compiler**

EWRL78 V4.20.1 including ICCRL78 V4.20.1.226 (16KB KickStart Edition)  
e2 studio v7.8.0 (32bit version) with ICCRL78 V4.20.1.226  
e2 studio v2020-07 (64bit version) with ICCRL78 V4.20.1.226

**Device information and Project settings**

RL78\_RL78G13\_Promo\_Board\_IAR project

```
                        Tick On-chip Non-task Compiler e2 studio's                            
                        Interrupt Memory model MUL/DIV Stack Optimize Debug launch configurations            
Board Device Vector ROM/RAM Code/Data Unit Size (*1) Level Emulator Simulator            
                                                                                                                                
YRPBRL78G13 R5F100LE 0x38 64KB/4KB Near/Near Disabled 128B High on-board EZ (*2) Renesas RL78 Sim (*3)

```

RL78\_multiple\_IAR project

```
                        Tick On-chip Non-task Compiler e2 studio's                       
                        Interrupt Memory model MUL/DIV Stack Optimize Debug launch configurations           
Board Device Vector ROM/RAM Code/Data Unit Size Level Emulator Simulator       
                                                                                                   
YRPBRL78G13 R5F100LE 0x38 64KB/4KB Near/Near Disabled 128B High on-board EZ (*2) Renesas RL78 Sim (*3)
                                                                                                
YRDKRL78G14 R5F104PJ 0x38 256KB/24KB Far/Far Disabled 144B High on-board EZ (*2) Renesas RL78 Sim (*3)
                                                                                                
RSKRL78G1C R5F10JGC 0x38 32KB/5.5KB Near/Near Disabled 128B High E1 (*2) N/A                  
                                                                                                
RSKRL78L1C R5F110PJ 0x3C 256KB/16KB Far/Far Disabled 144B High E1 (*2) N/A                  
                                                                                                
RSKRL78L13 R5F10WMG 0x3C 128KB/8KB Far/Far Disabled 144B High E1 (*2) N/A                  
                                                                                                
RL78_G1A_TB R5F10ELE 0x38 64KB/4KB Near/Near Disabled 128B High E1 (*2) N/A                  
                                                                                                
RL78_G14_FPB R5F104ML 0x38 512KB/48KB Far/Far Disabled 144B High on-board E2 Lite Renesas RL78 Sim (*3)

```

\*1: Non-task Stack Size means that stack size before the scheduler starts.  
\*2: These launch configurations are not tested because I don’t have these evaluation boards.  
\*3: e2 studio’s Visual Expression view can show blinking of LED graphically. (Note that please don’t open the view when emulator is used because the view strongly disturbs program running.)

**Other information**

You can select build configuration as follows:

EWRL78  
 ![e2studio_freertos_build_issues_31](https://d2v6vdsk2p900z.cloudfront.net/original/1X/fbe48270cac46da21d16f08cfc15f2ef8446f1d4.png)

e2 studio (Please note that tool bar is customized by me.)

 ![e2studio_freertos_build_issues_32](https://d2v6vdsk2p900z.cloudfront.net/original/1X/5ab40b670d6522f0d4c4f6915a8e845834d25ba5.png)

You can select debug configuration as follows:

e2 studio (Please note that tool bar is customized by me.)

 ![e2studio_freertos_build_issues_41](https://d2v6vdsk2p900z.cloudfront.net/original/1X/a58e1ac9a24bdfaae23f1af2e22255e815fdee91.png)

You can open the Visual Expression view when you user e2 studio and Renesas RL78 Simulator.  
(If non LED image is displayed, please wait for a next timing of LED turn on/turn off.)

 ![e2studio_freertos_build_issues_51](https://d2v6vdsk2p900z.cloudfront.net/original/1X/6d3c873fe7d993780865517402a618abf0b49717.png)  
 ![e2studio_freertos_build_issues_52](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7c20c958e6f515bea83f6cb5dc17d09f8d5630ee.png)  
 ![e2studio_freertos_build_issues_53](https://d2v6vdsk2p900z.cloudfront.net/original/1X/e1777b30d16376223193c2090fc89c4675254de3.png)  
 ![e2studio_freertos_build_issues_54](https://d2v6vdsk2p900z.cloudfront.net/original/1X/3f8dfbd6885248700493e8bf42c230c61fb24945.png)

IDE’s bugs need some workarounds of project settings:

Changing Memory Model (Near\<–\>Far) removes preprocessor macro definitions in certain cases.  
So, I did the following settings.  
 ![e2studio_freertos_build_issues_61](https://d2v6vdsk2p900z.cloudfront.net/original/1X/cc616c2dab7b8b0df579ea863274267c6daad9f6.png)

 ![e2studio_freertos_build_issues_62](https://d2v6vdsk2p900z.cloudfront.net/original/1X/f2976ebb2a0164a88c84dccf4f611d1943f3d42f.png)  
 ![e2studio_freertos_build_issues_63](https://d2v6vdsk2p900z.cloudfront.net/original/1X/d06b5421cab346fab145ee32fb1200b6a741576e.png)  
 ![e2studio_freertos_build_issues_64](https://d2v6vdsk2p900z.cloudfront.net/original/1X/8a96602e7209ed3017c456a0e0d2cc74b595517f.png)  
 ![e2studio_freertos_build_issues_65](https://d2v6vdsk2p900z.cloudfront.net/original/1X/7b6fee1a7dc3d17b6d3a4304f29117b68d9a0416.png)

Changing Build Configuration leads to link error.  
So, I added a pre-build command to show an error message and please do the steps in the error message when it is displayed.

 ![e2studio_freertos_build_issues_71](https://d2v6vdsk2p900z.cloudfront.net/original/1X/8843975a2295fb4c872709bd1d7eef82f36b47ed.png)  
 ![e2studio_freertos_build_issues_72](https://d2v6vdsk2p900z.cloudfront.net/original/1X/a6a4d8fabe03bd8389e7b26335ee44a556d87c6c.png)

Best regards,  
NoMaY
