Skip to content

Commit

Permalink
[bouffalo lab] fix crash issues in route hook and rpc uart driver mod…
Browse files Browse the repository at this point in the history
…ules
  • Loading branch information
wy-hh committed Dec 30, 2024
1 parent 2249628 commit aa8eebf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/platform/bouffalolab/bl602/lwipopts/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ a lot of data that needs to be copied, this should be set high. */

/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One
per active UDP "connection". */
#define MEMP_NUM_UDP_PCB 8
#define MEMP_NUM_UDP_PCB 12

/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP
connections. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ int8_t bl_route_hook_init(void)
goto exit;
}

for (bl_route_hook_t * iter = s_hooks; iter != NULL; iter++)
for (bl_route_hook_t * iter = s_hooks; iter != NULL; iter = iter->next)
{
if (iter->netif == lwip_netif)
{
ret = 0;
break;
goto exit;
}
}

Expand All @@ -194,6 +194,11 @@ int8_t bl_route_hook_init(void)

hook->netif = lwip_netif;
hook->pcb = raw_new_ip_type(IPADDR_TYPE_V6, IP6_NEXTH_ICMP6);
if (NULL == hook->pcb) {
ret = -1;
goto exit;
}

hook->pcb->flags |= RAW_FLAGS_MULTICAST_LOOP;
hook->pcb->chksum_reqd = 1;
// The ICMPv6 header checksum offset
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/bouffalolab/common/rpc/pw_sys_io/sys_io.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ Status ReadByte(std::byte * dest)
return Status::InvalidArgument();

int16_t ret = uartRead(reinterpret_cast<char *>(dest), 1);
return ret <= 0 ? Status::FailedPrecondition() : OkStatus();
return ret < 0 ? Status::FailedPrecondition() : OkStatus();
}

Status WriteByte(std::byte b)
{
int16_t ret = uartWrite(reinterpret_cast<const char *>(&b), 1);

return ret <= 0 ? Status::FailedPrecondition() : OkStatus();
return ret < 0 ? Status::FailedPrecondition() : OkStatus();
}

// Writes a string using pw::sys_io, and add newline characters at the end.
Expand Down

0 comments on commit aa8eebf

Please sign in to comment.