Renesas CCRX Cmake - Unresolved symbol __INITSCT

Hi Everyone.

I am following this guide: https://www.renesas.com/us/en/document/apn/integrated-development-environment-e-studio-using-cmake-renesas-cc-rx-compiler?language=en   to set up a very basic CCRX executable project in e2 Studio

The make files are built without error, but I face the following error when I type "make all": 

E0562310:Undefined external symbol "__INITSCT" referenced in "CMakeFiles\CCRX_Project.dir\resetprg.c.obj"

Suprisigly, I didn't receive any error while compiling this with IDE, I immediately thought to replicate all the compiler and linker options from IDE into the CmakeLists.txt. None of was much use.

I have spent 2 days on this issue, the file is located in the CCrx\include folder in program files. It is also included in the CmakeLists.txt command. 

The __InitSCT function is declared in _h_c_lib.h. I searched my whole computer but couldnt find the function body / definition. I couldnt find any source file either that uses this function, just the start up.

The function copes data section from ROM to RAM on start up. If any path is hidden in the IDE, please tell me as I am stuck with this for days.

I would also suggest that you update your documentation 

  • From the header file that you mentioned:

    _h_c_lib.h:extern void _INITSCT(void);   /* Clear BSS, and copy DATA from ROM to RAM */

    This seems to be a simple enough function.  I can load a pre-built ELF executable from a sample app-note and see the assembly code for it:

    The ELF file doesn't have much information about this symbol:

    I find the symbol in the RX library (CC-RX\lib\rx600xx.lib), and it is also in the "bin\libsrc_C89.pak" file, which 7zip does not seem able to view (must be a proprietary file format).  I would have to assume that your link command already includes this lib, so I don't know why it would not be found when you try to build.  If you can build and create a detailed map-file you should be able to confirm this symbol is defined in this lib rather than simply referenced.

    Don't you just luv it when the IDE hides details like this?  Just push the build button, you don't need to know anything about how it actually works.

  • Hi JB

    Thanks a lot for such a detailed response. It's so strange a hardware start up function's symbol would reside in C89 std library

    I also have some findings. The CCRX library generator utility is creating a .lib file with the project's name. It was using the C89 file. It's really strange

    I tried to do the same with CMake using -input option with the linker, it gave me this output

    E0562002:Input option cannot be specified on command line

    Here is the library generator command:

    I still cant figure out how to use this in CMake format. But this is causing problems

  • Also, what elf viewer are you using? I have to make do with e2 Studio's map file viewer. But viewing an .elf file would help

    The process of going through an .elf file's format manually is very tedious.

  • I am using the Lauterbach simulator for RX to load and view information about the ELF file.  Lauterbach isn't terribly popular for the RX b/c it isn't promoted heavily by Renesas, but it is probably the best debugger solution on the market.  As such the price is not cheap, it certainly cannot complete with the E2 or E2-Lite in terms of cost, but it is a very powerful tool for those who know about it and know how to use it.  I have been using it for various MCU development projects for over 20years, and I still use it today for just about everything Renesas.

    I was going to say that you can download the free (limited) simulator from the Lauterbach web site, but apparently RX is not available.  I have the simulator as part of the debugger.  A free evaluation version of the simulator is available for several MCU architectures but RX is not listed.

    www.lauterbach.com/download_demo.html

  • I have an update. I request any Renesas expert who comments here to please give me a relevant answer. Nobody from renesas has replied to me yet

    1) The CMake guide by Renesas in OP (original post) is invalid. There are many problems in it. I'll list them in the next points

    2) The main problem is library generator. The e2 Studio library generator creates a .lib file with C standard libraries.

    I found the symbol in the RX library (CC-RX\lib\rx600xx.lib), and it is also in the "bin\libsrc_C89.pak" file

    There is no syntax provided by Renesas tutorial to include library generator in the CMake script. The Library generator (lbgrx.exe) in bin folder of Renesas toolchain.

    3) I tried to use e2 Studio generated .lib file, add it to the -library options like this:

    -library="F:\test_cmake_rx\HardwareDebug\test_cmake_rx.lib" 

    It detects it and proceeds to create .mot file.

    Next I end up having these errors:

    W0561012:Duplicate symbol/section specified in option "start" : "C"

    W0561120:Section address is not assigned to "C$DSEC"

    W0561120:Section address is not assigned to "C$BSEC"

    W0561120:Section address is not assigned to "C$INIT"

    W0561120:Section address is not assigned to "C$VECT"

    W0561120:Section address is not assigned to "C$VTBL"

    F0563100:Section address overflow out of range : "C$DSEC"

    I found the reason of this error as well. The map file created trims out the first alphatbet after $ in the linker section. For example C$DSEC becomes CSEC

    Here's proof:

    -start=SU,SI,B_1,R_1,B_2,R_2,B,R/04,PResetPRG,C_1,C_2,C,C,D*,W*,L,PIntPRG,P/0FFF80000,FIXEDVECT/0FFFFFF80

    I'm attaching the .map file as well so you can view it.

    If I edit the .lib file to change the section's name. It considers it as a corrupt library upon Linking, which it should. I cant change the section name within source code because this is being linked to C89.pak and other libraries as well. I cant change it

    The professional solution should be to provide the library generator commands with CMake. That way I can change section name in source code since because of some reason it clips of the '$' sign. Notice that's why it says 'C' symbol is declared twice.

    Please provide me with the correct solution and do not point me towards HEW or any other obsolete material. I just want the correct syntax of the library generator command, and possibly the fact that why is -list command stripping "$" input. This is mostly backend stuff and I can't do much about it. 

    I am attaching .map file and the Cmake generated make file as well.

    Notice how

    This from build.make:

    rlink  -noprelink -library=F:/test_cmake_rx/HardwareDebug/test_cmake_rx.lib -start=SU,SI,B_1,R_1,B_2,R_2,B,R/04,PResetPRG,C_1,C_2,C,C$*,D*,W*,L,PIntPRG,P/0FFF80000,FIXEDVECT/0FFFFFF80 

    Becomes this in .map:

    -start=SU,SI,B_1,R_1,B_2,R_2,B,R/04,PResetPRG,C_1,C_2,C,C,D*,W*,L,PIntPRG,P/0FFF80000,FIXEDVECT/0FFFFFF80

    Once again, I request all the renesas experts to provide me with the correct solution. This seems like there has been a problem with renesas documentation and tutorial. Please make it a point and even it takes time it's alright at least we can know it's taking time.

    We can notify our client of this as well. We are in development phase.

    Thanks in advance for going through this lengthy post.

    Ali

  • The simulator seems very cool. I will try to get it as well. I am about to use J-link. I dont have an idea if it would give me some functionality like this too. 

    it does have a simulator but I dont know if it would help me view .elf files in such an interactive way.

  • Ali, I can help with W0561012:Duplicate symbol/section specified in option "start" : "C" ...

    You are using MAKE and the characters $* represent an automatic variable. In this case referring to part of your target file name. So this is expanding and damaging your start option. You need to escape the $. Here that gets done by doubling upo the $ like this

    C_1,C_2,C,L,C$$*,D*, ...

    That should fix this for you.

  • Hi

    Yes you are absolutely right.

    I figured this out on my own two weeks ago when I got no reply from Renesas forum. Its strange that the support from Renesas is really awful.

    Thanks a lot for your input though :)

  • Ali, yeah I had hoped that you resolved this on your own given the time. But I thought to post it for others that may search for help. I had just ran into this myself in setting up a project to compile our system outside of any IDE.

    Support from all directions generally is "really awful". 

  • I should have posted for others too. I got too busy..

    Yes I agree with you but the support here has been really lacklustre