Les membres ayant 30 points peuvent parler sur les canaux annonces, projets et hs du chat.

Forum Casio - Autres questions


Index du Forum » Autres questions » SDK programming on fx-9750GIII
Druzyek Hors ligne Membre Points: 21 Défis: 0 Message

SDK programming on fx-9750GIII

Posté le 23/10/2020 05:06

Hi, I hope it's ok if I post a question in English. Please answer in French if you like.

I just got an fx-9750GIII that I would like to make an add-in for. I setup the SDK as described here: Programmer en C sur Graph 35/75 +E I was able to compile the example program and run it in the simulator.

I copied the Default folder and MonochromeLib files described here so the SDK will produce an SH4 add-in. [Tutoriel] Configurer le SDK pour le rendre compatible SH4 I created a new project and got warnings about SH4_compatibility.h redefining key macros. I put #define __KEYBIOS_H__ at the top of my file so keybios.h would not include key constants and the warning went away.

My project contains MonochromeLib.c, SH4_compatibility.c, and main.c. It compiles to a G1A that is 4.34k. When I run it in the simulator, I get an error saying "Nonexisting memory by data write access at 87FFFFFC" and the trace jumps to the declaration for GetKeyMod, but maybe that is normal for the simulator if it doesn't support the new GIII. When I run the add-in on my calculator, the screen freezes and I have to press the reset button on the back.

What can I do? Does anyone have an empty project that will compile and run for the 9750GIII or 9860GIII that they can share?

Here is my code:
define __KEYBIOS_H__
#include "fxlib.h"
#include "SH4_compatibility.h"
#include "MonochromeLib.h"
// #include "string.h"

int AddIn_main(int isAppli, unsigned short OptionNum)
{
    unsigned int key;

    //Bdisp_AllClr_DDVRAM();
    ML_clear_vram();

    locate(1,4);
    Print((unsigned char*)"This application is");
    locate(1,5);
    Print((unsigned char*)" sample Add-In.");

    while(1){
        GetKey(&key);
    }

    return 1;
}



Lephenixnoir Hors ligne Administrateur Points: 20112 Défis: 143 Message

Citer : Posté le 10/05/2021 16:43 | #


These modules are provided by the fxSDK, along with compiler settings. You can use fxsdk build-fx or fxsdk build-cg which will run CMake and make for you. If you want to pass additional parameters besides the default, use fxsdk build-fx -c ... to pass CMake parameters, or fxsdk build-fx ... to pass make parameters.
Druzyek Hors ligne Membre Points: 21 Défis: 0 Message

Citer : Posté le 10/05/2021 17:16 | #


So nothing to build or install for gint before I can use it? Hmm, I tried running sh-elf-gcc --print-search-dirs but I'm not sure where to move gint. Do the include and lib folders need to be copied separately to the existing include and lib folders?
Lephenixnoir Hors ligne Administrateur Points: 20112 Défis: 143 Message

Citer : Posté le 10/05/2021 17:27 | #


You do need to build and install gint; however it is now an fxSDK library, therefore you should build and install it with the fxSDK commands. Previously, gint included cross-compiling code and different build system tools that had to be replicated for every library or program destined to the calculator. Since the change to CMake, all these tools are now provided by the fxSDK.

gint, in a sense, is now an fxSDK project and you can build and install it like this:

% fxsdk build-fx install
% fxsdk build-cg install

It installs itself in the compiler's default search path (in the install search dir that you queried).

Once you've done that, you can create new projects with the fxSDK and have them use gint as it will be installed. (For new projects, you can pass --makefile to fxsdk new if you want the old Makefile-based system, or just fxsdk new with the new CMake-based one. There is an introduction to CMake here if you want details; you can copy-paste it to DeepL for a very good translation.)
Druzyek Hors ligne Membre Points: 21 Défis: 0 Message

Citer : Posté le 10/05/2021 17:39 | #


That's an interesting way to do it! Another error. Hmm, do I need to install OpenLibM separately?
[ 72%] Building C object CMakeFiles/gint-fx.dir/src/3rdparty/grisu2b_59_56/grisu2b_59_56.c.obj
In file included from /home/druzyek/fx9750giii/gint/gint/src/3rdparty/grisu2b_59_56/grisu2b_59_56.c:26:
/home/druzyek/fx9750giii/gint/gint/src/3rdparty/grisu2b_59_56/k_comp.h:26:10: fatal error: openlibm.h: No such file or directory
   26 | #include <openlibm.h>
      |          ^~~~~~~~~~~~
Lephenixnoir Hors ligne Administrateur Points: 20112 Défis: 143 Message

