Skip to content

Commit ab23f54

Browse files
authored
Merge pull request #726 from ckormanyos/trivial_cleanup
Trivial cleanup
2 parents b345212 + 78b2c92 commit ab23f54

File tree

11 files changed

+54
-62
lines changed

11 files changed

+54
-62
lines changed

ref_app/src/sys/start/sys_start.cpp

Lines changed: 3 additions & 3 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)
@@ -11,9 +11,9 @@
1111
#include <util/utility/util_attribute.h>
1212

1313
#if (defined(__XTENSA__) && !defined(CONFIG_IDF_TARGET_ESP32S3))
14-
extern "C" auto app_main_loop() -> int ATTRIBUTE(used);
14+
extern "C" auto app_main_loop() -> int ATTRIBUTE(used, noinline);
1515
#else
16-
ATTRIBUTE(used) auto main() -> int;
16+
ATTRIBUTE(used, noinline) auto main() -> int;
1717
#endif
1818

1919
#if (defined(__XTENSA__) && !defined(CONFIG_IDF_TARGET_ESP32S3))

ref_app/target/micros/am6254_soc/Code/Appli/Core/a53/main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717

1818
extern uint32_t GetActiveCoreId(void);
1919

20-
extern int main(void) ATTRIBUTE(used);
20+
extern int main(void) ATTRIBUTE(used,noinline);
2121

2222
//extern void main_core0(void);
2323
extern void main_core1(void);
2424
extern void main_core2(void);
2525
extern void main_core3(void);
2626
extern void main_core0_init(void);
2727

28-
void timer_isr(void) ATTRIBUTE(used);
29-
void main_x(void) ATTRIBUTE(used);
30-
static void main_init(const uint32_t ActiveCore) ATTRIBUTE(used);
28+
void timer_isr(void) ATTRIBUTE(used,noinline);
29+
void main_x(void) ATTRIBUTE(used,noinline);
30+
static void main_init(const uint32_t ActiveCore) ATTRIBUTE(used,noinline);
3131

