[continuous-integration] add SPI build check (#5165)
Enables NCP SPI in build checks. Also fixes some build errors in SPI code.
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index e80ec21..9c7e023 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -153,12 +153,32 @@
script/check-simulation-build
script/check-posix-build
+ clang:
+ name: clang-${{ matrix.clang_ver }}
+ runs-on: ubuntu-18.04
+ strategy:
+ matrix:
+ clang_ver: ["6.0", "7", "8", "9"]
+ env:
+ CC: clang-${{ matrix.clang_ver }}
+ CXX: clang++-${{ matrix.clang_ver }}
+ steps:
+ - uses: actions/checkout@v2
+ - name: Bootstrap
+ run: |
+ sudo apt-get update
+ sudo apt-get --no-install-recommends install -y clang-${{ matrix.clang_ver }} clang++-${{ matrix.clang_ver }} ninja-build libreadline-dev libncurses-dev
+ - name: Build
+ run: |
+ script/check-simulation-build
+ script/check-posix-build
+
clang-m32:
name: clang-m32-${{ matrix.clang_ver }}
runs-on: ubuntu-18.04
strategy:
matrix:
- clang_ver: [9]
+ clang_ver: ["6.0", "7", "8", "9"]
env:
CC: clang-${{ matrix.clang_ver }}
CXX: clang++-${{ matrix.clang_ver }}
@@ -175,6 +195,7 @@
sudo apt-get --no-install-recommends install -y libreadline-dev:i386 libncurses-dev:i386
- name: Build
run: |
+ script/check-simulation-build
script/check-posix-build
gn:
diff --git a/script/check-simulation-build-autotools b/script/check-simulation-build-autotools
index 84a1439..ed68111 100755
--- a/script/check-simulation-build-autotools
+++ b/script/check-simulation-build-autotools
@@ -72,6 +72,7 @@
"-DOPENTHREAD_CONFIG_MLE_ATTACH_BACKOFF_ENABLE=1"
"-DOPENTHREAD_CONFIG_MLE_STEERING_DATA_SET_OOB_ENABLE=1"
"-DOPENTHREAD_CONFIG_MPL_DYNAMIC_INTERVAL_ENABLE"
+ "-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1"
"-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
"-DOPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE=1"
"-DOPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE=1"
diff --git a/src/core/common/debug.hpp b/src/core/common/debug.hpp
index ba15fde..50dd2b2 100644
--- a/src/core/common/debug.hpp
+++ b/src/core/common/debug.hpp
@@ -71,7 +71,7 @@
} \
} while (0)
-#else
+#else // OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
#define OT_ASSERT(cond) \
do \
@@ -86,7 +86,7 @@
#endif // OPENTHREAD_CONFIG_PLATFORM_ASSERT_MANAGEMENT
-#else
+#else // OPENTHREAD_CONFIG_ASSERT_ENABLE
#define OT_ASSERT(cond)
diff --git a/src/ncp/ncp_spi.cpp b/src/ncp/ncp_spi.cpp
index b8a931b..f4dc788 100644
--- a/src/ncp/ncp_spi.cpp
+++ b/src/ncp/ncp_spi.cpp
@@ -35,6 +35,7 @@
#include <openthread/ncp.h>
#include <openthread/platform/misc.h>
#include <openthread/platform/spi-slave.h>
+#include <openthread/platform/toolchain.h>
#include "openthread-core-config.h"
#include "common/code_utils.hpp"
@@ -81,7 +82,7 @@
, mTxState(kTxStateIdle)
, mHandlingRxFrame(false)
, mResetFlag(true)
- , mPrepareTxFrameTask(*aInstance, &NcpSpi::PrepareTxFrame, this)
+ , mPrepareTxFrameTask(*aInstance, NcpSpi::PrepareTxFrame, this)
, mSendFrameLength(0)
{
SpiFrame sendFrame(mSendFrame);
@@ -102,14 +103,15 @@
mTxFrameBuffer.SetFrameAddedCallback(HandleFrameAddedToTxBuffer, this);
- otPlatSpiSlaveEnable(&NcpSpi::SpiTransactionComplete, &NcpSpi::SpiTransactionProcess, this);
+ IgnoreError(otPlatSpiSlaveEnable(&NcpSpi::SpiTransactionComplete, &NcpSpi::SpiTransactionProcess, this));
// We signal an interrupt on this first transaction to
// make sure that the host processor knows that our
// reset flag was set.
- otPlatSpiSlavePrepareTransaction(mEmptySendFrameZeroAccept, kSpiHeaderSize, mEmptyReceiveFrame, kSpiHeaderSize,
- /* aRequestTransactionFlag */ true);
+ IgnoreError(otPlatSpiSlavePrepareTransaction(mEmptySendFrameZeroAccept, kSpiHeaderSize, mEmptyReceiveFrame,
+ kSpiHeaderSize,
+ /* aRequestTransactionFlag */ true));
}
bool NcpSpi::SpiTransactionComplete(void * aContext,
@@ -217,7 +219,8 @@
sendFrame.SetHeaderAcceptLen(aInputLen - kSpiHeaderSize);
- otPlatSpiSlavePrepareTransaction(aOutputBuf, aOutputLen, aInputBuf, aInputLen, (mTxState == kTxStateSending));
+ IgnoreError(
+ otPlatSpiSlavePrepareTransaction(aOutputBuf, aOutputLen, aInputBuf, aInputLen, (mTxState == kTxStateSending)));
return shouldProcess;
}
@@ -278,6 +281,9 @@
readLength = mTxFrameBuffer.OutFrameRead(frameLength, sendFrame.GetData());
OT_ASSERT(readLength == frameLength);
+ // Suppress the warning when assertions are disabled
+ OT_UNUSED_VARIABLE(readLength);
+
sendFrame.SetHeaderDataLen(frameLength);
mSendFrameLength = frameLength + kSpiHeaderSize;
@@ -302,7 +308,7 @@
ExitNow();
}
- mTxFrameBuffer.OutFrameRemove();
+ IgnoreError(mTxFrameBuffer.OutFrameRemove());
exit:
return;
@@ -367,8 +373,9 @@
{
sendFrame.SetHeaderAcceptLen(kSpiBufferSize - kSpiHeaderSize);
- otPlatSpiSlavePrepareTransaction(mEmptySendFrameFullAccept, kSpiHeaderSize, mReceiveFrame, kSpiBufferSize,
- /* aRequestTrans */ false);
+ IgnoreError(otPlatSpiSlavePrepareTransaction(mEmptySendFrameFullAccept, kSpiHeaderSize, mReceiveFrame,
+ kSpiBufferSize,
+ /* aRequestTrans */ false));
// No need to check the error status. Getting `OT_ERROR_BUSY`
// is OK as everything will be set up properly from callback when