Citer : Posté le 10/05/2021 17:46 | #


Hmm, yes, I forgot to mention it. This is required for math functions and floating-point printing in printf()-family functions. OpenLibm is a port of an existing project with its own build system, so it's not an fxSDK project. It is compiled with a simple make command, please see this section of the README.

As you can guess, over time the number of ported libraries and tools has increased. Most of them can be installed in minutes once you get used to the process, but I realize it's a bit tedious. This is another reason why I designed GiteaPC, as it automates some of this work. Because of the wide range of skill in the user base of the fxSDK, I have yet to find a comfortable way of handling the install process. Feedback is welcome.
Druzyek Hors ligne Membre Points: 21 Défis: 0 Message

Citer : Posté le 10/05/2021 17:49 | #


Holy moly Ok, I'll give this one a try too. Are there others I'll need that I can look into while this is installing?
Lephenixnoir Hors ligne Administrateur Points: 20112 Défis: 143 Message

Citer : Posté le 10/05/2021 18:07 | #


There are no more dependencies, fortunately. There is a project to build a proper libc (as currently gint simply provides the most commonly-used functions), which would become one in the future, but at this point I might start shipping binary versions of the development environment. Right now you should be good to go

Once again thank you for bearing with me!
Druzyek Hors ligne Membre Points: 21 Défis: 0 Message

Citer : Posté le 10/05/2021 23:23 | #


It works! I feel like I should make something to prove it works. Thanks for all your help!

I noticed that Hello, World is now 26k. Is there any way to cut that down a little? Is it including the whole floating point package and other stuff I won't need?
Lephenixnoir Hors ligne Administrateur Points: 20112 Défis: 143 Message

Citer : Posté le 10/05/2021 23:32 | #


That's awesome! Good job! o/

It's a little bit heavy indeed. The floating-point is not included (as part of an effort to not blow up the file size). You can see exactly what's included by generating and checking the map file. This option will enable the generation during link in CMakeLists.txt:

target_link_options(myaddin PRIVATE -Wl,-Map=map)

then read build-fx/map after recompiling.

What you get in the default add-in is mostly base drivers, drawing functions, the heap and printf-style functionality (floating point excluded). It's difficult to cut it down, but the most important is what happens next. There are popular add-ins programmed "naively" that get over 100 kB because of imperfect structure, while others are much more compact. In general, since the storage memory is big, 25 kB doesn't matter too much.
Druzyek Hors ligne Membre Points: 21 Défis: 0 Message

Citer : Posté le 18/05/2021 15:11 | #


I'm back with more errors! I tried installing on a fresh copy of Ubuntu 21.04 rather than a copy upgraded from 20.04 which is how I got it working last time. Here's what I get when I try to run fxsdk build-fx on a new project:

-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:10 (find_package):
  By not providing "FindGint.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Gint", but
  CMake did not find one.


I did try GiteaPC again on a fresh install of 21.04 and it installed but wouldn't work (I didn't save the error).

Here's my attempt at a build script:

#!/bin/bash

export PAUSE_BETWEEN=false
export BINUTILS_VER="2.36.1"
export GCC_VER="11.1.0"
export PREFIX="$HOME/fx9750giii/sh-elf-$BINUTILS_VER-$GCC_VER"
export PATH="$PATH:$PREFIX/bin"

function pause_key() {
  if [ "$PAUSE_BETWEEN" = true ]; then
    read -p "$1"
  fi
}

sudo apt install -y libmpfr-dev
sudo apt install -y libmpc-dev
sudo apt install -y libgmp-dev
sudo apt install -y libpng-dev
sudo apt install -y libppl-dev
sudo apt install -y flex
sudo apt install -y g++
sudo apt install -y git
sudo apt install -y texinfo
sudo apt install -y tree
sudo apt install -y cmake

mkdir -p $PREFIX
cd $PREFIX

sudo apt install curl
curl -u anonymous: -O ftp://ftp.gnu.org/gnu/binutils/binutils-$BINUTILS_VER.tar.xz
curl -u anonymous: -O ftp://gcc.gnu.org/pub/gcc/releases/gcc-$GCC_VER/gcc-$GCC_VER.tar.xz

tar -xJf binutils-$BINUTILS_VER.tar.xz
tar -xJf gcc-$GCC_VER.tar.xz
mkdir build-binutils build-gcc
tree -L 1
pause_key "Press enter if tree looks correct"

