~aleteoryx/muditaos

783ebcbb6ca8b97a8c3153139eb15a21f4e6f956 — Lefucjusz 2 years ago b792bd7
[MOS-183] Fix RT1051 debug build

Fix of multiple issues that resulted
in debug build failing.
M CMakeLists.txt => CMakeLists.txt +2 -2
@@ 69,11 69,11 @@ if (${PROJECT_TARGET} STREQUAL "TARGET_Linux")
    set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
    set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb3 -DNDEBUG")
else()
    set(CMAKE_C_FLAGS_DEBUG "-ggdb3 -DDEBUG")
    set(CMAKE_C_FLAGS_DEBUG "-Og -ggdb3 -DDEBUG")
    set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
    set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -ggdb3 -DNDEBUG")

    set(CMAKE_CXX_FLAGS_DEBUG "-ggdb3 -DDEBUG")
    set(CMAKE_CXX_FLAGS_DEBUG "-Og -ggdb3 -DDEBUG")
    set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
    set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb3 -DNDEBUG")


M board/rt1051/CMakeLists.txt => board/rt1051/CMakeLists.txt +1 -1
@@ 8,7 8,7 @@ if (${MEMORY_LINKER_FILE_PATH} STREQUAL "")
    message(FATAL_ERROR "Linker RAM layout not provided")
endif()

set (CMAKE_EXE_LINKER_FLAGS "-nostdlib -Xlinker --gc-sections -Xlinker --sort-section=alignment -mcpu=cortex-m7 -mfpu=fpv5-sp-d16 -mfloat-abi=hard -mthumb -Xlinker -print-memory-usage -T ${LDSCRIPTSDIR}/libs.ld -T ${MEMORY_LINKER_FILE_PATH} -T ${LDSCRIPTSDIR}/sections.ld -nostartfiles" CACHE INTERNAL "")
set (CMAKE_EXE_LINKER_FLAGS "-nostdlib -Xlinker --gc-sections -Xlinker --sort-section=alignment -mcpu=cortex-m7 -mthumb -mfpu=fpv5-sp-d16 -mfloat-abi=hard -Xlinker -print-memory-usage -T ${LDSCRIPTSDIR}/libs.ld -T ${MEMORY_LINKER_FILE_PATH} -T ${LDSCRIPTSDIR}/sections.ld -nostartfiles" CACHE INTERNAL "")

if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_LESS 12))
    set(GCC_CXX_DIR_ITERATOR "newlib/gcc11/fs_dir.cc")

M board/rt1051/ldscripts/libs.ld => board/rt1051/ldscripts/libs.ld +9 -9
@@ 9,13 9,13 @@
 */

GROUP (
  "libgcc.a"
  "libc.a"
  "libstdc++.a"
  "libm.a"
  "libnosys.a"
  "crti.o"
  "crtn.o"
  "crtbegin.o"
  "crtend.o"
    "libstdc++.a"
    "libm.a"
    "libc.a"
    "libgcc.a"
    "libnosys.a"
    "crti.o"
    "crtn.o"
    "crtbegin.o"
    "crtend.o"
)

M module-apps/application-special-input/ApplicationSpecialInput.cpp => module-apps/application-special-input/ApplicationSpecialInput.cpp +2 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ApplicationSpecialInput.hpp"


@@ 9,7 9,7 @@ using namespace app;

namespace
{
    constexpr auto SpecialInputAppStackDepth = 512 * 5;
    constexpr auto SpecialInputAppStackDepth = 1024 * 3;
} // namespace

