CartFlasher

From F256 Foenix
Jump to navigationJump to search

Hardware and memory map for carts

Apart from the 256K RAM expansion cartridge there is also 256K flash expansion cartridge for the F256 K/Jr. available from Foenix Retro Systems.

The 256K flash chip in the cartridge is a SST39LF/VF020 by Microchip. Its data sheet can be found here. The data sheet is necessary if one wants to understand what both of the programs linked above actually do. The flash cartridge is also compatible with the K2/JrJr.

This cartridge contains extra flash memory which can be used to store software and data in a non volatile fashion.

The extra memory is visible at 24 bit address $100000. The MMU (see Memory Management) can map the 32 8K blocks on the cartridge as blocks $80 to $9F into the 64K base memory.

Behavior at bootup

Since an early February 2025 release of a micro-kernel version (classic MMU 6502 mode), DIP switch #1 (see DIP switches) can be involved to avoid a chicken-and-the-egg scenario.

When the DIP Switch #1 is off (regular behavior):

  1. The MicroKernel looks for a Kernel User Program (KUP, see File Formats) in the 256kb flash cartridge first and boots the first one it finds; if not, it proceeds to step 2.
  2. It then looks in the on-board 512kb of flash memory and boots the first one it finds; most people have something that can run in on-board flash, namely: superbasic, dos or f/manager. If not, step 3.
  3. If you operate with a minimalistic flash and cart contents that both only have microkernel, then your machine will hang at the microkernel text splash screen.

Important to note: this can lead to a situation where you are stuck with a written cartridge that has a bootable, working program, but there would be no way to rewrite it with a new program, or with an updated version of the existing program. The cartridge needs to be inserted beforehand when the bootup is performed and it's strongly not recommended to hot-insert a cartridge while the machine is running. The problem occurs because you need the machine to access a cartridge rewriter program, but in order to do so, you must not boot into whatever program is contained in the cart. There needs to be a way to return to superbasic, or dos, or f/manager, but the cart's program prevents doing so. The solution is right below:

When the DIP Switch #1 is on (dev mode):

  1. The MicroKernel will no longer look for a KUP in the 256kb flash cartridge and instead go right to step 2;
  2. It looks for a program inserted in RAM, which could have been inserted from methods such as FoenixMgr from a usb connected modern dev computer, or from the emulator FoenixIDE, if none is found, then:
  3. It then looks for KUP inside the onboard 512kb flash memory.

Important to note: you must use this DIP switch position in order to edit a previously written flash cartridge so that you can access the programs that do perform this operation. The only exception would be if the cartridge itself had been prepared with a boot loader program that includes a flash cartridge writing program.

Tools for getting software on a Flash cartridge

If you want to write data on your flash expansion cartridge then there are two programs which can be used for this purpose:

Both do run on your Foenix machine.

F256_FlashCart

is written in BASIC and always erases the whole flash chip before writing new data to it.

fcart

allows to incrementally write data to a flash cartridge by only erasing the flash blocks which it is told to overwrite.

Additionally it can be built in three versions.

  1. First as a pgz file (see File Formats) which can be run py Pexec,
  2. then as a KUP which expects to be run from on-board flash
  3. as a KUP which can be run from the last block of the flash cartridge itself. This allows the cartridge to be self contained in such a way that no additional software is needed to store data on it.
pgz2flash

this tool allows to convert a regular .pgz executable into either a single .bin file destined for flash cartridges (usable by fcart for instance) or for the on-board flash memory by chopping it up in 8kb pieces, destined to be flashed with FoenixMgr.

Find instructions for usage, for building in linux or a pre-compiled executable for Windows here: https://github.com/rmsk2/pgz2flash

Step by step guide to get software on a Flash Cart

  1. Download fcart.pgz from https://github.com/rmsk2/cartflash/releases
  2. Download loader.bin from https://github.com/rmsk2/flashselect/releases
  3. Use fcart.pgz to write loader.bin to block 0 of your cartridge
  4. Optional: Download cartridge.bin from https://github.com/rmsk2/cartflash/releases and use fcart.pgz to write it to block 31 of your cartridge. Now the software to write on the cartridge is on the cartridge itself
  5. Use pgz2flash https://github.com/rmsk2/pgz2flash/releases to convert all the PGZs files you want to KUPs and store them on the cartridge
  6. Use your software without load times and without typing any commands. Simply insert the cartridge and turn on the machine.
  7. Optional: If you want to type commands you can start all software on the cartridge by typing /progname in BASIC or simply progname in DOS and still have no load times