Skip to content

Commit 5ef0b8d

Browse files
committed
Recover PP-def and ensure both Cores run
1 parent 63c9916 commit 5ef0b8d

File tree

11 files changed

+142
-24
lines changed

11 files changed

+142
-24
lines changed

ref_app/src/mcal/am6254_soc/mcal_gpt.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2025.
2+
// Copyright Christopher Kormanyos 2007 - 2026.
33
// Distributed under the Boost Software License,
44
// Version 1.0. (See accompanying file LICENSE_1_0.txt
55
// or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -32,7 +32,11 @@ auto mcal::gpt::secure::get_time_elapsed_core1() -> mcal::gpt::value_type_core1
3232
const value_type_core1 consistent_microsecond_tick = static_cast<value_type_core1>(ARM64_READ_SYSREG(CNTPCT_EL0));
3333

3434
// Convert the consistent tick to microseconds.
35-
return static_cast<value_type_core1>(static_cast<value_type_core1>(consistent_microsecond_tick + UINT64_C(100)) / UINT64_C(200));
35+
return
36+
static_cast<value_type_core1>
37+
(
38+
static_cast<value_type_core1>(consistent_microsecond_tick + UINT64_C(100)) / UINT64_C(200)
39+
);
3640
}
3741

3842
auto mcal::gpt::secure::get_time_elapsed_core2() -> mcal::gpt::value_type_core2
@@ -41,7 +45,11 @@ auto mcal::gpt::secure::get_time_elapsed_core2() -> mcal::gpt::value_type_core2
4145
const value_type_core2 consistent_microsecond_tick = static_cast<value_type_core2>(ARM64_READ_SYSREG(CNTPCT_EL0));
4246

4347
// Convert the consistent tick to microseconds.
44-
return static_cast<value_type_core2>(static_cast<value_type_core2>(consistent_microsecond_tick + UINT64_C(100)) / UINT64_C(200));
48+
return
49+
static_cast<value_type_core2>
50+
(
51+
static_cast<value_type_core2>(consistent_microsecond_tick + UINT64_C(100)) / UINT64_C(200)
52+
);
4553
}
4654

4755
auto mcal::gpt::secure::get_time_elapsed_core3() -> mcal::gpt::value_type_core3
@@ -50,5 +58,9 @@ auto mcal::gpt::secure::get_time_elapsed_core3() -> mcal::gpt::value_type_core3
5058
const value_type_core3 consistent_microsecond_tick = static_cast<value_type_core3>(ARM64_READ_SYSREG(CNTPCT_EL0));
5159

5260
// Convert the consistent tick to microseconds.
53-
return static_cast<value_type_core3>(static_cast<value_type_core3>(consistent_microsecond_tick + UINT64_C(100)) / UINT64_C(200));
61+
return
62+
static_cast<value_type_core3>
63+
(
64+
static_cast<value_type_core3>(consistent_microsecond_tick + UINT64_C(100)) / UINT64_C(200)
65+
);
5466
}

ref_app/src/mcal/xtensa32/from_sdk/esp32-hal-gpio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
#include <stdint.h>
3030

31-
#ifdef __cplusplus
31+
#if defined(__cplusplus)
3232
extern "C"
3333
{
3434
#endif
@@ -57,7 +57,7 @@
5757
void digitalWrite(const uint8_t pin, const uint8_t val);
5858
int digitalRead (const uint8_t pin);
5959

60-
#ifdef __cplusplus
60+
#if defined(__cplusplus)
6161
}
6262
#endif
6363

ref_app/src/mcal/xtensa32/from_sdk/soc/gpio_struct.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
#include <stdint.h>
2929

30-
#ifdef __cplusplus
30+
#if defined(__cplusplus)
3131
extern "C" {
3232
#endif
3333

@@ -222,7 +222,7 @@ typedef struct gpio_dev_t
222222

223223
extern gpio_dev_t GPIO;
224224

225-
#ifdef __cplusplus
225+
#if defined(__cplusplus)
226226
}
227227
#endif
228228

