Writing a Bootloader That Chainloads Human68k from SD Card

An SD card gives the Sharp X68000 a practical replacement for aging floppy disks, hard drives, and removable media. The storage is inexpensive, silent, and easy to back up, but making it bootable requires more than copying files into a directory. The machine still expects a device that behaves like an X68000 disk during the earliest part of startup.

A useful bootloader must bridge two environments. It begins with the limited services available immediately after reset, identifies a valid SD-card partition or disk image, loads the Human68k system files, and then hands execution to the operating system without damaging the machine state that Human68k expects. The exact implementation depends on the SD interface, controller firmware, and whether the card appears as a hard disk, floppy, or custom block device.

The safest design is incremental. First prove that the hardware can read sectors. Then add a filesystem or disk-image reader. Finally, implement the Human68k handoff and test it with known-good media. This separates electrical, storage, and operating-system problems instead of hiding them inside one large assembly program.

Define The Boot Environment

Before writing code, document what the X68000 sees when the SD interface is powered on. Some adapters present an SD card as a block device through an IDE-like interface, while others use a custom expansion-board protocol. The boot ROM may recognize the device directly, or a small resident loader may need to initialize the interface before any sector can be read.

This distinction determines the first-stage boot strategy. If the machine can fetch a sector from the SD device through its normal disk BIOS path, the boot sector can remain compact and delegate device handling to firmware. If the hardware is invisible to the ROM, the first-stage loader must contain controller initialization, command handling, timeout logic, and sector transfer routines.

Record the address map, interrupt assignments, reset state, byte order, and sector size before coding. The Motorola 68000 is big-endian, while many SD controllers expose command and response fields in byte-oriented formats. A single incorrect word swap can make a valid partition table appear corrupt.

A hardware reset is especially useful during development because it avoids repeatedly cycling the power supply while testing failed transfers. A physical switch can make this process safer and faster, as described in these reset-button notes. The switch should be debounced or used only after the system has reached a stable stopped state.

Choose A Chainloading Model

There are two practical meanings of chainloading Human68k. The first is disk-level chainloading: the SD adapter presents a disk image that contains a normal X68000 boot sector, and the machine's existing boot process loads Human68k. The second is application-level chainloading: custom code reads the Human68k system file itself and jumps directly to its entry point.

Disk-level chainloading is generally the better first target. It preserves the conventions expected by the X68000 ROM, allows existing disk utilities to inspect the media, and reduces the amount of operating-system knowledge embedded in the loader. The SD card can contain a raw floppy or hard-disk image, making backup and restoration straightforward.

Direct loading can be useful when the adapter has no compatible BIOS path or when a menu needs to select among several Human68k installations. It requires more knowledge of the system file format, relocation behavior, memory layout, and startup parameters. A loader that works with one Human68k release may fail with another if it assumes fixed addresses or an undocumented header layout.

Keep the boundary explicit. The bootloader should initialize only what it owns, load the next component into a documented memory region, preserve required registers, and transfer control through the expected entry convention. Do not assume that a warm reset leaves the same RAM, vector table, or peripheral state as a cold start.

Read Sectors Before Files

The first useful milestone is a sector diagnostic. Initialize the SD interface, issue a read for logical block zero, verify the response, and display a short hexadecimal dump or a simple error code. This proves communication without involving partitions, FAT structures, or Human68k.

Implement conservative timeouts. A missing card, incomplete command, or electrical fault must return an error rather than spin forever. Check card presence if the hardware provides that signal, validate response tokens, and reject impossible sector counts. During development, a serial console, text screen, or diagnostic LED pattern can reveal whether failure occurred during initialization, command transmission, data reception, or checksum validation.

Once raw reads work, decide whether the card contains a filesystem or a disk image. A filesystem-aware loader must parse a partition table, locate the active partition, read the BIOS Parameter Block, and follow FAT chains. A disk-image loader can treat the card as a sequence of virtual sectors and translate a requested floppy or hard-disk sector into an SD logical block.

The disk-image approach is usually more compatible with original software. It also avoids writing a second implementation of every X68000 filesystem detail. Its limitation is that the bootloader cannot easily select a file by name unless a separate menu or image index is provided.

Locate Human68k Reliably

For a FAT-based SD volume, avoid assuming that Human68k files occupy contiguous sectors. A small loader may be tempted to search for a fixed filename and read the following blocks, but file fragmentation will eventually expose that weakness. Parse directory entries, match names using the media's actual naming rules, and follow the FAT chain until the complete file has been loaded.

The loader should validate every calculated address. Check that the first cluster is legal, that a FAT entry does not point outside the volume, and that the file size cannot overflow the destination buffer. A malformed or deliberately damaged card should produce a readable failure message instead of overwriting the bootloader, vector table, or video memory.

For a disk image, validate the image geometry before booting. Sector size, sectors per track, heads, reserved sectors, and total sector count must agree with the image format expected by the X68000 software. If the adapter translates virtual geometry into linear SD blocks, keep that translation in one routine so it can be tested independently.

Human68k startup files should remain inside the image or filesystem in their expected locations. Depending on the installation, these may include the operating system image, command processor, configuration file, and automatic command file. Do not rename system files merely to simplify the loader unless the loader explicitly documents the new convention.

Design choice Strength Main risk Suitable first milestone
Raw disk image High compatibility with existing software Fixed image capacity and limited file selection Boot one known-good image
FAT-aware file loader Flexible file selection and easy updates More parsing code and fragmentation issues Load a test file from a simple volume
BIOS-assisted boot Small custom loader and familiar device path Depends on adapter firmware and ROM behavior Read sectors through the established API
Direct Human68k handoff Useful for menus and custom launchers Requires precise format and register knowledge Load a verified system image
Multi-image menu Convenient access to several environments Larger code footprint and more failure paths Select among read-only images

