Skip to content

Commit

Permalink
When the Beken driver malloc spaces from MEM_HEAP TYPE,the device would
Browse files Browse the repository at this point in the history
be  corruption on commissioning.This modifcation will resovle the problem.

Change-Id: I8b37a4ea3a90e08d34a7cb6f37e56b76238d57d8
  • Loading branch information
fuxingguo16 authored and ThomasFang1012 committed Apr 20, 2022
1 parent c852287 commit 2cd61b0
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 3 deletions.
52 changes: 51 additions & 1 deletion examples/lighting-app/beken/main/chipinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ extern "C" void ApplyUpdateCmdHandler()

static_cast<OTARequestor *>(GetRequestorInstance())->ApplyUpdate();
}

extern "C" void NotifyUpdateAppliedHandler(uint32_t version)
{
ChipLogProgress(DeviceLayer, "NotifyUpdateApplied");

static_cast<OTARequestor *>(GetRequestorInstance())->NotifyUpdateApplied(version);
}

/*********************************************************************
* Funtion Name:BkQueryImageCmdHandler
*
Expand Down Expand Up @@ -157,7 +165,48 @@ extern "C" void BkQueryImageCmdHandler(char *pcWriteBuffer, int xWriteBufferLen,
extern "C" void BkApplyUpdateCmdHandler(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv )
{
ApplyUpdateCmdHandler();
ChipLogProgress(DeviceLayer,"ApplyUpdateCmdHandler send requst");
ChipLogProgress(DeviceLayer,"ApplyUpdateCmdHandler send request");

return ;
}

/*********************************************************************
* Funtion Name:BkNotifyUpdateApplied
*
* Funtion Discription:trigger ota requestor notify update applied to ota provider
*
*
* Date:2022-03-10
*******************************************************************/
extern "C" void BkNotifyUpdateApplied(char *pcWriteBuffer, int xWriteBufferLen, int argc, char **argv )
{
uint32_t dwLoop = 0;
uint32_t version = 0;

char cmd0 = 0;
char cmd1 = 0;

for(dwLoop = 0; dwLoop < argc; dwLoop++)
{
ChipLogProgress(DeviceLayer, "NotifyUpdateApplied %d = %s\r\n", dwLoop + 1, argv[dwLoop]);
}

if(argc == 2)
{
cmd0 = argv[1][0] - 0x30;
cmd1 = argv[1][1] - 0x30;
version = (uint32_t)(cmd0 * 10 + cmd1);

ChipLogProgress(DeviceLayer, "version %lu \r\n", version);
}
else
{
ChipLogProgress(DeviceLayer,"cmd param error ");
return ;
}

NotifyUpdateAppliedHandler( version);
ChipLogProgress(DeviceLayer,"NotifyUpdateApplied send request");

return ;
}
Expand All @@ -166,6 +215,7 @@ static void InitOTARequestor(void)
{
// Initialize and interconnect the Requestor and Image Processor objects -- START
SetRequestorInstance(&gRequestorCore);
ChipLogProgress(DeviceLayer,"InitOTARequestor gRequestorCore init");

// Set server instance used for session establishment
/* - Set server instance used to get access to the system resources necessary to open CASE sessions and drive
Expand Down
6 changes: 5 additions & 1 deletion src/inet/UDPEndPointImplLwIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,11 @@ struct netif * UDPEndPointImplLwIP::FindNetifFromInterfaceId(InterfaceId aInterf

IPPacketInfo * UDPEndPointImplLwIP::GetPacketInfo(const System::PacketBufferHandle & aBuffer)
{
if (!aBuffer->EnsureReservedSize(sizeof(IPPacketInfo) + 3))
//The original Matter codes
//if (!aBuffer->EnsureReservedSize(sizeof(IPPacketInfo) + 3))

//Modify by Beken CorPoration
if (!aBuffer->EnsureReservedSize(sizeof(IPPacketInfo)))
{
return nullptr;
}
Expand Down
18 changes: 17 additions & 1 deletion src/system/SystemPacketBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,27 @@ CHIP_ERROR PacketBuffer::Read(uint8_t * aDestination, size_t aReadLength) const
bool PacketBuffer::EnsureReservedSize(uint16_t aReservedSize)
{
const uint16_t kCurrentReservedSize = this->ReservedSize();
uint32_t dwReturn = 0;
uint32_t dwAllocsize = 0;

if (aReservedSize <= kCurrentReservedSize)
return true;
//The original Matter codes
//if ((aReservedSize + this->len) > this->AllocSize())

/*============= Modify by Beken Corporation============*/
/*========================START========================*/
dwReturn = pbuf_length_get (this, &dwAllocsize);
ChipLogError(chipSystemLayer, "The pbuf type is wrong");

if ((aReservedSize + this->len) > this->AllocSize())
if ((aReservedSize + this->len) > dwAllocsize)
{
ChipLogError(chipSystemLayer, "The pbuf space is not adequte");
return false;
}
/*============= Modify by Beken Corporation============*/
/*========================END========================*/


// Cast is safe because aReservedSize > kCurrentReservedSize.
const uint16_t kMoveLength = static_cast<uint16_t>(aReservedSize - kCurrentReservedSize);
Expand Down

0 comments on commit 2cd61b0

Please sign in to comment.