Files
JIANT/firmware/app.ld
T
Claude c4e04dd749 The second code segment (flash 0xC8000..0xCFFFF), ported from JIANT BYTE (e807224d): 31.8 KB out of the app slot
FM's reserve 0xC8000..0xD7FFF (storage.c FL_SAMPLES, written by nothing) now holds, in its first half, cold main-loop
code run in place through the plain XIP window as the Bluetooth segment is. 0xD0000.. stays reserved; JAM's takes at
0xDA000 / 0xDB000 untouched.

- Build: app.ld C2SEG (XIP 0x020C4000), section .c2 (c2_head first, then .c2.text / .c2.rodata); core.h C2_FN / C2_IN /
  C2_RO; src/seg2.c (header, c2_want, c2_seg_ok). tools/build.py writes build/c2.bin (JBC2, length, CRC-32) and patches
  c2_want as bt_want; c2_check: nothing an interrupt, core 1 or RAM code reaches is in it, every call in from the slot
  comes from a hand-checked gate (C2_GATES), no segment address stored as data.
- Moved: the editor protocol's commands and pushes (ed_command, ed_sync, their helpers, FM's ed_fm6_handle; INFO, the
  backup and the project library stay in the slot), GEN's generators (gen_make, gen_parts, gen_pitched, gcpu_fit,
  gen_sound, gen_kit, gen_mix, gl_write, gsong, gplan, grich, gls_prep, gen_arp, trackgen_run ...). FM differs from
  BYTE: gen_make / gen_parts are slot code here (BYTE: Bluetooth segment), so they moved too, gen_go a gate;
  gen_evolve and gx_comps stay in the slot (gen_post calls them); gen_rs_apply was already in the Bluetooth segment;
  no dice_seq. Slot: 583660 -> 551828 B (676 -> 32508 B free). Segment: 31660 of 32768 B (1108 B free).
