pico430prog/test/rl78/link-rom.ld

167 lines
4.6 KiB
Plaintext

OUTPUT_FORMAT("elf32-rl78","elf32-rl78","elf32-rl78")
OUTPUT_ARCH(rl78)
ENTRY(_start)
MEMORY
{
/*data (rwx) : ORIGIN = 0x0200, LENGTH = 0x100
text (rx) : ORIGIN = 0xf800, LENGTH = 0x800 - 0x20
vectors (rw) : ORIGIN = 0xffe0, LENGTH = 0x20*/
rom (rx) : ORIGIN = 0x00000, LENGTH = 0x04000
/* vectors, boot clusters, etc.: part of ^ */
ram (rwx) : ORIGIN = 0xff900, LENGTH = (0xffee0 - 0xff900)
/*
* 16k code flash: 00000..03FFF
* 2k data flash: F1000..F17FF
* 1.5k ram: FF900..FFEDF
*
* boot clusters: +00000; +01000
* vectors: 00000..0007F
* callt: 00080..000BF
* option byte: 000C0..000C3
* debugpasswd: 000C4..000CD
*
* flash block = 0x400 bytes => 0x10 blocks
*
* vectors:
* 000: RESET/POR/WDT/TRAP/RPE/...
* 004: INTWDTI/INTSRO
* 006: INTLVI
* 008: INTP0
* 00A: INTP1
* ...
* .14: INTP6
* 016: INTST0/INTCSI00/INTIIC00
* 018: INTSR0/INTCSI01/INTIIC01
* 01e: INTSRE0
* 020: INTTM00
* 022: INTST1/INTCSI10/INTIIC10
* 024: INTSR1/INTCSI11/INTIIC11
* 026: INTSRE1
* bluh bluh not really interesting
* 07E: BRK
*
* 02000..03FFF mirrored to F2000..F3FFF (if enabmed in PMC)
*
* IO regs:
* serial data reg 00: TXD0/SIO00/SDR00 = 0xfff10
* serial data reg 01: RXD0/SIO01/SDR01 = 0xfff12
* serial data reg 02: TXD1/SIO10/SDR02 = 0xfff44
* serial data reg 03: RXD1/SIO11/SDR03 = 0xfff42
*
* port mode reg? PMx = 0xFFF2x
*
* port input mode PIMx = 0xF004x
* port output mode POMx = 0xF005x
* port mode control PMCx = 0xF006x
* port mode select PMS = 0xF007B
* peripheral io redirection regs?
* flash operating mode FLMODE = 0xF00AA
* serial status reg SSR0x = F010(x*2)
* serial mode reg SMR0x = F011(x*2)
* serial comm ops setting SCR0x = F011(8+x*2)
* + channel enable, start stop, clocksel, output, output enable, output level, standby control
* interrupt stuff at 0xF0441+...
*
* F0090: rom enable flag etc : DFLCTL bit 0 (enable dataflash access?)
* F0800: request data etc (not interesting here)
* F0803=1
* F0880=4
* F0880: also rom enable bit?
* FLMODE (voltages stuff, bluh), FLMWRP(?) (enable prev reg), PMMC (also voltages)
*
* TXD1 enable = PMC20=0 PM20=0 P20=1
* RXD1 enable = PMC31=0 PM31=1
*
* WDT: WDTE (enable reg) + option byte C0: set WDTON bit to 0 (bit 4)
*
* serial: UART1: ch2
* 8n1 lsbfirst
* PER0: bit 2 hi
* PRR0: bit 2 lo
* SPSm: 0b0100<<4 (125kbaud?)
* SMRmn:
* SEm SSm STm SOEm SOm SOLm SSCm ISC
*
* opt C1: 0b00000010 // 0x1a?
* opt C2: 0b11101001 // 0x2d?
* opt C3: 0b10000101 == 0x85
* C4..CD: 00 ...
*/
}
SECTIONS {
.btc0 :
{
. = 0x00000;
KEEP(*(.vectors))
. = 0x00080;
KEEP(*(.callt))
. = 0x000c0;
KEEP(*(.option))
. = 0x000c4;
KEEP(*(.password))
. = 0x000ce;
*(.text.btc0)
} > rom =0xff
/* TODO: btc1? */
.text :
{
. = ALIGN(2);
*(.text .rodata* .eh_frame_hdr)
. = ALIGN(256);
/*KEEP(*(.eh_frame) *(.gcc_except_table*))
PROVIDE (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE (__preinit_array_end = .);
PROVIDE (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE (__init_array_end = .);
PROVIDE (__fini_array_start = .);
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
PROVIDE (__fini_array_end = .);
LONG(0);*/ /* Sentinel. */
/* gcc uses crtbegin.o to find the start of the constructors, so
we make sure it is first. Because this is a wildcard, it
doesn't matter if the user does not actually link against
crtbegin.o; the linker won't look for a file to match a
wildcard. The wildcard also means that it doesn't matter which
directory crtbegin.o is in. */
/*KEEP (*crtbegin*.o(.ctors))*/
/* We don't want to include the .ctor section from from the
crtend.o file until after the sorted ctors. The .ctor section
from the crtend file contains the end of ctors marker and it
must be last */
/*KEEP (*(EXCLUDE_FILE (*crtend*.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
KEEP (*crtbegin*.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend*.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))*/
} > rom =0xff
.data :
{
__data_vma_start = ABSOLUTE(.);
__data_lma_start = SIZEOF(.text);
*(.data)
}
__data_size = SIZEOF(.data);
.bss :
{
__bss_start = ABSOLUTE(.);
*(.bss .sbss)
} >ram
__bss_size = SIZEOF(.bss);
/DISCARD/ :
{
*(.plt)
}
}