linker template, move build output
This commit is contained in:
parent
256c308060
commit
2d4b0a5f69
8 changed files with 66 additions and 168 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -17,4 +17,6 @@ build_script/
|
|||
test_emu/
|
||||
*.pyc
|
||||
dcc_test.py
|
||||
old_stuff/
|
||||
old_stuff/
|
||||
linker/linker.ld
|
||||
.out/
|
||||
14
crt.s
14
crt.s
|
|
@ -54,7 +54,7 @@ _vectors:
|
|||
.global DCC_PKT_RW_SIZE
|
||||
#endif
|
||||
|
||||
#ifdef PIC
|
||||
#ifdef USE_PIC
|
||||
.extern pic_relocate
|
||||
#endif
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ CrashHandler:
|
|||
|
||||
/* DCC info */
|
||||
.ascii "DNDL"
|
||||
#ifdef PIC
|
||||
#ifdef USE_PIC
|
||||
.word 1
|
||||
#else
|
||||
.word 0
|
||||
|
|
@ -127,20 +127,20 @@ ResetHandler:
|
|||
#endif
|
||||
|
||||
/* 01 - Initialize stack section */
|
||||
#ifdef PIC
|
||||
#ifdef USE_PIC
|
||||
mov r0, #0
|
||||
adr r0, _vectors
|
||||
#endif
|
||||
|
||||
ldr sp, =__stack_svc_end
|
||||
#ifdef PIC
|
||||
#ifdef USE_PIC
|
||||
add sp, r0
|
||||
#endif
|
||||
|
||||
bl plat_init
|
||||
|
||||
/* 02 - Reset memory */
|
||||
#ifdef PIC
|
||||
#ifdef USE_PIC
|
||||
mov r0, #0
|
||||
adr r0, _vectors
|
||||
#endif
|
||||
|
|
@ -152,7 +152,7 @@ ResetHandler:
|
|||
ldr r2, =__bss_end
|
||||
mov r3, #0
|
||||
|
||||
#ifdef PIC
|
||||
#ifdef USE_PIC
|
||||
add r1, r0
|
||||
add r2, r0
|
||||
#endif
|
||||
|
|
@ -162,7 +162,7 @@ bss_clear_loop:
|
|||
bne bss_clear_loop
|
||||
|
||||
/* 03 - Code initialize */
|
||||
#ifdef PIC
|
||||
#ifdef USE_PIC
|
||||
mov r0, #0
|
||||
adr r0, _vectors
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ PHDRS
|
|||
|
||||
MEMORY
|
||||
{
|
||||
ram : org = 0x78000000, len = 128k
|
||||
ram : org = ${DCC_LOAD_OFFSET}, len = ${DCC_MEMORY_SIZE_KB}k
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -134,6 +134,5 @@ SECTIONS
|
|||
PROVIDE (__stack_end = .);
|
||||
PROVIDE (__heap_start = .);
|
||||
} > ram
|
||||
|
||||
}
|
||||
/*** EOF ***/
|
||||
138
linker/ram.ld
138
linker/ram.ld
|
|
@ -1,138 +0,0 @@
|
|||
/* SPDX-License-Identifier: BSD-3-Clause */
|
||||
|
||||
/****************************************************************************
|
||||
* Copyright (c) 2006 by Michael Fischer. All rights reserved.
|
||||
****************************************************************************
|
||||
*
|
||||
* History:
|
||||
*
|
||||
* 30.03.06 mifi First Version
|
||||
****************************************************************************/
|
||||
|
||||
ENTRY(ResetHandler)
|
||||
SEARCH_DIR(.)
|
||||
|
||||
/*
|
||||
* Define stack size here
|
||||
*/
|
||||
FIQ_STACK_SIZE = 0x0100;
|
||||
IRQ_STACK_SIZE = 0x0100;
|
||||
ABT_STACK_SIZE = 0x0100;
|
||||
UND_STACK_SIZE = 0x0100;
|
||||
SVC_STACK_SIZE = 0x0100;
|
||||
|
||||
PHDRS
|
||||
{
|
||||
code PT_LOAD;
|
||||
data PT_LOAD;
|
||||
}
|
||||
|
||||
MEMORY
|
||||
{
|
||||
ram : org = 0x00000000, len = 512k
|
||||
}
|
||||
|
||||
/*
|
||||
* Do not change the next code
|
||||
*/
|
||||
SECTIONS
|
||||
{
|
||||
.text :
|
||||
{
|
||||
*(.vectors);
|
||||
. = ALIGN(4);
|
||||
*(.init);
|
||||
. = ALIGN(4);
|
||||
*(.text);
|
||||
. = ALIGN(4);
|
||||
*(.rodata);
|
||||
. = ALIGN(4);
|
||||
*(.rodata*);
|
||||
. = ALIGN(4);
|
||||
*(.glue_7t);
|
||||
. = ALIGN(4);
|
||||
*(.glue_7);
|
||||
. = ALIGN(4);
|
||||
etext = .;
|
||||
} > ram :code
|
||||
|
||||
.data :
|
||||
{
|
||||
PROVIDE (__data_start = .);
|
||||
*(.data)
|
||||
. = ALIGN(4);
|
||||
edata = .;
|
||||
PROVIDE (__data_end = .);
|
||||
} > ram :data
|
||||
|
||||
.plt : ALIGN(4)
|
||||
{
|
||||
*(.plt)
|
||||
. = ALIGN(4);
|
||||
} > ram :code
|
||||
|
||||
.got : ALIGN(4)
|
||||
{
|
||||
_sgot = .;
|
||||
_sgot_main = .;
|
||||
*(.got)
|
||||
_egot_main = .;
|
||||
} > ram :data
|
||||
|
||||
.got.plt : ALIGN(4)
|
||||
{
|
||||
_sgot_plt = .;
|
||||
*(.got.plt)
|
||||
_egot_plt = .;
|
||||
_egot = .;
|
||||
_edata = .;
|
||||
} > ram :data
|
||||
|
||||
.rel.dyn : ALIGN(4)
|
||||
{
|
||||
_reloc_start = .;
|
||||
*(.rel.dyn)
|
||||
} > ram :data
|
||||
|
||||
.bss :
|
||||
{
|
||||
_reloc_end = .;
|
||||
PROVIDE (__bss_start = .);
|
||||
*(.bss)
|
||||
*(COMMON)
|
||||
. = ALIGN(4);
|
||||
PROVIDE (__bss_end = .);
|
||||
|
||||
. = ALIGN(256);
|
||||
|
||||
PROVIDE (__stack_start = .);
|
||||
|
||||
PROVIDE (__stack_fiq_start = .);
|
||||
. += FIQ_STACK_SIZE;
|
||||
. = ALIGN(4);
|
||||
PROVIDE (__stack_fiq_end = .);
|
||||
|
||||
PROVIDE (__stack_irq_start = .);
|
||||
. += IRQ_STACK_SIZE;
|
||||
. = ALIGN(4);
|
||||
PROVIDE (__stack_irq_end = .);
|
||||
|
||||
PROVIDE (__stack_abt_start = .);
|
||||
. += ABT_STACK_SIZE;
|
||||
. = ALIGN(4);
|
||||
PROVIDE (__stack_abt_end = .);
|
||||
|
||||
PROVIDE (__stack_und_start = .);
|
||||
. += UND_STACK_SIZE;
|
||||
. = ALIGN(4);
|
||||
PROVIDE (__stack_und_end = .);
|
||||
|
||||
PROVIDE (__stack_svc_start = .);
|
||||
. += SVC_STACK_SIZE;
|
||||
. = ALIGN(4);
|
||||
PROVIDE (__stack_svc_end = .);
|
||||
PROVIDE (__stack_end = .);
|
||||
PROVIDE (__heap_start = .);
|
||||
} > ram
|
||||
}
|
||||
/*** EOF ***/
|
||||
2
main.c
2
main.c
|
|
@ -6,8 +6,8 @@
|
|||
const char CFLAGS[] = "C:DumpNow DCC Loader. (c) 2026 Wrapper.;Compile flags: " CDEFS ";Compile Date: " __DATE__;
|
||||
#endif
|
||||
|
||||
#if !USE_BREAKPOINTS && !DISABLE_COMPRESS
|
||||
static uint8_t read_buffer[DCC_BUFFER_SIZE + 0x2000];
|
||||
#if !USE_BREAKPOINTS && !DISABLE_COMPRESS
|
||||
static uint8_t compress_buffer[DCC_BUFFER_SIZE + 0x4000];
|
||||
#endif
|
||||
|
||||
|
|
|
|||
57
makefile
57
makefile
|
|
@ -2,6 +2,7 @@
|
|||
# Start of default section
|
||||
#
|
||||
|
||||
# Tools
|
||||
TRGT = arm-none-eabi-
|
||||
CC = $(TRGT)gcc
|
||||
CP = $(TRGT)objcopy
|
||||
|
|
@ -9,8 +10,7 @@ AS = $(TRGT)gcc -x assembler-with-cpp
|
|||
HEX = $(CP) -O ihex
|
||||
BIN = $(CP) -O binary
|
||||
OBJDUMP = $(TRGT)objdump
|
||||
|
||||
MCU = arm7tdmi
|
||||
PYTHON = python
|
||||
|
||||
# List all default C defines here, like -D_DEBUG=1
|
||||
DDEFS =
|
||||
|
|
@ -38,8 +38,9 @@ DLIBS =
|
|||
# Define project name here
|
||||
PROJECT = dumpnow
|
||||
|
||||
# Define linker script file here
|
||||
LDSCRIPT = linker/ram.ld
|
||||
# Auto LD script stuff
|
||||
LOADER_LOAD_START = 0x00000000
|
||||
LOADER_LOAD_SIZE_KB = 512
|
||||
|
||||
# List all user C define here, like -D_DEBUG=1
|
||||
UDEFS =
|
||||
|
|
@ -47,14 +48,24 @@ UDEFS =
|
|||
# Define ASM defines here
|
||||
UADEFS =
|
||||
|
||||
# List C source files here
|
||||
# CPU type
|
||||
MCU = arm7tdmi
|
||||
|
||||
# Target platform
|
||||
PLATFORM = default
|
||||
|
||||
# Storage devices for the target platform
|
||||
LOADER_DEVICES = default
|
||||
|
||||
# Define optimisation level here
|
||||
OPT = -O2
|
||||
|
||||
# Dependencies
|
||||
DEVICES = flash/mmap/mmap.c
|
||||
CONTROLLERS =
|
||||
ADD_DEPS =
|
||||
PLATFORM = default
|
||||
LOADER_DEVICES = default
|
||||
|
||||
# Additional deps
|
||||
# Optional dependencies
|
||||
ifeq ($(LZO), 1)
|
||||
ADD_DEPS += minilzo/minilzo.c
|
||||
DDEFS += -DHAVE_MINILZO=1
|
||||
|
|
@ -65,7 +76,7 @@ ADD_DEPS += lz4/lz4_fs.c
|
|||
DDEFS += -DHAVE_LZ4=1
|
||||
endif
|
||||
|
||||
# Devices
|
||||
# Storage devices
|
||||
ifeq ($(CFI), 1)
|
||||
DEVICES += flash/cfi/cfi.c
|
||||
endif
|
||||
|
|
@ -85,7 +96,7 @@ DEVICES += flash/superand/superand.c
|
|||
CONTROLLERS += flash/superand/controller/$(SUPERAND_CONTROLLER).c
|
||||
endif
|
||||
|
||||
# Configuration
|
||||
# Loader configuration
|
||||
ifeq ($(MCU), xscale)
|
||||
DDEFS += -DCPU_XSCALE
|
||||
DADEFS += -DCPU_XSCALE
|
||||
|
|
@ -115,6 +126,7 @@ DADEFS += -DUSE_PIC
|
|||
ADD_DEPS += dcc/pic.c
|
||||
endif
|
||||
|
||||
# List C source files here
|
||||
SRC = main.c dcc/memory.c dcc/dn_dcc_proto.c dcc/bitutils.c dcc/lwprintf.c plat/$(PLATFORM).c devices/$(LOADER_DEVICES).c $(DEVICES) $(CONTROLLERS) $(ADD_DEPS)
|
||||
|
||||
# List ASM source files here
|
||||
|
|
@ -129,19 +141,15 @@ ULIBDIR =
|
|||
# List all user libraries here
|
||||
ULIBS =
|
||||
|
||||
# Define optimisation level here
|
||||
OPT = -O2
|
||||
|
||||
#
|
||||
# End of user defines
|
||||
##############################################################################################
|
||||
|
||||
|
||||
INCDIR = $(patsubst %,-I%,$(DINCDIR) $(UINCDIR))
|
||||
LIBDIR = $(patsubst %,-L%,$(DLIBDIR) $(ULIBDIR))
|
||||
DEFS = $(DDEFS) $(UDEFS) -DCDEFS="\"FLAGS=$(DDEFS) $(UDEFS) CPU=$(MCU) PLATFORM=$(PLATFORM) LOADER_DEVICES=$(LOADER_DEVICES) DEVICES=$(DEVICES) CONTROLLERS=$(CONTROLLERS)\""
|
||||
ADEFS = $(DADEFS) $(UADEFS) -DADEFS="\"FLAGS=$(DADEFS) $(UADEFS) CPU=$(MCU)\""
|
||||
OBJS = $(ASRC:.s=.o) $(SRC:.c=.o)
|
||||
OBJS = $(ASRC:%.s=.out/%.o) $(SRC:%.c=.out/%.o)
|
||||
LIBS = $(DLIBS) $(ULIBS)
|
||||
MCFLAGS = -mcpu=$(MCU)
|
||||
CC_PIC =
|
||||
|
|
@ -173,12 +181,23 @@ ifeq ($(PLATFORM), default)
|
|||
$(warning Building without platform specific routines, specify PLATFORM to change that)
|
||||
endif
|
||||
|
||||
ifndef LDSCRIPT
|
||||
LDSCRIPT = linker/linker.ld
|
||||
all: $(LDSCRIPT) $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).lst
|
||||
else
|
||||
all: $(OBJS) $(PROJECT).elf $(PROJECT).hex $(PROJECT).bin $(PROJECT).lst
|
||||
endif
|
||||
|
||||
%.o : %.c
|
||||
%.ld : %.ld.tl
|
||||
$(info Generating linker script with offset: $(LOADER_LOAD_START); size: $(LOADER_LOAD_SIZE_KB)k)
|
||||
$(PYTHON) "utils/substitute.py" $< $@ $(LOADER_LOAD_START) $(LOADER_LOAD_SIZE_KB)
|
||||
|
||||
.out/%.o : %.c
|
||||
@mkdir -p $(@D)
|
||||
$(CC) -c $(CPFLAGS) -I . $(INCDIR) $< -o $@
|
||||
|
||||
%.o : %.s
|
||||
.out/%.o : %.s
|
||||
@mkdir -p $(@D)
|
||||
$(AS) -c $(ASFLAGS) $< -o $@
|
||||
|
||||
%elf: $(OBJS)
|
||||
|
|
@ -221,12 +240,14 @@ endif
|
|||
$(info $(NULL) MCU=(MCU) = Select CPU architecture)
|
||||
$(info $(NULL) ICACHE=1 = Use instruction cache (ARM9 and later))
|
||||
$(info $(NULL) BP_LOADER=1 = If the chipset have broken DCC Support, compiling as Breakpoint-based loader might help)
|
||||
$(info $(NULL) BUFFER_SIZE=(Buffer Size) = DCC Buffer Size (Default: 0x40000))
|
||||
$(info $(NULL) BUFFER_SIZE=(Buffer Size) = DCC Buffer Size (Default: 0x4000))
|
||||
$(info $(NULL) PROJECT=(name) = Output name)
|
||||
$(info $(NULL) LDSCRIPT=(ld) = Linker script)
|
||||
$(info $(NULL) NO_COMPRESS=1 = Disable RLE compression, used if using with RIFF says failed to unpack received data.)
|
||||
$(info $(NULL) BIG_ENDIAN=1 = Big endian format)
|
||||
$(info $(NULL) PIC=1 = Use PIC code)
|
||||
$(info $(NULL) LOADER_LOAD_START=(LOAD_OFFSET_IN_HEX) = With LDSCRIPT unset, set loader start offset)
|
||||
$(info $(NULL) LOADER_LOAD_SIZE_KB=(LOAD_SIZE_IN_KB) = With LDSCRIPT unset, set RAM size for the loader)
|
||||
$(info Flash devices:)
|
||||
$(info $(NULL) CFI=1 = Enable CFI interface)
|
||||
$(info $(NULL) NAND_CONTROLLER=(name) = Enable NAND controller)
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const uint32_t gpio_mask_index[4] = {0xffffffff, 0xffffffff, 0xffffffff, 0xfffff
|
|||
const uint32_t gpio_mask_index[3] = {0x1f801fe, 0xffffe1c0, 0x3fff};
|
||||
#endif
|
||||
|
||||
inline void plat_gpio_get_base(uint32_t pin, uint32_t reg_offset, uint32_t *reg_conv_offset, uint32_t *reg_mask) {
|
||||
static inline void plat_gpio_get_base(uint32_t pin, uint32_t reg_offset, uint32_t *reg_conv_offset, uint32_t *reg_mask) {
|
||||
uint32_t pin_bit_offset = pin & 0x1f;
|
||||
uint32_t mask_index = pin >> 5;
|
||||
uint32_t base_offset = (gpio_mask_index[mask_index] & (1 << pin_bit_offset)) ? GPIO1_OFFSET : GPIO2_OFFSET; // 1 - GPIO1, 0 - GPIO2
|
||||
|
|
|
|||
14
utils/substitute.py
Normal file
14
utils/substitute.py
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
from string import Template
|
||||
from argparse import ArgumentParser
|
||||
|
||||
if __name__ == "__main__":
|
||||
ap = ArgumentParser()
|
||||
ap.add_argument("in_file")
|
||||
ap.add_argument("out_file")
|
||||
ap.add_argument("dcc_start")
|
||||
ap.add_argument("dcc_mem_size")
|
||||
|
||||
args = ap.parse_args()
|
||||
|
||||
temp = Template(open(args.in_file, "r").read())
|
||||
open(args.out_file, "w").write(temp.substitute(DCC_LOAD_OFFSET=args.dcc_start, DCC_MEMORY_SIZE_KB=args.dcc_mem_size))
|
||||
Loading…
Add table
Add a link
Reference in a new issue