0

Hello,
I’m new to the rl78-elf-gcc toolchain so maybe what I’m asking can be obvious for everyone else but I’m lost.

I wanted to program something on a device with a R5F104JGAFA processor.
I downloaded and compiled the rl78-elf-gcc toolchain (my OS is Debian Wheezy), not without problems.
I managed to successfully compile a program that does nothing (a while(1) loop).

The next step was to write an actual program. The program will use IO pins, timers, and other things.
These are controlled by the Special Function Registers.
The compiler will only understand these symbols if there are some #define directives which map the register names to addresses. These would typically be in some include files.

And indeed, when I was using the gnu toolchain for a different architecture (msp430) it had .h files for all the processors.
The rl78-elf one, however, has no such thing. I looked everywhere in the include directory and there wasn’t.
I thought that maybe Renesas has them available somewhere, which would make including them in the toolchain redundant; but no. Renesas does not have such files available either.

This makes absolutely no sense to me. I mean, everyone who wants to do anything with a rl78 microcontroller will need this but it can’t be found anywhere. Am I missing something? Am I looking in the wrong place? Where can I find it?

I managed to find out that if I use the e2 studio it will generate the necessary .h files.
But that’s not an option for me:
1. I don’t want to use an IDE. I only want to write my code and a makefile.
2. e2studio requires Windows 7, 8 or 10. I do not have any of these systems. Only GNU/Linux (Debian Wheezy) and older versions of Windows (XP, 98)
3. There are also some other reasons but they are not relevant.
Also, it’s a convoluted way of obtaining something that should be easily available.

Of course, in worst case, I can write my own #define directives based on the G14 hardware manual but I hoped that this will not be necessary. Also, in this case every developer has to write their own defines. That’s not very practical.

 

So, my question is:

If I want to use SFRs in a code that will be compiled by the gnu toolchain do I have to write my own #defines?
Or maybe there are some include files available somewhere, which I haven’t noticed? If so, how can I get them?

Thank you in advance,
B

EDITED TO ADD:
in rl78-elf-gcc I can only set if the processor is a g10, g13 or g14 with -mcpu. I can not set exactly which chip it is. And the micros have different sizes of memory and flash.
How will the linker know? Should I provide this info as well? Are there files for it? Where can I find them?

