Skip to content

Commit 37d10a5

Browse files
committed
ref_app runs with second blinky on core1
1 parent 3926b05 commit 37d10a5

17 files changed

Lines changed: 100 additions & 201563 deletions

File tree

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ The reference application supports the following targets (in alpha-numeric order
9696
| `wch_ch32v307` | WCH CH32v307 RISC-V board | |
9797
| `wch_ch32v307_llvm` | WCH CH32v307 RISC-V board (but using an LLVM toolchain) | |
9898
| `x86_64-w64-mingw32` | PC on `Win*`/`mingw64` via GNU/GCC x86_x64 compiler | |
99+
| `xtensa_esp32_p4` | Espressif (XTENSA) ESP32-P4 multicore RISC-V SoC | X |
99100
| `xtensa_esp32_s3` | Espressif (XTENSA) NodeMCU ESP32-S3 | X |
100101
| `xtensa32` | Espressif (XTENSA) NodeMCU ESP32 | X |
101102

ref_app/src/mcal/xtensa_esp32_p4/mcal_port.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,12 @@
2020

2121
void init(const config_type*);
2222

23-
template<const std::uint32_t PfsBase>
23+
template<const unsigned PortIndex>
2424
class port_pin
2525
{
26-
private:
27-
static constexpr auto my_pfs_base() -> std::uint32_t { return PfsBase; }
28-
2926
public:
3027
static auto set_direction_output() -> void
3128
{
32-
// Configure the pin as output.
33-
// Disable register write protection for PFS.
34-
// PMISC->PWPR.bit.B0WI = 0;
35-
// PMISC->PWPR.bit.PFSWE = 1;
36-
// PFS->PxxxPFS.bit.PDR = 1;
37-
38-
mcal::reg::reg_access_static<std::uint32_t, std::uint8_t, mcal::reg::pmisc_pwpr, UINT8_C(7)>::bit_clr();
39-
mcal::reg::reg_access_static<std::uint32_t, std::uint8_t, mcal::reg::pmisc_pwpr, UINT8_C(6)>::bit_set();
40-
mcal::reg::reg_access_static<std::uint32_t, std::uint32_t, my_pfs_base(), UINT32_C(2)>::bit_set();
4129
}
4230

4331
static auto set_direction_input() -> void
@@ -59,8 +47,6 @@
5947

6048
static auto toggle_pin() -> void
6149
{
62-
// PFS->P111PFS.bit.PODR ^= 1;
63-
mcal::reg::reg_access_static<std::uint32_t, std::uint32_t, my_pfs_base(), UINT32_C(0)>::bit_not();
6450
}
6551
};
6652
}

ref_app/target.vcxproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,10 +1304,7 @@
13041304
<ItemGroup>
13051305
<ClInclude Include="target\micros\am6254_soc\Code\Startup\Core\a53\core_macros.h" />
13061306
<ClInclude Include="target\micros\am6254_soc\Code\Startup\Core\a53\gic-500.h" />
1307-
<ClInclude Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\esp32p4.h" />
13081307
<ClInclude Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\gpio.h" />
1309-
<ClInclude Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\interrupt.h" />
1310-
<ClInclude Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\riscv-csr.h" />
13111308
<ClInclude Include="target\micros\xtensa_esp32_s3\startup\Std\core-isa.h" />
13121309
</ItemGroup>
13131310
<ItemGroup>

ref_app/target.vcxproj.filters

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,18 +1200,9 @@
12001200
<ClInclude Include="target\micros\am6254_soc\Code\Startup\Core\a53\gic-500.h">
12011201
<Filter>micros\am6254_soc\Code\Startup\Core\a53</Filter>
12021202
</ClInclude>
1203-
<ClInclude Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\esp32p4.h">
1204-
<Filter>micros\xtensa_esp32_p4\startup\Code\Mcal</Filter>
1205-
</ClInclude>
12061203
<ClInclude Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\gpio.h">
12071204
<Filter>micros\xtensa_esp32_p4\startup\Code\Mcal</Filter>
12081205
</ClInclude>
1209-
<ClInclude Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\interrupt.h">
1210-
<Filter>micros\xtensa_esp32_p4\startup\Code\Mcal</Filter>
1211-
</ClInclude>
1212-
<ClInclude Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\riscv-csr.h">
1213-
<Filter>micros\xtensa_esp32_p4\startup\Code\Mcal</Filter>
1214-
</ClInclude>
12151206
</ItemGroup>
12161207
<ItemGroup>
12171208
<Library Include="target\micros\xtensa_esp32_s3\startup\Std\lib_call0_abi\libc_call0_abi.a">

ref_app/target/micros/xtensa_esp32_p4/make/xtensa_esp32_p4_files.gmk

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@
99
# File list of the target-specific files in the project
1010
# ------------------------------------------------------------------------------
1111

12-
FILES_CPP :=
13-
14-
FILES_TGT := $(PATH_APP)/mcal/$(TGT)/mcal_gpt \
15-
$(PATH_APP)/mcal/$(TGT)/mcal_wdg \
12+
FILES_TGT := $(PATH_APP)/mcal/mcal_gcc_cxx_completion \
1613
$(PATH_TGT)/startup/Code/Appli/main \
1714
$(PATH_TGT)/startup/Code/Appli/main_cores \
1815
$(PATH_TGT)/startup/Code/Mcal/gpio \

