From f68fdaba7a3886e93c88b129d886a2db52ec3435 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sat, 6 Oct 2012 17:33:17 -0700 Subject: [PATCH] Add .usbram section handling to linker scripts and makefile. --- firmware/common/LPC4330_M4.ld | 3 ++ firmware/common/LPC4330_M4_ROM_to_RAM.ld | 3 ++ firmware/common/LPC4330_M4_ram_only.ld | 3 ++ firmware/common/Makefile_inc.mk | 4 ++- firmware/common/usbram.ld | 35 ++++++++++++++++++++++++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 firmware/common/usbram.ld diff --git a/firmware/common/LPC4330_M4.ld b/firmware/common/LPC4330_M4.ld index 8a9b2ad4..5edc3428 100644 --- a/firmware/common/LPC4330_M4.ld +++ b/firmware/common/LPC4330_M4.ld @@ -1,5 +1,6 @@ /* * Copyright 2012 Michael Ossmann + * Copyright 2012 Jared Boone * * This file is part of HackRF * @@ -32,3 +33,5 @@ MEMORY /* Include the common ld script. */ INCLUDE libopencm3_lpc43xx.ld + +INCLUDE usbram.ld diff --git a/firmware/common/LPC4330_M4_ROM_to_RAM.ld b/firmware/common/LPC4330_M4_ROM_to_RAM.ld index 995c54f5..f7e5886d 100644 --- a/firmware/common/LPC4330_M4_ROM_to_RAM.ld +++ b/firmware/common/LPC4330_M4_ROM_to_RAM.ld @@ -1,6 +1,7 @@ /* * Copyright 2012 Michael Ossmann * Copyright (C) 2012 Benjamin Vernoux + * Copyright 2012 Jared Boone * * This file is part of HackRF * @@ -36,3 +37,5 @@ MEMORY /* Include the common ld script. */ INCLUDE libopencm3_lpc43xx_rom_to_ram.ld + +INCLUDE usbram.ld diff --git a/firmware/common/LPC4330_M4_ram_only.ld b/firmware/common/LPC4330_M4_ram_only.ld index eb9ace11..11bb1d88 100644 --- a/firmware/common/LPC4330_M4_ram_only.ld +++ b/firmware/common/LPC4330_M4_ram_only.ld @@ -1,5 +1,6 @@ /* * Copyright 2012 Michael Ossmann + * Copyright 2012 Jared Boone * * This file is part of HackRF * @@ -30,3 +31,5 @@ MEMORY /* Include the common ld script. */ INCLUDE libopencm3_lpc43xx_ram_only.ld + +INCLUDE usbram.ld diff --git a/firmware/common/Makefile_inc.mk b/firmware/common/Makefile_inc.mk index 384fd9f1..1c635525 100644 --- a/firmware/common/Makefile_inc.mk +++ b/firmware/common/Makefile_inc.mk @@ -4,6 +4,7 @@ # Copyright 2010 Piotr Esden-Tempski # Copyright 2012 Michael Ossmann # Copyright 2012 Benjamin Vernoux +# Copyright 2012 Jared Boone # # This file is part of HackRF. # @@ -51,6 +52,7 @@ CFLAGS += -std=c99 -O2 -g3 -Wall -Wextra -I$(LIBOPENCM3)/include -I../common \ $(HACKRF_OPTS) #LDSCRIPT ?= $(BINARY).ld LDFLAGS += -L$(TOOLCHAIN_DIR)/lib/armv7e-m/fpu \ + -L../common \ -L$(LIBOPENCM3)/lib -L$(LIBOPENCM3)/lib/lpc43xx \ -T$(LDSCRIPT) -nostartfiles \ -Wl,--gc-sections -Xlinker -Map=$(BINARY).map @@ -78,7 +80,7 @@ flash: $(BINARY).flash %.bin: %.elf @#printf " OBJCOPY $(*).bin\n" - $(Q)$(OBJCOPY) -Obinary $(*).elf $(*).bin + $(Q)$(OBJCOPY) -Obinary -R .usbram $(*).elf $(*).bin %.hex: %.elf @#printf " OBJCOPY $(*).hex\n" diff --git a/firmware/common/usbram.ld b/firmware/common/usbram.ld new file mode 100644 index 00000000..279aaad3 --- /dev/null +++ b/firmware/common/usbram.ld @@ -0,0 +1,35 @@ +/* + * 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 +{ + . = ORIGIN(ram_ahb); + + .usbram : { + . = ALIGN(4096); + *(.usb_data) + . = ALIGN(2048); + *(.usb_qh) + . = ALIGN(64); + *(.usb_td) + } >ram_ahb + +}