From 10e379f492a00c12dadcd1969cf8328635ed18d0 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sat, 11 Jan 2014 15:52:38 -0800 Subject: [PATCH] Add ldscripts for LPC4320 targets (e.g. HackRF One). Qualify Makefile ldscripts based on BOARD. --- firmware/common/LPC4320_M0.ld | 29 ++++++++++++ firmware/common/LPC4320_M4.ld | 55 +++++++++++++++++++++++ firmware/common/LPC4320_M4_rom_to_ram.ld | 56 ++++++++++++++++++++++++ firmware/common/Makefile_inc.mk | 14 ++++-- 4 files changed, 150 insertions(+), 4 deletions(-) create mode 100644 firmware/common/LPC4320_M0.ld create mode 100644 firmware/common/LPC4320_M4.ld create mode 100644 firmware/common/LPC4320_M4_rom_to_ram.ld diff --git a/firmware/common/LPC4320_M0.ld b/firmware/common/LPC4320_M0.ld new file mode 100644 index 00000000..04dc7428 --- /dev/null +++ b/firmware/common/LPC4320_M0.ld @@ -0,0 +1,29 @@ +/* + * 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. + */ + +MEMORY +{ + ram (rwx) : ORIGIN = 0x00000000, LENGTH = 28K +} + +/* Include the common ld script. */ +INCLUDE libopencm3_lpc43xx_m0_ram_only.ld diff --git a/firmware/common/LPC4320_M4.ld b/firmware/common/LPC4320_M4.ld new file mode 100644 index 00000000..8b1382eb --- /dev/null +++ b/firmware/common/LPC4320_M4.ld @@ -0,0 +1,55 @@ +/* + * 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. + */ + +/* 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_usb0 (rwx) : ORIGIN = 0x20008000, LENGTH = 16K + ram_usb1 (rwx) : ORIGIN = 0x2000c000, LENGTH = 16K + /* ram_usb[01]: 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) + */ +} + +/* 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/LPC4320_M4_rom_to_ram.ld b/firmware/common/LPC4320_M4_rom_to_ram.ld new file mode 100644 index 00000000..23a309ae --- /dev/null +++ b/firmware/common/LPC4320_M4_rom_to_ram.ld @@ -0,0 +1,56 @@ +/* + * 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 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_usb0 (rwx) : ORIGIN = 0x20008000, LENGTH = 16K + ram_usb1 (rwx) : ORIGIN = 0x2000c000, LENGTH = 16K + /* ram_usb[01]: 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) + */ +} + +/* 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/Makefile_inc.mk b/firmware/common/Makefile_inc.mk index ac1874af..5cb449e3 100644 --- a/firmware/common/Makefile_inc.mk +++ b/firmware/common/Makefile_inc.mk @@ -29,7 +29,13 @@ BOARD ?= JAWBREAKER RUN_FROM ?= SPIFI -HACKRF_OPTS = -D$(BOARD) -DLPC43XX +ifeq ($(BOARD),HACKRF_ONE) + MCU_PARTNO=LPC4320 +else + MCU_PARTNO=LPC4330 +endif + +HACKRF_OPTS = -D$(BOARD) -DLPC43XX -D$(MCU_PARTNO) # comment to disable RF transmission HACKRF_OPTS += -DTX_ENABLE @@ -62,9 +68,9 @@ OBJ_M0_C = $(patsubst %.c, $(OBJDIR_M0)/%.o, $(notdir $(SRC_M0_C))) OBJ_M0_S = $(patsubst %.s, $(OBJDIR_M0)/%.o, $(notdir $(SRC_M0_S))) ifeq ($(RUN_FROM),RAM) - LDSCRIPT_M4 = $(PATH_HACKRF_FIRMWARE_COMMON)/LPC4330_M4.ld + LDSCRIPT_M4 = $(PATH_HACKRF_FIRMWARE_COMMON)/$(MCU_PARTNO)_M4.ld else - LDSCRIPT_M4 = $(PATH_HACKRF_FIRMWARE_COMMON)/LPC4330_M4_rom_to_ram.ld + LDSCRIPT_M4 = $(PATH_HACKRF_FIRMWARE_COMMON)/$(MCU_PARTNO)_M4_rom_to_ram.ld endif PREFIX ?= arm-none-eabi @@ -84,7 +90,7 @@ LDFLAGS_COMMON += -mthumb \ -Wl,--gc-sections \ -lc -lnosys CFLAGS_M0 += -mcpu=cortex-m0 -DLPC43XX_M0 -LDSCRIPT_M0 ?= $(PATH_HACKRF_FIRMWARE_COMMON)/LPC4330_M0.ld +LDSCRIPT_M0 ?= $(PATH_HACKRF_FIRMWARE_COMMON)/$(MCU_PARTNO)_M0.ld LDFLAGS_M0 += -mcpu=cortex-m0 -DLPC43XX_M0 LDFLAGS_M0 += -T$(LDSCRIPT_M0) LDFLAGS_M0 += --specs=nano.specs