Skip to content

Commit 91122fe

Browse files
committed
Simplify and repair RISCV boot and run
1 parent 25f9691 commit 91122fe

8 files changed

Lines changed: 19 additions & 112 deletions

File tree

ref_app/src/mcal/xtensa_esp32_s3/mcal_cpu.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ auto Mcu_StartCoProcessorRiscV() -> void
9696
RTC_CNTL->COCPU_CTRL.bit.COCPU_CLKGATE_EN = 1;
9797
RTC_CNTL->COCPU_CTRL.bit.COCPU_SEL = 0;
9898
RTC_CNTL->ULP_CP_CTRL.bit.ULP_CP_FORCE_START_TOP = 0;
99+
RTC_CNTL->ULP_CP_TIMER.bit.ULP_CP_SLP_TIMER_EN = 1;
99100
}
100101

101102
extern "C"
@@ -123,11 +124,11 @@ auto mcal::cpu::post_init() noexcept -> void
123124
// Set the private cpu timer1 for core0.
124125
set_cpu_private_timer1(mcal::gpt::timer1_reload());
125126

126-
// Use core0 to start core1.
127-
Mcu_StartCore1();
128-
129127
// Use core0 to start the RISC-V core.
130128
Mcu_StartCoProcessorRiscV();
129+
130+
// Use core0 to start core1.
131+
Mcu_StartCore1();
131132
}
132133

133134
auto mcal::cpu::init() -> void

ref_app/target.vcxproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,6 @@
11491149
<ClCompile Include="target\micros\xtensa_esp32_s3\startup\crt1.cpp" />
11501150
<ClCompile Include="target\micros\xtensa_esp32_s3\startup\Std\StdLib.cpp" />
11511151
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Appli\main.c" />
1152-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Mcal\Mcu.c" />
11531152
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup\Startup.c" />
11541153
</ItemGroup>
11551154
<ItemGroup>

