Ship a device support pack: .lcf-style linker command files, startup, and register headers for the S12/S12X family #3

Open
opened 2026-09-24 09:52:47 +02:00 by sid · 0 comments
Owner

CodeWarrior ships a per-device support pack for essentially the entire S12/S12X family: linker command files (.lcf) defining the memory map (REGIONS/PLACEMENT), startup code, and register definition headers. This repo has one generic newlib crt0.o and a single example linker script derived from an MC9S12C32 (tests/s12/link.ld). Users targeting other parts (e.g. MC9S12XDP512, MC9S08..., S12XS) must hand-write every memory map and startup.

Motivation

  • A working replacement toolchain must let users build for the actual device in their project without reverse-engineering its memory map.
  • CodeWarrior .lcf files are a de-facto project interchange format; being able to consume or translate them lowers migration cost.

Current state

  • tests/s12/link.ld: RAM @ 0x0800 (2K), ROM @ 0xC000 (16K), vectors @ 0xFF80 (MC9S12C32-like, hard-coded in the firmware build (pkgs/s12-firmware.nix)).
  • newlib provides a generic crt0.o and sim-valid.ld ($out/m68hc11-elf/lib/), not device-specific.
  • No register/peripheral header files beyond what the sim models.

Proposed scope

  • Define a canonical, versioned memory-map description format for this repo (a .lcf-like text format or structured .ld templates) and a tool that renders it into GNU ld scripts.
  • Ship memory maps, startup code, and register headers for a set of common parts (MC9S12C32, MC9S12DP256, MC9S12XDP512, MC9S12XS128, ...).
  • Provide s19/s28/s37 build output and a memory map report (equivalent to the CodeWarrior MAP file) as part of the normal build.

Acceptance criteria

  • Building the same firmware for two different supported parts changes only the device selection, not the application source.
  • Register headers compile for both -m68hc12 and -m9s12x.
  • Generated link scripts place sections exactly per the declared REGIONS, and the placement is verified in gdb-sim tests.

References

  • tests/s12/link.ld, tests/s12/start.s, tests/s12/vectors.c
  • pkgs/s12-firmware.nix
  • pkgs/newlib-m68hc11.nix (crt0, sim-valid.ld)
CodeWarrior ships a per-device support pack for essentially the entire S12/S12X family: linker command files (`.lcf`) defining the memory map (REGIONS/PLACEMENT), startup code, and register definition headers. This repo has one generic newlib `crt0.o` and a single example linker script derived from an MC9S12C32 (`tests/s12/link.ld`). Users targeting other parts (e.g. MC9S12XDP512, MC9S08..., S12XS) must hand-write every memory map and startup. ## Motivation - A working replacement toolchain must let users build for the actual device in their project without reverse-engineering its memory map. - CodeWarrior `.lcf` files are a de-facto project interchange format; being able to consume or translate them lowers migration cost. ## Current state - `tests/s12/link.ld`: RAM @ 0x0800 (2K), ROM @ 0xC000 (16K), vectors @ 0xFF80 (MC9S12C32-like, hard-coded in the firmware build (`pkgs/s12-firmware.nix`)). - newlib provides a generic `crt0.o` and `sim-valid.ld` (`$out/m68hc11-elf/lib/`), not device-specific. - No register/peripheral header files beyond what the sim models. ## Proposed scope - Define a canonical, versioned memory-map description format for this repo (a `.lcf`-like text format or structured `.ld` templates) and a tool that renders it into GNU ld scripts. - Ship memory maps, startup code, and register headers for a set of common parts (MC9S12C32, MC9S12DP256, MC9S12XDP512, MC9S12XS128, ...). - Provide `s19`/`s28`/`s37` build output and a memory map report (equivalent to the CodeWarrior MAP file) as part of the normal build. ## Acceptance criteria - Building the same firmware for two different supported parts changes only the device selection, not the application source. - Register headers compile for both `-m68hc12` and `-m9s12x`. - Generated link scripts place sections exactly per the declared REGIONS, and the placement is verified in `gdb-sim` tests. ## References - `tests/s12/link.ld`, `tests/s12/start.s`, `tests/s12/vectors.c` - `pkgs/s12-firmware.nix` - `pkgs/newlib-m68hc11.nix` (crt0, sim-valid.ld)
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sid/m68hc11-toolchain#3
No description provided.