Skip to content

Commit

Permalink
samples: add support for esp32s3 on the ping pong sample
Browse files Browse the repository at this point in the history
Signed-off-by: Felipe Neves <[email protected]>
  • Loading branch information
uLipe committed Nov 4, 2024
1 parent 9d9dec9 commit 7561d53
Show file tree
Hide file tree
Showing 8 changed files with 3,426 additions and 4 deletions.
8 changes: 8 additions & 0 deletions samples/ping-pong/rx/boards/esp32s3_devkitm_appcpu.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CONFIG_IPM=y
CONFIG_MAIN_STACK_SIZE=2048

CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y
CONFIG_GPIO=y
CONFIG_CLOCK_CONTROL=y
60 changes: 60 additions & 0 deletions samples/ping-pong/rx/boards/esp32s3_devkitm_appcpu.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2024 Felipe Neves
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,console = &uart1;
zephyr,shell-uart = &uart1;
};

aliases {
led0 = &red_led_0;
};

leds {
compatible = "gpio-leds";
red_led_0: led_0 {
gpios = <&gpio0 8 GPIO_ACTIVE_HIGH>;
label = "User LD0";
};
};
};

&shm0 {
#address-cells = <1>;
#size-cells = <0>;

zipm_pool: zipm_pool@3fcbd400 {
compatible = "zipm,node-pool";
block-size = <32>;
nodes-quantity = <32>;
reg = <0x3fcbd400>;
};

zipm_doorbell_queue: zipm_doorbell_queue@3fcbd800 {
compatible = "zipm,shared-queue";
reg = <0x3fcbd800>;
};

zipm_rx_queue: zipm_rx_queue@3fcbdc00 {
compatible = "zipm,shared-queue";
reg = <0x3fcbdc00>;
};

zipm_device0: zipm_device {
compatible = "zipm,message-device";
status = "okay";
node-pool = <&zipm_pool>;
shared-queues = <&zipm_doorbell_queue &zipm_rx_queue>;
ipc = <&mbox0>;
tx-id = <0>;
rx-id = <1>;
should-init;
};
};

&mbox0 {
status = "okay";
};
2 changes: 1 addition & 1 deletion samples/ping-pong/rx/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0), gpios);
static const struct device *handle = DEVICE_DT_GET(DT_NODELABEL(zipm_device0));
static struct zipm_callback callback;
static struct zipm_callback callback;
static const char msg[] = {"Hello from other side! Aka secondary core! \0"};
static char rx_msg[64] = {0};
const int doorbell_queue = 0;
Expand Down
3 changes: 3 additions & 0 deletions samples/ping-pong/tx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(zipm_tx)

target_sources(app PRIVATE src/main.c)

# Temporary solution for esp32 variants until its AMP gets fixed on zephyr tree:
zephyr_sources_ifdef(CONFIG_BOARD_ESP32S3_DEVKITM_ESP32S3_PROCPU src/zephyr.c)
4 changes: 4 additions & 0 deletions samples/ping-pong/tx/boards/esp32s3_devkitm_procpu.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_IPM=n
CONFIG_SHELL=y
CONFIG_PRINTK=y
CONFIG_LOG=y
56 changes: 56 additions & 0 deletions samples/ping-pong/tx/boards/esp32s3_devkitm_procpu.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2024 Felipe Neves
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
aliases {
led0 = &red_led_0;
};

leds {
compatible = "gpio-leds";
red_led_0: led_0 {
gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
label = "User LD0";
};
};
};

&shm0 {
#address-cells = <1>;
#size-cells = <0>;

zipm_pool: zipm_pool@3fcbd400 {
compatible = "zipm,node-pool";
block-size = <32>;
nodes-quantity = <32>;
reg = <0x3fcbd400>;
};

zipm_doorbell_queue: zipm_doorbell_queue@3fcbd800 {
compatible = "zipm,shared-queue";
reg = <0x3fcbd800>;
};

zipm_rx_queue: zipm_rx_queue@3fcbdc00 {
compatible = "zipm,shared-queue";
reg = <0x3fcbdc00>;
};

zipm_device0: zipm_device {
compatible = "zipm,message-device";
status = "okay";
node-pool = <&zipm_pool>;
shared-queues = <&zipm_doorbell_queue &zipm_rx_queue>;
ipc = <&mbox0>;
tx-id = <1>;
rx-id = <0>;
should-init;
};
};

&mbox0 {
status = "okay";
};
6 changes: 3 additions & 3 deletions samples/ping-pong/tx/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void zipm_event_callback(const struct device *dev, int sq, void *user_dat
if(ret > 0) {
copied += block_size;
}
}while(ret != 0);
}while(ret != 0);
printk("%lld: Other core said: %s \n", k_uptime_get(), (const char *)rx_msg);
}
}
Expand All @@ -47,9 +47,9 @@ int main(void)
}

gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE);

while(1) {
k_msleep(500);
k_msleep(500);
zipm_send(handle, &tx_msg, sizeof(tx_msg), doorbell_queue, 0);
}

Expand Down
3,291 changes: 3,291 additions & 0 deletions samples/ping-pong/tx/src/zephyr.c

Large diffs are not rendered by default.

0 comments on commit 7561d53

Please sign in to comment.