Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
This is my first technical post on Cemetech

I have a CG50 that I am interested in programming. I am on Ubuntu 17.04 and looking to set up the C SDK. I have seen the wiki page on setting up the SDK, but it seems to be rather old. Are there any up to date instructions on setup? Can I use the version of GCC I have on my computer already? (gcc 6.3.0 20170406.) I have only recently got Ubuntu after using Windows for years, so I have a bit of learning to do. I have written only very basic C before, but I also have some slightly more advanced C++ experience.

I have some questions about the calculator and Casio themselve's. What microcontroller/processor is used in the CG50? I have read that a SuperH 3 processor is used on the CG10/20 calculator here, supposedly with a base clock rate of 116MHz, underclocked to 58MHz. The CG50 is about twice as fast in tests, yet has a longer battery life than the CG10/20, so presumably it has a different processor, but I am guessing the same instruction set. Do we know exactly what processor is in the CG50? I have searched online and can't find the answer, why doe Casio not make this information easily available? Does Casio provide technical documentation of the calculator anywhere? I have found some basic user guides, but few specifics. Does Casio provide any official programming tools for the PRIZM series or does it plan to do so?

Edit: On the wiki http://prizm.cemetech.net/index.php/Technical_Info , it says that the processor is a SH4-A family SH7305 in the CG10/20 . So is it a SH3 in the CG10/20 or an SH4-A? This technical documentation is all for the CG10/20, will the wiki ever be updated for the CG50?

Thanks
There are some great programmers using ubuntu for fx-cg addins so I think they will be able to help you. I haven’t switched from windows aa linux was too hard for me. Maybe when you succeed despite being new to ubuntu - i will give it a try again. I used windows for addins coding and struggled with some parts but it was mostly solved so if you need help with windows post the problems here and I will try to help
Here is a very easy way to setup a compiler.
If you have not already done so run

Code:

sudo apt install build-essential

You might need other packages, I don't use Ubuntu.

First copy this:

Code:

#!/bin/bash
set -e
set -o pipefail

TMPDIR=/tmp
cd $TMPDIR

wget 'http://ftp.gnu.org/gnu/binutils/binutils-2.29.1.tar.xz'
wget 'http://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz'

tar -xf binutils*
tar -xf gcc*

export PREFIX=$HOME/casio-gcc
mkdir -p $PREFIX
export PATH=$PATH:$PREFIX/bin
export TARGET=sh3eb-elf
export CFLAGS="-O2 -pipe -s -fomit-frame-pointer -ffunction-sections -fdata-sections"
export CXXFLAGS=$CFLAGS && export LDFLAGS="-Wl,--gc-sections"
mkdir -p build-binutils
cd build-binutils
../binutils-*/configure --disable-werror --target=$TARGET --prefix=$PREFIX --disable-nls --disable-tls --disable-libssp --enable-plugin --enable-plugins --enable-gold=yes
make -j8
make -j8 install
cd ..
mkdir -p build-gcc
cd build-gcc
../gcc-*/configure --target=$TARGET --prefix=$PREFIX  --without-headers --enable-plugin --enable-plugins --enable-gold=yes --enable-sjlj-exceptions --disable-hosted-libstdcxx --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --disable-nls --disable-tls --disable-libssp --disable-threads --disable-shared --enable-static --disable-__cxa_atexit --disable-libvtv --disable-libada --with-endian=big
make -j8 all-gcc
make -j8 install-gcc

make -j8 all-target-libgcc
make -j8 install-target-libgcc


To a file. You can call it whatever you like but there is a convention to give it a .sh extension for example setup-casio-gcc.sh.

Then in a terminal cd to the directory you created this file and run bash setup-casio-gcc.sh or whatever you called it.

This will compile gcc and install it to a folder called casio-gcc which will be found in your home directory.

Once the script is done you may cleanup your /tmp directory.

Note that /tmp should have lots of space maybe even 4gb. If you don't have that in /tmp modify TMPDIR. The reason we use /tmp is because it is a ram disk so compiling is very fast. It only takes a few minutes to run this script for me (excluding downloading GCC and binutils).

Now to get the SDK just run

Code:

git clone https://github.com/Jonimoose/libfxcg --depth 1

If this does not work because you don't have git run

Code:

sudo apt-get install git
ProgrammerNerd wrote:
Here is a very easy way to setup a compiler.
If you have not already done so run

Code:

sudo apt install build-essential

You might need other packages, I don't use Ubuntu.

First copy this:

Code:

#!/bin/bash
set -e
set -o pipefail

TMPDIR=/tmp
cd $TMPDIR

wget 'http://ftp.gnu.org/gnu/binutils/binutils-2.29.1.tar.xz'
wget 'http://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz'

tar -xf binutils*
tar -xf gcc*

export PREFIX=$HOME/casio-gcc
mkdir -p $PREFIX
export PATH=$PATH:$PREFIX/bin
export TARGET=sh3eb-elf
export CFLAGS="-O2 -pipe -s -fomit-frame-pointer -ffunction-sections -fdata-sections"
export CXXFLAGS=$CFLAGS && export LDFLAGS="-Wl,--gc-sections"
mkdir -p build-binutils
cd build-binutils
../binutils-*/configure --disable-werror --target=$TARGET --prefix=$PREFIX --disable-nls --disable-tls --disable-libssp --enable-plugin --enable-plugins --enable-gold=yes
make -j8
make -j8 install
cd ..
mkdir -p build-gcc
cd build-gcc
../gcc-*/configure --target=$TARGET --prefix=$PREFIX  --without-headers --enable-plugin --enable-plugins --enable-gold=yes --enable-sjlj-exceptions --disable-hosted-libstdcxx --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --disable-nls --disable-tls --disable-libssp --disable-threads --disable-shared --enable-static --disable-__cxa_atexit --disable-libvtv --disable-libada --with-endian=big
make -j8 all-gcc
make -j8 install-gcc

