[nrf52840] disable compilation of unused transports (#3561)

Add DISABLE_TRANSPORTS switch which disables build of all transports and examples using them.
Disable compilation of USB and UART transports if NCP_SPI switch is set. This also disables
the build of CLI example.
This commit is contained in:
RaKu
2019-02-07 08:42:27 -08:00
committed by Jonathan Hui
parent f01e3f34e5
commit bfe0c492d9
4 changed files with 43 additions and 23 deletions
+26 -18
View File
@@ -43,12 +43,8 @@ BuildJobs ?= 10
GCCVersion = $(shell expr `$(CC) -dumpversion | cut -f1 -d.`)
configure_OPTIONS = \
--enable-cli \
--enable-diag \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--enable-linker-map \
--with-examples=nrf52840 \
$(NULL)
@@ -61,12 +57,6 @@ ifdef SRC_PATH
configure_OPTIONS += --srcdir="$(SRC_PATH)"
endif
ifeq ($(NCP_SPI),1)
configure_OPTIONS += --with-ncp-bus=spi
else
configure_OPTIONS += --with-ncp-bus=uart
endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
@@ -99,23 +89,41 @@ ifneq ($(CERT_LOG),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LOG_OUTPUT=OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED
endif
ifeq ($(USB),1)
COMMONCFLAGS += -DUSB_CDC_AS_SERIAL_TRANSPORT=1
endif
ifeq ($(BOOTLOADER),1)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf52840/nrf52840_bootloader.ld
COMMONCFLAGS += -DAPP_USBD_NRF_DFU_TRIGGER_ENABLED=1
endif
#
# Select transport which CLI, NCP and NCP-Radio examples will use to communicate.
# To disable all transports use the DISABLE_TRANSPORTS switch. This will disable
# the build of all above examples.
# If NCP_SPI switch is set, only NCP and NCP-Radio examples will be built.
# Otherwise the user can select USB transport. If no transports were selected,
# the default serial transport is UART.
#
ifndef DISABLE_TRANSPORTS
configure_OPTIONS += --enable-ncp
configure_OPTIONS += --enable-radio-only
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DSPIS_AS_SERIAL_TRANSPORT=1
configure_OPTIONS += --with-ncp-bus=spi
else
configure_OPTIONS += --with-ncp-bus=uart
configure_OPTIONS += --enable-diag
configure_OPTIONS += --enable-cli
ifeq ($(USB),1)
COMMONCFLAGS += -DUSB_CDC_AS_SERIAL_TRANSPORT=1
else
COMMONCFLAGS += -DUART_AS_SERIAL_TRANSPORT=1
endif # USB == 1
endif # NCP_SPI == 1
endif # DISABLE_TRANSPORTS
ifeq ($(DISABLE_CC310), 1)
NRF52840_MBEDTLS_CPPFLAGS += -DDISABLE_CC310=1
endif
ifeq ($(DISABLE_SPI),1)
COMMONCFLAGS += -DSPIS_TRANSPORT_DISABLE=1
endif
ifeq ($(shell expr $(GCCVersion) \>= 7), 1)
COMMONCFLAGS += -Wno-expansion-to-defined
endif
+4
View File
@@ -39,6 +39,8 @@
#include <hal/nrf_spis.h>
#include <platform-nrf5.h>
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
/**
* SPI Slave transaction variables.
*/
@@ -231,3 +233,5 @@ void SPIM0_SPIS0_TWIM0_TWIS0_SPI0_TWI0_IRQHandler(void)
}
}
}
#endif // SPIS_AS_SERIAL_TRANSPORT == 1
+11 -3
View File
@@ -78,15 +78,19 @@ void otSysInit(int argc, char *argv[])
nrf5RandomInit();
if (!gPlatformPseudoResetWasRequested)
{
#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1))
nrf5UartInit();
#endif
nrf5CryptoInit();
}
else
{
#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1))
nrf5UartClearPendingData();
#endif
}
#ifndef SPIS_TRANSPORT_DISABLE
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
nrf5SpiSlaveInit();
#endif
nrf5MiscInit();
@@ -105,13 +109,15 @@ void otSysDeinit(void)
nrf5TempDeinit();
nrf5RadioDeinit();
nrf5MiscDeinit();
#ifndef SPIS_TRANSPORT_DISABLE
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
nrf5SpiSlaveDeinit();
#endif
if (!gPlatformPseudoResetWasRequested)
{
nrf5CryptoDeinit();
#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1))
nrf5UartDeinit();
#endif
}
nrf5RandomDeinit();
nrf5AlarmDeinit();
@@ -129,9 +135,11 @@ bool otSysPseudoResetWasRequested(void)
void otSysProcessDrivers(otInstance *aInstance)
{
nrf5RadioProcess(aInstance);
#if ((UART_AS_SERIAL_TRANSPORT == 1) || (USB_CDC_AS_SERIAL_TRANSPORT == 1))
nrf5UartProcess();
#endif
nrf5TempProcess();
#ifndef SPIS_TRANSPORT_DISABLE
#if (SPIS_AS_SERIAL_TRANSPORT == 1)
nrf5SpiSlaveProcess();
#endif
nrf5AlarmProcess(aInstance);
+2 -2
View File
@@ -49,7 +49,7 @@
#include <hal/nrf_gpio.h>
#include <hal/nrf_uart.h>
#if (USB_CDC_AS_SERIAL_TRANSPORT == 0)
#if (UART_AS_SERIAL_TRANSPORT == 1)
bool sUartEnabled = false;
@@ -319,7 +319,7 @@ void UARTE0_UART0_IRQHandler(void)
}
}
#endif // USB_CDC_AS_SERIAL_TRANSPORT == 0
#endif // UART_AS_SERIAL_TRANSPORT == 1
/**
* The UART driver weak functions definition.