ref_app/target.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@
634634
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='target stm32h7a3|x64'">$(SolutionDir)src\util\STL_C++XX_stdfloat;$(SolutionDir)src\util\STL;$(SolutionDir)/src;$(SolutionDir)/src/mcal/stm32f446</NMakeIncludeSearchPath>
635635
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='target xtensa32|x64'">$(ProjectDir)/src/util/STL_C++XX_stdfloat; $(ProjectDir)/src/util/STL; $(ProjectDir)/src; $(ProjectDir)/src/mcal/xtensa32;</NMakeIncludeSearchPath>
636636
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='target xtensa_esp32_s3|x64'">$(ProjectDir)/src/util/STL_C++XX_stdfloat; $(ProjectDir)/src/util/STL; $(ProjectDir)/src; $(ProjectDir)/src/mcal/xtensa_esp32_s3;</NMakeIncludeSearchPath>
637-
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='target xtensa_esp32_p4|x64'">$(ProjectDir)/src/util/STL_C++XX_stdfloat; $(ProjectDir)/src/util/STL; $(ProjectDir)/src; $(ProjectDir)/src/mcal/xtensa_esp32_p4;</NMakeIncludeSearchPath>
637+
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='target xtensa_esp32_p4|x64'">$(ProjectDir)/target/micros/xtensa_esp32_p4/startup/Code; $(ProjectDir)/target/micros/xtensa_esp32_p4/startup/Code/Appli; $(ProjectDir)/target/micros/xtensa_esp32_p4/startup/Code/Mcal; $(ProjectDir)/target/micros/xtensa_esp32_p4/startup/Code/Startup; $(ProjectDir)/src; $(ProjectDir)/src/mcal/xtensa_esp32_p4;</NMakeIncludeSearchPath>
638638
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='target xtensa_esp32_s3_riscv_cop|x64'">$(ProjectDir)/src/util/STL_C++XX_stdfloat; $(ProjectDir)/src/util/STL; $(ProjectDir)/src; $(ProjectDir)/src/mcal/xtensa_esp32_s3;</NMakeIncludeSearchPath>
639639
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='target stm32f429|x64'">$(SolutionDir)src\util\STL_C++XX_stdfloat;$(SolutionDir)src\util\STL;$(SolutionDir)/src;$(SolutionDir)/src/mcal/stm32f429</NMakeIncludeSearchPath>
640640
<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='target am335x|x64'">$(SolutionDir)/src;$(SolutionDir)/src/mcal/am335x</NMakeIncludeSearchPath>
@@ -1287,6 +1287,7 @@
12871287
<ClCompile Include="target\micros\xtensa_esp32_p4\startup\Code\Mcal\gpio.c" />
12881288
<ClCompile Include="target\micros\xtensa_esp32_p4\startup\Code\Startup\intvect.c" />
12891289
<ClCompile Include="target\micros\xtensa_esp32_p4\startup\Code\Startup\Startup.c" />
1290+
<ClCompile Include="target\micros\xtensa_esp32_p4\startup\Code\StdLib\StdLib.c" />
12901291
<ClCompile Include="target\micros\xtensa_esp32_s3\startup\crt0.cpp" />
12911292
<ClCompile Include="target\micros\xtensa_esp32_s3\startup\crt0_init_ram.cpp" />
12921293
<ClCompile Include="target\micros\xtensa_esp32_s3\startup\crt1.cpp" />

ref_app/target.vcxproj.filters

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@
361361
<Filter Include="micros\xtensa_esp32_p4\startup\Code\Startup">
362362
<UniqueIdentifier>{17889d6f-9174-40cb-bcad-01e3995207e5}</UniqueIdentifier>
363363
</Filter>
364+
<Filter Include="micros\xtensa_esp32_p4\startup\StdLib">
365+
<UniqueIdentifier>{509b8385-c65b-4236-9b5a-93e8cc7bf887}</UniqueIdentifier>
366+
</Filter>
364367
</ItemGroup>
365368
<ItemGroup>
366369
<None Include="target\app\make\app_files.gmk">
@@ -1178,6 +1181,9 @@
11781181
<ClCompile Include="target\micros\xtensa_esp32_p4\startup\Code\Startup\Startup.c">
11791182
<Filter>micros\xtensa_esp32_p4\startup\Code\Startup</Filter>
11801183
</ClCompile>
1184+
<ClCompile Include="target\micros\xtensa_esp32_p4\startup\Code\StdLib\StdLib.c">
1185+
<Filter>micros\xtensa_esp32_p4\startup\StdLib</Filter>
1186+
</ClCompile>
11811187
</ItemGroup>
11821188
<ItemGroup>
11831189
<Text Include="target\micros\bcm2835_raspi_b\startup\SD_CARD\PiZero\config.txt">