ApplicationSpecialInput::ApplicationSpecialInput(std::string name,

M module-bsp/board/rt1051/common/startup_mimxrt1052.cpp => module-bsp/board/rt1051/common/startup_mimxrt1052.cpp +5 -13
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

//*****************************************************************************


@@ 457,12 457,6 @@ extern "C"
#endif

#include "MIMXRT1051.h"
#include "macros.h"
#include <log/log.hpp>
#include <cinttypes>
#include <cstdlib>
#include <cstdint>
#include <string>

//*****************************************************************************
// The vector table.


@@ 666,16 660,18 @@ __attribute__((section(".after_vectors.init_data"))) void data_init(unsigned int
    unsigned int *pulDest = (unsigned int *)start;
    unsigned int *pulSrc  = (unsigned int *)romstart;
    unsigned int loop;
    for (loop = 0; loop < len; loop = loop + 4)
    for (loop = 0; loop < len; loop = loop + 4) {
        *pulDest++ = *pulSrc++;
    }
}

__attribute__((section(".after_vectors.init_bss"))) void bss_init(unsigned int start, unsigned int len)
{
    unsigned int *pulDest = (unsigned int *)start;
    unsigned int loop;
    for (loop = 0; loop < len; loop = loop + 4)
    for (loop = 0; loop < len; loop = loop + 4) {
        *pulDest++ = 0;
    }
}

//*****************************************************************************


@@ 692,9 688,6 @@ extern unsigned int __data_section_table_end;
extern unsigned int __bss_section_table;
extern unsigned int __bss_section_table_end;

__attribute__((section(".sdram"))) volatile unsigned int LoadAddr, ExeAddr, SectionLen;
__attribute__((section(".sdram"))) volatile unsigned int *SectionTableAddr;

//*****************************************************************************
// Reset entry point for your code.
// Sets up a simple runtime environment and initializes the C/C++


@@ 702,7 695,6 @@ __attribute__((section(".sdram"))) volatile unsigned int *SectionTableAddr;
//*****************************************************************************
__attribute__((section(".after_vectors.reset"))) void ResetISR(void)
{

    // Disable interrupts
    __asm volatile("cpsid i");


M module-gui/gui/widgets/status-bar/SignalStrengthBar.cpp => module-gui/gui/widgets/status-bar/SignalStrengthBar.cpp +3 -3
@@ 1,11 1,11 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "SignalStrengthBar.hpp"
#include "Style.hpp"
#include <string>
#include <Image.hpp>
#include <unordered_map>
#include <map>

namespace gui::status_bar
{


@@ 25,7 25,7 @@ namespace gui::status_bar
        constexpr auto signal3_roaming = "gsm_3_roaming";
        constexpr auto signal4_roaming = "gsm_4_roaming";

        using SignalMap = std::unordered_map<Store::RssiBar, std::string>;
        using SignalMap = std::map<Store::RssiBar, std::string>;

        const SignalMap signalMapHomeCon = {{Store::RssiBar::zero, signal0},
                                            {Store::RssiBar::one, signal1},

M module-services/service-appmgr/model/ApplicationManagerCommon.cpp => module-services/service-appmgr/model/ApplicationManagerCommon.cpp +1 -1
@@ 32,7 32,7 @@ namespace app::manager
{
    namespace
    {
        constexpr auto ApplicationManagerStackDepth = 1024 * 4;
        constexpr auto ApplicationManagerStackDepth = 1024 * 5;

        bool checkIfCloseableAction(const actions::Action action)
        {

M module-services/service-desktop/ServiceDesktop.cpp => module-services/service-desktop/ServiceDesktop.cpp +8 -9
@@ 2,7 2,6 @@
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <service-desktop/ServiceDesktop.hpp>
#include <service-desktop/WorkerDesktop.hpp>
#include <endpoints/EndpointFactory.hpp>
#include <endpoints/bluetooth/BluetoothMessagesHandler.hpp>
#include <service-appmgr/Constants.hpp>


@@ 13,7 12,7 @@
#include <service-db/agents/settings/SystemSettings.hpp>

ServiceDesktop::ServiceDesktop(const std::filesystem::path &mtpRootPath)
    : sys::Service(service::name::service_desktop, "", sdesktop::service_stack),
    : sys::Service(service::name::service_desktop, "", sdesktop::serviceStackSize),
      btMsgHandler(std::make_unique<sdesktop::bluetooth::BluetoothMessagesHandler>(this)),
      connectionActiveTimer{sys::TimerFactory::createSingleShotTimer(
          this,


@@ 152,19 151,19 @@ void ServiceDesktop::removeNotificationEntries(const std::vector<uint32_t> &uids

auto ServiceDesktop::generateDeviceUniqueId() -> void
{
    const auto deviceUniqueId = utils::generateRandomId(sdesktop::DeviceUniqueIdLength);
    const auto deviceUniqueId = utils::generateRandomId(sdesktop::deviceUniqueIdLength);
    LOG_SENSITIVE(LOGINFO, "Device unique id: %s", deviceUniqueId.c_str());
    setDeviceUniqueId(deviceUniqueId);
}

auto ServiceDesktop::getDeviceUniqueId() const -> std::string
{
    return settings->getValue(sdesktop::DeviceUniqueIdName);
    return settings->getValue(sdesktop::deviceUniqueIdName);
}

auto ServiceDesktop::setDeviceUniqueId(const std::string &token) -> void
{
    return settings->setValue(sdesktop::DeviceUniqueIdName, token);
    return settings->setValue(sdesktop::deviceUniqueIdName, token);
}

auto ServiceDesktop::usbWorkerInit() -> sys::ReturnCodes


@@ 185,10 184,10 @@ auto ServiceDesktop::usbWorkerInit() -> sys::ReturnCodes
                                                    mtpRootPath);

    initialized = desktopWorker->init(
        {{sdesktop::RECEIVE_QUEUE_BUFFER_NAME, sizeof(std::string *), sdesktop::cdcReceiveQueueLength},
         {sdesktop::SEND_QUEUE_BUFFER_NAME, sizeof(std::string *), sdesktop::cdcSendQueueLength},
         {sdesktop::IRQ_QUEUE_BUFFER_NAME, sdesktop::irqQueueSize, sdesktop::irqQueueLength},
         {sdesktop::SIGNALLING_QUEUE_BUFFER_NAME, sizeof(WorkerDesktop::Signal), sdesktop::signallingQueueLength}});
        {{sdesktop::cdcReceiveQueueName, sdesktop::cdcReceiveQueueItemSize, sdesktop::cdcReceiveQueueLength},
         {sdesktop::cdcSendQueueName, sdesktop::cdcSendQueueItemSize, sdesktop::cdcSendQueueLength},
         {sdesktop::irqQueueName, sdesktop::irqQueueItemSize, sdesktop::irqQueueLength},
         {sdesktop::signallingQueueName, sdesktop::signallingQueueItemSize, sdesktop::signallingQueueLength}});

    if (!initialized) {
        LOG_FATAL("Failed to initialize USB worker, ServiceDesktop won't work!");

M module-services/service-desktop/WorkerDesktop.cpp => module-services/service-desktop/WorkerDesktop.cpp +44 -36
@@ 23,8 23,8 @@ WorkerDesktop::WorkerDesktop(sys::Service *ownerServicePtr,
                             const std::string &serialNumber,
                             const std::string &caseColour,
                             const std::string &rootPath)
    : sys::Worker(ownerServicePtr, sdesktop::worker_stack), securityModel(securityModel), serialNumber(serialNumber),
      caseColour(caseColour), rootPath{rootPath}, ownerService(ownerServicePtr), parser(ownerServicePtr),
    : sys::Worker(ownerServicePtr, sdesktop::workerStackSize), securityModel(securityModel), serialNumber(serialNumber),
      caseColour(caseColour), rootPath(rootPath), ownerService(ownerServicePtr), parser(ownerServicePtr),
      messageProcessedCallback(std::move(messageProcessedCallback))
{}



@@ 36,13 36,13 @@ bool WorkerDesktop::init(std::list<sys::WorkerQueueInfo> queues)

    Worker::init(queues);

    irqQueue     = Worker::getQueueHandleByName(sdesktop::IRQ_QUEUE_BUFFER_NAME);
    receiveQueue = Worker::getQueueHandleByName(sdesktop::RECEIVE_QUEUE_BUFFER_NAME);
    sdesktop::endpoints::sender::setSendQueueHandle(Worker::getQueueHandleByName(sdesktop::SEND_QUEUE_BUFFER_NAME));
    irqQueue     = Worker::getQueueHandleByName(sdesktop::irqQueueName);
    receiveQueue = Worker::getQueueHandleByName(sdesktop::cdcReceiveQueueName);
    sdesktop::endpoints::sender::setSendQueueHandle(Worker::getQueueHandleByName(sdesktop::cdcSendQueueName));

    cpuSentinel                  = std::make_shared<sys::CpuSentinel>("WorkerDesktop", ownerService);
    auto sentinelRegistrationMsg = std::make_shared<sys::SentinelRegistrationMessage>(cpuSentinel);
    ownerService->bus.sendUnicast(sentinelRegistrationMsg, service::name::system_manager);
    ownerService->bus.sendUnicast(std::move(sentinelRegistrationMsg), service::name::system_manager);

    const bsp::usbInitParams initParams = {receiveQueue,
                                           irqQueue,


@@ 93,7 93,6 @@ void WorkerDesktop::closeWorker(void)
void WorkerDesktop::reset()
{
    initialized = false;
    usbStatus   = bsp::USBDeviceStatus::Disconnected;
    bsp::usbDeinit();

    const bsp::usbInitParams initParams = {receiveQueue,


@@ 106,7 105,6 @@ void WorkerDesktop::reset()
    initialized = bsp::usbInit(initParams) == 0;

    if (initialized) {
        usbStatus = bsp::USBDeviceStatus::Connected;
        ownerService->bus.sendMulticast(std::make_shared<sdesktop::usb::USBConnected>(),
                                        sys::BusChannel::USBNotifications);
    }


@@ 114,8 112,8 @@ void WorkerDesktop::reset()

void WorkerDesktop::notify(Signal command)
{
    if (auto queue = getQueueByName(sdesktop::SIGNALLING_QUEUE_BUFFER_NAME); !queue->Overwrite(&command)) {
        LOG_ERROR("Unable to overwrite the command in the commands queue.");
    if (auto queue = getQueueByName(sdesktop::signallingQueueName); !queue->Overwrite(&command)) {
        LOG_ERROR("Unable to overwrite the command in the commands queue '%s'.", sdesktop::signallingQueueName);
    }
}



@@ 124,23 122,24 @@ bool WorkerDesktop::handleMessage(std::uint32_t queueID)
    bool result       = false;
    auto &queue       = queues[queueID];
    const auto &qname = queue->GetQueueName();
    if (qname == sdesktop::RECEIVE_QUEUE_BUFFER_NAME) {

    if (qname == sdesktop::cdcReceiveQueueName) {
        result = handleReceiveQueueMessage(queue);
    }
    else if (qname == sdesktop::SEND_QUEUE_BUFFER_NAME) {
    else if (qname == sdesktop::cdcSendQueueName) {
        result = handleSendQueueMessage(queue);
    }
    else if (qname == SERVICE_QUEUE_NAME) {
        result = handleServiceQueueMessage(queue);
    }
    else if (qname == sdesktop::IRQ_QUEUE_BUFFER_NAME) {
    else if (qname == sdesktop::irqQueueName) {
        result = handleIrqQueueMessage(queue);
    }
    else if (qname == sdesktop::SIGNALLING_QUEUE_BUFFER_NAME) {
    else if (qname == sdesktop::signallingQueueName) {
        result = handleSignallingQueueMessage(queue);
    }
    else {
        LOG_INFO("handeMessage got message on an unhandled queue");
        LOG_INFO("handleMessage got message on an unhandled queue '%s'!", qname.c_str());
    }

    return result;


@@ 153,7 152,7 @@ bool WorkerDesktop::handleReceiveQueueMessage(std::shared_ptr<sys::WorkerQueue> 
    }
    std::string *receivedMsg = nullptr;
    if (!queue->Dequeue(&receivedMsg, 0)) {
        LOG_ERROR("handleMessage failed to receive from \"%s\"", sdesktop::RECEIVE_QUEUE_BUFFER_NAME);
        LOG_ERROR("handleMessage xQueueReceive failed for '%s'.", sdesktop::cdcReceiveQueueName);
        return false;
    }



@@ 174,7 173,7 @@ bool WorkerDesktop::handleSendQueueMessage(std::shared_ptr<sys::WorkerQueue> &qu
    }
    std::string *sendMsg = nullptr;
    if (!queue->Dequeue(&sendMsg, 0)) {
        LOG_ERROR("handleMessage xQueueReceive failed for %s.", sdesktop::SEND_QUEUE_BUFFER_NAME);
        LOG_ERROR("handleMessage xQueueReceive failed for '%s'.", sdesktop::cdcSendQueueName);
        return false;
    }



@@ 192,8 191,8 @@ bool WorkerDesktop::handleServiceQueueMessage(std::shared_ptr<sys::WorkerQueue> 
        return false;
    }
    auto &serviceQueue = getServiceQueue();
    sys::WorkerCommand cmd;

    sys::WorkerCommand cmd;
    if (serviceQueue.Dequeue(&cmd, 0)) {
        LOG_DEBUG("Received cmd: %d", static_cast<int>(cmd.command));
#if defined(DEBUG)


@@ 201,7 200,7 @@ bool WorkerDesktop::handleServiceQueueMessage(std::shared_ptr<sys::WorkerQueue> 
#endif
    }
    else {
        LOG_ERROR("handleMessage xQueueReceive failed for %s.", SERVICE_QUEUE_NAME.c_str());
        LOG_ERROR("handleMessage xQueueReceive failed for '%s'.", SERVICE_QUEUE_NAME.c_str());
        return false;
    }
    return true;


@@ 210,34 209,42 @@ bool WorkerDesktop::handleIrqQueueMessage(std::shared_ptr<sys::WorkerQueue> &que
{
    bsp::USBDeviceStatus notification = bsp::USBDeviceStatus::Disconnected;
    if (!queue->Dequeue(&notification, 0)) {
        LOG_ERROR("handleMessage xQueueReceive failed for %s.", sdesktop::IRQ_QUEUE_BUFFER_NAME);
        LOG_ERROR("handleMessage xQueueReceive failed for %s.", sdesktop::irqQueueName);
        return false;
    }

    if (notification == bsp::USBDeviceStatus::Connected) {
    switch (notification) {
    case bsp::USBDeviceStatus::Connected:
        LOG_DEBUG("USB status: Connected");
        ownerService->bus.sendMulticast(std::make_shared<sdesktop::usb::USBConnected>(),
                                        sys::BusChannel::USBNotifications);
        usbStatus = bsp::USBDeviceStatus::Connected;
    }
    else if (notification == bsp::USBDeviceStatus::Configured) {
        break;

    case bsp::USBDeviceStatus::Configured:
        LOG_DEBUG("USB status: Configured");
        ownerService->bus.sendMulticast(std::make_shared<sdesktop::usb::USBConfigured>(),
                                        sys::BusChannel::USBNotifications);
        usbStatus = bsp::USBDeviceStatus::Configured;
    }
    else if (notification == bsp::USBDeviceStatus::Disconnected) {
        break;

    case bsp::USBDeviceStatus::Disconnected:
        LOG_DEBUG("USB status: Disconnected");
        ownerService->bus.sendMulticast(std::make_shared<sdesktop::usb::USBDisconnected>(),
                                        sys::BusChannel::USBNotifications);
        usbStatus = bsp::USBDeviceStatus::Disconnected;
    }
    else if (notification == bsp::USBDeviceStatus::DataReceived) {
        break;

    case bsp::USBDeviceStatus::DataReceived:
        bsp::usbHandleDataReceived();
    }
    else if (notification == bsp::USBDeviceStatus::Reset) {
        break;

    case bsp::USBDeviceStatus::Reset:
        LOG_DEBUG("USB status: Reset");
        break;

    default:
        LOG_ERROR("Notification not valid.");
        return false;
    }

    return true;
}



@@ 246,13 253,14 @@ bool WorkerDesktop::handleSignallingQueueMessage(std::shared_ptr<sys::WorkerQueu
    if (!initialized) {
        return false;
    }
    sys::WorkerCommand command;
    if (!queue->Dequeue(&command, 0)) {
        LOG_ERROR("handleMessage failed to receive from \"%s\"", sdesktop::SIGNALLING_QUEUE_BUFFER_NAME);

    sys::WorkerCommand cmd;
    if (!queue->Dequeue(&cmd, 0)) {
        LOG_ERROR("handleMessage xQueueReceive failed for '%s'.", sdesktop::signallingQueueName);
        return false;
    }

    switch (static_cast<Signal>(command.command)) {
    switch (static_cast<Signal>(cmd.command)) {
    case Signal::unlockMTP:
        bsp::usbUnlockMTP();
        break;

M module-services/service-desktop/WorkerDesktop.hpp => module-services/service-desktop/WorkerDesktop.hpp +1 -7
@@ 7,7 7,7 @@
#include <Service/Service.hpp>
#include <Service/Worker.hpp>
#include <SystemManager/CpuSentinel.hpp>
#include <ParserFSM.hpp>
#include <service-desktop/parser/ParserFSM.hpp>
#include <bsp/usb/usb.hpp>
#include <service-desktop/USBSecurityModel.hpp>



@@ 37,11 37,6 @@ class WorkerDesktop : public sys::Worker
    bool handleMessage(std::uint32_t queueID) override final;
    void notify(Signal command);

    xQueueHandle getReceiveQueue()
    {
        return receiveQueue;
    }

  private:
    void reset();



@@ 61,7 56,6 @@ class WorkerDesktop : public sys::Worker
    std::string rootPath;
    sys::Service *ownerService = nullptr;
    sdesktop::endpoints::StateMachine parser;
    bsp::USBDeviceStatus usbStatus = bsp::USBDeviceStatus::Disconnected;

    std::shared_ptr<sys::CpuSentinel> cpuSentinel;
    std::function<void()> messageProcessedCallback;

M module-services/service-desktop/include/service-desktop/ServiceDesktop.hpp => module-services/service-desktop/include/service-desktop/ServiceDesktop.hpp +27 -17
@@ 16,34 16,44 @@
#include <service-desktop/Sync.hpp>
#include <service-desktop/OutboxNotifications.hpp>
#include <service-evtmgr/BatteryMessages.hpp>
#include <service-desktop/WorkerDesktop.hpp>

namespace settings
{
    class Settings;
}

class WorkerDesktop;

namespace sdesktop
{
    inline constexpr auto service_stack                = 8192;
    inline constexpr auto worker_stack                 = 8704;
    using namespace std::chrono_literals;

    inline constexpr auto serviceStackSize = 1024 * 8;
    inline constexpr auto workerStackSize  = 1024 * 9;

    inline constexpr auto cdcReceiveQueueName          = "cdcReceiveQueueBuffer";
    inline constexpr auto cdcReceiveQueueItemSize      = sizeof(std::string *);
    inline constexpr auto cdcReceiveQueueLength        = 1024;

    inline constexpr auto cdcSendQueueName             = "cdcSendQueueBuffer";
    inline constexpr auto cdcSendQueueItemSize         = sizeof(std::string *);
    inline constexpr auto cdcSendQueueLength           = 1024;
    inline constexpr auto signallingQueueLength        = 4;
    inline constexpr auto irqQueueLength               = 4;
    inline constexpr auto irqQueueSize                 = sizeof(bsp::USBDeviceStatus);
    constexpr auto connectionActiveTimerName           = "connectionActiveTimer";
    constexpr auto connectionActiveTimerDelayMs        = std::chrono::milliseconds{1000 * 20};
    inline constexpr auto RECEIVE_QUEUE_BUFFER_NAME    = "receiveQueueBuffer";
    inline constexpr auto SEND_QUEUE_BUFFER_NAME       = "sendQueueBuffer";
    inline constexpr auto IRQ_QUEUE_BUFFER_NAME        = "irqQueueBuffer";
    inline constexpr auto SIGNALLING_QUEUE_BUFFER_NAME = "signallingQueueBuffer";
    inline constexpr auto DeviceUniqueIdLength         = 32;
    inline constexpr auto DeviceUniqueIdName           = "sd_device_unique_id";
    constexpr auto pathFactoryDataSerial               = "factory_data/serial";
    constexpr auto pathFactoryDataCaseColour           = "factory_data/case_colour";

    inline constexpr auto irqQueueName     = "irqQueueBuffer";
    inline constexpr auto irqQueueItemSize = sizeof(bsp::USBDeviceStatus);
    inline constexpr auto irqQueueLength   = 1;

    inline constexpr auto signallingQueueName     = "signallingQueueBuffer";
    inline constexpr auto signallingQueueItemSize = sizeof(WorkerDesktop::Signal);
    inline constexpr auto signallingQueueLength   = 1;

    inline constexpr auto connectionActiveTimerName    = "connectionActiveTimer";
    inline constexpr auto connectionActiveTimerDelayMs = 20s;

    inline constexpr auto deviceUniqueIdName   = "sd_device_unique_id";
    inline constexpr auto deviceUniqueIdLength = 32;

    inline constexpr auto pathFactoryDataSerial     = "factory_data/serial";
    inline constexpr auto pathFactoryDataCaseColour = "factory_data/case_colour";
}; // namespace sdesktop

namespace sdesktop::bluetooth

M module-sys/Service/Worker.cpp => module-sys/Service/Worker.cpp +9 -14
@@ 14,7 14,7 @@

namespace sys
{
    unsigned int Worker::count = 0;
    std::uint32_t Worker::count = 0;

    void Worker::taskAdapter(void *taskParam)
    {


@@ 31,15 31,13 @@ namespace sys
        assert(receivedMessage < controlMessagesCount);

        switch (static_cast<Worker::ControlMessage>(receivedMessage)) {
        // stop the thread
        case ControlMessage::Stop: {
        case ControlMessage::Stop: // stop the thread
            setState(State::Stopping);
        } break;
            break;

        default: {
        default:
            LOG_FATAL("Unexpected control message %d received", receivedMessage);
            return false;
        } break;
        }

        return true;


@@ 60,7 58,7 @@ namespace sys
            }

            // find id of the queue that was activated
            for (uint32_t i = 0; i < queues.size(); i++) {
            for (std::uint32_t i = 0; i < queues.size(); i++) {
                if (queues[i]->GetQueueHandle() == activeMember) {
                    handleMessage(i);
                }


@@ 159,7 157,7 @@ namespace sys
        };

        // iterate over all user queues and add them to set
        for (uint32_t i = 0; i < queues.size(); ++i) {
        for (std::uint32_t i = 0; i < queues.size(); ++i) {
            if (xQueueAddToSet(queues[i]->GetQueueHandle(), queueSet) != pdPASS) {
                state = State::Invalid;
                deinit();


@@ 189,7 187,7 @@ namespace sys
        queues.clear();

        // delete queues set
        vQueueDelete((QueueHandle_t)queueSet);
        vQueueDelete(static_cast<QueueHandle_t>(queueSet));

        vSemaphoreDelete(joinSemaphore);
        vSemaphoreDelete(stateMutex);


@@ 235,15 233,12 @@ namespace sys
        return getServiceQueue().Enqueue(&command);
    }

    bool Worker::send(uint32_t cmd, uint32_t *data)
    bool Worker::send(std::uint32_t cmd, std::uint32_t *data)
    {
        assert(getState() == State::Running);

        WorkerCommand workerCommand{cmd, data};
        if (getServiceQueue().Enqueue(&workerCommand, portMAX_DELAY)) {
            return true;
        }
        return false;
        return getServiceQueue().Enqueue(&workerCommand, portMAX_DELAY);
    }

    xQueueHandle Worker::getQueueHandleByName(const std::string &qname) const

M module-sys/Service/include/Service/Worker.hpp => module-sys/Service/include/Service/Worker.hpp +12 -13
@@ 13,7 13,6 @@

namespace sys
{

    class WorkerQueueInfo
    {
      public:


@@ 48,8 47,8 @@ namespace sys

    struct WorkerCommand
    {
        uint32_t command = 0;
        uint32_t *data   = NULL;
        std::uint32_t command = 0;
        std::uint32_t *data   = nullptr;
    };

    /*


@@ 98,8 97,8 @@ namespace sys
        std::string getControlQueueName() const;
        size_t addQueue(const std::string &queueName, UBaseType_t maxItems, UBaseType_t itemSize);

        std::optional<size_t> controlQueueIndex;
        std::optional<size_t> serviceQueueIndex;
        std::optional<std::size_t> controlQueueIndex;
        std::optional<std::size_t> serviceQueueIndex;
        WorkerQueue &getControlQueue() const;

        static constexpr std::size_t controlMessagesCount = static_cast<std::size_t>(ControlMessage::MessageCount);


@@ 116,7 115,7 @@ namespace sys
        State state = State::New;

      protected:
        virtual bool handleMessage(uint32_t queueID) = 0;
        virtual bool handleMessage(std::uint32_t queueID) = 0;

        WorkerQueue &getServiceQueue() const;



@@ 127,12 126,12 @@ namespace sys
        bool sendCommand(WorkerCommand command);
        State getState() const;

        const static uint32_t SERVICE_QUEUE_LENGTH = 10;
        const static uint32_t CONTROL_QUEUE_LENGTH = 4;
        const static uint32_t SERVICE_QUEUE_SIZE   = sizeof(WorkerCommand);
        static constexpr std::uint32_t SERVICE_QUEUE_LENGTH = 10;
        static constexpr std::uint32_t CONTROL_QUEUE_LENGTH = 4;
        static constexpr std::uint32_t SERVICE_QUEUE_SIZE   = sizeof(WorkerCommand);
        const std::string SERVICE_QUEUE_NAME       = "ServiceQueue";

        static unsigned int count;
        static std::uint32_t count;
        const UBaseType_t priority;
        std::uint16_t stackDepth = defaultStackSize;



@@ 140,8 139,8 @@ namespace sys
        std::vector<std::shared_ptr<WorkerQueue>> queues;

      public:
        Worker(sys::Service *service, std::uint16_t stackDepth = defaultStackSize);
        Worker(std::string workerNamePrefix, const UBaseType_t priority, std::uint16_t stackDepth = defaultStackSize);
        explicit Worker(sys::Service *service, std::uint16_t stackDepth = defaultStackSize);
        Worker(std::string workerNamePrefix, UBaseType_t priority, std::uint16_t stackDepth = defaultStackSize);

        virtual ~Worker();



@@ 172,7 171,7 @@ namespace sys
        /**
         * @brief Sends command and pointer to data to worker
         */
        virtual bool send(uint32_t cmd, uint32_t *data);
        virtual bool send(std::uint32_t cmd, std::uint32_t *data);
        /**
         * @brief Closes worker by combining stop, join and deinit operations in a single call.
         * If it is not possible to close the worker gently it would kill it forcibly.

M module-utils/EventStore/EventStore.hpp => module-utils/EventStore/EventStore.hpp +1 -1
@@ 64,7 64,7 @@ namespace Store
        two   = 2,
        three = 3,
        four  = 4,
        noOfSupprtedBars
        noOfSupportedBars
    };

    struct SignalStrength

M products/BellHybrid/services/evtmgr/EventManager.cpp => products/BellHybrid/services/evtmgr/EventManager.cpp +8 -6
@@ 94,9 94,12 @@ void EventManager::initProductEvents()

    connect(typeid(sevm::ScreenLightControlMessage), [&](sys::Message *msgl) {
        auto *m           = static_cast<sevm::ScreenLightControlMessage *>(msgl);
        const auto params = m->getParams();
        backlightHandler.processRequest(
            m->getAction(), params.value_or(screen_light_control::Parameters()), m->getSender());
        const auto receivedParams = m->getParams();

        /* Required to avoid false positive maybe-uninitialized on value_or due to GCC bug */
        const auto params = receivedParams.has_value() ? receivedParams.value() : screen_light_control::Parameters();
        backlightHandler.processRequest(m->getAction(), params, m->getSender());

        return sys::msgHandled();
    });



@@ 125,13 128,13 @@ void EventManager::initProductEvents()
    });

    connect(sevm::ScreenLightControlRequestParameters(), [&](sys::Message *msgl) {
        screen_light_control::ManualModeParameters params = {backlightHandler.getScreenBrightnessValue()};
        const screen_light_control::ManualModeParameters params = {backlightHandler.getScreenBrightnessValue()};
        auto msg = std::make_shared<sevm::ScreenLightControlParametersResponse>(
            backlightHandler.getScreenLightState(), backlightHandler.getScreenAutoModeState(), params);
        return msg;
    });

    connect(sevm::LatchStatusRequest(), [&](sys::Message *msgl) {
    connect(sevm::LatchStatusRequest(), [&]([[maybe_unused]] sys::Message *msgl) {
        auto msg = std::make_shared<sevm::LatchStatusResponse>(latchStatus);
        return msg;
    });


@@ 139,7 142,6 @@ void EventManager::initProductEvents()

sys::MessagePointer EventManager::DataReceivedHandler(sys::DataMessage *msgl, sys::ResponseMessage *resp)
{

    auto responseMessage =
        std::static_pointer_cast<sys::ResponseMessage>(EventManagerCommon::DataReceivedHandler(msgl, resp));


M third-party/libical/CMakeLists.txt => third-party/libical/CMakeLists.txt +3 -0
@@ 10,4 10,7 @@ include(libical/cmake/modules/LibIcalMacrosInternal.cmake)
libical_add_cflag(-Wno-format-truncation NO_FORMAT_TRUNCATION)
libical_add_cflag(-Wno-stringop-truncation NO_STRINGOP_TRUNCATION)

# Turn off false positive errors for debug build.
libical_add_cflag(-Wno-maybe-uninitialized NO_MAYBE_UNINITIALIZED)

add_subdirectory(libical)