GNU Tools Support 質問が編集されました
質問 は閉じられました。新しい回答は受け付けておりません。
    • Hello,

      The most elegant solution to your problem would be the use e2studio IDE.
      Unfortunately e2studio installation is not supported on Linux and older Windows operating systems.

      If, however, you have access to an e2studio installation directory you can do the following:
      The .h files you’re interested in can be found in the e2studio installation directory at the following location (for RL78):
      \internal\projectgen\rl78\Generate\iodefine\
      We recommend copying the dedicated .h files from Windows to Linux, as a solution to the problem you are experiencing.
      Note: each .h file corresponds to an appropriate RL78 device.

      Regarding the “-mcpu” option – there are only three types (G10, G13, G14) of GNURL78 cores, so it is all right to set the processor using one of these three options.

      Furthermore, when creating a sample project, e2studio will generate an appropriate linker script, which will define the correct memory regions for the device of your choice.
      Otherwise, you will have to provide your own linker script.

      Here is an example of memory region mappings from an e2studio generated linker script file for the R5F104JGAFA device type:
      MEMORY
      {
      VEC : ORIGIN = 0x0, LENGTH = 4
      IVEC : ORIGIN = 0x4, LENGTH = 188
      OPT : ORIGIN = 0xC0, LENGTH = 4
      SEC_ID : ORIGIN = 0xC4, LENGTH = 10
      OCDSTAD : ORIGIN = 0xCE, LENGTH = 10
      OCDROM : ORIGIN = 0x1FE00, LENGTH = 512
      ROM : ORIGIN = 0xD8, LENGTH = 130344
      MIRROR : ORIGIN = 0xF3000, LENGTH = 36607
      RAM : ORIGIN = 0xFBF00, LENGTH = 16383
      }

      We could provide you with a sample iodefine.h file and a linker script, if that would help you get started.
      Unfortunately, we cannot attach files to our forum replies.
      If you wish to receive the sample files, please open a ticket at: https://gcc-renesas.com/my-support-requests/
      Please keep in mind that you have to login first.

      Regards,
      GNU Tools Team

    • Hello,
      thank you for the answer.
      I managed to install e2studio in Wine.
      In WIne it’s not really usable as an IDE but at least I can create new projects with the files I need.

      Unfortunately, this doesn’t help.
      I generated a new project for 104jg and copied all the generated source files, include files and the linker script to a directory. I tried to compile but I get linker errors:

      make
      rl78-elf-gcc -mcpu=g14 -mmul=none -o pwm.elf -T linker.gsi main.c hardware_setup.c interrupt_handlers.c vector_table.c reset.S
      /usr/bin/../lib/gcc/rl78-elf/4.9-GNURL78_v15.02/../../../../rl78-elf/bin/ld: address 0x6 of pwm.elf section `.vec’ is not within region `VEC’
      /usr/bin/../lib/gcc/rl78-elf/4.9-GNURL78_v15.02/../../../../rl78-elf/bin/ld: address 0x6 of pwm.elf section `.vec’ is not within region `VEC’
      /usr/bin/../lib/gcc/rl78-elf/4.9-GNURL78_v15.02/../../../../rl78-elf/bin/ld: section .vects loaded at [00000004,0000007f] overlaps section .vec loaded at [00000000,00000005]
      /usr/bin/../lib/gcc/rl78-elf/4.9-GNURL78_v15.02/../../../../rl78-elf/lib/g14/crt0.o: In function `_start’:
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:145: undefined reference to `__stack’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:158: undefined reference to `__romdatastart’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:159: undefined reference to `__datastart’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:164: undefined reference to `__romsaddrcopysize’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:171: undefined reference to `__romsaddrstart’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:172: undefined reference to `__saddrstart’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:179: undefined reference to `__bsssize’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:184: undefined reference to `__bssstart’
      /usr/bin/../lib/gcc/rl78-elf/4.9-GNURL78_v15.02/../../../../rl78-elf/lib/g14/crt0.o: In function `L0′:
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:221: undefined reference to `__preinit_array_start’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:222: undefined reference to `__preinit_array_end’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:229: undefined reference to `__init_array_start’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:230: undefined reference to `__init_array_end’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:237: undefined reference to `__fini_array_start’
      /b/Downloads/rl78/source/newlib-2.1.0-20150423/libgloss/rl78/crt0.S:238: undefined reference to `__fini_array_end’
      collect2: error: ld returned 1 exit status

      I don’t know how to continue.

      Best regards,
      B

    • Hello,

      Thank you for the feedback!

      Given that we do not have your project setup, we cannot recreate the scenario you have presented in your comment.
      We can, however, make a few assumptions based on the build log you provided:

      [*] Looking at the build log we can presume that you are using a custom Makefile. There could be a problem in the makefile itself.
      Possible solution: If you intend to use e2studio to generate your source files, you should also look at the automatically generated makefiles for inspiration.
      [*] Judging by the error presented in the build log, a potential problem could be usage of the inappropriate linker script.
      Possible solution: check if the correct linker script is used (the one generated, as a part of the sample project, for R5F104JGxx device type).

      Furthermore, we have generated a sample project, moved the source files (and the linker script) to another location and created a makefile to build the project.
      We could share this makefile with you, as a sample for your project, however that would require you to open a ticket at: https://gcc-renesas.com/my-support-requests/
      Please note that in order to open a support ticket you will have to log in first.

      Regards,
      GNU Tools Team

    • Hello,
      Yes, I also think that the problem in my case is the makefile.

      I used the sources generated by e2studio. I thought that it will be the best option for the beginning when I have no experience with it yet. I never worked with rl78 before.

      Actually, I was wondering if I came back here too early, saying it doesn’t work, before trying to understand the autogenerated makefile.

      But now I see that you already created a makefile (thank you!) so it would be a waste not to use it.
      I opened a ticket.

      Thank you,
      B