3232
void main_x(void)
3333
{

ref_app/target/micros/am6254_soc/Code/Startup/Core/a53/Startup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static void Startup_Unexpected_Exit(void);
6161
static void Startup_InitSystemClock(void);
6262
static void Startup_InitSystemPeripheral(void);
6363

64-
extern void main_x(void) ATTRIBUTE(used);
64+
extern void main_x(void) ATTRIBUTE(used,noinline);
6565

6666
void Startup_Init(void)
6767
{

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ INPUT(libc.a libm.a libgcc.a)
3636
/******************************************************************************************
3737
Globals
3838
******************************************************************************************/
39-
__STACK_SIZE_CORE0 = 1K;
40-
__STACK_SIZE_CORE1 = 1K;
39+
__STACK_SIZE_CORE0 = 4K;
40+
__STACK_SIZE_CORE1 = 4K;
4141

4242
/******************************************************************************************
4343
Memory configuration
@@ -122,9 +122,15 @@ SECTIONS
122122
*(.data*)
123123
. = ALIGN(4);
124124
KEEP (*(.data*))
125+
*(.sdata)
126+
. = ALIGN(4);
127+
KEEP (*(.sdata))
128+
*(.sdata*)
129+
. = ALIGN(4);
130+
KEEP (*(.sdata*))
125131
_data_end = .;
126132
} > RAM AT>FLASH
127-
133+
128134
/* The uninitialized (zero-cleared) data sections */
129135
.bss : ALIGN(4)
130136
{
@@ -135,6 +141,12 @@ SECTIONS
135141
*(.bss*)
136142
. = ALIGN(4);
137143
KEEP (*(.bss*))
144+
*(.sbss)
145+
. = ALIGN(4);
146+
KEEP (*(.sbss))
147+
*(.sbss*)
148+
. = ALIGN(4);
149+
KEEP (*(.sbss*))
138150
_bss_end = .;
139151
} > RAM
140152

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

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ WARN_FLAGS :=
2020
TGT_ALLFLAGS = -O2 \
2121
-march=rv32imafc_zicsr_zifencei_xesppie \
2222
-mabi=ilp32f \
23-
-msmall-data-limit=0 \
23+
-msmall-data-limit=32 \
2424
-falign-functions=4 \
2525
-fomit-frame-pointer \
26-
-fno-reorder-blocks-and-partition \
27-
-fno-reorder-functions \
2826
-DHP_CORES_SMP_MODE
2927

3028
TGT_CFLAGS = -std=c23 \
@@ -50,36 +48,24 @@ TGT_LDFLAGS = -nostdlib
5048
--specs=nosys.specs
5149

5250

53-
# ------------------------------------------------------------------------------
54-
# Rule to assemble source file (*.S) to object file (*.o).
55-
# ------------------------------------------------------------------------------
56-
57-
ifeq ($(TYP_OS),WIN)
58-
TGT_GCC := $(PATH_TOOLS_CC)/$(GCC_PREFIX)-gcc.exe
59-
TGT_GCC := $(subst /,\,$(TGT_GCC))
60-
else
61-
TGT_GCC := $(GCC_PREFIX)-gcc
62-
endif
63-
64-
6551
# ------------------------------------------------------------------------------
6652
# Image file and flash batch file.
6753
# ------------------------------------------------------------------------------
6854

69-
RULE_SPECIAL_MAKE_IMAGE_FILE :=
55+
RULE_SPECIAL_MAKE_IMAGE_FILE :=
7056

7157
ifeq ($(TYP_OS),WIN)
7258

7359
ESP32S3_ESP_TOOL_DIR := $(PATH_TOOLS)/espressif/esptool-v4.11.0-windows-amd64
7460

75-
ESP32S3_ESP_TOOL_FLAGS_PROG := --chip esp32p4 \
76-
-p COM5 -b 460800 \
77-
--before=default_reset \
78-
--after=hard_reset write_flash \
79-
--flash_mode dio \
80-
--flash_freq 80m \
81-
--flash_size 32MB \
82-
0x2000 $(CURDIR)/$(PATH_TGT)/startup/Code/SBL/Output/SBL.bin \
61+
ESP32S3_ESP_TOOL_FLAGS_PROG := --chip esp32p4 \
62+
-p COM5 -b 460800 \
63+
--before=default_reset \
64+
--after=hard_reset write_flash \
65+
--flash_mode dio \
66+
--flash_freq 80m \
67+
--flash_size 32MB \
68+
0x2000 $(CURDIR)/$(PATH_TGT)/startup/Code/SBL/Output/SBL.bin \
8369
0x5000 $(CURDIR)/$(basename $(APP).$(TGT_SUFFIX)).bin
8470

8571

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
extern "C"
1717
{
1818
extern auto osGetActiveCore(void) -> std::uint32_t;
19+
extern auto main_caller(void) -> void;
1920

2021
auto main_core0() -> void;
2122
auto main_core1() -> void;
22-
auto main_caller() -> void;
2323
}
2424

2525
auto main(void) -> int __attribute__((used,noinline));

ref_app/target/micros/xtensa_esp32_p4/startup/Code/Startup/Startup.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static void Startup_InitMcuSystem(void);
3636
// Extern function prototype
3737
//=========================================================================================
3838
extern int main_x(void) __attribute__((used,noinline));
39+
extern void crt_init_ram(void);
40+
extern void crt_init_ctors(void);
3941

4042
//-----------------------------------------------------------------------------------------
4143
/// \brief Startup_Init function
@@ -68,9 +70,7 @@ void Startup_Init(void)
6870
//-----------------------------------------------------------------------------------------
6971
static void Startup_InitRam(void)
7072
{
71-
// Use my own standard static RAM initialization.
72-
73-
extern void crt_init_ram(void);
73+
// Use the ref_app's standard static RAM initialization.
7474

7575
crt_init_ram();
7676
}
@@ -84,9 +84,7 @@ static void Startup_InitRam(void)
8484
//-----------------------------------------------------------------------------------------
8585
static void Startup_InitCtors(void)
8686
{
87-
// Use my own standard static constructor initialization.
88-
89-
extern void crt_init_ctors();
87+
// Use the ref_app's standard static constructor initialization.
9088

9189
crt_init_ctors();
9290
}
@@ -100,22 +98,18 @@ static void Startup_InitCtors(void)
10098
//-----------------------------------------------------------------------------------------
10199
static void Startup_RunApplication(void)
102100
{
103-
/* check the weak function */
104-
if((unsigned int) &main_x != 0)
105-
{
106-
#ifdef HP_CORES_SMP_MODE
107-
// note: RISC-V has no WFE/SEV instructions to synchronize SMP system
108-
// so I am using CLINT to synchronize both HP cores on ESP32-P4
109-
110-
// Notify core1 that the setup of the runtime environment is done
111-
// by setting the SW interrupt pending bit in CLINT on core1.
112-
113-
*(volatile uint32_t*)0x20010000 = 1;
114-
#endif
115-
116-
// Call the main function.
117-
main_x();
118-
}
101+
#if defined(HP_CORES_SMP_MODE)
102+
// note: RISC-V has no WFE/SEV instructions to synchronize SMP system
103+
// so I am using CLINT to synchronize both HP cores on ESP32-P4
104+
105+
// Notify core1 that the setup of the runtime environment is done
106+
// by setting the SW interrupt pending bit in CLINT on core1.
107+
108+
*(volatile uint32_t*)0x20010000 = 1;
109+
#endif
110+
111+
// Call the main function.
112+
main_x();
119113

120114
// Catch unexpected exit from main or if main does not exist.
121115
Startup_Unexpected_Exit();

ref_app/target/micros/xtensa_esp32_p4/startup/Code/Startup/intvect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
// Functions prototype
3434
//=====================================================================================================
3535
static void UndefinedHandler(void);
36-
static void UndefinedHandler(void){ for(;;); }
36+
static void UndefinedHandler(void){ for(;;) { ; } }
3737

3838
void Isr_SW_Interrupt (void) __attribute__((weak, alias("UndefinedHandler")));
3939
void Isr_ExtInt00 (void) __attribute__((weak, alias("UndefinedHandler")));

ref_app/target/micros/xtensa_esp32_p4/startup/crt0_init_ram.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2022.
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)

ref_app/target/micros/xtensa_esp32_p4/startup/crt1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
///////////////////////////////////////////////////////////////////////////////
2-
// Copyright Christopher Kormanyos 2007 - 2022.
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)

0 commit comments

Comments
 (0)