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

[zephyr] Fixed defining thread stack for Matter thread #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions config/nrfconnect/app/sample-defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CONFIG_PRINTK_SYNC=y
CONFIG_ASSERT=y
CONFIG_HW_STACK_PROTECTION=y
CONFIG_SHELL=y
CONFIG_FPU=y

# Enable getting reboot reasons information
CONFIG_HWINFO=y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ void GenericPlatformManagerImpl_Zephyr<ImplClass>::EventLoopTaskMain(void * this
template <class ImplClass>
CHIP_ERROR GenericPlatformManagerImpl_Zephyr<ImplClass>::_StartEventLoopTask(void)
{
const auto tid = k_thread_create(&mChipThread, mChipThreadStack, K_THREAD_STACK_SIZEOF(mChipThreadStack), EventLoopTaskMain,
if (!mChipThreadStack)
return CHIP_ERROR_WELL_UNINITIALIZED;

const auto tid = k_thread_create(&mChipThread, mChipThreadStack, CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE, EventLoopTaskMain,
this, nullptr, nullptr, CHIP_DEVICE_CONFIG_CHIP_TASK_PRIORITY, 0, K_NO_WAIT);

#ifdef CONFIG_THREAD_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ template <class ImplClass>
class GenericPlatformManagerImpl_Zephyr : public GenericPlatformManagerImpl<ImplClass>
{
protected:
using ThreadStack = k_thread_stack_t[K_THREAD_STACK_LEN(CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE)];
using ThreadStack = k_thread_stack_t*;

// Members for select() loop
int mMaxFd;
Expand All @@ -65,7 +65,7 @@ class GenericPlatformManagerImpl_Zephyr : public GenericPlatformManagerImpl<Impl
// Although defining thread stack as a class member is feasible it's discouraged according to
// the Zephyr documentation (see remarks on K_THREAD_STACK_MEMBER macro). Therefore, this class
// requires the stack reference to be passed in the constructor.
ThreadStack & mChipThreadStack;
ThreadStack mChipThreadStack;
k_thread mChipThread;

// ===== Methods that implement the PlatformManager abstract interface.
Expand All @@ -82,7 +82,7 @@ class GenericPlatformManagerImpl_Zephyr : public GenericPlatformManagerImpl<Impl
CHIP_ERROR _Shutdown(void);

// ===== Methods available to the implementation subclass.
explicit GenericPlatformManagerImpl_Zephyr(ThreadStack & stack) : mChipThreadStack(stack) {}
explicit GenericPlatformManagerImpl_Zephyr(ThreadStack stack) : mChipThreadStack(stack) {}

private:
// ===== Private members for use by this class only.
Expand Down
2 changes: 1 addition & 1 deletion src/platform/Zephyr/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
System::Clock::Timestamp mStartTime = System::Clock::kZero;
uint32_t mSavedOperationalHoursSinceBoot = 0;

explicit PlatformManagerImpl(ThreadStack & stack) : Internal::GenericPlatformManagerImpl_Zephyr<PlatformManagerImpl>(stack) {}
explicit PlatformManagerImpl(ThreadStack stack) : Internal::GenericPlatformManagerImpl_Zephyr<PlatformManagerImpl>(stack) {}

static PlatformManagerImpl sInstance;
};
Expand Down