Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
22a5f85
Initial work on wifi for the zephyr platform
MaartenS11 Jul 10, 2026
0dbe085
Disable display driver for now
MaartenS11 Dec 17, 2025
d867e71
Disable wifi credentials library
MaartenS11 Dec 17, 2025
491c94f
Optimize prj.conf
MaartenS11 Jul 10, 2026
0b57aea
Move wifi connection code into a wifi_connect primitive
MaartenS11 Jul 10, 2026
1042729
Add overlay for rpi_pico w
MaartenS11 Jul 10, 2026
3890b45
Try to make wifi connect a bit more stable + show list of networks in…
MaartenS11 Jul 10, 2026
0e9ffa9
Start writing a basic tcp client interface
MaartenS11 Jul 10, 2026
e65566f
Add tcp client primitives
MaartenS11 Jul 10, 2026
e522a5e
Add primitive to disconnect from the network
MaartenS11 Jul 10, 2026
e1577ff
Retry 5 times when creating a socket
MaartenS11 Jul 10, 2026
346d227
Scan only once instead of 3 times
MaartenS11 Jul 11, 2026
554f53b
Zero the other fields in wifi_connect_req_params
MaartenS11 Jul 11, 2026
2971b41
Add small delay to socket_close to ensure all messages have been sent…
MaartenS11 Jul 11, 2026
a4d5e58
Create server socket + accept primitives
MaartenS11 Jul 12, 2026
9568be3
Add socket_receive primitive
MaartenS11 Jul 12, 2026
cb56ef5
clang-format
MaartenS11 Jul 14, 2026
d9a767e
Add primitive to obtain the local ip address
MaartenS11 Jul 14, 2026
a0ebc1a
Re-enable display drivers
MaartenS11 Jul 14, 2026
794ebb2
Update rpi pico w overlay to match regular pico overlay
MaartenS11 Jul 14, 2026
fa6d24d
Minor changes removed socket retry since we don't really need it
MaartenS11 Jul 15, 2026
22288a9
Update GitHub action to include hal_espressif blobs
MaartenS11 Jul 15, 2026
6934e1b
Move socket code into a separate header file
MaartenS11 Jul 15, 2026
dea1745
Rename directory to Networking
MaartenS11 Jul 15, 2026
25c50b9
Add functional socket primitives to the emulator
MaartenS11 Jul 15, 2026
30c5f6c
Re-use some code from Utils/sockets for socket creation
MaartenS11 Jul 16, 2026
c5d509e
Add WARDUINO_NETWORKING to Kconfig to toggle on and off the networkin…
MaartenS11 Jul 16, 2026
f1c9692
Make wifi_localip have the same number of arguments and return values…
MaartenS11 Jul 16, 2026
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 .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ jobs:

cd zephyr
west sdk install
west blobs fetch hal_espressif

- name: Checkout repository
uses: actions/checkout@v6
Expand Down
41 changes: 39 additions & 2 deletions platforms/Zephyr/Kconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
source "samples/subsys/usb/common/Kconfig.sample_usbd"

source "Kconfig.zephyr"

menu "WARDuino"

config WARDUINO_NETWORKING
bool "Enable WARDuino networking primitives"
default y
select NETWORKING
select NET_MGMT
select NET_MGMT_EVENT
select NET_MGMT_EVENT_INFO
select WIFI
select NET_L2_WIFI_MGMT
select NET_IPV4
select NET_DHCPV4
select NET_SOCKETS
select NET_TCP
help
Enables all networking primitives supported by WARDuino.

if WARDUINO_NETWORKING

config NET_PKT_RX_COUNT
default 10

config NET_PKT_TX_COUNT
default 10

config NET_BUF_RX_COUNT
default 20

config NET_BUF_TX_COUNT
default 20

config NET_MAX_CONTEXTS
default 10

endif # WARDUINO_NETWORKING

endmenu
2 changes: 2 additions & 0 deletions platforms/Zephyr/boards/rpi_pico_rp2040_w.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CONFIG_ENTROPY_GENERATOR=n
CONFIG_TEST_RANDOM_GENERATOR=y
94 changes: 94 additions & 0 deletions platforms/Zephyr/boards/rpi_pico_rp2040_w.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#include <zephyr/dt-bindings/display/panel.h>

#include "../app.overlay"

/ {
chosen {
zephyr,console = &cdc_acm_uart0;
};
};

&zephyr_udc0 {
cdc_acm_uart0: cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};

/ {
zephyr,user {
warduino-gpios =
<&gpio0 0 0>,
<&gpio0 1 0>,
<&gpio0 2 0>,
<&gpio0 3 0>,
<&gpio0 4 0>,
<&gpio0 5 0>,
<&gpio0 6 0>,
<&gpio0 7 0>,
<&gpio0 8 0>,
<&gpio0 9 0>,
<&gpio0 10 0>,
<&gpio0 11 0>,
<&gpio0 12 0>,
<&gpio0 13 0>,
<&gpio0 14 0>,
<&gpio0 15 0>,
<&gpio0 16 0>,
<&gpio0 17 0>,
<&gpio0 18 0>,
<&gpio0 19 0>,
<&gpio0 20 0>,
<&gpio0 21 0>,
<&gpio0 22 0>,
<&gpio0 23 0>,
<&gpio0 24 0>,
<&gpio0 25 0>,
<&gpio0 26 0>,
<&gpio0 27 0>,
<&gpio0 28 0>,
<&gpio0 29 0>;

pwms = < &pwm 2 PWM_USEC(1500) PWM_POLARITY_NORMAL >;
pwm-names = "builtin-buzzer";
};
};