ref_app/target/micros/xtensa_esp32_p4/make/xtensa_esp32_p4.ld

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ SECTIONS
5656
PROVIDE(__CODE_BASE_ADDRESS = .);
5757
*(.boot)
5858
*(.text)
59+
*(.text*)
5960
. = ALIGN(4);
6061
} > FLASH
6162

@@ -64,6 +65,7 @@ SECTIONS
6465
{
6566
PROVIDE(__RODATA_BASE_ADDRESS = .);
6667
*(.rodata)
68+
*(.rodata*)
6769
} > FLASH
6870

6971
/* Section for constructors */

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ FILES_TGT := $(PATH_TGT)/startup/Code/Appli/main
1515
$(PATH_TGT)/startup/Code/Mcal/gpio \
1616
$(PATH_TGT)/startup/Code/Startup/boot \
1717
$(PATH_TGT)/startup/Code/Startup/intvect \
18-
$(PATH_TGT)/startup/Code/Startup/Startup
18+
$(PATH_TGT)/startup/Code/Startup/Startup \
19+
$(PATH_TGT)/startup/Code/StdLib/StdLib

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ TGT_ALLFLAGS = -O2
2323
-msmall-data-limit=0 \
2424
-ffreestanding \
2525
-falign-functions=4 \
26-
-fomit-frame-pointer
26+
-fomit-frame-pointer \
27+
-fno-reorder-blocks-and-partition \
28+
-fno-reorder-functions \
29+
-DHP_CORES_SMP_MODE
2730

28-
29-
TGT_CFLAGS = -std=c23 \
30-
-nostdlib \
31+
TGT_CFLAGS = -std=c11 \
3132
$(TGT_ALLFLAGS)
3233

3334
TGT_CXXFLAGS = -std=c++23 \

ref_app/target/micros/xtensa_esp32_p4/startup/Code/Appli/main.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@ void __attribute__((interrupt)) Isr_TIMER_Interrupt(void);
5555
///
5656
/// \return
5757
//-----------------------------------------------------------------------------------------
58-
int main(void);
59-
60-
int main(void)
58+
void main(void)
6159
{
6260
osHwAcquireSpinLock(&sync_lock);
6361
/* output a text message on the uart console */
@@ -100,12 +98,10 @@ int main(void)
10098
CLINT_MTIMECTL |= (3ul << 4);
10199

102100
/* set MTIME timeout to 500ms */
103-
CLINT_MTIMECMP = (uint64_t)(CLINT_MTIME + (TIMEOUT_500MS + TIMEOUT_500MS));
101+
CLINT_MTIMECMP = (uint64_t)(CLINT_MTIME + TIMEOUT_1S);
104102

105103
/* endless loop */
106104
while(1);
107-
108-
return 0;
109105
}
110106

111107
//-----------------------------------------------------------------------------------------
@@ -117,7 +113,7 @@ int main(void)
117113
//-----------------------------------------------------------------------------------------
118114
void Isr_TIMER_Interrupt(void)
119115
{
120-
CLINT_MTIMECMP = (uint64_t)(CLINT_MTIME + (TIMEOUT_500MS + TIMEOUT_500MS));
116+
CLINT_MTIMECMP = (uint64_t)(CLINT_MTIME + TIMEOUT_1S);
121117

122118
if(0 == osGetActiveCore())
123119
{

ref_app/target/micros/xtensa_esp32_p4/startup/Code/Startup/boot.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ _start:
5353

5454
.L_core1:
5555
/* note: - RISC-V has no WFE/SEV instructions to synchronize SMP system
56-
so I'm using CLINT to synchronize both HP cores on ESP32-P4.
57-
- Core0 will set the software interrupt pending flag in Core1's CLINT
56+
so I am using CLINT to synchronize both HP cores on ESP32-P4.
57+
- Core0 will set the software interrupt pending flag in CLINT on Core1
5858
once the runtime environment setup is complete.
5959
*/
6060
li a5, msip
@@ -196,4 +196,4 @@ osHwReleaseSpinLock: lr.w a1, (a0)
196196
f18-27 | fs2-11 | FP saved registers | Callee
197197
f28-31 | ft8-11 | FP temporaries | Caller
198198
-----------------------------------------------------------------
199-
*/
199+
*/

0 commit comments

Comments
 (0)