- Sound: every pinned / recorded audio function and table at its address (layout unchanged, no repin); audio flash
  code identical but for immediates; RAM code +36 B (the flash driver's range check, FL_RANGE_OK). The merged
  constants' floor (build/layout_cst.ld) is the first pool's start as laid out (FM's pools have UI constants before
  the sound's first). seq_steps always inline (no out-of-line copy for the segment's calls).
- Runtime: bt_hw_seg() checks both segments once at power-on; missing / torn / another build's: FLASH PART MISSING /
  REINSTALL at power-on and on GEN; the editor answers INFO ('X' 2), the backup and the project library only.
- Package / loader: fourth UFW entry c2.bin (type 201), checked before anything is erased, all of [0xC8000, 0xD0000)
  written (0xFF past the code), never 0xD0000 and up. FL_STORE_OK / FL_RANGE_OK leave the segment out (static asserts).
- Tests: ldr_test (c2 written, rest erased, damaged c2 refused, 0xD0000.. untouched), editor_test (segments missing),
  storage map assert, layout packing test. Manuals and EDITOR_PROTOCOL: FLASH PART MISSING.

Needs a hardware test on the FM-1 before any release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KMHk6yH4XbP1xxHYKCo9Mh
2026-12-04 22:33:34 +00:00

104 lines
8.7 KiB
Plaintext

/* SPDX-License-Identifier: GPL-3.0-only
* Copyright (C) 2026 Leo Kuroshita (@kurogedelic), Hügelton Instruments
* Portions Copyright (C) 2026 Juan Ignacio Antonucci (Juan Jiant) */
/* FELUCCA memory map.
* Code + constants execute in place from XIP (app.bin offset 0 = 0x02000120).
* RAMTEXT (JIANT 0.6.78: at the top of the pool, was 0x01C00000): .ram_text (code that must run while the flash is
* busy: the flash driver), .c1_text (the second core's loop), .hot_text (core 0's hottest audio code). A call reaches
* +-4 MiB (pi32v2 imm23 x 2, no long calls in this compiler): RAM code there reaches the whole XIP image (build.py
* checks the margin); at 0x01C00000 it reached none of it.
* LOWBUF 0x01C00000..0x01C08000 (0.6.78; 0.6.82: 4 KiB more, the steps grew): main-loop buffers (undo, the song
* section's stage; the project scratch until 0.8.4 and the fonts' decode tables in 0.8.4, both in the pool since
* 0.8.5; 0.9.9-beta4: the fonts' tables and the user presets' banks back here, 9 KiB of the pool given to RAMTEXT),
* zeroed at boot. 0x01C07000..0x01C08000 was kept for RAM-run debug until 0.9.9-beta4 (LOWBUF took it).
* RAM : .data/.bss (96 KiB)
* POOL : big zero-initialised buffers (FX lines, canvases), section .pool
* STACKS with 256-byte guard bands; NOINIT survives resets and UBOOT entry.
* 0x01C7FD50.. is reserved: boot_info, boot-state mailbox, vector table. */
MEMORY
{
XIP (rx) : ORIGIN = 0x02000120, LENGTH = 0x8EA90 /* = tools/fm1pkg_make.py APP_SLOT (0.9.13: the region ends at 0x92FFE) */
LOWBUF (rw) : ORIGIN = 0x01C00000, LENGTH = 0x8000
RAM (rwx) : ORIGIN = 0x01C08000, LENGTH = 96K
POOL (rw) : ORIGIN = 0x01C20000, LENGTH = 0x4BA00
RAMTEXT (rwx): ORIGIN = 0x01C6BA00, LENGTH = 0xA600 /* (V10.8.60: 7.5 KiB lower, the USB resampler's table halved,
* usb.c rs_tab, JIANT BYTE's devcpu2: more of the sound's
* per-block code in RAM, tools/build.py HOT_LO) (0.6.97, 0.7.0: up 4 KiB each, the image grew: a call from here must
* reach its end; the user stack 4 KiB shorter each time, 15.75 KiB;
* 0.9.9-stab, as 0.9.12: 1 KiB lower, from the pool: the 320 MHz switch;
* 0.9.9-beta4: 9 KiB lower, from the pool (8 KiB of its main-loop
* buffers moved to LOWBUF): the delay's, the reverbs' and the
* chorus's block code in RAM, out of the I-cache the engines share) */
NOINIT (rw) : ORIGIN = 0x01C7C000, LENGTH = 0x3D50
BTSEG (rx) : ORIGIN = 0x020E6000, LENGTH = 0x12000 /* (V10.12) flash 0xEA000..0xFBFFF (hal/fm1_flash.h FL_EXT_*): the
* Bluetooth segment, read in place through the plain XIP window */
C2SEG (rx) : ORIGIN = 0x020C4000, LENGTH = 0x8000 /* (seg2) flash 0xC8000..0xCFFFF (hal/fm1_flash.h FL_SEG2_*): the
* second code segment, run in place through the plain XIP
* window as the Bluetooth segment */
PACKED (r) : ORIGIN = 0x02200000, LENGTH = 0x10000 /* (V10.6z5) the load images of .ram_text, .c1_text, .hot_text,
* .data as linked, never in flash: tools/build.py packs them
* (LZ4) into the image after .text (_etext), main.c fm1_cstart
* unpacks them (src/boot_lz4.h). Past the probe link's larger XIP */
}
SECTIONS
{
/* (V10.12) the Bluetooth segment (firmware/bt/bt_seg.c, its own unit): its header first (bt_seg.c bt_head, filled by
* tools/build.py), then its code and constants, outside the app slot; written by the update loader from the
* package's bt.bin (firmware/loader/ldr_core.c), checked by the app before any call (src/bt_hw.c). First here so
* that no rule below takes its sections; its zeroed RAM goes to the pool (below), its RAM code (.ram_text) with
* the app's. No initialised data (tools/build.py). (V10.13) then the app's own code and constants kept there (src/bt.c
* BTAPP_FN / BTAPP_RO: cold, read only once the segment checked) */
.bt : { _bt_start = .; KEEP(*(.bt_head)) *bt_seg.o(.text .text.* .rodata .rodata.*)
*(.btapp.text) *(.btapp.rodata) . = ALIGN(4); _bt_end = .; } > BTSEG
/* (seg2) the second code segment (src/seg2.c): its header first (c2_head, filled by tools/build.py), then the app's
* cold main-loop code and constants kept there (core.h C2_FN / C2_IN / C2_RO), outside the app slot; written by the
* update loader from the package's c2.bin, called only once bt_hw_seg() said both segments are this build's. Here,
* before .text, so that no rule below takes its sections */
.c2 : { _c2_start = .; KEEP(*(.c2_head)) *(.c2.text) *(.c2.rodata) . = ALIGN(4); _c2_end = .; } > C2SEG
/* (0.9.9-snd3) the code in tools/audio_layout.txt's order, each run of the sound at its recorded address (tools/build.py
* writes build/layout.ld: the UI cannot move the sound; "cannot move location counter backwards" = the code before a
* run grew: FELUCCA_REPIN=1), the tables (the sound's first), the merged constants (their small tables, then the
* strings), the UI's tables that filled no hole (.rodata.n.*), code not in the layout; (seg2) build/layout_cst.ld:
* the merged constants no lower than recorded */
.text : { KEEP(*(.text.crt0)) *(.text) INCLUDE build/layout.ld *(.rodata) INCLUDE build/layout_cst.ld *(.rodata.cst*) *(.rodata.str*)
*(SORT_BY_ALIGNMENT(.rodata.n.*)) *(.text*) *(.rodata*)
. = ALIGN(4); _etext = .; } > XIP
.ram_text : { _rt_start = .; KEEP(*(.ram_text*)) . = ALIGN(4); _rt_end = .; } > RAMTEXT AT > PACKED
_rt_load = LOADADDR(.ram_text);
/* (JIANT 0.6.71) the second core's waiting loop (hal/fm1_multicore.h): in RAM, after the flash driver, inside the
* guard's RAM code window (_rt_start .. _c1t_end); its own section, as it calls the jobs (the build's check that
* .ram_text calls nothing still holds) */
.c1_text : { _c1t_start = .; KEEP(*(.c1_text*)) . = ALIGN(4); _c1t_end = .; } > RAMTEXT AT > PACKED
_c1t_load = LOADADDR(.c1_text);
/* (JIANT 0.6.78) core 0's hottest audio code (tools/build.py HOT_FNS): in RAM after the second core's loop, inside the
* same RAM code window (_rt_start .. _hot_end) */
.hot_text : {
_hot_start = .;
KEEP(*(.hot_text.lo.*)) /* (V10.8.60, tools/build.py HOT_LO, JIANT BYTE's devcpu3: the lowest, what was before
* stays where it was) */
KEEP(*(.hot_text*)) /* (tools/build.py HOT_FNS: their sections renamed in the optimised IR) */
. = ALIGN(4);
_hot_end = .;
} > RAMTEXT AT > PACKED
_hot_load = LOADADDR(.hot_text);
/* (V10.31) EUCLID's keep: the sequence a track had before EUCLID transformed it (src/ui_euclid.c eu_bk), RAM data
* in RAMTEXT's room above the RAM code (not loaded, not zeroed: valid only once eu_bk_k names a track) */
.eu_keep (NOLOAD) : { . = ALIGN(4); *(.eu_keep*) . = ALIGN(4); } > RAMTEXT
.data : { . = ALIGN(4); _data_start = .; *(.data*) *(.sdata*) . = ALIGN(4); _data_end = .; } > RAM AT > PACKED
_data_load = LOADADDR(.data);
/* (V10.12) the Bluetooth segment's RAM in the pool, but its baseband block (ble_hw_wl82.c bb, 1508 B, read and
* written by the radio's DMA) here, in the RAM every DMA reaches */
.bss (NOLOAD) : { _bss_start = .; *(EXCLUDE_FILE(*bt_seg.o) .bss*) *(EXCLUDE_FILE(*bt_seg.o) .sbss*)
*(EXCLUDE_FILE(*bt_seg.o) COMMON) *bt_seg.o(.bss.bb) . = ALIGN(4); _bss_end = .; } > RAM
.pool (NOLOAD) : { _pool_start = .; *(.pool) *(.pool.*) *bt_seg.o(.bss* .sbss* COMMON) . = ALIGN(4); _pool_end = .; } > POOL
/* (JIANT 0.6.71) the second core's stacks (hal/fm1_multicore.h): 6 KiB for the render, 1 KiB for an exception */
.c1_stacks (NOLOAD) : { . = ALIGN(32); _c1_stack_lo = .; . += 7168; _c1_stack_hi = .; } > POOL
_c1_ustack_top = _c1_stack_lo + 6144;
_c1_sstack_top = _c1_stack_hi;
.lowbuf (NOLOAD) : { _low_start = .; *(.lowbuf*) . = ALIGN(4); _low_end = .; } > LOWBUF
.noinit (NOLOAD) : { *(.noinit) *(.noinit.*) } > NOINIT /* (V10.12: .noinit.* after: none of the others moves) */
_guard0 = 0x01C76000; _ustack_lo = 0x01C76100; _ustack_top = 0x01C7A000;
_guard1 = 0x01C7A000; _sstack_lo = 0x01C7A100; _sstack_top = 0x01C7C000;
/DISCARD/ : { *(.comment) *(.note*) }
}