diff --git a/firmware/common/LPC4320_M4_rom_to_ram.ld b/firmware/common/LPC4320_M4_memory.ld similarity index 61% rename from firmware/common/LPC4320_M4_rom_to_ram.ld rename to firmware/common/LPC4320_M4_memory.ld index 13436e79..536db5eb 100644 --- a/firmware/common/LPC4320_M4_rom_to_ram.ld +++ b/firmware/common/LPC4320_M4_memory.ld @@ -1,6 +1,5 @@ /* * Copyright 2012 Michael Ossmann - * Copyright (C) 2012 Benjamin Vernoux * Copyright 2012 Jared Boone * * This file is part of HackRF @@ -25,33 +24,11 @@ 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 = 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_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 -} +INCLUDE LPC43xx_M4_memory.ld diff --git a/firmware/common/LPC4330_M4.ld b/firmware/common/LPC4330_M4_memory.ld similarity index 63% rename from firmware/common/LPC4330_M4.ld rename to firmware/common/LPC4330_M4_memory.ld index c87fbf68..42e217cf 100644 --- a/firmware/common/LPC4330_M4.ld +++ b/firmware/common/LPC4330_M4_memory.ld @@ -24,33 +24,11 @@ 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.ld - -SECTIONS -{ - .m0 0x20000000 : { - PROVIDE(__m0_start__ = .); - KEEP(*(.m0_bin*)); - . = ALIGN(4); - PROVIDE(__m0_end__ = .); - } >ram_m0 -} +INCLUDE LPC43xx_M4_memory.ld diff --git a/firmware/common/LPC4330_M4_rom_to_ram.ld b/firmware/common/LPC4330_M4_rom_to_ram.ld deleted file mode 100644 index 7833245d..00000000 --- a/firmware/common/LPC4330_M4_rom_to_ram.ld +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2012 Michael Ossmann - * Copyright (C) 2012 Benjamin Vernoux - * Copyright 2012 Jared Boone - * - * 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 -} diff --git a/firmware/common/LPC4320_M0.ld b/firmware/common/LPC43xx_M0_memory.ld similarity index 92% rename from firmware/common/LPC4320_M0.ld rename to firmware/common/LPC43xx_M0_memory.ld index 04dc7428..ec2f646a 100644 --- a/firmware/common/LPC4320_M0.ld +++ b/firmware/common/LPC43xx_M0_memory.ld @@ -24,6 +24,3 @@ MEMORY { ram (rwx) : ORIGIN = 0x00000000, LENGTH = 28K } - -/* Include the common ld script. */ -INCLUDE libopencm3_lpc43xx_m0_ram_only.ld diff --git a/firmware/common/LPC4330_M0.ld b/firmware/common/LPC43xx_M4_M0_image_from_spifi.ld similarity index 86% rename from firmware/common/LPC4330_M0.ld rename to firmware/common/LPC43xx_M4_M0_image_from_spifi.ld index 04dc7428..3c61f69e 100644 --- a/firmware/common/LPC4330_M0.ld +++ b/firmware/common/LPC43xx_M4_M0_image_from_spifi.ld @@ -20,10 +20,12 @@ * 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 diff --git a/firmware/common/LPC43xx_M4_M0_image_in_ram.ld b/firmware/common/LPC43xx_M4_M0_image_in_ram.ld new file mode 100644 index 00000000..e07bd79d --- /dev/null +++ b/firmware/common/LPC43xx_M4_M0_image_in_ram.ld @@ -0,0 +1,31 @@ +/* + * Copyright 2012 Michael Ossmann + * Copyright 2012 Jared Boone + * + * 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 +} diff --git a/firmware/common/LPC4320_M4.ld b/firmware/common/LPC43xx_M4_memory.ld similarity index 71% rename from firmware/common/LPC4320_M4.ld rename to firmware/common/LPC43xx_M4_memory.ld index f72ef9ee..71e78216 100644 --- a/firmware/common/LPC4320_M4.ld +++ b/firmware/common/LPC43xx_M4_memory.ld @@ -20,17 +20,10 @@ * Boston, MA 02110-1301, USA. */ -/* Linker script for HackRF One (LPC4320, 1M SPI flash, 200K 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 = 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_shared (rwx) : ORIGIN = 0x20007000, LENGTH = 4K ram_usb (rwx) : ORIGIN = 0x20008000, LENGTH = 32K @@ -41,16 +34,3 @@ MEMORY } 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 -} diff --git a/firmware/common/Makefile_inc.mk b/firmware/common/Makefile_inc.mk index 5cb449e3..288b7fc5 100644 --- a/firmware/common/Makefile_inc.mk +++ b/firmware/common/Makefile_inc.mk @@ -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_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) - 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 - 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 +LDSCRIPT_M0 += -T$(PATH_HACKRF_FIRMWARE_COMMON)/LPC43xx_M0_memory.ld +LDSCRIPT_M0 += -Tlibopencm3_lpc43xx_m0_ram_only.ld + PREFIX ?= arm-none-eabi CC = $(PREFIX)-gcc LD = $(PREFIX)-gcc @@ -90,9 +96,8 @@ LDFLAGS_COMMON += -mthumb \ -Wl,--gc-sections \ -lc -lnosys 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 += -T$(LDSCRIPT_M0) +LDFLAGS_M0 += $(LDSCRIPT_M0) LDFLAGS_M0 += --specs=nano.specs LDFLAGS_M0 += -Xlinker -Map=$(OBJDIR_M0)/m0.map 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 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 += -T$(LDSCRIPT_M4) +LDFLAGS_M4 += $(LDSCRIPT_M4) LDFLAGS_M4 += -Xlinker -Map=$(OBJDIR_M4)/m4.map LDFLAGS_M4 += -lopencm3_lpc43xx -lm