make -j8 all-target-libgcc
make -j8 install-target-libgcc


To a file. You can call it whatever you like but there is a convention to give it a .sh extension for example setup-casio-gcc.sh.

Then in a terminal cd to the directory you created this file and run bash setup-casio-gcc.sh or whatever you called it.

This will compile gcc and install it to a folder called casio-gcc which will be found in your home directory.

Once the script is done you may cleanup your /tmp directory.

Note that /tmp should have lots of space maybe even 4gb. If you don't have that in /tmp modify TMPDIR. The reason we use /tmp is because it is a ram disk so compiling is very fast. It only takes a few minutes to run this script for me (excluding downloading GCC and binutils).

Now to get the SDK just run

Code:

git clone https://github.com/Jonimoose/libfxcg --depth 1

If this does not work because you don't have git run

Code:

sudo apt-get install git


Thank you for the answer. So am I correct that your instructions will build another version of gcc, that wont affect the existing gcc on my system? The wiki says that I need mk3ga for the makefile to package the .elf files into .g3a files, does mk3ga come with the SDK? How do I invoke gcc to compile for the processor on the casio and not for my computer?

Thanks!

I have a lot of questions, I imagine some of them obvious.
RobC wrote:
Thank you for the answer. So am I correct that your instructions will build another version of gcc, that wont affect the existing gcc on my system? The wiki says that I need mk3ga for the makefile to package the .elf files into .g3a files, does mk3ga come with the SDK? How do I invoke gcc to compile for the processor on the casio and not for my computer?

Thanks!

I have a lot of questions, I imagine some of them obvious.

Normally you can just rename gcc in the installed compiler directory to gcc-casio if it isn't already. Then it will be able to compile for casio by running gcc-casio instead. I believe that mk3ga does come; but you should probably check that.
MateoConLechuga wrote:

Normally you can just rename gcc in the installed compiler directory to gcc-casio if it isn't already.

Assuming that it isn't, how would I do this?
RobC wrote:
MateoConLechuga wrote:

Normally you can just rename gcc in the installed compiler directory to gcc-casio if it isn't already.

Assuming that it isn't, how would I do this?

Navigate into the created script directory 'casio-gcc' and rename the 'gcc' file to 'gcc-casio' Smile
MateoConLechuga wrote:
RobC wrote:
MateoConLechuga wrote:

Normally you can just rename gcc in the installed compiler directory to gcc-casio if it isn't already.

Assuming that it isn't, how would I do this?

Navigate into the created script directory 'casio-gcc' and rename the 'gcc' file to 'gcc-casio' Smile

Doh, Thanks!
I never had to do that. All you do is run sh3eb-elf-gcc instead of gcc. Also run

Code:

export PATH=$PATH:~/casio-gcc/bin

To easily use sh3eb-elf-gcc anywhere. In practice you will never have to type sh3eb-elf-gcc because the make files will do it for you. When I want to compile my programs I just type make and everything is taken care of for me.

The reason this installation of will not interfere with your systems installation of GCC is because we install it in a different directory. In addition the script is not ran as root so your system's GCC installation is protected.
ProgrammerNerd wrote:
I never had to do that. All you do is run sh3eb-elf-gcc instead of gcc. Also run

Code:

export PATH=$PATH:~/casio-gcc/bin

To easily use sh3eb-elf-gcc anywhere. In practice you will never have to type sh3eb-elf-gcc because the make files will do it for you. When I want to compile my programs I just type make and everything is taken care of for me.

Oh, OK, I will try this first instead. So sh3-elf-gcc will produce the .elf that I can then convert to .g3a with the mkg3a. Great, I will try to set this up tomorrow if I have time, and compile, package and upload a test C program to confirm it all works. If I get this all working I will document the steps on the wiki.
Yes that is all correct. Note that when compiling your programs you will need to specify a few options. Running sh3eb-elf-gcc main.c -o my_program is not enough. Look at this make file for an example
https://github.com/ComputerNerd/Mandelbrot-Casio-Prizm-Explorer/blob/master/Makefile.casio

Note that not everything in that Makefile is necessary for compiling a program. The -DCASIO_PRIZM is only used by my Mandelbrot project to allow cross compiling for PC.

Also this makefile assumes it is in the libfxcg/examples/project_name because of its use of relative paths.
ProgrammerNerd wrote:
Yes that is all correct. Note that when compiling your programs you will need to specify a few options. Running sh3eb-elf-gcc main.c -o my_program is not enough. Look at this make file for an example
https://github.com/ComputerNerd/Mandelbrot-Casio-Prizm-Explorer/blob/master/Makefile.casio

Note that not everything in that Makefile is necessary for compiling a program. The -DCASIO_PRIZM is only used by my Mandelbrot project to allow cross compiling for PC.

Also this makefile assumes it is in the libfxcg/examples/project_name because of its use of relative paths.


Does this makefile definitely work? Mandelbrot explorer does not work on cg50 for me.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement