Flash the DTV Rom

From C64 DTV Hacking Wiki

Jump to: navigation, search

Contents

[edit] Introduction

[edit] Disclaimer

Flashing may transform your lovely DTV in a cool book-ends (especially flashing $000000-$00FFFF) so know what you are doing. Some of the instructions here are not well tested or may be outdated.

[edit] Why reflash the DTV?

[edit] What means flashing the DTV?

  • By (re)flashing the DTV flash ROM, you can change BASIC/CHARGEN/KERNAL ROM as well as files accessible via device 1 (normally menu and games, that is).
    • FlashROM layout
    • BASIC/CHARGEN/KERNAL resides in $000000-$00FFFF. An error when reflashing this area most likely bricks your DTV.
    • DTV Flash File System resides at $010000 upward. This area is relatively safe to reflash since the worst thing that can happen is that you get temporarily stuck with starting to BASIC only (as with a normal C64).

Note that changing BASIC and KERNAL ROM can also be done with the DTV's Memory Mapper so if you know how to code, reflashing DTV lower memory isn't necessary really.

[edit] Basic steps

  1. Build/get whatever data you want to flash
  2. Get this data as well as the flashing program on the DTV
  3. Reflash the device.

[edit] Requirements

Method 1 (using a C64 Drive):

  • IEC connector mod
    • an IEC device (1541, MMC2IEC or 1541-III, 64hdd...)
    • a D64 editor (c1541 from VICE, ...)
    • Tools for transferring the D64 to the IEC device

Method 2 (using DTVTrans cable)

Additional requirements for 1541-III(-DTV) or MMC2IEC

  • VICEplus (x64dtv)
  • DTV FlashROM image file (for VICEplus)

[edit] Flash new programs

On the DTV, programs are located starting at $010000 (see DTV Flash File System). You can reflash that area without touching $00xxxx which contains KERNAL and BASIC ROMs that are crucial for the DTV's booting procedure.

When booting, stock KERNAL searches for a file called INTRO, loads this, and jumps to $080d. For a standard DTV, this program displays the C= logo and copyright information, then loads DTVMENU and executes that.

When reflashing, you probably want to exchange the normal INTRO with DTVSlimIntro that immediately displays a menu of files in the flash.

Now, how to build the complete flash image?

  • Get all archives that are of interest to you from Spiff's repository or from somewhere else.
  • Get a recent version of VICE (2.1 or later).
  • Create the filesystem image
    • Method 1 (GUI): Use DTVFSEdit to build the new flash image. Drag/drop basic/kernal from dtvrom.bin included in VICE (or use File/Open...if drag'n'drop doesn't work).
    • Method 2 (command line): Use dtvmkfs.
  • Test the new flash image: x64dtv -c64dtvromimage flashfs.bin
  • If everything looks fine, flash the image. Doing this is easiest using the sync functionality of DTVTrans+.
    • You can also transfer the new image using disks which is quite tedious though.
      • If using dtvmkfs, you have to use its -c parameter that breaks the flash image into parts that fit to 1541 disks - if you use another medium supporting bigger files (1581, SD2IEC, etc.) you can split the image into larger chunks using helper tools like split. Then, flash each of these parts manually using the Flash utility.
      • For DTVFSEdit, see this post for a guide.
      • Note that flashing $00xxxx is NOT needed normally.

[edit] Patch kernal

Note that normal users do NOT need to reflash the KERNAL typically. Reflashing $00xxxx can brick your DTV. If you just want to put new games on the DTV, DO NOT flash the KERNAL.

If you want to use some C64 kernal replacement, use DTVSlimIntro to start a softkernal generated by Kernalpatcher. Also see JiffyDOS.

[edit] Status of this section

The following needs some rewriting. Probably one of the easiest ways to get a DTV you can code on is flashing DTVBIOS which wasn't available at the time the guide was written.

[edit] Setting up

This section describes hot to make a disk image that contains the required utilities.

[edit] Download

In order to flash your DTV ROM you will need some tools, download from Daniel Kahlin's website :

[edit] Configure dtvmon (optional)

The default behavior of DTVMON is to read the user port to determine the video mode. The video mode settings can be hardcoded to the dtvmon; this allows the user port to be used for general I/O without affecting the video output.

The port used in dtvmon's embedded dtvtrans is joystick port 1 as default. This can be changed to port 2 or user port by modifying the last configuration byte.

The following table is an example of hardcoding the (PAL) video mode to dtvmon_rom.prg. The hexadecimal values "FF FF 03 24 00 00 00 02 FF" are the configuration bytes. See the dtvmon README.txt for the details. TODO: include explanation on the conf. bytes from the README.txt here?

00000000   00 40 25 80  00 00 C4 D4  D6 38 30 2D  20 44 54 56  .@%......80- DTV
00000010   42 4F 4F 54  20 2F 20 54  4C 52 20 2D  01 00 FF FF  BOOT / TLR -....
00000020   03 24 00 00  00 02 FF A2  FF 78 9A D8  42 ED 98 AA  .$.......x..B...

[edit] Method 1 : using an IEC Drive

[edit] Creating the D64 (Method 1)

Create a D64 image flashutl.d64 that contains:

  • flash-0.9a.prg as flash
  • kernalpatcher-0.8.prg as kerpatch
  • dtvmon_rom.prg as dtvmon (optional)

The program c1541 (included with VICE) can be used to create the image.

c1541
C1541 Version 4.00.
Copyright 1995-2003 The VICE Development Team.
C1541 is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type `show copying' to see the conditions.
There is absolutely no warranty for C1541.  Type `show warranty' for details.
c1541 #8> format flashutils,12 d64 flashutl.d64
L1: flashutl.d64
Unit: 0
Formatting in unit 8...
c1541 #8> write flash-0.9a.prg flash
Writing file `FLASH-0.9A.PRG' as `FLASH' to unit 8.
c1541 #8> write kernalpatcher-0.8.prg kerpatch
Writing file `KERNALPATCHER-0.8.PRG' as `KERPATCH' to unit 8.
c1541 #8> write dtvmon_rom.prg dtvmon
Writing file `DTVMONROM.PRG' as `DTVMON' to unit 8.
c1541 #8> list
L1: flashutl.d64
0 "flashutils      " 12 2a
28    "flash"             prg 
44    "kerpatch"          prg 
43    "dtvmon"            prg 
549 BLOCKS FREE.
c1541 #8> quit
[edit] Patching the kernal with x64dtv

NOTE: If you have an IEC device that can write to the disk (or disk image) then this step can be done with the DTV.

Install x64dtv (VICE with DTV support, link) and obtain the DTV FlashROM image file dtvflash.img. Start x64dtv with the command

x64dtv -c64dtvromimage dtvflash.img -8 flashutl.d64 

Hold TAB during the reset sequence to enter BASIC mode.

  • LOAD"KERPATCH",8,1 and RUN.
  • Press C to create a patched kernal.
  • TODO: explain config...

Image:Howto-dtvflash-01.gif

  • Press S to save the patched kernal. Use NEWKER as the filename and select RAW DATA=N.

Image:Howto-dtvflash-02.gif

[edit] Saving sector00 with x64dtv

NOTE: If you have an IEC device that can write to the disk (or disk image) then this step can be done with the DTV.

Start x64dtv with the command

x64dtv -c64dtvromimage dtvflash.img -8 flashutl.d64 

Hold TAB during the reset sequence to enter BASIC mode.

  • LOAD"FLASH",8,1 and RUN.
  • Press D to dump range to buffer. Use $000000 as start address and $010000 as end address.
  • Press S to save. Use SECTOR00 as the filename, $000000 as start address and $010000 as end address. Select RAW DATA=N.

Image:Howto-dtvflash-03.gif

  • Press X to exit.
[edit] Write flashutl.d64 to IEC device media

This step depends on your IEC device.

  • 1541/1571/...: TODO
  • 1541-III(-DTV)/MMC2IEC: copy flashutl.d64 to the SD/MMC card.
  • 64hdd: TODO

[edit] Method 2 : Using DTVtrans cable

See DTVTrans page for instructions on how to bootstrap using the DTVTrans cable.

[edit] Option 1 : Flash an existing flashROM image

Obviously, you will need a working (be sure !) DTV flashROM image dump like

To make a compliant flashROM image you can use tlr flash program (which can dump too).

  • Transfer :
    • Flash utility
    • the flashROM image at the tlr's flash himem buffer start address ($020000) in raw mode
  • Press <Esc> to exit server mode.
  • Start the flash utility (Just type RUN, no LOAD required)
    • Write half of the flash.
    • Repeat for the second half.
[edit] Option 2 : Patch the kernal and flash it

In this case you will patch the current DTV kernal then reflash the patched version. Currently, tlr's Kernalpatcher is the tool to use to patch the kernal.

  • Transfer :
  • Press <Esc> to exit server mode.
  • Start the kernalpatcher utility (Type RUN)
    • Choose patching option [ADD SCREENSHOTS AND EXPLANATIONS]
    • The patched kernal will be located at $006000
  • Restart DTVTrans bootstrap to transfer :
  • Press <Esc> to exit server mode.
  • Start the flash utility (Just type RUN, no LOAD required)
    • Write half of the flash located at $006000.
    • Repeat for the second half.

[edit] Flashing

This section describes how to flash the patched DTV kernal and (optionally) DTVMON.

[edit] Testing

  • LOAD"KERPATCH",8,1 and RUN.
  • Press L to load custom kernal. Enter NEWKER as the filename and select RAW DATA=N.

Image:Howto-dtvflash-04.gif

  • Press T to test kernal.
  • TODO: LBUTTON+RESET HOOK? Hmm..

The patched kernal works if everything looks ok after reset.

[edit] Flashing the kernal

  • LOAD"FLASH",8,1 and RUN.
  • Press L to load the patched kernal to buffer. Enter NEWKER as the filename and $000000 as start offset. Select RAW DATA=N.

Image:Howto-dtvflash-05.gif

DANGER MODE ON! If something goes wrong while programming the kernel to flash, DO NOT RESET OR EXIT THE APPLICATION! See If the flashing fails...section.

  • Press W to disable low-mem write protection.
  • Press P to program range from buffer. Select $00E000 as start address and $010000 as end address.

Image:Howto-dtvflash-06.gif

  • Press W to enable low-mem write protection.
  • DANGER MODE OFF!
  • Skip to the Verifying section if everything was OK.

[edit] If the flashing fails...

DO NOT RESET OR EXIT THE APPLICATION!

  • Press L to load the backup. Enter SECTOR00 as the filename and $000000 as the start offset. Select RAW DATA=N.
  • Press P to program range from buffer. Select $000000 as start address and $010000 as end address.
  • Press V to verify. Select $000000 as start address and $010000 as end address.
    • Try to flash the kernal again with better luck.


[edit] Verifying

  • Press V to verify. Select $00E000 as start address and $010000 as end address.
    • If the verify fails, see previous section.
  • Press L to load the backup. Enter SECTOR00 as the filename and $000000 as the start offset. Select RAW DATA=N.
  • Press V to verify. Select $000000 as start address and $00E000 as end address.
    • If the verify fails, see previous section.


[edit] Flashing dtvmon (optional)

  • Press L to load dtvmon to buffer. Enter DTVMON as the filename and $000000 as start offset. Select RAW DATA=N.
  • Press P to program range from buffer. Select $1F8000 as start address and $1FC000 as end address.
  • Press V to verify. Select $1F8000 as start address and $1FC000 as end address.

[edit] The end

  • Press X to exit the application.
  • Reset the DTV and enjoy your new kernal!

The kernal flashing part of this page was first written by Hannu Nuotio (based on information on this forum thread) and with his permission, reused here then edited.

Personal tools