gcc for M16C/M32C

Hi all

Is gcc and C libraries already ported to M16C/M32C architectures from renesas ?

I tried googling with, but nothing relevant. Any advices ?

Many Thx, Habib.

Reply to
Habib Bouaziz-Viallet
Loading thread data ...

Go to:

formatting link

-- =^.^= StoneThrower

"To invent, you need an imagination and a pile of junk." Thomas Alva Edison

Reply to
StoneThrower

Le Fri, 09 Nov 2007 16:15:52 +0100, StoneThrower a écrit:

Mmmh ... I have been trying to register kpitgnutools, unfortunately they do not apply my request ... Are you using these tools?

Habib.

Reply to
Habib Bouaziz-Viallet

If you can't get their tools, you can always build them yourself from the FSF repositories. I've got the key pieces of info you need here:

formatting link

(FYI I'm the m32c maintainer for the FSF sources)

Reply to
DJ Delorie

Le Sat, 10 Nov 2007 12:12:47 -0500, DJ Delorie a écrit:

Hi !

I have some questions. I can't see any procedure to build this cross-compiler from FSF repository. You mention "configure --target=m32c-elf" but i don't know from what package i'll do it (gcc-core i presume) what is the svn server adress ? i did not heard about new lib, is this an equivalent to glibc or uclibc ?

I already build GNUTools for msp430 and avr's, i did'nt remeber exactly but configure scripts (binutils, gcc, glibc) require many arguments.

Please point some documentation about build procedure.

Many thanks, Habib

Reply to
Habib Bouaziz-Viallet

formatting link
is a good starting point. Read the documentation on building and installing gcc; specifically how to build a cross compiler. You might also want to try googling for "crossgcc".

The key sequence is:

  • build and install binutils
  • attempt to build gcc, "make -i install" to install whatever got built.
  • build and install newlib.
  • build the rest of gcc and install it.

Make sure you use "--with-newlib" when configuring gcc.

See

formatting link
(gcc) and
formatting link
(binutils, newlib)

Newlib is like glibc or uclibc, but for non-Linux embedded systems. Specifically, it includes the "libgloss" module, which has crt0.s and linker maps for many embedded targets, including m32c.

Same procedure, but use m32c-elf for the target.

Reply to
DJ Delorie

Le Mon, 12 Nov 2007 03:56:04 -0500, DJ Delorie a écrit:

i have to configure newlib with --target=m32c-elf and

--with-newlib. Correct ?

Assuming "libgloss" module is included in newlib, how to tell configure script to include "libgloss" ? I read crossgcc FAQ and i did'nt see any infos about this topic. May be it's an argument to make ?

Reply to
Habib Bouaziz-Viallet

It happens automatically when you use --target=m32c-elf

Reply to
DJ Delorie

Le Mon, 12 Nov 2007 13:19:44 -0500, DJ Delorie a écrit:

Hi !

Although i have no hardware platform to test any application, i compile the helloworld program :

#include

int main(void) { int ret=0; printf("Hello world!"); return(ret); }

I made this :

m32c-elf-gcc -O2 -mcpu=m16c -o hello hello.c

and the result is :

habib@mizar:~/PROJETS/M32CGCC/examples$ m32c-elf-gcc -O2 -mcpu=m16c -o hello hello.c /usr/local/lib/gcc/m32c-elf/4.2.2/../../../../m32c-elf/lib/libc.a(lib_a-closer.o): In function `_close_r': /home/habib/PROJETS/M32CGCC/m32c-elf-gcc/m32c-elf/newlib/libc/reent/../../../../../gcc-4.2.2/newlib/libc/reent/closer.c:53: warning: _close is not implemented and will always fail /usr/local/lib/gcc/m32c-elf/4.2.2/../../../../m32c-elf/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r': /home/habib/PROJETS/M32CGCC/m32c-elf-gcc/m32c-elf/newlib/libc/reent/../../../../../gcc-4.2.2/newlib/libc/reent/fstatr.c:62: warning: _fstat is not implemented and will always fail /usr/local/lib/gcc/m32c-elf/4.2.2/../../../../m32c-elf/lib/libc.a(lib_a-makebuf.o): In function `__smakebuf_r': /home/habib/PROJETS/M32CGCC/m32c-elf-gcc/m32c-elf/newlib/libc/stdio/../../../../../gcc-4.2.2/newlib/libc/stdio/makebuf.c:110: warning: isatty is not implemented and will always fail /usr/local/lib/gcc/m32c-elf/4.2.2/../../../../m32c-elf/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r': /home/habib/PROJETS/M32CGCC/m32c-elf-gcc/m32c-elf/newlib/libc/reent/../../../../../gcc-4.2.2/newlib/libc/reent/lseekr.c:58: warning: _lseek is not implemented and will always fail /usr/local/lib/gcc/m32c-elf/4.2.2/../../../../m32c-elf/lib/libc.a(lib_a-readr.o): In function `_read_r': /home/habib/PROJETS/M32CGCC/m32c-elf-gcc/m32c-elf/newlib/libc/reent/../../../../../gcc-4.2.2/newlib/libc/reent/readr.c:58: warning: _read is not implemented and will always fail /usr/local/lib/gcc/m32c-elf/4.2.2/../../../../m32c-elf/lib/libc.a(lib_a-writer.o): In function `_write_r': /home/habib/PROJETS/M32CGCC/m32c-elf-gcc/m32c-elf/newlib/libc/reent/../../../../../gcc-4.2.2/newlib/libc/reent/writer.c:58: warning: _write is not implemented and will always fail habib@mizar:~/PROJETS/M32CGCC/examples$

gcc does compile and produce an hello: ELF 32-bit LSB executable, version

1 (SYSV), statically linked, not stripped

but what are these weird messages about _close_r , ... etc ? Have you already experienced the same problem ?

Many thanks, Habib

Reply to
Habib Bouaziz-Viallet

If you build gdb for m32c-elf, it will build a simulator (m32c-elf-run) which can run most m32c programs that don't require hardware.

When you build for hardware, you have to provide a "gloss" library[*] that figures out how to do I/O for your particular hardware. If you want to run your program on the simulator, there's a gloss library already for that - to use it, add "-msim" to your compile line. Without -msim, you have to provide your own functions for all that, somehow.

[*] It's called that because it has all the stuff we "gloss over" when we first do the port, and have to get around to later. Mostly, it's how to start up the chip, do I/O, and allocate memory.
Reply to
DJ Delorie

Le Tue, 13 Nov 2007 08:07:23 -0500, DJ Delorie a écrit:

First of all thank you for your outstanding help ! Indeed i want (not for the moment) to run our apps on a real hardware (bought or build by us i think). I did not really understand what you mean when you say "provide your own functions" but i realize that there is no .h file (like ) i can include in relation with the hardware (CPU IO's registers, CPU memory spaces). So could you please send me an example where i can start with ?

Many thanks, Habib

Reply to
Habib Bouaziz-Viallet

Le Tue, 13 Nov 2007 14:54:41 +0000, Habib Bouaziz-Viallet a écrit:

oh BTW, m32c-elf-run runs fine

habib@mizar:~/PROJETS/M32CGCC/examples$ m32c-elf-run hello Hello world!

I'm impressed !

Habib

Reply to
Habib Bouaziz-Viallet

Aside from exit() calling too many things, anything that shows up is something your software is asking for (often indirectly), so if you need it, you need to figure out what it does. Plus, you need to use the right linker script (*.ld) for your specific chip. I include a couple in libgloss, but you need to adjust the ram/flash values to match the specific chip you're using.

However, here's an example from my own M3A0835 project:

void exit(int rv) { asm volatile (""); }

void outb(int c) { while (!ti_u1c1) asm volatile (""); u1tbl = c; }

int write(int fd, char *buf, int len) { int l = len; while (len--) outb(*buf++); return len; }

That's enough to give me printf() on the serial port, which is all I use.

Reply to
DJ Delorie

Le Tue, 13 Nov 2007 10:17:44 -0500, DJ Delorie a écrit:

Oh i see ! I've just include your write function on my helloworld and gcc does not complains about "writer function".

But in this case, write function is devoted only for writing into chip UART. Ok this can be solved by fd arg.

Many Thanks, Habib.

Reply to
Habib Bouaziz-Viallet

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.