From ba2cc32ac696faa730cb2f81862ec6ae3e62c520 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sat, 11 Jan 2014 17:07:49 -0800 Subject: [PATCH] Combine ram_usb[01] into a single region. Assign usb_bulk_buffer symbol to ram_usb origin, instead of hard-coding a pointer in C. Change declaration of usb_bulk_buffer from a pointer to an array. --- firmware/common/LPC4320_M4.ld | 7 ++++--- firmware/common/LPC4320_M4_rom_to_ram.ld | 7 ++++--- firmware/common/LPC4330_M4.ld | 7 ++++--- firmware/common/LPC4330_M4_rom_to_ram.ld | 7 ++++--- firmware/hackrf_usb/usb_bulk_buffer.c | 7 ++++++- firmware/hackrf_usb/usb_bulk_buffer.h | 2 +- 6 files changed, 23 insertions(+), 14 deletions(-) diff --git a/firmware/common/LPC4320_M4.ld b/firmware/common/LPC4320_M4.ld index 8b1382eb..f72ef9ee 100644 --- a/firmware/common/LPC4320_M4.ld +++ b/firmware/common/LPC4320_M4.ld @@ -33,14 +33,15 @@ MEMORY 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 + 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 diff --git a/firmware/common/LPC4320_M4_rom_to_ram.ld b/firmware/common/LPC4320_M4_rom_to_ram.ld index 23a309ae..13436e79 100644 --- a/firmware/common/LPC4320_M4_rom_to_ram.ld +++ b/firmware/common/LPC4320_M4_rom_to_ram.ld @@ -34,14 +34,15 @@ MEMORY 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 + 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 diff --git a/firmware/common/LPC4330_M4.ld b/firmware/common/LPC4330_M4.ld index db336a52..c87fbf68 100644 --- a/firmware/common/LPC4330_M4.ld +++ b/firmware/common/LPC4330_M4.ld @@ -33,14 +33,15 @@ MEMORY ram_sleep (rwx) : ORIGIN = 0x10090000, 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 + 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 diff --git a/firmware/common/LPC4330_M4_rom_to_ram.ld b/firmware/common/LPC4330_M4_rom_to_ram.ld index e7701a5a..7833245d 100644 --- a/firmware/common/LPC4330_M4_rom_to_ram.ld +++ b/firmware/common/LPC4330_M4_rom_to_ram.ld @@ -34,14 +34,15 @@ MEMORY ram_sleep (rwx) : ORIGIN = 0x10090000, 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 + 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 diff --git a/firmware/hackrf_usb/usb_bulk_buffer.c b/firmware/hackrf_usb/usb_bulk_buffer.c index b4da7e6d..9048f49a 100644 --- a/firmware/hackrf_usb/usb_bulk_buffer.c +++ b/firmware/hackrf_usb/usb_bulk_buffer.c @@ -22,6 +22,11 @@ #include "usb_bulk_buffer.h" -uint8_t* const usb_bulk_buffer = (uint8_t*)0x20008000; +/* Address of usb_bulk_buffer is set in ldscripts. If you change the name of this + * variable, it won't be where it needs to be in the processor's address space, + * unless you also adjust the ldscripts. + */ +uint8_t usb_bulk_buffer[32768]; + const uint32_t usb_bulk_buffer_mask = 32768 - 1; volatile uint32_t usb_bulk_buffer_offset = 0; diff --git a/firmware/hackrf_usb/usb_bulk_buffer.h b/firmware/hackrf_usb/usb_bulk_buffer.h index fe298e69..967bd16c 100644 --- a/firmware/hackrf_usb/usb_bulk_buffer.h +++ b/firmware/hackrf_usb/usb_bulk_buffer.h @@ -25,7 +25,7 @@ #include -extern uint8_t* const usb_bulk_buffer; +extern uint8_t usb_bulk_buffer[32768]; extern const uint32_t usb_bulk_buffer_mask; extern volatile uint32_t usb_bulk_buffer_offset;