C64Mini FEL-mode hack – no UART needed

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

A post off jj_0 on the Thec64community forum https://thec64community.online/thread/270/c64mini-mode-hack-uart-needed

From (mostly) the source released by Retro LTD I’ve created a kernel+ramdisk that you can use to boot the C64Mini from via FEL mode. I’ve included:

  • An on-screen command shell that allows you to do all the command-line stuff from an USB keyboard. So opening up the Mini should not be necessary anymore.
  • Support for a number of USB2Serial converters (CP210x, FTDI, Prolific 2302, CH431). You can insert an USB2Serial converter in one of the Mini’s USB ports and connect the RX/TX/GND to either a second USB2Serial converter on a PC, or direclty to TTL-level serial port on e.g. a Raspberry PI, Cubieboard, etc etc.
  • Support for a number of USB2Ethernet devices (ASIX AS88xxx and AX88179_178A, QF9700, SMSC LAN75XX and LAN95XX, DM9601, MCS7830). If you insert one of these in the Mini’s USB port and connect it with your router (using an Ethernet cable) it will get an IP address. Supported services are SSH, SCP and/or ftp
  • The UART is also still supported
  • Running scripts from an inserted USB drive. If the USB drive has a directory ‘scripts’ each file in this directory will be run as if it were a Linux shell script. So you can do unattended copies etc. I’ve included two example scripts, one that backs up the nand firmware, and one that copies games from a ‘copygames’ folder to the Mini.
  • root password is ‘manicminerrules!’

The required files can be found in C64Mini-FEL-boot-v1.1.zip which was unfortunately just too large to upload directly to the forum. If you unzip the file to a directory on your PC you will have the following folders:

  • boot: This  contains the required kernel, script.bin etc files
  • USB: Example ‘scripts’ and ‘copygames’ to put on an USB stick
  • linux: sunxi-fel tool for linux (x86_64) and boot.sh to upload the kernel etc to the Mini. If the tools don’t work you might need to install them yourself (apt-get sunxi-tools) or compile them from source.
  • windows: sunxi-fel tool + dll’s for Windows (64-bit) and boot.sh to upload the kernel etc to the Mini. If the tools don’t work then googling is your best friend, I don’t know too much about compiling this on Windows.

To use this:

Examine the USB directory and put the content in the root of an USB drive if you want to use scripts. Look at the scripts in the ‘scripts-examples’ directory and if you want to use them put them in the scripts folder of the USB drive. You can also leave this out, or do it later, or write your own scripts.

Then you have to start your C64 Mini in FEL mode. Insert a (fully-functioning data-cable, so not just for power) USB cable in the Mini’s micro-USB port. Before inserting the other side into your PC  (or for ease of use, use an USB hub that let’s you switch ports on and off) :

  • If you have an UART connected keep ‘2’ pressed and insert the USB cable into your PC/switch the USB port on. But that kind of defeats the purpose, though it’s still kind of useful
  • If your Mini has a silver sticker on the underside, there should be a button ‘hidden’ underneath the silver sticker. It’s accessible through a hole in the case right under the ’00’ in the ‘RGL001′[ text,  you need e.g. a paperclip to press it. Keep this pressed and then insert the USB cable into your PC/switch the USB port on
  • If (as per deerwings  post) your Mini doesn’t have a silver sticker underneath then there’s no pre-installed FEL-mode button so you will have to add one. However, assuming the port header is still there, you can connect the LED to that port as per spannernick

Once you’ve done either of these your PC should have a new USB device (1f3a:efe8, on my Ubuntu PC it’s called an  ‘Onda (unverified) V972 tablet in flashing mode’).

Next

  • If you’re using Linux, cd to the linux folder and run ./boot.sh
  • If you’re using Windows 7 or 10 (64 bit) cd to the windows folder and run boot.cmd. You might need to install an USB driver. But if you have hackchi2 installed the USB driver might already be installed. 

If all works well you will see that the kernel etc files are being uploaded:

USB device 001:040   Allwinner A20     xxxxxxxx:xxxxxxxx:xxxxxxx:xxxxxxxx
Stack pointers: sp_irq=0x00002000, sp=0x00005E08
Reading the MMU translation table from 0x00020000
Disabling I-cache, MMU and branch prediction... done.
=> Executing the SPL... done.
Setting write-combine mapping for DRAM.
Setting cached mapping for BROM.
Writing back the MMU translation table.
Enabling I-cache, MMU and branch prediction... done.
Writing image "U-Boot 2018.05-jj_0+ for sunxi b", 372007 bytes @ 0x4A000000.
Passing boot info via sunxi SPL: script address = 0x43100000, uEnv length = 260
Starting U-Boot (0x4A000000).

Then you will see activity on screen (a.o. u-boot starting and booting the kernel) and after ~35 seconds you should end up with an on-screen command-line shell where you can type away at your leisure with an attached USB keyboard. If you have a supported USB2Serial device attached there will also be a command-line shell on that, and also on the UART. If you have a supported USB2Ethernet device attached you should see a ‘c64mini’ in your routers list of devices as well. The on-screen shell prompt should also show the IP address between brackets:
root@c64mini (10.0.0.125):/#
At this point (unless you’ve run some of the scripts) your Mini is just another small-board computer and nothing has touched the actual ‘C6Mini’ contents. However after you load the NAND driver (included from the C64Mini firmware version 1_2_0) you have access to the Mini’s root filesystem and can modify it at will:

root@c64mini (10.0.0.125):/#insmod -f /opt/nand.ko
root@c64mini (10.0.0.125):/#mount /dev/nandb /mnt

Retro Games LTD uses various different NAND chips and seems that updates to the associated nand.ko driver lead to different nand.ko versions in ‘same version’ firmwares.  At the time of writing they haven’t provided the full source of the nand driver so it could be that the included nand driver doesn’t support the NAND chip in your Mini. In that case please report back the output of loading the NAND driver, and hopefully someone with an UART connected and same firmware can provide an updated /lib/modules/3.4.39/nand.ko.

Please note that I’m not responsible for ANYTHING you do with your C64Mini, everything you do is at your own risk. I recommend that you first of all make a backup of the nand before doing anything else.

Let me know if/how it works for you