Skip to content

Add S12XE/XS/XF flash programming (XMMC/XFTMRK routine) - #1

Open
udv2g wants to merge 1 commit into
0xJustus:mainfrom
udv2g:hcs12-xmmc-xftmrk
Open

udv2g wants to merge 1 commit into
0xJustus:mainfrom
udv2g:hcs12-xmmc-xftmrk

Conversation

@udv2g

@udv2g udv2g commented Sep 30, 2026

Copy link
Copy Markdown

Vendor USBDM's HCS12-XMMC-XFTMRK-flash-program.s19 and route the paged S12X device entries to it. The routine uses the same large-code ABI as GMMC, so the driver is unchanged. Five parts gain geometry: mc9s12xep100-family, xs64, xs128, xs256 and xf512. Every existing table entry is byte-identical.

  • gen_devices: accept the XFTMRK routine. XMMC entries give the reset page (0xFE) as pageReset and size the window with pages, so the lowest page is derived from pageEnd and the page count (1024K -> C0). MMCV4 keeps using pageReset.
  • prepareFlash: every HCS12 flash operation now starts with a special-mode hardware reset and a reconnect, as the reference programmer does. A target running its own code acks memory access but not the PC write that starts the routine (BDM_RC_ACK_TIMEOUT), so flashing a running board failed.
  • XFTMRK expects FCLKDIV to be loaded already and otherwise reports an invalid divider. Port the reference Tcl initTarget/initFlash: COP off, FCLKDIV from 2x the special-mode bus clock, FPROT/EPROT unprotected.
  • --sim refuses XFTMRK parts; there is no S12XE flash model and the FTS one would report a meaningless pass.

Tested on an MC9S12XET256 (SDID 0xC081) with a JS16 USBDM on macOS: unsecure (mass erase, then FSEC=0xFE), then program with verify of a 61 KB image across both fixed windows and four PPAGE pages. A raw-BDM readback of every window, setting PPAGE directly, matched all 61,825 bytes. After a normal reset the board runs the image: halted in the application's main loop, PPAGE=0xFB.

Vendor USBDM's HCS12-XMMC-XFTMRK-flash-program.s19 and route the paged
S12X device entries to it. The routine uses the same large-code ABI as
GMMC, so the driver is unchanged. Five parts gain geometry:
mc9s12xep100-family, xs64, xs128, xs256 and xf512. Every existing table
entry is byte-identical.

- gen_devices: accept the XFTMRK routine. XMMC entries give the reset
  page (0xFE) as pageReset and size the window with `pages`, so the
  lowest page is derived from pageEnd and the page count (1024K -> C0).
  MMCV4 keeps using pageReset.
- prepareFlash: every HCS12 flash operation now starts with a
  special-mode hardware reset and a reconnect, as the reference
  programmer does. A target running its own code acks memory access but
  not the PC write that starts the routine (BDM_RC_ACK_TIMEOUT), so
  flashing a running board failed.
- XFTMRK expects FCLKDIV to be loaded already and otherwise reports an
  invalid divider. Port the reference Tcl initTarget/initFlash: COP off,
  FCLKDIV from 2x the special-mode bus clock, FPROT/EPROT unprotected.
- --sim refuses XFTMRK parts; there is no S12XE flash model and the FTS
  one would report a meaningless pass.

Tested on an MC9S12XET256 (SDID 0xC081) with a JS16 USBDM on macOS:
unsecure (mass erase, then FSEC=0xFE), then program with verify of a
61 KB image across both fixed windows and four PPAGE pages. A raw-BDM
readback of every window, setting PPAGE directly, matched all 61,825
bytes. After a normal reset the board runs the image: halted in the
application's main loop, PPAGE=0xFB.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant