summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon McNab <[email protected]>2021-10-27 12:30:51 +0100
committerGordon McNab <[email protected]>2021-10-27 12:30:51 +0100
commit6a658007a5145147bd7435346f3617a7cda589b7 (patch)
tree1ec888886c0ff4bad545a6a711a61444b2a983e1
parent5e6edecaa3594980198d8f687b3d97979ae85092 (diff)
Changes to use ft90x-sdk as submodule or installed SDK from toolchain.
-rw-r--r--hw/bsp/brtmm90x/family.mk57
-rw-r--r--hw/mcu/bridgetek/ft9xx/scripts/crt0.S (renamed from hw/mcu/bridgetek/ft9xx/hardware/scripts/crt0.S)0
-rw-r--r--hw/mcu/bridgetek/ft9xx/scripts/ldscript.ld (renamed from hw/mcu/bridgetek/ft9xx/hardware/scripts/ldscript.ld)1
-rw-r--r--src/portable/bridgetek/ft9xx/dcd_ft9xx.c11
4 files changed, 50 insertions, 19 deletions
diff --git a/hw/bsp/brtmm90x/family.mk b/hw/bsp/brtmm90x/family.mk
index 211f97f1b..d47f4820c 100644
--- a/hw/bsp/brtmm90x/family.mk
+++ b/hw/bsp/brtmm90x/family.mk
@@ -1,11 +1,28 @@
-
+# GCC prefix for FT90X compile tools.
CROSS_COMPILE = ft32-elf-
-DEPS_SUBMODULES += hw/mcu/bridgetek/ft9xx/hardware
SKIP_NANOLIB = 1
-# This is installed at "C:/Program Files(x86)/Bridgetek/FT9xx Toolchain/Toolchain/hardware"
-FT9XX_SDK = $(TOP)/hw/mcu/bridgetek/ft9xx/hardware
+# Set to use FT90X prebuilt libraries.
+FT90X_PREBUILT_LIBS = 1
+ifeq ($(FT90X_PREBUILT_LIBS),1)
+# If the FT90X toolchain is installed on Windows systems then the SDK
+# include files and prebuilt libraries are at: %FT90X_TOOLCHAIN%/hardware
+FT9XX_SDK = $(FT90X_TOOLCHAIN)/hardware
+else
+# The submodule BRTSG-FOSS/ft90x-sdk contains header files and source
+# code for the Bridgetek SDK. This can be used instead of the prebuilt
+# library.
+DEPS_SUBMODULES += hw/mcu/bridgetek/ft9xx/hardware
+# The SDK can be used to load specific files from the Bridgetek SDK.
+FT9XX_SDK = hw/mcu/bridgetek/ft9xx/hardware/Source
+endif
+
+# Add include files which are within the TinyUSB directory structure.
+INC += \
+ $(TOP)/hw/mcu/bridgetek/ft9xx/hardware/Source/include \
+ $(TOP)/$(BOARD_PATH)
+# Add required C Compiler flags for FT90X.
CFLAGS += \
-D__FT900__ \
-fvar-tracking \
@@ -16,20 +33,34 @@ CFLAGS += \
# lwip/src/core/raw.c:334:43: error: declaration of 'recv' shadows a global declaration
CFLAGS += -Wno-error=shadow
-CFLAGS:=$(filter-out -Wcast-function-type,$(CFLAGS))
-# All source paths should be relative to the top level.
-LDINC += $(FT9XX_SDK)/lib/Release
-LIBS += -lft900
-LD_FILE = hw/mcu/bridgetek/ft9xx/hardware/scripts/ldscript.ld
+# Add include files outside the TinyUSB structure that are added manually.
+CFLAGS += -I"$(FT9XX_SDK)/include"
+
+# Set Linker flags.
+LD_FILE = hw/mcu/bridgetek/ft9xx/scripts/ldscript.ld
LDFLAGS += $(addprefix -L,$(LDINC)) \
-Xlinker --entry=_start \
-Wl,-lc
+# Additional Source files for FT90X.
SRC_C += src/portable/bridgetek/ft9xx/dcd_ft9xx.c
-#SRC_S += hw/mcu/bridgetek/ft9xx/hardware/scripts/crt0.S
+# Linker library.
+ifneq ($(FT90X_PREBUILT_LIBS),1)
+# Optionally add in files from the Bridgetek SDK instead of the prebuilt
+# library. These are the minimum required.
+SRC_C += $(FT9XX_SDK)/src/sys.c
+SRC_C += $(FT9XX_SDK)/src/interrupt.c
+SRC_C += $(FT9XX_SDK)/src/delay.c
+SRC_C += $(FT9XX_SDK)/src/timers.c
+SRC_C += $(FT9XX_SDK)/src/uart_simple.c
+SRC_C += $(FT9XX_SDK)/src/gpio.c
+else
+# Or if using the prebuilt libraries add them.
+LDFLAGS += -L"$(FT9XX_SDK)/lib"
+LIBS += -lft900
+endif
-INC += \
- $(FT9XX_SDK)/include \
- $(TOP)/$(BOARD_PATH)
+# Not required crt0 file for FT90X. Use compiler built-in file.
+#SRC_S += hw/mcu/bridgetek/ft9xx/scripts/crt0.S
diff --git a/hw/mcu/bridgetek/ft9xx/hardware/scripts/crt0.S b/hw/mcu/bridgetek/ft9xx/scripts/crt0.S
index 62fa266ee..62fa266ee 100644
--- a/hw/mcu/bridgetek/ft9xx/hardware/scripts/crt0.S
+++ b/hw/mcu/bridgetek/ft9xx/scripts/crt0.S
diff --git a/hw/mcu/bridgetek/ft9xx/hardware/scripts/ldscript.ld b/hw/mcu/bridgetek/ft9xx/scripts/ldscript.ld
index d1b4d46cd..987c2b2ba 100644
--- a/hw/mcu/bridgetek/ft9xx/hardware/scripts/ldscript.ld
+++ b/hw/mcu/bridgetek/ft9xx/scripts/ldscript.ld
@@ -9,6 +9,7 @@ MEMORY
{
flash (rx) : ORIGIN = 0, LENGTH = __PMSIZE
ram (rw!x) : ORIGIN = 0x800000, LENGTH = __RAMSIZE
+ ehci_mmap (rw!x) : ORIGIN = 0x811000, LENGTH = 2K
}
SECTIONS
{
diff --git a/src/portable/bridgetek/ft9xx/dcd_ft9xx.c b/src/portable/bridgetek/ft9xx/dcd_ft9xx.c
index 09ca2904f..3235d0ef1 100644
--- a/src/portable/bridgetek/ft9xx/dcd_ft9xx.c
+++ b/src/portable/bridgetek/ft9xx/dcd_ft9xx.c
@@ -29,20 +29,19 @@
* in https://brtchip.com/BRTSourceCodeLicenseAgreement
*/
+#include <stdint.h>
+#include <ft900.h>
+#include <registers/ft900_registers.h>
+
#include "board.h"
#include "bsp/board.h"
#include "tusb_option.h"
#if TUSB_OPT_DEVICE_ENABLED && \
- (CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X)
+ (CFG_TUSB_MCU == OPT_MCU_FT90X || CFG_TUSB_MCU == OPT_MCU_FT93X)
#define USBD_USE_STREAMS
-#include <stdint.h>
-#include <errno.h>
-#include <ft900.h>
-#include <registers/ft900_registers.h>
-
#include "device/dcd.h"
//--------------------------------------------------------------------+