/ {
chosen {
zephyr,display = &ili9341;
};
mipi_dbi {
compatible = "zephyr,mipi-dbi-spi";
spi-dev = <&spi0>;
dc-gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
reset-gpios = <&gpio0 14 GPIO_ACTIVE_LOW>;
#address-cells = <1>;
#size-cells = <0>;
ili9341: ili9341@0 {
compatible = "ilitek,ili9341";
reg = <0>;
mipi-max-frequency = <20000000>;
mipi-mode = "MIPI_DBI_MODE_SPI_4WIRE";
width = <240>;
height = <320>;
pixel-format = <PANEL_PIXEL_FORMAT_RGB_565>;
rotation = <0>;
status = "okay";
h-mirror;
};
};
};

&pinctrl {
pwm_ch1a_default: pwm_ch1a_default {
group1 {
pinmux = <PWM_1A_P2>; // Channel 1 A, 1 * 1 + 1 = 2, &pwm 2 in pwms
};
};
};

&pwm {
status="okay";
divider-int-4 = <255>;
pinctrl-0 = < &pwm_ch1a_default >;
};
1 change: 0 additions & 1 deletion platforms/Zephyr/boards/stm32l496g_disco.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@
status = "okay";
st,adc-clock-source = "SYNC";
st,adc-prescaler = < 0x4 >;
resolutions = < 0x60630c 0x51630c 0x42630c 0x33630c >;
sampling-times = < 0x3 0x7 0xd 0x19 0x30 0x5d 0xf8 0x281 >;
st,adc-sequencer = "programmable";
st,adc-oversampler = "minimal";
Expand Down
2 changes: 1 addition & 1 deletion platforms/Zephyr/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,4 @@ int main(void) {
loaded_modules.clear();

return 0;
}
}
8 changes: 8 additions & 0 deletions platforms/Zephyr/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ CONFIG_SYS_HEAP_RUNTIME_STATS=y

CONFIG_USB_DEVICE_PRODUCT="WARDuino Microcontroller"
CONFIG_USB_DEVICE_MANUFACTURER="TOPLLab"

CONFIG_WARDUINO_NETWORKING=y

# Disable these options, they will stay disabled even when networking is enabled
CONFIG_NET_SHELL=n
CONFIG_NET_IPV6=n
CONFIG_WIFI_CREDENTIALS=n
CONFIG_LOG=n
88 changes: 88 additions & 0 deletions src/Primitives/Networking/sockets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#pragma once

#include <arpa/inet.h>
#include <unistd.h>

#include <cerrno>
#include <cstdio>
#include <cstring>
#include <ctime>

#include "../../Utils/sockets.h"

namespace sockets {
inline int socket_create(const char *ip, const int32_t port) {
printf("Create socket %s:%d\n", ip, port);
const int sock = createSocketFileDescriptor();
if (sock < 0) {
return -1;
}

sockaddr_in server_addr = {};
server_addr.sin_family = AF_INET;
server_addr.sin_port = htons(port);
server_addr.sin_addr.s_addr = inet_addr(ip);

if (connect(sock, reinterpret_cast<sockaddr *>(&server_addr),
sizeof(server_addr)) < 0) {
printf("Failed to connect %s\n", strerror(errno));
close(sock);
return -1;
}
printf("Connected to %s:%d\n", ip, port);
printf("sock = %d\n", sock);
return sock;
}

inline int socket_create_server(const int32_t port) {
const int sock = createSocketFileDescriptor();
if (sock < 0) {
return -1;
}
const sockaddr_in addr = createServerAddress(port);
if (bindSocketToAddress(sock, addr) < 0) {
return -1;
}
if (startListening(sock) < 0) {
return -1;
}

printf("Server listening on port %d (sock=%d)\n", port, sock);
return sock;
}

inline int socket_accept(const int socket) {
sockaddr_in client_addr = {};
socklen_t client_addr_len = sizeof(client_addr);
printf("Waiting for connection on sock=%d\n", socket);
const int client_sock = accept(
socket, reinterpret_cast<sockaddr *>(&client_addr), &client_addr_len);
if (client_sock < 0) {
printf("error: accept failed: %s\n", strerror(errno));
return -1;
}
printf("Client connected (client_sock=%d)\n", client_sock);
return client_sock;
}

inline int socket_send(const int socket, const char *message) {
printf("socket_send(%d, \"%s\" (len = %lu))\n", socket, message,
strlen(message));
return send(socket, message, strlen(message), 0);
}

inline int socket_receive(const int socket, char *buffer, const size_t size) {
printf("socket_receive(%d, 0x%p, %lu)\n", socket, buffer, size);
return recv(socket, buffer, size, 0);
}

inline int socket_close(int socket) {
printf("socket_close(%d)\n", socket);
// Wait a bit to make sure any sent messages in the buffer are still sent.
timespec ts = {};
ts.tv_sec = 0;
ts.tv_nsec = 500 * 1000000L;
nanosleep(&ts, nullptr);
return close(socket);
}
} // namespace sockets
Loading
Loading