Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update EFR32 SDK from 2.7 to 3.1 #4870

Merged
merged 6 commits into from
Feb 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions examples/lighting-app/efr32/include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ extern "C" {
* See the comments at the top of main.c, main_full.c and main_low_power.c for
* more information.
*/

#define configCREATE_LOW_POWER_DEMO (0)

/* Some configuration is dependent on the demo being built. */
Expand All @@ -147,7 +148,7 @@ turn the tick off. */
#define configUSE_TICK_HOOK (1)
#define configCHECK_FOR_STACK_OVERFLOW (2)
#define configUSE_MALLOC_FAILED_HOOK (1)
#define configUSE_IDLE_HOOK (0)
#define configUSE_IDLE_HOOK (1)

#define configENERGY_MODE (sleepEM1)

Expand Down Expand Up @@ -221,8 +222,8 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configUSE_PORT_OPTIMISED_TASK_SELECTION (1)
#define configUSE_TICKLESS_IDLE_SIMPLE_DEBUG (1) /* See into vPortSuppressTicksAndSleep source code for explanation */
#define configMAX_PRIORITIES (8)
#define configMINIMAL_STACK_SIZE (120) /* Number of words to use for Idle and Timer stacks */
#define configMAX_TASK_NAME_LEN (4)
#define configMINIMAL_STACK_SIZE (140) /* Number of words to use for Idle and Timer stacks */
#define configMAX_TASK_NAME_LEN (10)
#define configUSE_16_BIT_TICKS (0)
#define configIDLE_SHOULD_YIELD (0)
#define configUSE_MUTEXES (1)
Expand All @@ -233,6 +234,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configUSE_QUEUE_SETS (0)
#define configUSE_NEWLIB_REENTRANT (0)
#define configENABLE_BACKWARD_COMPATIBILITY (1)
#define configSUPPORT_STATIC_ALLOCATION (1)

/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet (1)
Expand Down
2 changes: 1 addition & 1 deletion examples/lighting-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int main(void)
EFR32_LOG("PlatformMgr().InitChipStack() failed");
appError(ret);
}

chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName("EFR32_LIGHT");
#if CHIP_ENABLE_OPENTHREAD
EFR32_LOG("Initializing OpenThread stack");
ret = ThreadStackMgr().InitThreadStack();
Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/efr32/include/FreeRTOSConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ See http://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html. */
#define configUSE_QUEUE_SETS (0)
#define configUSE_NEWLIB_REENTRANT (0)
#define configENABLE_BACKWARD_COMPATIBILITY (1)
#define configSUPPORT_STATIC_ALLOCATION (1)

/* Optional functions - most linkers will remove unused functions anyway. */
#define INCLUDE_vTaskPrioritySet (1)
Expand Down
2 changes: 1 addition & 1 deletion examples/lock-app/efr32/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int main(void)
EFR32_LOG("PlatformMgr().InitChipStack() failed");
appError(ret);
}

chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName("EFR32_LOCK");
#if CHIP_ENABLE_OPENTHREAD
EFR32_LOG("Initializing OpenThread stack");
ret = ThreadStackMgr().InitThreadStack();
Expand Down
107 changes: 95 additions & 12 deletions examples/platform/efr32/init_otSystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,39 @@
#include "common/logging.hpp"

#include "bsp.h"
#include "bsp_init.h"
#include "dmadrv.h"
#include "ecode.h"
#include "em_chip.h"
#include "em_cmu.h"
#include "em_core.h"
#include "em_device.h"
#include "em_emu.h"
#include "em_system.h"
#include "hal-config.h"
#include "hal_common.h"
#include "rail.h"
#include "sl_mpu.h"
#include "sl_sleeptimer.h"
#if OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE
#include "openthread/heap.h"
#include "sl_malloc.h"
#endif

#include "platform-efr32.h"

#if (HAL_FEM_ENABLE)
#include "fem-control.h"
#endif

#include "platform-efr32.h"

#if DISPLAY_ENABLED
#include "lcd.h"
#endif

void halInitChipSpecific(void);
static void halInitChipSpecific(void);
void initAntenna(void);

void initOtSysEFR(void)
{
Expand Down Expand Up @@ -93,15 +104,12 @@ void initOtSysEFR(void)
#endif
BSP_Init(BSP_INIT_BCC);

#if defined(EFR32MG12)
CMU_ClockSelectSet(cmuClock_LFE, cmuSelect_LFRCO);
CMU_ClockEnable(cmuClock_CORELE, true);
#elif defined(EFR32MG21)
// Enable LE peripheral clock. Needed for RTCC initialization in sl_sleeptimer_init()
#if !defined(_SILICON_LABS_32B_SERIES_2)
CMU_ClockEnable(cmuClock_HFLE, true);
CMU_OscillatorEnable(cmuOsc_LFRCO, true, true);
#else
#error "Enable Clocks for the used board"
#endif /* EFR32 PLATFORM */
CMU_ClockEnable(cmuClock_RTCC, true);
#endif // !defined(_SILICON_LABS_32B_SERIES_2)

status = sl_sleeptimer_init();
assert(status == SL_STATUS_OK);

Expand All @@ -118,8 +126,83 @@ void initOtSysEFR(void)
efr32RadioInit();
efr32AlarmInit();
efr32MiscInit();
#ifndef EFR32MG21
efr32RandomInit();
#endif /* EFR32 PLATFORM */

otHeapSetCAllocFree(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree);
}