ref_app/target.vcxproj.filters

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,6 @@
298298
<Filter Include="micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Appli">
299299
<UniqueIdentifier>{7b9aadde-8fde-47da-bd4b-d348e1b2778d}</UniqueIdentifier>
300300
</Filter>
301-
<Filter Include="micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Mcal">
302-
<UniqueIdentifier>{fbf8a8a1-b81b-418d-b1b2-9f8d5724180d}</UniqueIdentifier>
303-
</Filter>
304301
<Filter Include="micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup">
305302
<UniqueIdentifier>{66ae9aa3-915d-4366-9492-87cdb30add93}</UniqueIdentifier>
306303
</Filter>
@@ -1010,9 +1007,6 @@
10101007
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup\Startup.c">
10111008
<Filter>micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup</Filter>
10121009
</ClCompile>
1013-
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Mcal\Mcu.c">
1014-
<Filter>micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Mcal</Filter>
1015-
</ClCompile>
10161010
<ClCompile Include="target\micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Appli\main.c">
10171011
<Filter>micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Appli</Filter>
10181012
</ClCompile>

ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
.global coprocessor_bin
33
coprocessor_bin:
44
.byte 0x6F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
5-
.byte 0x17, 0x11, 0x00, 0x00, 0x13, 0x01, 0x01, 0x42, 0x6F, 0x00, 0xC0, 0x06, 0xA9, 0x67, 0x83, 0xA6
5+
.byte 0x17, 0x11, 0x00, 0x00, 0x13, 0x01, 0x01, 0x42, 0x6F, 0x00, 0x00, 0x06, 0xA9, 0x67, 0x83, 0xA6
66
.byte 0xC7, 0x4C, 0xB7, 0x05, 0x08, 0x00, 0x37, 0x06, 0x00, 0x10, 0xCD, 0x8E, 0x23, 0xA6, 0xD7, 0x4C
77
.byte 0x23, 0xA8, 0x07, 0x46, 0x83, 0xA6, 0xC7, 0x40, 0xD1, 0x8E, 0x23, 0xA6, 0xD7, 0x40, 0x03, 0xA6
88
.byte 0x87, 0x4C, 0x93, 0x86, 0x07, 0x40, 0x4D, 0x8E, 0x23, 0xA4, 0xC7, 0x4C, 0x23, 0xA6, 0x07, 0x46
99
.byte 0x03, 0xA7, 0xC7, 0x40, 0x37, 0x06, 0x00, 0x18, 0x51, 0x8F, 0x23, 0xA6, 0xE7, 0x40, 0x23, 0xA0
10-
.byte 0x06, 0x00, 0x37, 0x06, 0x00, 0x08, 0x98, 0x42, 0xB7, 0x07, 0x0C, 0x00, 0x31, 0x8F, 0x98, 0xC2
11-
.byte 0x01, 0x00, 0xFD, 0x17, 0xF5, 0xFF, 0xC5, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00
12-
.byte 0x82, 0x80, 0x00, 0x00, 0x41, 0x11, 0x06, 0xC6, 0x22, 0xC4, 0x26, 0xC2, 0xD5, 0x3F, 0xFD, 0x37
13-
.byte 0xB7, 0x16, 0x00, 0x50, 0x83, 0xA7, 0x86, 0x00, 0x7D, 0x56, 0x93, 0x86, 0x86, 0x00, 0x63, 0x83
10+
.byte 0x06, 0x00, 0x37, 0x06, 0x00, 0x08, 0x98, 0x42, 0xB7, 0x07, 0x10, 0x00, 0x31, 0x8F, 0x98, 0xC2
11+
.byte 0xFD, 0x17, 0xFD, 0xFF, 0xCD, 0xBF, 0x00, 0x00, 0xB7, 0x16, 0x00, 0x50, 0x83, 0xA7, 0x86, 0x00
12+
.byte 0x41, 0x11, 0x06, 0xC6, 0x22, 0xC4, 0x26, 0xC2, 0x7D, 0x56, 0x93, 0x86, 0x86, 0x00, 0x63, 0x83
1413
.byte 0xC7, 0x02, 0xD8, 0x42, 0x63, 0x00, 0xC7, 0x02, 0x81, 0x47, 0x09, 0xCB, 0x98, 0x42, 0x3E, 0x97
1514
.byte 0x23, 0x00, 0x07, 0x00, 0xD8, 0x42, 0x85, 0x07, 0xE3, 0xEA, 0xE7, 0xFE, 0x9C, 0x46, 0xA1, 0x06
1615
.byte 0xE3, 0x91, 0xC7, 0xFE, 0xB7, 0x17, 0x00, 0x50, 0x83, 0xA7, 0x07, 0x00, 0x37, 0x14, 0x00, 0x50
1716
.byte 0xFD, 0x54, 0x13, 0x04, 0x44, 0x00, 0x63, 0x87, 0x97, 0x00, 0x82, 0x97, 0x1C, 0x40, 0x11, 0x04
18-
.byte 0xE3, 0x9D, 0x97, 0xFE, 0x25, 0x3F, 0x01, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
17+
.byte 0xE3, 0x9D, 0x97, 0xFE, 0xA1, 0x37, 0x01, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
18+
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1919
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2020
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
2121
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00

ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_files.gmk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
FILES_CPP :=
1313