ref_app/target/micros/xtensa_esp32_p4/make/xtensa_esp32_p4_flags.gmk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ TGT_ALLFLAGS = -O2
2121
-march=rv32imafc_zicsr_zifencei_xesppie \
2222
-mabi=ilp32f \
2323
-msmall-data-limit=0 \
24-
-ffreestanding \
2524
-falign-functions=4 \
2625
-fomit-frame-pointer \
2726
-fno-reorder-blocks-and-partition \
Lines changed: 19 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2026.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
8+
// Originally from:
9+
110
/******************************************************************************************
211
Filename : main.c
312
@@ -15,9 +24,8 @@
1524
1625
******************************************************************************************/
1726

18-
#include <gpio.h>
19-
2027
#include <stdbool.h>
28+
#include <stdint.h>
2129

2230
extern uint32_t osGetActiveCore(void);
2331

@@ -30,32 +38,6 @@ void main_x(void)
3038
{
3139
const bool core_id_is_zero = ((uint32_t) UINT8_C(0) == osGetActiveCore());
3240

33-
if(core_id_is_zero)
34-
{
35-
gpio_cfg_output(7);
36-
gpio_cfg_output(8);
37-
gpio_cfg_output(24);
38-
gpio_cfg_output(25);
39-
gpio_cfg_output(46);
40-
gpio_cfg_output(47);
41-
gpio_cfg_output(48);
42-
gpio_cfg_output(54);
43-
gpio_cfg_output(20);
44-
gpio_cfg_output(19);
45-
gpio_cfg_output(18);
46-
gpio_cfg_output(17);
47-
gpio_cfg_output(16);
48-
gpio_cfg_output(15);
49-
gpio_cfg_output(14);
50-
gpio_cfg_output(33);
51-
gpio_cfg_output(32);
52-
gpio_cfg_output(27);
53-
gpio_cfg_output(26);
54-
gpio_cfg_output(23);
55-
gpio_cfg_output(32);
56-
gpio_cfg_output(21);
57-
}
58-
5941
// Go to the core-specific main subroutines.
6042
if(core_id_is_zero)
6143
{
@@ -66,3 +48,12 @@ void main_x(void)
6648
main_core1();
6749
}
6850
}
51+
52+
int main(void) __attribute__((used,noinline));
53+
54+
void main_caller();
55+
56+
void main_caller()
57+
{
58+
(void) main();
59+
}

ref_app/target/micros/xtensa_esp32_p4/startup/Code/Appli/main_cores.cpp

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
/******************************************************************************************
2-
Filename : main.c
3-
4-
Core : RISC-V
5-
6-
MCU : ESP32-P4
7-
8-
Author : Chalandi Amine
9-
10-
Owner : Chalandi Amine
11-
12-
Date : 25.01.2026
13-
14-
Description : Application main function
15-
16-
******************************************************************************************/
17-
18-
#include <gpio.h>
1+
///////////////////////////////////////////////////////////////////////////////
2+
// Copyright Christopher Kormanyos 2026.
3+
// Distributed under the Boost Software License,
4+
// Version 1.0. (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
197

208
#include <mcal_gpt.h>
9+
#include <mcal_led.h>
10+
#include <mcal_osc.h>
11+
#include <mcal_port.h>
12+
#include <mcal_wdg.h>
2113

2214
#include <util/utility/util_time.h>
2315

@@ -27,6 +19,7 @@ extern "C"
2719

2820
auto main_core0() -> void;
2921
auto main_core1() -> void;
22+
auto main_caller() -> void;
3023
}
3124

3225
auto main(void) -> int __attribute__((used,noinline));
@@ -54,39 +47,34 @@ namespace local
5447
extern "C"
5548
auto main_core0() -> void
5649
{
57-
gpio_toggle_output_level(54);
50+
mcal::wdg::init(nullptr);
51+
mcal::osc::init(nullptr);
5852

59-
mcal::gpt::init(nullptr);
60-
61-
local::timer_type local_led_timer(local::led_timeout);
62-
63-
// Endless LED tollge-loop: Never return or break.
64-
for(;;)
65-
{
66-
if(local_led_timer.timeout())
67-
{
68-
gpio_toggle_output_level(54);
53+
mcal::port::init(nullptr);
6954

70-
local_led_timer.start_interval(local::led_timeout);
71-
}
72-
}
55+
::main_caller();
7356
}
7457

7558
extern "C"
7659
auto main_core1() -> void
7760
{
78-
gpio_toggle_output_level(19);
61+
mcal::wdg::init(nullptr);
62+
mcal::osc::init(nullptr);
7963

8064
mcal::gpt::init(nullptr);
8165

8266
local::timer_core1_type local_led_timer(local::led_timeout);
8367

84-
// Endless LED tollge-loop: Never return or break.
68+
auto& my_led1_ref { mcal::led::led1() };
69+
70+
my_led1_ref.toggle();
71+
72+
// Endless LED1 togglee-loop: Never return or break.
8573
for(;;)
8674
{
8775
if(local_led_timer.timeout())
8876
{
89-
gpio_toggle_output_level(19);
77+
my_led1_ref.toggle();
9078

9179
local_led_timer.start_interval(local::led_timeout);
9280
}

0 commit comments

Comments
 (0)