void halInitChipSpecific(void)
{
#if defined(BSP_DK) && !defined(RAIL_IC_SIM_BUILD)
BSP_Init(BSP_INIT_DK_SPI);
#endif
BSP_initDevice();

#if !defined(RAIL_IC_SIM_BUILD)
BSP_initBoard();
#endif

#if HAL_PTI_ENABLE
RAIL_PtiConfig_t railPtiConfig = {
#if HAL_PTI_MODE == HAL_PTI_MODE_SPI
.mode = RAIL_PTI_MODE_SPI,
#elif HAL_PTI_MODE == HAL_PTI_MODE_UART
.mode = RAIL_PTI_MODE_UART,
#elif HAL_PTI_MODE == HAL_PTI_MODE_UART_ONEWIRE
.mode = RAIL_PTI_MODE_UART_ONEWIRE,
#else
.mode = RAIL_PTI_MODE_DISABLED,
#endif
.baud = HAL_PTI_BAUD_RATE,
#ifdef BSP_PTI_DOUT_LOC
.doutLoc = BSP_PTI_DOUT_LOC,
#endif
.doutPort = (uint8_t) BSP_PTI_DOUT_PORT,
.doutPin = BSP_PTI_DOUT_PIN,
#if HAL_PTI_MODE == HAL_PTI_MODE_SPI
#ifdef BSP_PTI_DCLK_LOC
.dclkLoc = BSP_PTI_DCLK_LOC,
#endif
.dclkPort = (uint8_t) BSP_PTI_DCLK_PORT,
.dclkPin = BSP_PTI_DCLK_PIN,
#endif
#if HAL_PTI_MODE != HAL_PTI_MODE_UART_ONEWIRE
#ifdef BSP_PTI_DFRAME_LOC
.dframeLoc = BSP_PTI_DFRAME_LOC,
#endif
.dframePort = (uint8_t) BSP_PTI_DFRAME_PORT,
.dframePin = BSP_PTI_DFRAME_PIN
#endif
};

RAIL_ConfigPti(RAIL_EFR32_HANDLE, &railPtiConfig);
#endif // HAL_PTI_ENABLE

#if !defined(RAIL_IC_SIM_BUILD)
initAntenna();

// Disable any unused peripherals to ensure we enter a low power mode
#if defined(BSP_EXTFLASH_USART) && !defined(HAL_DISABLE_EXTFLASH)
#include "mx25flash_spi.h"
MX25_init();
MX25_DP();
#endif

#endif

#if RAIL_DMA_CHANNEL == DMA_CHANNEL_DMADRV
Ecode_t dmaError = DMADRV_Init();
if ((dmaError == ECODE_EMDRV_DMADRV_ALREADY_INITIALIZED) || (dmaError == ECODE_EMDRV_DMADRV_OK))
{
unsigned int channel;
dmaError = DMADRV_AllocateChannel(&channel, NULL);
if (dmaError == ECODE_EMDRV_DMADRV_OK)
{
RAIL_UseDma(channel);
}
}
#elif defined(RAIL_DMA_CHANNEL) && (RAIL_DMA_CHANNEL != DMA_CHANNEL_INVALID)
LDMA_Init_t ldmaInit = LDMA_INIT_DEFAULT;
LDMA_Init(&ldmaInit);
RAIL_UseDma(RAIL_DMA_CHANNEL);
#endif
}
2 changes: 2 additions & 0 deletions scripts/examples/gn_efr32_example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ env
if [ -z "$3" ]; then
gn gen --check --fail-on-unused-args --root="$1" "$2"/"$EFR32_BOARD"/
ninja -v -C "$2"/"$EFR32_BOARD"/
arm-none-eabi-size -A "$2"/"$EFR32_BOARD"/*.out
else
gn gen --check --fail-on-unused-args --root="$1" --args="efr32_board=\"$3\"" "$2/$3"
ninja -v -C "$2/$3"
arm-none-eabi-size -A "$2"/"$3"/*.out
fi
2 changes: 1 addition & 1 deletion scripts/tests/cirque_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function __cirquetest_start_flask() {
echo 'Start Flask'
cd "$REPO_DIR"/third_party/cirque/repo
FLASK_APP='cirque/restservice/service.py' \
PATH="$PATH":"$REPO_DIR"/third_party/openthread/repo/output/x86_64-unknown-linux-gnu/bin/ \
PATH="$PATH":"$REPO_DIR"/third_party/openthread/repo/output/simulation/bin/ \
python3 -m flask run >"$LOG_DIR/$CURRENT_TEST/flask.log" 2>&1
}

Expand Down
2 changes: 2 additions & 0 deletions src/lwip/efr32/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@

#define LWIP_SOCKET 0

#define LWIP_FREERTOS_USE_STATIC_TCPIP_TASK 0

// TODO: seems like this is unnecessary on Thread-only platforms
#define LWIP_RAW 1
#define MEMP_NUM_RAW_PCB (5)
Expand Down
2 changes: 1 addition & 1 deletion src/lwip/freertos/sys_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ sys_thread_t sys_thread_new(const char * name, lwip_thread_fn thread, void * arg
return NULL;

#if LWIP_FREERTOS_USE_STATIC_TCPIP_TASK
taskH = xTaskCreateStatic(thread, name, stacksizeWords, arg, (UBaseType_t) prio, (StackType_t *) gTCPIPTaskStack, NULL);
taskH = xTaskCreateStatic(thread, name, stacksizeWords, arg, (UBaseType_t) prio, (StackType_t *) gTCPIPTaskStack, &gTCPIPTask);
#else // LWIP_FREERTOS_USE_STATIC_TCPIP_TASK
if (xTaskCreate(thread, name, stacksizeWords, arg, (UBaseType_t) prio, &taskH) != pdPASS)
taskH = NULL;
Expand Down
Loading