1414
FILES_TGT := $(PATH_TGT)/startup/from_no_sdk/Code/Appli/main \
15-
$(PATH_TGT)/startup/from_no_sdk/Code/Mcal/Mcu \
1615
$(PATH_TGT)/startup/from_no_sdk/Code/Startup/boot \
1716
$(PATH_TGT)/startup/from_no_sdk/Code/Startup/IntVectTable \
1817
$(PATH_TGT)/startup/from_no_sdk/Code/Startup/Startup

ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Appli/main.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@
5252
///
5353
/// \return void
5454
//-----------------------------------------------------------------------------------------
55-
int main() __attribute__((used, noinline));
56-
57-
int main()
55+
void main()
5856
{
5957
/* configure GPIO17 and GPIO18 as output low */
6058
RTC_IO_RTC_PAD18_REG |= (1ul << 19);
@@ -68,12 +66,6 @@ int main()
6866
for(;;)
6967
{
7068
TOGGLE_GPIO17();
71-
72-
for(uint32_t i=0; i< 0xC0000; ++i)
73-
{
74-
__asm("nop");
75-
}
69+
for(uint32_t i=0; i< 0x100000; i++);
7670
}
77-
78-
return 0;
7971
}

ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Mcal/Mcu.c

Lines changed: 0 additions & 27 deletions
This file was deleted.

ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/Startup.c

Lines changed: 7 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,13 @@ extern unsigned long __CPPCTOR_LIST__[];
4545
#define __STARTUP_RUNTIME_CTORS (unsigned long*)(&__CPPCTOR_LIST__[0])
4646

4747
//=========================================================================================
48-
// function prototype
48+
// function prototypes
4949
//=========================================================================================
5050
void Startup_Init(void) __attribute__((used));
5151
static void Startup_InitRam(void);
5252
static void Startup_InitCtors(void);
53-
static void Startup_RunApplication(void);
54-
static void Startup_Unexpected_Exit(void);
55-
static void Startup_InitSystemClock(void);
56-
static void Startup_InitCore(void);
57-
//=========================================================================================
58-
// extern function prototype
59-
//=========================================================================================
60-
extern int main(void) __attribute__((used, noinline));
61-
extern void Mcu_ClockInit(void);
62-
extern void Mcu_InitCore(void);
53+
54+
extern void main(void);
6355

6456
//=========================================================================================
6557
// macros
@@ -74,20 +66,17 @@ extern void Mcu_InitCore(void);
7466
//-----------------------------------------------------------------------------------------
7567
void Startup_Init(void)
7668
{
77-
/* Initialize the CPU Core */
78-
Startup_InitCore();
79-
80-
/* Configure the system clock */
81-
Startup_InitSystemClock();
82-
8369
/* Initialize the RAM memory */
8470
Startup_InitRam();
8571

8672
/* Initialize the non-local C++ objects */
8773
Startup_InitCtors();
8874

8975
/* Start the application */
90-
Startup_RunApplication();
76+
main();
77+
78+
/* Catch unexpected exit from main or if main does not exist */
79+
for(;;) { ; }
9180
}
9281

9382

@@ -149,43 +138,3 @@ static void Startup_InitCtors(void)
149138
((void (*)(void))((__STARTUP_RUNTIME_CTORS)[CtorIdx++]))();
150139
}
151140
}
152-
153-
//-----------------------------------------------------------------------------------------
154-
/// \brief Startup_RunApplication function
155-
///
156-
/// \param void
157-
///
158-
/// \return void
159-
//-----------------------------------------------------------------------------------------
160-
static void Startup_RunApplication(void)
161-
{
162-
/* Check the weak function */
163-
(void)main();
164-
165-
/* Catch unexpected exit from main or if main does not exist */
166-
for(;;);
167-
}
168-
169-
//-----------------------------------------------------------------------------------------
170-
/// \brief Startup_InitSystemClock function
171-
///
172-
/// \param void
173-
///
174-
/// \return void
175-
//-----------------------------------------------------------------------------------------
176-
static void Startup_InitSystemClock(void)
177-
{
178-
Mcu_ClockInit();
179-
}
180-
181-
//-----------------------------------------------------------------------------------------
182-
/// \brief Startup_InitCore function
183-
///
184-
/// \param void
185-
///
186-
/// \return void
187-
//-----------------------------------------------------------------------------------------
188-
void Startup_InitCore(void)
189-
{
190-
Mcu_InitCore();
191-
}

0 commit comments

Comments
 (0)