From 9bc293c82793ac2409116c6508ca6348d763c9c1 Mon Sep 17 00:00:00 2001 From: Gil Pitney Date: Tue, 13 Dec 2016 19:48:15 -0800 Subject: [PATCH] cc3200: Use peripheral driver library functions from ROM Previously, CC3200 drivers had two options to use the peripheral driver library APIs: 1) Build driverlib SDK files in Zephyr, in ext/hal/ti/cc3200/* 2) Link directly with the driverlib.a, from an externally installed TI CC3200 SDK. A new option is added to replace option 2), and is now the default: 3) Use the driverlib functions already provided in ROM. This enables a savings in code size, which will depend on the types of device drivers configured and the number of SDK APIs actually used. A rom_report build of the shell sample application showed a savings of about 2kb in code space using this new config option. Change-Id: Ie1ede6f7aacd23db20f5292e776f1dfeab5c7fe0 Signed-off-by: Gil Pitney Signed-off-by: Kumar Gala --- .../cc32xx/Kconfig.defconfig.cc3200 | 3 -- .../cc3200_launchxl/cc3200_launchxl_defconfig | 2 +- ext/hal/Kbuild | 2 +- ext/hal/ti/cc3200sdk/Kbuild | 17 ++++++----- ext/hal/ti/cc3200sdk/Kconfig | 19 ++++-------- ext/hal/ti/cc3200sdk/Makefile | 14 ++++----- ext/hal/ti/cc3200sdk/README | 30 ++++++++++++++++--- 7 files changed, 49 insertions(+), 38 deletions(-) diff --git a/arch/arm/soc/ti_simplelink/cc32xx/Kconfig.defconfig.cc3200 b/arch/arm/soc/ti_simplelink/cc32xx/Kconfig.defconfig.cc3200 index f9b16082a17..ef0ef3ba762 100644 --- a/arch/arm/soc/ti_simplelink/cc32xx/Kconfig.defconfig.cc3200 +++ b/arch/arm/soc/ti_simplelink/cc32xx/Kconfig.defconfig.cc3200 @@ -20,9 +20,6 @@ config FLASH_SIZE config CC3200SDK_LIBRARY def_bool n -config CC3200SDK_INSTALL_PATH - default "" - config NUM_IRQS int # must be >= the highest interrupt number used diff --git a/boards/arm/cc3200_launchxl/cc3200_launchxl_defconfig b/boards/arm/cc3200_launchxl/cc3200_launchxl_defconfig index eff4c9f68e0..f28683443a0 100644 --- a/boards/arm/cc3200_launchxl/cc3200_launchxl_defconfig +++ b/boards/arm/cc3200_launchxl/cc3200_launchxl_defconfig @@ -22,4 +22,4 @@ CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y # Enable CC3200 SDK driver files -CONFIG_CC3200SDK_BUILTIN=y +CONFIG_CC3200SDK_ROM_DRIVERLIB=y diff --git a/ext/hal/Kbuild b/ext/hal/Kbuild index 933586cc21f..41a729828e3 100644 --- a/ext/hal/Kbuild +++ b/ext/hal/Kbuild @@ -1,4 +1,4 @@ obj-$(CONFIG_HAS_KSDK) += ksdk/ obj-$(CONFIG_QMSI_BUILTIN) += qmsi/ obj-$(CONFIG_HAS_STM32CUBE) += st/stm32cube/ -obj-$(CONFIG_CC3200SDK_BUILTIN) += ti/cc3200sdk/ +obj-$(CONFIG_HAS_CC3200SDK) += ti/cc3200sdk/ diff --git a/ext/hal/ti/cc3200sdk/Kbuild b/ext/hal/ti/cc3200sdk/Kbuild index c495e6c4f62..0e371f6fef7 100644 --- a/ext/hal/ti/cc3200sdk/Kbuild +++ b/ext/hal/ti/cc3200sdk/Kbuild @@ -1,17 +1,18 @@ -# CC3200 SDK builds driverlib with level 0 optimization (-O0). -# Zephyr uses -Os optimization level, which causes issues -# with the uart module: characters are garbled on output. -# Until this is resolved with the vendor, we keep -O0 here, -# to ensure correct operation. +# CONFIG_CC3200SDK_BUILTIN can be used for debugging purposes. +# In that case, the CC3200 SDK driverlib must be built with level 0 +# optimization (-O0) for the uart module to work properly. +# Note the default build for Zephyr is CONFIG_CC3200SDK_ROM_DRIVERLIB=y +# which uses the ROM versions of the APIs instead. ccflags-$(CONFIG_CC3200SDK_BUILTIN) += -O0 -ccflags-$(CONFIG_CC3200SDK_BUILTIN) += -D$(COMPILER) +ccflags-$(CONFIG_HAS_CC3200SDK) += -D$(COMPILER) obj-$(CONFIG_CC3200SDK_BUILTIN) += driverlib/gpio.o obj-$(CONFIG_CC3200SDK_BUILTIN) += driverlib/interrupt.o obj-$(CONFIG_CC3200SDK_BUILTIN) += driverlib/pin.o -obj-$(CONFIG_CC3200SDK_BUILTIN) += driverlib/prcm.o obj-$(CONFIG_CC3200SDK_BUILTIN) += driverlib/uart.o -obj-$(CONFIG_CC3200SDK_BUILTIN) += driverlib/utils.o obj-$(CONFIG_CC3200SDK_BUILTIN) += driverlib/udma.o # spi.c warns on parens CFLAGS_spi.o += -Wno-parentheses obj-$(CONFIG_CC3200SDK_BUILTIN) += driverlib/spi.o +# Need prcm and utils for PRCMCC3200MCUInit which is not in ROM +obj-$(CONFIG_HAS_CC3200SDK) += driverlib/utils.o +obj-$(CONFIG_HAS_CC3200SDK) += driverlib/prcm.o diff --git a/ext/hal/ti/cc3200sdk/Kconfig b/ext/hal/ti/cc3200sdk/Kconfig index d8a399e6b2b..e5e3b23e717 100644 --- a/ext/hal/ti/cc3200sdk/Kconfig +++ b/ext/hal/ti/cc3200sdk/Kconfig @@ -19,18 +19,11 @@ config CC3200SDK_BUILTIN help Link with local CC3200 SDK driverlib sources. -config CC3200SDK_LIBRARY - bool "Link with CC3200 SDK static driver library" - default n - select CC3200SDK - help - The CC3200 SDK provides a static library (libdriver.a) - which implements peripheral APIs for the CC3200. - -config CC3200SDK_INSTALL_PATH - depends on CC3200SDK_LIBRARY - string "CC3200 SDK install path" - help - This option holds the path where the CC3200 SDK is installed. +config CC3200SDK_ROM_DRIVERLIB + bool "Use the Peripheral Driver library functions in ROM" + default n + select CC3200SDK + help + Vector to CC3200 SDK driverlib APIs in ROM. endif diff --git a/ext/hal/ti/cc3200sdk/Makefile b/ext/hal/ti/cc3200sdk/Makefile index 88503123f77..5a4e8d8c06b 100644 --- a/ext/hal/ti/cc3200sdk/Makefile +++ b/ext/hal/ti/cc3200sdk/Makefile @@ -1,11 +1,9 @@ -ifdef CONFIG_CC3200SDK_LIBRARY -ZEPHYRINCLUDE += -I$(CONFIG_CC3200SDK_INSTALL_PATH) -LIB_INCLUDE_DIR += -L$(CONFIG_CC3200SDK_INSTALL_PATH:"%"=%)/driverlib/gcc/exe -ALL_LIBS += driver -endif # CONFIG_CC3200SDK_LIBRARY - -ifdef CONFIG_CC3200SDK_BUILTIN +ifdef CONFIG_HAS_CC3200SDK ZEPHYRINCLUDE +=-I$(srctree)/ext/hal/ti/cc3200sdk ZEPHYRINCLUDE +=-I$(srctree)/ext/hal/ti/cc3200sdk/inc ZEPHYRINCLUDE +=-I$(srctree)/ext/hal/ti/cc3200sdk/driverlib -endif # CONFIG_CC3200_BUILTIN +endif # CONFIG_HAS_CC3200SDK + +ifdef CONFIG_CC3200SDK_ROM_DRIVERLIB +KBUILD_CFLAGS += -DTARGET_IS_CC3200 +endif # CONFIG_CC3200SDK_ROM_DRIVERLIB diff --git a/ext/hal/ti/cc3200sdk/README b/ext/hal/ti/cc3200sdk/README index 48dac8776e8..f2de9ea3470 100644 --- a/ext/hal/ti/cc3200sdk/README +++ b/ext/hal/ti/cc3200sdk/README @@ -10,8 +10,30 @@ from: Files in driverlib/ and inc/ are copied from an SDK installation (without modification). -Setting CONFIG_CC3200SDK_BUILTIN allows building those files within -the Zephyr ext/hal/ subdirectory. +After setting CONFIG_HAS_CC3200SDK=y in Kconfig, there are two methods +for using the peripheral driver library: -Setting CONFIG_CC3200SDK_INSTALL_PATH and CONFIG_CC3200SDK_LIBRARY enables -linking with the library provided by the CC3200 SDK, installed separately. +1) (Default) Use the driverlib functions in ROM instead of RAM. + +TI provides the driver library functions burned into ROM at the factory, +or updated via a service pack patch, thus saving application code space. + +For the zephyr shell sample, for example, this resulted in a savings of +about 2Kb in code space. + +Setting CONFIG_CC3200SDK_ROM_DRIVERLIB enables all driverlib APIs prefixed by +"MAP_" to vector to those functions already existing in ROM. + +See: Section 6.2.2 "Linking User Application with ROM APIs", + CC3200 Programmer's Guide, www.ti.com/lit/pdf/swru369 + +2) Use the driver library functions built from the CC3200SDK files in Zephyr. + +Setting CONFIG_CC3200SDK_BUILTIN allows building those files within +the Zephyr ext/hal/ti/ subdirectory. Though this will take more code space +than using the ROM driverlib functions, this may be useful for debugging +purposes. + +Applications can use the two configurations simultaneously: For example, calling +APIs without the "MAP_" prefix would call into Zephyr-built driver lib functions in +RAM, while calling APIs with the "MAP_" prefix would call into the ROM.