NumWorks additional flash & giac
Disclaim
This article is not up to date. It is just a place to document what I have done some time ago regarding this contest on TI-Planet : https://tiplanet.org/forum/viewtopic.php?t=20557
Introduction
First, a compatible SPI flash chip must be soldered inside the calculator on the U7 pad. I used an AT25SF641 kindly donated by TI-Planet, as it was the part referenced on the official schematics.
At the time, there was no implementation of USB inside the official firmware so I choose to write a small loader compatible with the flashrom serprog protocol. Doing this, I only had to care about low level stuff (sending raw bytes to the flash), and all the flashing protocol (erasing, writing, …) is handled by flashrom.
Then, some modifications were needed in the firmware to initialise and use the flash, but also to split the code between the internal and the external flash (linker script).
In the process, I fried the MCU of my NumWorks for an unknown reason, so be careful and/or prepared to replace it !
An ARM compiler is needed, I’m using the binaries provided by ARM here, and also the dependencies listed in the NumWorks SDK documentation.
Compiling giac & the firmware
I assume that all the repositories are cloned in the same folder, as there are relative path references between them.
libtommath:
$ git clone https://github.com/zardam/libtommath-0.39
$ cd libtommath-0.39
$ make
giac:
$ git clone https://github.com/zardam/giac-1.4.9.git
$ cd giac-1.4.9/src
$ make -f Makefile.numworks
epsilon:
$ git clone -b giac https://github.com/zardam/epsilon.git
$ cd epsilon
$ make app.bin app-extflash.bin
Compiling QSPI Loader & flashrom
Note: flashrom needs to be patched in order to support the Adesto flash chip.
$ git clone https://github.com/zardam/qspi_loader.git
$ cd qspi_loader
$ git submodule init
$ git submodule update
$ cd libopencm3
$ make
$ cd ../flashrom
$ patch -p1 < ../flashrom_patch/AT25SF641.patch
$ make CONFIG_ENABLE_LIBPCI_PROGRAMMERS=no CONFIG_ENABLE_LIBUSB0_PROGRAMMERS=no CONFIG_ENABLE_LIBUSB1_PROGRAMMERS=no
Flashing the beast
The first thing is to run QSPI Loader on the calculator. The calculator must be in the bootloader mode (plugged to a USB port then reseted).
$ cd qspi_loader/qspi_loader
$ make run_qspi_loader
There should be a new serial port connected (probably ttyACM0):
$ dmesg
[195276.110697] usb 1-2: USB disconnect, device number 13
[195276.417775] usb 1-2: new full-speed USB device number 14 using xhci_hcd
[195276.567101] usb 1-2: New USB device found, idVendor=0483, idProduct=5740, bcdDevice= 2.00
[195276.567106] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[195276.567110] usb 1-2: Product: QSPI serprog
[195276.567113] usb 1-2: Manufacturer: zardam
[195276.567115] usb 1-2: SerialNumber: 30333036145136341F802700
[195276.600532] cdc_acm 1-2:1.0: ttyACM0: USB ACM device
[195276.601102] usbcore: registered new interface driver cdc_acm
[195276.601103] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
The Adesto flash chip needs to be put in QSPI mode for proper operation. This is needed only once. I did not know this at first, and I think I killed the MCU of my calculator because the unused data pins are not floating on the Adesto chip when it is not in QSPI mode.
$ cd qspi_loader/tools
$ ./enable_qspi_AT25SF641.py
Then load the external flash using flashrom:
$ cd epsilon
$ ../qspi_loader/flashrom/flashrom -p serprog:dev=/dev/ttyACM0:115200 -w app-extflash.bin
And then, reset the calculator (to go in the MCU bootloader) and flash epsilon:
$ make app_flash
Done !
Demo
Warning, the video was done with the external flash not running at full speed. Actual performance is much better.