numworks / epsilon

Modern graphing calculator operating system.
https://www.numworks.com/resources/engineering/software/
1.73k stars 458 forks source link

An open letter to Numworks: Are there any plans to have a more developer/user-friendly support for external apps? #2167

Open parisseb opened 6 months ago

parisseb commented 6 months ago

I'm the main author of Giac/Xcas, a CAS (computer algebra system) that I ported to several calculators under the name KhiCAS : Casio Graph 90/fxcg10/20/50, Casio Graph 35eii, TI Nspire (mono, CX, CX2) and HP Prime (builtin CAS), unlocked Numworks N0110 (with Epsilon version 15.5 or a 3rd-party fork). It also provides interactive geometry (2d/3d), 3d plots and a spreadsheet. Cf. https://xcas.univ-grenoble-alpes.fr/en

Recently some users have complainted about the KhiCAS nwa application with Epsilon version >=16, e.g. on tiplanet (https://tiplanet.org/forum/viewtopic.php?f=99&t=26532). This port was originally authored by a mysterious developer named Nwagyu (see note at the end), from the original port for unlocked N0110 calculators I made. His site (https://www.nwagyu.com/) has disappeared at the end of last year, it was cloned and later updated here https://yaya-cout.github.io/Nwagyu.

But this port of KhiCAS has several issues that are not present in the original unlocked Numworks N0110 port or on competing calculators:

It's beginning to be a major concern because it gives a bad opinion on the whole Xcas ecosystem to Numworks users trying KhiCAS on recent calculators. I have therefore decided to see if I could improve the port, my University has bought for me 2 Numworks calculators for development/testing. While some issues can probably be solved without Numworks intervention, the last issue I mentionned is a key issue that can not be solved without Numworks. It's also a key issue for anyone trying to develop an external application for Numworks calculators, and that probably explain why there are only a few of them, compared to other calculator brands. AFAIK, there are about 10 external apps for the Numworks, compared to a few hundreds for the FXCG50/Graph 90 (https://www.cemetech.net/downloads/browse/prizm) or the TI84 (https://www.cemetech.net/downloads/browse/84pce/asm).

Indeed the current behaviour after a reset is to delete the external applications, by writing in flash a 0x0 byte at a location where a magiccode for the additional app was flashed. This is done in the file ion/src/device/userland/boot/rt0.cpp:

  Ion::Device::Init::configureRAM();
  Ion::Init();
  // Initialize slotInfo to be accessible to Kernel
  Ion::Device::USB::slotInfo();
  Ion::ExternalApps::deleteApps();
  ion_main(0, nullptr);

There is no way to re-enable external app, you must make a full reinstallation after a reset/crash or an exammode in/out cycle. This is time consuming, very developer-unfriendly. Moreover, while writing a 0 does not really account for a flash writing cycle, reflashing the whole app does (and even reflashing only othe sector where the magic code was replaced by a 0 would still affect one sector). It will cause premature use of the concerned flash sectors, especially on developer calculators.

I do not understand the rationale behind this security measure. Why not :

I really hope that Numworks will improve external app support, as it is now, it is not seriously usable for 3rd party development. 3rd party development is not just games, it's also serious applications that are interesting to teach math at the highschool/college level, like CAS, 3d plots, interactive 2d and 3d geometry or spreadsheet, all these functionnalities are provided by KhiCAS, while not available on Numworks official firmware. Some countries like France allow CAS calculators during tests, some tests in the US allow CAS, Numworks users should be able to have access to a CAS that is competing with high-end calculators models like the TI Nspire CX2 CAS or HP Prime that cost about twice more. Students with less money should not be disadvantaged.

Bernard Parisse, Institut Fourier, Université Grenoble Alpes

A note about Nwagyu/ScarlettSpell (https://github.com/nwagyu/khicas): There are conjectures in the community that Nwagyu might be a pseudonym for someone within Numworks. The rationals behind this conjecture are:

BitRanger commented 6 months ago

I agree with your statement, and I also have a specific complaint regarding developing apps for the Numworks calculator. All of the template repos for the apps show how to build .nwa files and run them directly on the calculator; however, when you rebuild an app, you have to unplug and plug the calculator in again, which is very irritating. Another option would be running the apps in a simulator, but I also have not found any way to run those apps in an emulator yet.

parisseb commented 6 months ago

I have solved the simulator issue, in the sense that I have modified Epsilon in order to be able to run KhiCAS, but you can link to any code instead of KhiCAS, you just need to provide an extern "C" void ext_main() function. More details in French here https://tiplanet.org/forum/viewtopic.php?f=101&t=25699#p274772 For the reset issue, I have decided to split KhiCAS in 2 parts; a big app and a small nwa launcher linked by Numworks (BTW the make run command does not work on the C and C++ example, nwlink is probably broken). The launcher has an implementation of the same api as External, the external apps for the unlocked Numworks with 3rd party firmwares (Omega, Upsilon or Khi), it will call a big statically linked KhiCAS in slot B that is using this api for interaction with the hardware. That way, on reset, you must reflash one sector, but not the app in slot B. The same could be done for any app. In fact, it's probably possible to have something similar to External. The nwa launcher could display a menu of apps in a tar archive at 0x90200000 and run those apps statically linked. If we find a common free RAM area of 16K for External and for Epsilon 22 then we could achieve binary compatibility between Epsilon<16 and Epsilon 22. Or maybe Numworks could remove memory protection on ICTM RAM at 0x0, this area is used by External.

achkasov commented 6 months ago

I really hope NumWorks will support it. Can't wait to have the KhiCAS on my N0120 working properly and not being lost after a reboot.

parisseb commented 6 months ago

KhiCAS is now running well on my N0120. https://www-fourier.univ-grenoble-alpes.fr/~parisse/nws.html#install (French) https://www-fourier.univ-grenoble-alpes.fr/~parisse/nws_en.html#install (English) I have splitted the binary in 2 parts in the flash in order to not modify the exam mode sector at 0x903f0000: the rodata of khicas is at 0x90260000 (file khia) ending just before the exam mode sector of the 1st slot. The code (khi110ab.tar or khi120ab.tar) is at 0x90400000 (size about 3.5M). It's also possible to link KhiCAS in one shorter binary in the 2nd slot by removing the full online help and KhiCAS own MicroPython version (this version has some additional modules like arit for arithmetic or cas). I have added support in the launcher (khicas.nwa) for operations missing in the EADK, like detecting alpha/shift status, or erasing/writing a sector in the external flash. It's therefore possible to access/run scripts and KhiCAS sessions that are stored in flash, in a tarfile starting at 0x90200000 (6*64K available), working like for External on unlocked N0110). It's also possible to save scripts in the flash while running KhiCAS on the calculator. KhiCAS should also work on the n0110/n0115, but I did not have feedback up to now.

Source code: https://www-fourier.univ-grenoble-alpes.fr/~parisse/numworks/khib.tgz https://www-fourier.univ-grenoble-alpes.fr/~parisse/numworks/launch.tgz

I plan to update the documentation, first in French, maybe later in English if there is enough demand.

Now it's up to Numworks not to erase KhiCAS launcher after reset/crash, and why not keep it in exam mode in countries that allow CAS in exams, like in France ? It shouldn't be hard to authenticate the 2nd slot (at least for the stripped version of KhiCAS), e.g. by adding a sha256 signature of the khi110ab/khi120ab files inside the authenticated Numworks Epsilon firmware in the 1st slot.

BitRanger commented 6 months ago

I tried your website for the locked Numworks N0110, but it didn't work. When I pressed detect, the website responded that it successfully connected, but when I tried to flash the short, complete, or example scripts versions, it just stated that there was no calculator detected. When I went into the console to check, it seemed to have detected the calculator fine. Screenshot 2024-03-16 11 24 45 PM I tried manually running UI.numworks_install_slotb(), initially with the arguments (0,0), which failed, but when the second one was set to 1, it seemed to flash correctly. The Numworks app installer also worked fine, but when I launched the app, any key press immediately closed it. PXL_20240317_063401248~2

EmilieNumworks commented 6 months ago

Hi @parisseb, Thank you for your external app and contributions to its improvement. The NumWorks team agrees with your assessment: some features need to be improved to facilitate the development of external apps. We already have identified and included in our development trajectory two items that you mention:

parisseb commented 6 months ago

Hello Bitranger,

I tried your website for the locked Numworks N0110, but it didn't work...

The displayed entrypoint is wrong, you probably did a partial flash in slot A, but nothing in slot B. Please empty your browser cache and try again, I have a few successfull install reports now.

parisseb commented 6 months ago

Hello Emilie, Thanks for your answer. Avoiding external apps erase after a crash would be very welcome! Casio gives some infos in case of a crash, and it is most of the time possible to recover from crash by pressing MENU (aka HOME on the Numworks). What about an infinite loop that does not explicitly scan the keyboard? Is it possible to interrupt it by pressing HOME? I have another couple of questions:

fbeleznay commented 5 months ago

Hello, I have a question from the point of view of a teacher/exam invigilator. I came accross the following question from a reddit discussion group: Screen Shot 2024-04-07 at 17 32 29 How do we recognize on exams that students have this installed on their calculator? I am asking this not only about Numworks, I would like to know something about this for the Casio, TI, HPprime. Is there a link where I can read more about this?

parisseb commented 5 months ago

The Numworks version of KhiCAS is now ready for install from https://www-fourier.univ-grenoble-alpes.fr/~parisse/nws_en.html On the Numworks, KhiCAS displays a statusline (black on cyan) at the top and a help line at the bottom with shift-EXE menu|1 algb|2 calc|3 plot, it reminds that you have a quick access to the most useful CAS commands by pressing simultaneously shift 1 or shift 2 etc. On the Casio fxcg10/20/50 or TI Nspire (all models), the statusline at the top will display Xcas (native Xcas mode) or XcasPy (Python-compatible CAS) and at the bottom algb|calc|plot etc on the Casio (corresponding to the F1 F2 F3 etc. keys) or shift-1 algb|2 calc|3 plot on the Nspire (like on the Numworks but press the shift key, release, then press 1 or 2 or ...). Note that the TI Nspire has also a lua version of KhiCAS, pressing the doc button will display the app menu with Algebra, Calculus, etc. There is currently no port of KhiCAS on the TI83/84. On the HP Prime, there is no KhiCAS application, since Giac/Xcas is the builtin CAS. The statusline at the top displays CAS if the user is using the CAS interpreter (instead of the HOME numeric view) and the menuline at the bottom displays simplify in one of the 6 cells.

fbeleznay commented 5 months ago

Thanks for the info. I wanted to try it on my Numworks, but I failed at the first step (my calculator was detected by the website you linked, but then when I clicked "connect", it said I should try again. This is not important though, I only wanted to see how it works to see how my students might use it.

OK, I can imagine now how I can see that it is running on the calculators.

My real question is: Can I still set the Numworks (or Casio or TI nspire) to exam mode (I am interested in the IB exam mode) if the operating system includes KhiCAS, and will it be disabled (currently CAS is not allowed on IB exams)? On the HP prime (since this is the native CAS), this can be done.

If yes, it is fine. If not, I have some problems with this project.

I can see that it is a nice addition to have CAS on a handheld calculator, but to be honest, these are primariy exam calculators (I myself would use CAS on a computer if I need it and I use my calculator when a computer is not available, like on an exam).

adriweb commented 5 months ago

All external apps are removed upon enabling exam mode (or resetting the calc in general, currently, which is a problem in case of a crash of an app, as Parisse reminded in the first post)

parisseb commented 5 months ago

Thanks for the info. I wanted to try it on my Numworks, but I failed at the first step (my calculator was detected by the website you linked, but then when I clicked "connect", it said I should try again. This is not important though, I only wanted to see how it works to see how my students might use it.

This is quite strange, perhaps you had another tab open in your browser that captured the calculator ?

OK, I can imagine now how I can see that it is running on the calculators.

My real question is: Can I still set the Numworks (or Casio or TI nspire) to exam mode (I am interested in the IB exam mode) if the operating system includes KhiCAS, and will it be disabled (currently CAS is not allowed on IB exams)? On the HP prime (since this is the native CAS), this can be done.

It depends. On the Casio FXCG, exam mode disables addins, so KhiCAS is not usable. On (recent) locked N0110 Numworks (Epsilon>=16) and all N0115/N0120 Numworks, external apps are disabled, KhiCAS is not usable. On (old) unlocked N0110 Numworks (with Epsilon<=15.5 or a fork) and on some TI Nspire (all B&W and old colors models that were not upgraded to the latest OS version), KhiCAS remains usable in exam mode, following the French exam regulations (memory is erased, scripts can not be stored/retrieved from flash).

If yes, it is fine. If not, I have some problems with this project.

I can see that it is a nice addition to have CAS on a handheld calculator, but to be honest, these are primariy exam calculators (I myself would use CAS on a computer if I need it and I use my calculator when a computer is not available, like on an exam).

Exam regulations are not the same everywhere. In France, CAS is allowed. In Germany, graphing calculators without CAS will be forbidden in a few years. In the US, some tests allow CAS, some tests disallow CAS.

My main motivation for porting KhiCAS to calculators is that a student should not be disadvantaged because he can't afford to pay a high-end CAS calculator like the HP Prime or TI Nspire CX 2 CAS or Casio Classpad 500. And this is precisely the current situation: in France, student with CAS calculators represent about 1% of the market. In the US, it's more, between 5 and 10% I would say based on Amazon sales. When Numworks launched the N0110 in 2019, I had a big hope: giving all French students the opportunity to have a CAS calculator, allowed in exam, at half the price of a CAS calculator. Unfortunately, Numworks decided to lock their calc, because they feared to be banned in some countries. Now, I hope they will reconsider that because there are solutions to satisfy regulations with or without CAS, the HP Prime and TI Nspire CAS have exam modes with or without CAS.

Then there is the debate "should CAS be allowed in tests or not?". My opinion is that we should evaluate students using exams with and without calculators. It's important that students do some mental calculations (it's like training for a sportive competition) but it's also important that students know how to use technology, including CAS. CAS is a very useful tool to double-check a computation. It is also an exploratory tool. It is very well adapted to school situations on a calculator, not only exams, because it is available in a standard classroom, instant on, and it's better than a smartphone that can divert attention.

And let me finish this long message (sorry about that) by a few observations I made this year: I asked to advanced students in an effective algebra course at my University (4th year student math major) how many of them did use a CAS before? The answer was 0 over 9. I also asked 2nd year students with math major or math and CS major who choosed a course "Computer assisted maths" the same question: answer was 4 over 25. And I asked physics major how many have a CAS calculator: answer was 1 over 100. Tools like CAS are here, ignoring them will not make them disappear. We should really integrate smart use of CAS in math curriculum.

fbeleznay commented 5 months ago

Perfect, thank you for the clarification.

Just to be clear, I am not against CAS, in fact I encourage my students to use it (since CAS is not allowed on IB exams, we use CAS on a computer, not on the calculator).

I did not know about the trend in Germany and the current status in France. I understand your reasons, thanks for the details. I was asking these questions because I was not sure how easy it is for students to cheat (based on the student comment I pasted in my first post, this does cross the minds of students). Currently on IB exams CAS is not allowed and it would give unfair advantage if some students could use it. As you explained, this cannot be done if invigilators check that exam mode is activated, which I hope they do everywhere.

parisseb commented 3 months ago

FYI, I have released production ready versions of KhiCAS for the hardware calculators and simulators. Calculators: https://www-fourier.univ-grenoble-alpes.fr/~parisse/nws_en.html#install Simulator (based on Upsilon, aka Epsilon 15.5) web : https://www-fourier.univ-grenoble-alpes.fr/~parisse/kcasen.html PC: https://www-fourier.univ-grenoble-alpes.fr/~parisse/numworks/upsilon.zip Mac: https://www-fourier.univ-grenoble-alpes.fr/~parisse/numworks/upsilon.dmg The simulator is based on the latest redistribuable Epsilon version, until Numworks has support for external apps in the simulator. The simulator can export KhiCAS (Xcas or MicroPython) computation history and script that are not too large as a QR code: press the Power key of the simulator. This QR code can be displayed by a teacher, then students can flash it from their smartphone or tablets and get a clone of the teacher session on the smartphone/tablet (with the simulator web version). On hardware Numworks and fxcg50 calculators, KhiCAS can also display a QR code so that a student calculator session can also be cloned. I made this week the suggestion to Numworks to add a hardware component to calculators so that a calculator can flash a QR code (such a hardware component should of course be disabled in exam mode). I have no idea of the cost, but if it is not too expensive, I think it could be a key feature to convince TI users to switch to Numworks! A QR Numworks CAS!