Break ldscripts into smaller pieces that can be shared.

This commit is contained in:
Jared Boone
2014-01-11 17:38:27 -08:00
parent ba2cc32ac6
commit bb8943ce5b
8 changed files with 50 additions and 137 deletions

View File

@ -1,6 +1,5 @@
/* /*
* Copyright 2012 Michael Ossmann <mike@ossmann.com> * Copyright 2012 Michael Ossmann <mike@ossmann.com>
* Copyright (C) 2012 Benjamin Vernoux <titanmkd@gmail.com>
* Copyright 2012 Jared Boone <jared@sharebrained.com> * Copyright 2012 Jared Boone <jared@sharebrained.com>
* *
* This file is part of HackRF * This file is part of HackRF
@ -25,33 +24,11 @@
MEMORY MEMORY
{ {
/* Physical address in Flash used to copy Code from Flash to RAM */
rom_flash (rx) : ORIGIN = 0x80000000, LENGTH = 1M
/* rom is really the shadow region that points to SPI flash or elsewhere */ /* rom is really the shadow region that points to SPI flash or elsewhere */
rom (rx) : ORIGIN = 0x00000000, LENGTH = 96K rom (rx) : ORIGIN = 0x00000000, LENGTH = 96K
ram_local1 (rwx) : ORIGIN = 0x10000000, LENGTH = 96K ram_local1 (rwx) : ORIGIN = 0x10000000, LENGTH = 96K
ram_local2 (rwx) : ORIGIN = 0x10080000, LENGTH = 32K ram_local2 (rwx) : ORIGIN = 0x10080000, LENGTH = 32K
ram_sleep (rwx) : ORIGIN = 0x10088000, LENGTH = 8K ram_sleep (rwx) : ORIGIN = 0x10088000, LENGTH = 8K
ram_m0 (rwx) : ORIGIN = 0x20000000, LENGTH = 28K
ram_shared (rwx) : ORIGIN = 0x20007000, LENGTH = 4K
ram_usb (rwx) : ORIGIN = 0x20008000, LENGTH = 32K
/* ram_usb: USB buffer. Straddles two blocks of RAM
* to get performance benefit of having two USB buffers addressable
* simultaneously (on two different buses of the AHB multilayer matrix)
*/
} }
usb_bulk_buffer = ORIGIN(ram_usb); INCLUDE LPC43xx_M4_memory.ld
/* Include the common ld script. */
INCLUDE libopencm3_lpc43xx_rom_to_ram.ld
SECTIONS
{
.text : {
PROVIDE(__m0_start__ = .);
KEEP(*(.m0_bin*));
. = ALIGN(4);
PROVIDE(__m0_end__ = .);
} >rom
}

View File

