aboutsummaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/fx3/README.md56
-rw-r--r--firmware/fx3/b200/bootloader/makefile46
-rw-r--r--firmware/fx3/b200/firmware/makefile22
-rw-r--r--firmware/fx3/b200/fx3_mem_map.patch174
4 files changed, 130 insertions, 168 deletions
diff --git a/firmware/fx3/README.md b/firmware/fx3/README.md
index 00f38185f..49442e368 100644
--- a/firmware/fx3/README.md
+++ b/firmware/fx3/README.md
@@ -14,59 +14,37 @@ managing the transport from the host to the FPGA by configuring IO and DMA.
## Setting up the Cypress SDK
-In order to compile the USRP B200 and B210 firmware, you will need the FX3 SDK
-distributed by the FX3 manufacturer, Cypress Semiconductor. You can download the
-[FX3 SDK from here](http://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-sdk-archives)
-*Note*: You *must* use SDK version 1.2.3!
+In order to compile the USRP B200 and B210 bootloader and firmware, you will
+need the FX3 SDK distributed by Cypress Semiconductor. You can download the
+[FX3 SDK from here](https://www.cypress.com/documentation/software-and-drivers/ez-usb-fx3-software-development-kit)
-Once you have downloaded it, extract the ARM cross-compiler from the tarball
-`ARM_GCC.tar.gz` and put it somewhere useful. The highest level directory you
-need is `arm-2013.03/`.
+From the SDK, extract the ARM cross-compile toolchain tarball `ARM-GCC.tar.gz`
+and the FX3 firmware tarball `fx3_firmware_linux.tar.gz`.
-Now that you have extracted the cross compilation toolchain, you need to set up
-some environment variables to tell the B2xx `makefile` where to look for the
-tools. These variables are:
+Set up the appropriate environment variables for the build:
```
- $ export ARMGCC_INSTALL_PATH=<your path>/arm-2013.03
- $ export ARMGCC_VERSION=4.5.2
+ $ export ARMGCC_INSTALL_PATH=<ARM toolchain dir>
+ $ export ARMGCC_VERSION=<ARM toolchain version>
+ $ export FX3FWROOT=<FX3 firmware dir>
```
-Now, you'll need to set-up the Cypress SDK, as well. In the SDK, copy the
-following sub-directories from the `firmware` directory to
-`uhd.git/firmware/fx3`: `common/`, `lpp_source/`, `u3p_firmware/`, `boot_fw/`.
-In addition, copy the `elf2img` sub-directory from the `util` directory to
-`uhd.git/firmware/fx3`.
-
-Your directory structure should now look like:
+These should look something like this:
```
-uhd.git/
- |
- --firmware/
- |
- --fx3/
- |
- --b200/ # From UHD
- --boot_fw/ # From Cypress SDK
- --common/ # From Cypress SDK
- --elf2img/ # From Cypress SDK
- --gpif2_designer/ # From UHD
- --lpp_source/ # From Cypress SDK
- --u3p_firmware/ # From Cypress SDK
- --README.md # From UHD
+ $ export ARMGCC_INSTALL_PATH=/path/to/my/files/arm-2013.11
+ $ export ARMGCC_VERSION=4.8.1
+ $ export FX3FWROOT=/path/to/my/files/cyfx3sdk
```
-
## Applying the Patch to the Toolchain
-Now, you'll need to apply a patch to a couple of files in the Cypress SDK. Head
-into the `common/` directory you just copied from the Cypress SDK, and apply the
-patch `b200/fx3_mem_map.patch`.
+Now, you'll need to apply a patch to some files in the Cypress SDK. Apply the
+patch `b200/fx3_mem_map.patch` as follows:
```
- # cd uhd.git/firmware/fx3
- $ patch -p1 < ../b200/fx3_mem_map.patch
+ $ cd uhd.git/firmware/fx3
+ $ patch -p1 -d $FX3FWROOT < b200/fx3_mem_map.patch
```
If you don't see any errors print on the screen, then the patch was successful.
diff --git a/firmware/fx3/b200/bootloader/makefile b/firmware/fx3/b200/bootloader/makefile
index 3dc7fcb80..e8b7d5916 100644
--- a/firmware/fx3/b200/bootloader/makefile
+++ b/firmware/fx3/b200/bootloader/makefile
@@ -8,23 +8,24 @@ IMGOUT = usrp_b200_bl.img
all:$(IMGOUT)
-BL_ROOT=../../boot_fw
-BL_INC=$(BL_ROOT)/include
-BL_LIB=$(BL_ROOT)/lib
-BL_CYP_SRC=$(BL_ROOT)/src
-
-ELF2IMG_SRC=../../elf2img/elf2img.c
+ELF2IMG_SRC=$(FX3FWROOT)/util/elf2img/elf2img.c
ELF2IMG=elf2img
CYFXBUILD = gcc
-include fx3_build_config.mak
+include $(FX3FWROOT)/fw_build/boot_fw/fx3_build_config.mak
MODULE = cyfx_boot_app
+ifeq ($(CYFXBUILD), arm)
+ APP_ASM_SOURCE =
+else
+ APP_ASM_SOURCE = cyfx_gcc_startup.S
+endif
+
APP_SOURCE = main.c usb_boot.c usb_descriptors.c ../common/common_descriptors.c ../common/common_helpers.c
-INCFLAGS = -I$(BL_INC) -I../common
+INCFLAGS = -I../common
APP_OBJECT=$(APP_SOURCE:%.c=./%.o)
@@ -32,20 +33,11 @@ APP_ASM_OBJECT=$(APP_ASM_SOURCE:%.S=./%.o)
EXES = $(MODULE).$(EXEEXT)
-ifeq ($(CYFXBUILD), gcc)
-
-APP_ASM_SOURCE = cyfx_gcc_startup.S
-
-else
-
-APP_ASM_SOURCE =
-
-endif
-
$(APP_ASM_OBJECT) : %.o : %.S
$(ASSEMBLE)
-$(APP_OBJECT) : %.o : %.c ../lib/cyfx3_boot.a cyfx3.ld
+
+$(APP_OBJECT) : %.o : %.c
$(COMPILE) $(INCFLAGS)
$(MODULE).$(EXEEXT): $(APP_OBJECT) $(APP_ASM_OBJECT)
@@ -54,29 +46,15 @@ $(MODULE).$(EXEEXT): $(APP_OBJECT) $(APP_ASM_OBJECT)
$(ELF2IMG):
gcc -o $(ELF2IMG) $(ELF2IMG_SRC)
-fx3_build_config.mak:
- cp $(BL_CYP_SRC)/fx3_build_config.mak .
-fx3_armgcc_config.mak:
- cp $(BL_CYP_SRC)/fx3_armgcc_config.mak .
cyfx_gcc_startup.S:
- cp $(BL_CYP_SRC)/cyfx_gcc_startup.S .
-cyfx3.ld:
- cp $(BL_CYP_SRC)/cyfx3.ld .
-../lib/cyfx3_boot.a:
- mkdir -p ../lib
- cp $(BL_LIB)/cyfx3_boot.a ../lib
+ cp $(FX3FWROOT)/firmware/boot_fw/src/cyfx_gcc_startup.S .
clean:
rm -f ./$(MODULE).$(EXEEXT)
rm -f ./$(MODULE).map
rm -f ./$(IMGOUT)
- rm -f ./fx3_build_config.mak
- rm -f ./fx3_armgcc_config.mak
rm -f ./cyfx_gcc_startup.S
- rm -f ./cyfx3.ld
- rm -f ../lib/cyfx3_boot.a
- rmdir ../lib --ignore-fail-on-non-empty
rm -f ./*.o
rm -f ../common/*.o
rm -f ./$(ELF2IMG)
diff --git a/firmware/fx3/b200/firmware/makefile b/firmware/fx3/b200/firmware/makefile
index 53d423dfb..c4135829b 100644
--- a/firmware/fx3/b200/firmware/makefile
+++ b/firmware/fx3/b200/firmware/makefile
@@ -10,9 +10,7 @@ HEX_OUT = usrp_b200_fw.hex
all:$(HEX_OUT)
# Pull in the Cypress SDK files to build the firmware
-FX3FWROOT=../..
-FX3PFWROOT=../../u3p_firmware
-include $(FX3FWROOT)/common/fx3_build_config.mak
+include $(FX3FWROOT)/firmware/common/fx3_build_config.mak
ifndef OC
OC = arm-none-eabi-objcopy
@@ -20,13 +18,19 @@ endif
MODULE = b200_main
-SOURCE += $(MODULE).c b200_i2c.c b200_usb_descriptors.c ../common/common_helpers.c ../common/common_descriptors.c
+SOURCE += $(MODULE).c b200_i2c.c b200_usb_descriptors.c ../common/common_helpers.c ../common/common_descriptors.c cyfxtx.c
INCFLAGS = -I../common
LDLIBS += \
"$$ARMGCC_INSTALL_PATH"/arm-none-eabi/lib/libm.a
+ifeq ($(CYFXBUILD),arm)
+ SOURCE_ASM=cyfx_startup.S
+else
+ SOURCE_ASM=cyfx_gcc_startup.S
+endif
+
C_OBJECT=$(SOURCE:%.c=./%.o)
A_OBJECT=$(SOURCE_ASM:%.S=./%.o)
@@ -35,6 +39,15 @@ EXES = $(MODULE).$(EXEEXT)
$(MODULE).$(EXEEXT): $(A_OBJECT) $(C_OBJECT)
$(LINK) $(LINKFLAGS)
+cyfxtx.c:
+ cp $(FX3FWROOT)/fw_build/fx3_fw/cyfxtx.c .
+
+cyfx_startup.S:
+ cp $(FX3FWROOT)/fw_build/fx3_fw/cyfx_startup.S .
+
+cyfx_gcc_startup.S:
+ cp $(FX3FWROOT)/fw_build/fx3_fw/cyfx_gcc_startup.S .
+
$(C_OBJECT) : %.o : %.c
$(COMPILE) $(INCFLAGS)
@@ -46,6 +59,7 @@ clean:
rm -f ./$(MODULE).map
rm -f ./*.o
rm -f ../common/*.o
+ rm -f cyfxtx.c cyfx_startup.S cyfx_gcc_startup.S
$(HEX_OUT): $(C_OBJECT) $(A_OBJECT) $(EXES)
$(OC) -O ihex $(EXES) $@
diff --git a/firmware/fx3/b200/fx3_mem_map.patch b/firmware/fx3/b200/fx3_mem_map.patch
index df9ff0e7a..5c1ca9849 100644
--- a/firmware/fx3/b200/fx3_mem_map.patch
+++ b/firmware/fx3/b200/fx3_mem_map.patch
@@ -1,91 +1,83 @@
-diff -ur 1.2.3-orig/common/cyfxtx.c 1.2.3/common/cyfxtx.c
---- 1.2.3-orig/common/cyfxtx.c 2013-02-07 17:16:54.000000000 -0800
-+++ 1.2.3/common/cyfxtx.c 2014-03-25 16:56:12.484602382 -0700
-@@ -33,7 +33,7 @@
- such as thread stacks and memory for message queues. The Cypress FX3
- libraries require a Mem heap size of at least 32 KB.
- */
--#define CY_U3P_MEM_HEAP_BASE ((uint8_t *)0x40038000)
-+#define CY_U3P_MEM_HEAP_BASE ((uint8_t *)0x40044000)
- #define CY_U3P_MEM_HEAP_SIZE (0x8000)
-
- /* The last 32 KB of RAM is reserved for 2-stage boot operation. This value can be changed to
-diff -ur 1.2.3-orig/common/fx3.ld 1.2.3/common/fx3.ld
---- 1.2.3-orig/common/fx3.ld 2013-02-07 17:16:54.000000000 -0800
-+++ 1.2.3/common/fx3.ld 2014-03-25 16:59:40.872240377 -0700
-@@ -26,10 +26,11 @@
- The default memory map used for FX3 applications is as follows:
-
- Descriptor area Base: 0x40000000 Size: 12KB
-- Code area Base: 0x40003000 Size: 180KB
-- Data area Base: 0x40030000 Size: 32KB
-- Driver heap Base: 0x40038000 Size: 32KB (Update cyfxtx.c to change this.)
-- Buffer area Base: 0x40040000 Size: 256KB (Update cyfxtx.c to change this.)
-+ Code area Base: 0x40003000 Size: 212KB
-+ Data area Base: 0x40038000 Size: 32KB
-+ Heap Base: 0x40040000 Size: 16KB
-+ Driver heap Base: 0x40044000 Size: 32KB (Update cyfxtx.c to change this.)
-+ Buffer area Base: 0x4004C000 Size: 208KB (Update cyfxtx.c to change this.)
-
- Interrupt handlers to be placed in I-TCM (16KB).
- The first 256 bytes of ITCM are reserved for Exception Vectors.
-@@ -52,8 +53,8 @@
- MEMORY
- {
- I-TCM : ORIGIN = 0x100, LENGTH = 0x3F00
-- SYS_MEM : ORIGIN = 0x40003000 LENGTH = 0x2D000
-- DATA : ORIGIN = 0x40030000 LENGTH = 0x8000
-+ SYS_MEM : ORIGIN = 0x40003000 LENGTH = 0x35000
-+ DATA : ORIGIN = 0x40038000 LENGTH = 0x8000
- }
-
- SECTIONS
-@@ -75,7 +76,7 @@
- _etext = .;
- } > SYS_MEM
-
-- . = 0x40030000;
-+ . = 0x40038000;
- .data :
- {
- _data = .;
-@@ -104,5 +105,16 @@
- } > DATA
- __exidx_end = .;
-
-+ PROVIDE(__exidx_end = __exidx_end);
-+
-+ . = ALIGN(4);
-+ __heap_start = 0x40040000;
-+ PROVIDE(__heap_start = __heap_start);
-+
-+ . = ALIGN(4);
-+ __heap_end = 0x40044000;
-+ PROVIDE(__heap_end = __heap_end);
-+
-+ PROVIDE(__heap_size = __heap_end - __heap_start);
- }
-
-diff -ur 1.2.3-orig/boot_fw/src/cyfx3.ld 1.2.3/boot_fw/src/cyfx3.ld
---- 1.2.3-orig/boot_fw/src/cyfx3.ld 2019-02-12 16:40:48.000000000 -0800
-+++ 1.2.3/boot_fw/src/cyfx3.ld 2019-03-20 14:36:18.992529192 -0700
-@@ -34,12 +34,18 @@
-
- MEMORY
- {
-+ BLANK : ORIGIN = 0x40070000 LENGTH = 0x0100
- SYS_MEM : ORIGIN = 0x40078000 LENGTH = 0x7000
- DATA : ORIGIN = 0x4007F000 LENGTH = 0x1000
- }
-
- SECTIONS
- {
-+ . = 0x40070000;
-+ .blank :
-+ {
-+ . += 0x100;
-+ } > BLANK
- . = 0x40078000;
- .text :
- {
-
+diff -r -u cyfx3sdk/fw_build/boot_fw/cyfx3.ld cyfx3sdk-modified/fw_build/boot_fw/cyfx3.ld
+--- cyfx3sdk/fw_build/boot_fw/cyfx3.ld 2018-05-23 02:25:01.000000000 -0700
++++ cyfx3sdk-modified/fw_build/boot_fw/cyfx3.ld 2020-08-22 14:54:46.407481500 -0700
+@@ -39,12 +39,18 @@
+
+ MEMORY
+ {
++ BLANK : ORIGIN = 0x40070000 LENGTH = 0x0100
+ SYS_MEM : ORIGIN = 0x40078000 LENGTH = 0x7000
+ DATA : ORIGIN = 0x4007F000 LENGTH = 0x1000
+ }
+
+ SECTIONS
+ {
++ .blank :
++ {
++ . += 0x100;
++ } > BLANK
++
+ .text :
+ {
+ *(RESET)
+diff -r -u cyfx3sdk/fw_build/fx3_fw/cyfxtx.c cyfx3sdk-modified/fw_build/fx3_fw/cyfxtx.c
+--- cyfx3sdk/fw_build/fx3_fw/cyfxtx.c 2018-05-23 02:25:01.000000000 -0700
++++ cyfx3sdk-modified/fw_build/fx3_fw/cyfxtx.c 2020-08-21 12:34:14.344699800 -0700
+@@ -98,7 +98,7 @@
+ area which is used by the application code as well as the drivers to allocate thread
+ stacks and other internal data structures.
+ */
+-#define CY_U3P_MEM_HEAP_BASE (0x40038000)
++#define CY_U3P_MEM_HEAP_BASE (0x40044000)
+ #define CY_U3P_MEM_HEAP_SIZE (0x8000)
+
+ /*
+diff -r -u cyfx3sdk/fw_build/fx3_fw/fx3_512k.ld cyfx3sdk-modified/fw_build/fx3_fw/fx3_512k.ld
+--- cyfx3sdk/fw_build/fx3_fw/fx3_512k.ld 2018-05-23 02:25:01.000000000 -0700
++++ cyfx3sdk-modified/fw_build/fx3_fw/fx3_512k.ld 2020-08-21 12:34:14.345050200 -0700
+@@ -32,11 +32,11 @@
+ The default memory map used for FX3 applications is as follows:
+
+ Descriptor area Base: 0x40000000 Size: 12KB
+- Code area Base: 0x40003000 Size: 180KB
+- Data area Base: 0x40030000 Size: 32KB
+- Driver heap Base: 0x40038000 Size: 32KB (Update cyfxtx.c to change this.)
+- Buffer area Base: 0x40040000 Size: 224KB (Update cyfxtx.c to change this.)
+- 2-stage boot area Base: 0x40078000 Size: 32KB (Update cyfxtx.c to change this.)
++ Code area Base: 0x40003000 Size: 212KB
++ Data area Base: 0x40038000 Size: 32KB
++ Heap Base: 0x40040000 Size: 16KB
++ Driver heap Base: 0x40044000 Size: 32KB (Update cyfxtx.c to change this.)
++ Buffer area Base: 0x4004C000 Size: 208KB (Update cyfxtx.c to change this.)
+
+ Interrupt handlers are placed in I-TCM (16KB). The first 256 bytes of ITCM are
+ reserved for Exception Vectors and will be loaded during firmware initialization.
+@@ -58,8 +58,8 @@
+ MEMORY
+ {
+ I-TCM : ORIGIN = 0x100 LENGTH = 0x3F00
+- SYS_MEM : ORIGIN = 0x40003000 LENGTH = 0x2D000
+- DATA : ORIGIN = 0x40030000 LENGTH = 0x8000
++ SYS_MEM : ORIGIN = 0x40003000 LENGTH = 0x35000
++ DATA : ORIGIN = 0x40038000 LENGTH = 0x8000
+ }
+
+ SECTIONS
+@@ -114,5 +114,17 @@
+ . = ALIGN(4);
+ } > DATA
+ __exidx_end = .;
++
++ PROVIDE(__exidx_end = __exidx_end);
++
++ . = ALIGN(4);
++ __heap_start = 0x40040000;
++ PROVIDE(__heap_start = __heap_start);
++
++ . = ALIGN(4);
++ __heap_end = 0x40044000;
++ PROVIDE(__heap_end = __heap_end);
++
++ PROVIDE(__heap_size = __heap_end - __heap_start);
+ }
+