#moved above
#export PATH="$PATH:$PREFIX/bin"
echo "export PATH=\"\$PATH:$PREFIX/bin\"" >> $HOME/.profile
cd build-binutils
../binutils-$BINUTILS_VER/configure --prefix=$PREFIX --target=sh3eb-elf --with-multilib-list=m3,m4-nofpu --disable-nls --program-prefix=sh-elf-
pause_key "Press enter if  build-binutils configured correctly"

make -j4
pause_key "Press enter if  binutils built correctly"

make install
pause_key "Press enter if binutils installed correctly"

cd $PREFIX/build-gcc
../gcc-$GCC_VER/configure --prefix=$PREFIX --target=sh3eb-elf --with-multilib-list=m3,m4-nofpu --enable-languages=c,c++ --without-headers --with-newlib --disable-nls --program-prefix=sh-elf-
pause_key "Press enter if build-gcc configured correctly"

make -j4 all-gcc
pause_key "Press enter if gcc built correctly"

make install-gcc
pause_key "Press enter if gcc installed correctly"

make -j4 all-target-libgcc
pause_key "Press enter if libgcc built correctly"

make install-target-libgcc
pause_key "Press enter if libgcc installed correctly"


#END OF GCC/BINUTIL INSTALLATION


#INSTALLATION OF FXSDK
cd $PREFIX

python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow

sudo apt install -y libpng-dev
sudo apt install -y libusb-1.0-0-dev
sudo apt install -y pkg-config

git clone https://gitea.planet-casio.com/Lephenixnoir/fxsdk
pause_key "Press enter if fxsdk cloned"

cd fxsdk
sudo cmake -B build -DFXLINK_DISABLE_UDISKS2=1
sudo make -C build
pause_key "Press enter if fxsdk built successfully"

sudo make -C build install
pause_key "Press enter if fxsdk installed correctly"

#END OF FXSDK INSTALLATION


#GINT INSTALLATION
cd $PREFIX
git clone https://gitea.planet-casio.com/Lephenixnoir/OpenLibm
pause_key "Press enter if OpenLibm cloned"

cd OpenLibm
OL_PREFIX=$(sh-elf-gcc --print-search-dirs | grep install | sed 's/install: //')
make USEGCC=1 TOOLPREFIX=sh-elf- libdir="$OL_PREFIX" includedir="$OL_PREFIX/include" install-static install-headers
pause_key "Press enter if OpenLibm built correctly"

cd $PREFIX
git clone -b dev https://gitea.planet-casio.com/Lephenixnoir/gint
pause_key "Press enter if gint cloned"

cd gint
fxsdk build-fx
pause_key "Press enter if gint built correctly"

echo -e "\033[0;32mCasio install done"
echo "RESTART SHELL"

Lephenixnoir Hors ligne Administrateur Points: 20112 Défis: 143 Message

Citer : Posté le 18/05/2021 15:48 | #


You're almost there! At the very last step you ran fxsdk build-fx which does build gint but does not install it (it's like make alone). Make that fxsdk build-fx install (which is like make install) and you'll be up and running.

LienAjouter une imageAjouter une vidéoAjouter un lien vers un profilAjouter du codeCiterAjouter un spoiler(texte affichable/masquable par un clic)Ajouter une barre de progressionItaliqueGrasSoulignéAfficher du texte barréCentréJustifiéPlus petitPlus grandPlus de smileys !
Cliquez pour épingler Cliquez pour détacher Cliquez pour fermer
Alignement de l'image: Redimensionnement de l'image (en pixel):
Afficher la liste des membres
:bow: :cool: :good: :love: ^^
:omg: :fusil: :aie: :argh: :mdr:
:boulet2: :thx: :champ: :whistle: :bounce:
valider
 :)  ;)  :D  :p
 :lol:  8)  :(  :@
 0_0  :oops:  :grr:  :E
 :O  :sry:  :mmm:  :waza:
 :'(  :here:  ^^  >:)

Σ π θ ± α β γ δ Δ σ λ
Veuillez donner la réponse en chiffre
Vous devez activer le Javascript dans votre navigateur pour pouvoir valider ce formulaire.

Si vous n'avez pas volontairement désactivé cette fonctionnalité de votre navigateur, il s'agit probablement d'un bug : contactez l'équipe de Planète Casio.

Planète Casio v42 © créé par Neuronix et Muelsaco 2004 - 2021 | Il y a 50 connectés | Nous contacter | Qui sommes-nous ? | Licences et remerciements

Planète Casio est un site communautaire non affilié à Casio. Toute reproduction de Planète Casio, même partielle, est interdite.
Les programmes et autres publications présentes sur Planète Casio restent la propriété de leurs auteurs et peuvent être soumis à des licences ou copyrights.
CASIO est une marque déposée par CASIO Computer Co., Ltd