@ -24,33 +24,11 @@
MEMORY MEMORY
{ {
/* Physical address in Flash used to copy Code from Flash to RAM */
rom_flash (rx) : ORIGIN = 0x80000000, LENGTH = 1M
/* rom is really the shadow region that points to SPI flash or elsewhere */ /* rom is really the shadow region that points to SPI flash or elsewhere */
rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K
ram_local1 (rwx) : ORIGIN = 0x10000000, LENGTH = 128K ram_local1 (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
ram_local2 (rwx) : ORIGIN = 0x10080000, LENGTH = 64K ram_local2 (rwx) : ORIGIN = 0x10080000, LENGTH = 64K
ram_sleep (rwx) : ORIGIN = 0x10090000, LENGTH = 8K ram_sleep (rwx) : ORIGIN = 0x10090000, LENGTH = 8K
ram_m0 (rwx) : ORIGIN = 0x20000000, LENGTH = 28K
ram_shared (rwx) : ORIGIN = 0x20007000, LENGTH = 4K
ram_usb (rwx) : ORIGIN = 0x20008000, LENGTH = 32K
/* ram_usb: USB buffer. Straddles two blocks of RAM
* to get performance benefit of having two USB buffers addressable
* simultaneously (on two different buses of the AHB multilayer matrix)
*/
} }
usb_bulk_buffer = ORIGIN(ram_usb); INCLUDE LPC43xx_M4_memory.ld
/* Include the common ld script. */
INCLUDE libopencm3_lpc43xx.ld
SECTIONS
{
.m0 0x20000000 : {
PROVIDE(__m0_start__ = .);
KEEP(*(.m0_bin*));
. = ALIGN(4);
PROVIDE(__m0_end__ = .);
} >ram_m0
}

View File

@ -1,57 +0,0 @@
/*
* Copyright 2012 Michael Ossmann <mike@ossmann.com>
* Copyright (C) 2012 Benjamin Vernoux <titanmkd@gmail.com>
* Copyright 2012 Jared Boone <jared@sharebrained.com>
*
* This file is part of HackRF
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
/* Linker script for HackRF Jellybean/Jawbreaker (LPC4330, 1M SPI flash, 264K SRAM). */
MEMORY
{
/* Physical address in Flash used to copy Code from Flash to RAM */
rom_flash (rx) : ORIGIN = 0x80000000, LENGTH = 1M
/* rom is really the shadow region that points to SPI flash or elsewhere */
rom (rx) : ORIGIN = 0x00000000, LENGTH = 128K
ram_local1 (rwx) : ORIGIN = 0x10000000, LENGTH = 128K
ram_local2 (rwx) : ORIGIN = 0x10080000, LENGTH = 64K
ram_sleep (rwx) : ORIGIN = 0x10090000, LENGTH = 8K
ram_m0 (rwx) : ORIGIN = 0x20000000, LENGTH = 28K
ram_shared (rwx) : ORIGIN = 0x20007000, LENGTH = 4K
ram_usb (rwx) : ORIGIN = 0x20008000, LENGTH = 32K
/* ram_usb: USB buffer. Straddles two blocks of RAM
* to get performance benefit of having two USB buffers addressable
* simultaneously (on two different buses of the AHB multilayer matrix)
*/
}
usb_bulk_buffer = ORIGIN(ram_usb);
/* Include the common ld script. */
INCLUDE libopencm3_lpc43xx_rom_to_ram.ld
SECTIONS
{
.text : {
PROVIDE(__m0_start__ = .);
KEEP(*(.m0_bin*));
. = ALIGN(4);
PROVIDE(__m0_end__ = .);
} >rom
}

View File

@ -24,6 +24,3 @@ MEMORY
{ {
ram (rwx) : ORIGIN = 0x00000000, LENGTH = 28K ram (rwx) : ORIGIN = 0x00000000, LENGTH = 28K
} }
/* Include the common ld script. */
INCLUDE libopencm3_lpc43xx_m0_ram_only.ld

View File

@ -20,10 +20,12 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
MEMORY SECTIONS
{ {
ram (rwx) : ORIGIN = 0x00000000, LENGTH = 28K .text : {
PROVIDE(__m0_start__ = .);
KEEP(*(.m0_bin*));
. = ALIGN(4);
PROVIDE(__m0_end__ = .);
} >rom
} }
/* Include the common ld script. */
INCLUDE libopencm3_lpc43xx_m0_ram_only.ld

View File

@ -0,0 +1,31 @@
/*
* Copyright 2012 Michael Ossmann <mike@ossmann.com>
* Copyright 2012 Jared Boone <jared@sharebrained.com>
*
* This file is part of HackRF
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street,
* Boston, MA 02110-1301, USA.
*/
SECTIONS
{
.m0 0x20000000 : {
PROVIDE(__m0_start__ = .);
KEEP(*(.m0_bin*));
. = ALIGN(4);
PROVIDE(__m0_end__ = .);
} >ram_m0
}

View File

@ -20,17 +20,10 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
/* Linker script for HackRF One (LPC4320, 1M SPI flash, 200K SRAM). */
MEMORY MEMORY
{ {
/* Physical address in Flash used to copy Code from Flash to RAM */ /* Physical address in Flash used to copy Code from Flash to RAM */
rom_flash (rx) : ORIGIN = 0x80000000, LENGTH = 1M rom_flash (rx) : ORIGIN = 0x80000000, LENGTH = 1M
/* rom is really the shadow region that points to SPI flash or elsewhere */
rom (rx) : ORIGIN = 0x00000000, LENGTH = 96K
ram_local1 (rwx) : ORIGIN = 0x10000000, LENGTH = 96K
ram_local2 (rwx) : ORIGIN = 0x10080000, LENGTH = 32K
ram_sleep (rwx) : ORIGIN = 0x10088000, LENGTH = 8K
ram_m0 (rwx) : ORIGIN = 0x20000000, LENGTH = 28K ram_m0 (rwx) : ORIGIN = 0x20000000, LENGTH = 28K
ram_shared (rwx) : ORIGIN = 0x20007000, LENGTH = 4K ram_shared (rwx) : ORIGIN = 0x20007000, LENGTH = 4K
ram_usb (rwx) : ORIGIN = 0x20008000, LENGTH = 32K ram_usb (rwx) : ORIGIN = 0x20008000, LENGTH = 32K
@ -41,16 +34,3 @@ MEMORY
} }
usb_bulk_buffer = ORIGIN(ram_usb); usb_bulk_buffer = ORIGIN(ram_usb);
/* Include the common ld script. */
INCLUDE libopencm3_lpc43xx.ld
SECTIONS
{
.m0 0x20000000 : {
PROVIDE(__m0_start__ = .);
KEEP(*(.m0_bin*));
. = ALIGN(4);
PROVIDE(__m0_end__ = .);
} >ram_m0
}

View File

@ -67,12 +67,18 @@ OBJ_M4_S = $(patsubst %.s, $(OBJDIR_M4)/%.o, $(notdir $(SRC_M4_S)))
OBJ_M0_C = $(patsubst %.c, $(OBJDIR_M0)/%.o, $(notdir $(SRC_M0_C))) OBJ_M0_C = $(patsubst %.c, $(OBJDIR_M0)/%.o, $(notdir $(SRC_M0_C)))
OBJ_M0_S = $(patsubst %.s, $(OBJDIR_M0)/%.o, $(notdir $(SRC_M0_S))) OBJ_M0_S = $(patsubst %.s, $(OBJDIR_M0)/%.o, $(notdir $(SRC_M0_S)))
LDSCRIPT_M4 += -T$(PATH_HACKRF_FIRMWARE_COMMON)/$(MCU_PARTNO)_M4_memory.ld
ifeq ($(RUN_FROM),RAM) ifeq ($(RUN_FROM),RAM)
LDSCRIPT_M4 = $(PATH_HACKRF_FIRMWARE_COMMON)/$(MCU_PARTNO)_M4.ld LDSCRIPT_M4 += -Tlibopencm3_lpc43xx.ld
LDSCRIPT_M4 += -T$(PATH_HACKRF_FIRMWARE_COMMON)/LPC43xx_M4_M0_image_in_ram.ld
else else
LDSCRIPT_M4 = $(PATH_HACKRF_FIRMWARE_COMMON)/$(MCU_PARTNO)_M4_rom_to_ram.ld LDSCRIPT_M4 += -Tlibopencm3_lpc43xx_rom_to_ram.ld
LDSCRIPT_M4 += -T$(PATH_HACKRF_FIRMWARE_COMMON)/LPC43xx_M4_M0_image_from_spifi.ld
endif endif
LDSCRIPT_M0 += -T$(PATH_HACKRF_FIRMWARE_COMMON)/LPC43xx_M0_memory.ld
LDSCRIPT_M0 += -Tlibopencm3_lpc43xx_m0_ram_only.ld
PREFIX ?= arm-none-eabi PREFIX ?= arm-none-eabi
CC = $(PREFIX)-gcc CC = $(PREFIX)-gcc
LD = $(PREFIX)-gcc LD = $(PREFIX)-gcc
@ -90,9 +96,8 @@ LDFLAGS_COMMON += -mthumb \
-Wl,--gc-sections \ -Wl,--gc-sections \
-lc -lnosys -lc -lnosys
CFLAGS_M0 += -mcpu=cortex-m0 -DLPC43XX_M0 CFLAGS_M0 += -mcpu=cortex-m0 -DLPC43XX_M0
LDSCRIPT_M0 ?= $(PATH_HACKRF_FIRMWARE_COMMON)/$(MCU_PARTNO)_M0.ld
LDFLAGS_M0 += -mcpu=cortex-m0 -DLPC43XX_M0 LDFLAGS_M0 += -mcpu=cortex-m0 -DLPC43XX_M0
LDFLAGS_M0 += -T$(LDSCRIPT_M0) LDFLAGS_M0 += $(LDSCRIPT_M0)
LDFLAGS_M0 += --specs=nano.specs LDFLAGS_M0 += --specs=nano.specs
LDFLAGS_M0 += -Xlinker -Map=$(OBJDIR_M0)/m0.map LDFLAGS_M0 += -Xlinker -Map=$(OBJDIR_M0)/m0.map
LDFLAGS_M0 += -lopencm3_lpc43xx_m0 LDFLAGS_M0 += -lopencm3_lpc43xx_m0
@ -100,7 +105,7 @@ LDFLAGS_M0 += -lopencm3_lpc43xx_m0
CFLAGS_M4 += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DLPC43XX_M4 CFLAGS_M4 += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DLPC43XX_M4
LDFLAGS_M4 += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DLPC43XX_M4 LDFLAGS_M4 += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DLPC43XX_M4
LDFLAGS_M4 += -L$(TOOLCHAIN_DIR)/lib/armv7e-m/fpu LDFLAGS_M4 += -L$(TOOLCHAIN_DIR)/lib/armv7e-m/fpu
LDFLAGS_M4 += -T$(LDSCRIPT_M4) LDFLAGS_M4 += $(LDSCRIPT_M4)
LDFLAGS_M4 += -Xlinker -Map=$(OBJDIR_M4)/m4.map LDFLAGS_M4 += -Xlinker -Map=$(OBJDIR_M4)/m4.map
LDFLAGS_M4 += -lopencm3_lpc43xx -lm LDFLAGS_M4 += -lopencm3_lpc43xx -lm