Build The Human68k Handoff

Loading bytes into RAM is not the same as booting Human68k. The system expects a particular memory arrangement and startup state, which can vary according to whether the source is a floppy-style boot sector, a hard-disk installation, or a custom loader. Treat the handoff format as an interface contract rather than guessing from observed behavior.

Start by examining a known-good boot sequence with an emulator, debugger, or logic analyzer where available. Identify which code the ROM invokes, where that code loads the next stage, which registers contain device information, and where execution transfers. Compare several system disks if possible; assumptions that work with one image may be accidental.

A robust loader should preserve the stack until the final handoff, disable or mask interrupts while changing vectors, and avoid leaving controller interrupts enabled unless Human68k expects them. Clear only memory that the loader owns. Some startup code relies on firmware-provided vectors or low-memory structures, so an enthusiastic memory wipe can create failures that look unrelated to the SD card.

If the loader displays diagnostics, remove or isolate them before the final jump. Video hardware state, mapped expansion registers, DMA settings, and interrupt masks can affect startup. The cleanest handoff restores the machine to the state expected by the original disk boot path and then uses the same transfer convention as a verified X68000 boot sector.

Test Failure Paths And Media

A bootloader is easier to trust when every failure has a distinct cause. Use short status codes for card initialization failure, invalid media, missing partition, corrupt FAT, absent system file, memory overflow, and handoff failure. The screen message can be brief, while a debug build may also print the failing sector, cluster, or controller response.

Test with a card removed, a card inserted after reset, an empty volume, an invalid partition table, a truncated image, and a file with deliberately broken cluster links. Confirm that the machine remains recoverable through its original boot devices. A loader that can only boot when the SD card is perfect is less useful than one that fails cleanly and permits a fallback.

Power integrity matters during repeated tests. SD cards can draw current in short bursts, and expansion hardware may expose marginal supply rails or signal levels. Use short wiring, suitable decoupling, and a stable 3.3-volt interface. Never connect SD signals directly to a five-volt bus without verifying the adapter's level conversion and protection.

Keep a record of firmware revisions, card models, image geometry, and observed errors. The X68000 community spans original machines, accelerator boards, FPGA recreations, and many storage adapters, so behavior that appears universal may actually belong to one controller revision. The site's project diary is a useful model for recording those details as the implementation develops.

Recommendations For A Maintainable Loader

A small, well-tested loader is easier to preserve than a clever one that depends on undocumented timing. Separate hardware access, block translation, filesystem parsing, file loading, diagnostics, and the final handoff into distinct modules. This also makes it possible to replace an SD protocol layer without rewriting Human68k-specific code.

  • Begin with a read-only boot path and postpone write support until sector addressing is proven.
  • Keep a raw-image mode available even after adding FAT or menu support.
  • Validate every card response, partition field, cluster value, file size, and destination address.
  • Maintain a documented memory map and register contract for the Human68k handoff.
  • Test several physical X68000 models, SD cards, and controller firmware versions.

Use an emulator or a logic analyzer to confirm assumptions that are difficult to observe from the screen. A trace of reset, controller initialization, sector reads, and the final jump can reveal whether a failure comes from incorrect protocol timing or an invalid operating-system handoff.

Put The Loader On Real Hardware

Once the sector reader and boot path work in an emulator or test harness, move to a write-protected SD card containing a known-good Human68k image. Keep the original boot media nearby and make the loader's fallback behavior part of the test. Do not begin with a large multi-boot menu, compressed images, or automatic updates; each feature increases the number of states that must be debugged before the basic chainload is trustworthy.

Document the expected card layout, supported image types, controller assumptions, build command, and recovery procedure beside the source code. Include a hexdump of the first-stage image and a reproducible test image so later hardware repairs or firmware changes can distinguish a software regression from a failing adapter.

The finished result should feel uneventful: reset the X68000, let the SD interface initialize, select or locate the requested media, and watch Human68k start as though it had come from an original disk. Publish the source, test images, memory map, and hardware notes with the project so other enthusiasts can reproduce the boot path, report compatibility results, and keep this piece of X68000 software history usable.

Nereid-X Expansion Board

A personally-produced LAN+USB+Memory expansion board for Sharp X68000 series computers. Multiple production runs were offered, including a final batch and a later revival reproduction run.

Power Supply Repair

X68 power supply repair and modification services were offered by the site owner, with documentation shared through diary entries spanning 2001–2006.

Server & Networking

Notes on FreeBSD administration, ISP changes, server migration, and networking topics. The site itself ran on FreeBSD with the hns diary system and Namazu search integration.

A two-ink risograph print in muted slate-blue and charcoal on off-white paper, showing a stylized desktop computer monitor beside a circuit board with soft geometric trace lines, conveying a calm retro-computing workshop atmosphere. A two-ink risograph print in deep purple and dark grey on cream stock, depicting a compact expansion card with connector ports and subtle Japanese technical annotations, evoking a hobbyist electronics bench. A two-ink risograph print in teal and charcoal on warm white paper, showing a server rack silhouette with soft network-line motifs and a small weather icon, suggesting a personal server room corner.

Get in touch

X68K.NET connects Sharp X68000 enthusiasts through community links and shared projects. Reach out with questions about the Nereid project or X68 resources.