Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,17 @@ features a bare-metal startup _without_ using any of the SDK.
The bare-metal startup was taken from the work of
[Chalandi/Baremetal_esp32s3_nosdk](https://github.com/Chalandi/Baremetal_esp32s3_nosdk).
The multicore system first boots core0 which subsequently
starts up core1 and also starts up the RISCV coprocessor core.
starts up core1 and also starts up the RISC-V-ULP coprocessor core.
Blinky runs in the standard `ref_app`
on core0 toggling `port7` while an endless timer loop on core1
toggles `port6`. These LED ports togle in near unison
at the normal blinky feequency of $\frac{1}{2}~\text{Hz}$.
The RISCV coprocessor toggles `port17` at a randomly chosen
frequency slightly higher than that of the regular blinky show.
The RISC-V-ULP coprocessor performs an LED dimming
show on `port17` at a randomly chosen frequency
that is asynchronous to the regular blinky show.
Self-procured LEDs and resistors need to be fitted externally
on the port pins in order to observe blinking on this particular board.
on the port pins in order to observe blinking and dimming
on this particular board.

The NXP(R) OM13093 LPC11C24 board ARM(R) Cortex(R)-M0+ configuration
called `target lpc11c24` toggles the LED on `port0.8`.
Expand Down
1 change: 0 additions & 1 deletion ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_port.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
static auto set_direction_output() -> void
{
mcal::reg::reg_access_static<std::uint32_t, std::uint32_t, io_rtc_padxx_reg, UINT32_C(19)>::bit_set();
mcal::reg::reg_access_static<std::uint32_t, std::uint32_t, gpio_pinxx_reg, UINT32_C(0)>::reg_set();

// Set the pin to output low.
mcal::reg::reg_access_static<std::uint32_t, std::uint32_t, mcal::reg::gpio::rtc_gpio_out_reg, std::uint32_t { UINT32_C(10) + bpos }>::bit_clr();
Expand Down
174 changes: 89 additions & 85 deletions ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ SECTIONS
. = ALIGN(4);
*(.rodata*)
. = ALIGN(4);
PROVIDE(__INTVECT_BASE_ADDRESS = .);
*(.intvect_core*)
. = ALIGN(4);
} > D_SRAM

/* Section for constructors */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <mcal_led.h>
#include <mcal_port.h>

extern "C" void main();
extern "C" auto main() -> int;

namespace mcal
{
Expand All @@ -44,25 +44,47 @@ namespace
{
volatile std::uint32_t main_counter { };

auto delay() -> void
auto delay(const std::uint32_t loop_count) -> void
{
constexpr std::uint32_t loop_count{ UINT32_C(0x00060000) };

for (std::uint32_t loop{ UINT32_C(0) }; loop < loop_count; ++loop)
for (std::uint32_t loop { UINT32_C(0) }; loop < loop_count; ++loop)
{
main_counter = std::uint32_t { main_counter + UINT8_C(1) };
}
}
}

extern "C" void main()
extern "C" auto main() -> int
{
mcal::init();

unsigned prescaler { UINT8_C(0) };
unsigned cycle { UINT8_C(0) };

for(;;)
{
mcal::led::led0().toggle();
switch(unsigned { cycle % unsigned { UINT8_C(16) } })
{
case unsigned { UINT8_C( 0) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(60) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 4) }); break;
case unsigned { UINT8_C( 1) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(32) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(32) }); break;
case unsigned { UINT8_C( 2) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 8) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(56) }); break;
case unsigned { UINT8_C( 3) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 6) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(58) }); break;
case unsigned { UINT8_C( 4) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 4) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(60) }); break;
case unsigned { UINT8_C( 5) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 3) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(61) }); break;
case unsigned { UINT8_C( 6) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 2) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(62) }); break;
case unsigned { UINT8_C( 7) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 1) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(63) }); break;
case unsigned { UINT8_C( 8) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 1) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(60) }); break;
case unsigned { UINT8_C( 9) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 2) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(32) }); break;
case unsigned { UINT8_C(10) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 3) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 8) }); break;
case unsigned { UINT8_C(11) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 4) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 6) }); break;
case unsigned { UINT8_C(12) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 6) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 4) }); break;
case unsigned { UINT8_C(13) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 8) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 3) }); break;
case unsigned { UINT8_C(14) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(32) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 2) }); break;
case unsigned { UINT8_C(15) }: mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C(60) }); mcal::led::led0().toggle(); delay(std::uint32_t { UINT8_C( 1) }); break;
}

delay();
if(unsigned { ++prescaler % unsigned { UINT8_C(1024) } } == unsigned { UINT8_C(0) })
{
++cycle;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,35 +8,39 @@
// Originally from:
/******************************************************************************************
Filename : IntVectTable.S

Core : RISC-V

MCU : ESP32-S3

Author : Chalandi Amine

Owner : Chalandi Amine

Date : 22.02.2025

Description : interrupt vector table implementation for ULP-RISC-V Co-processor

******************************************************************************************/

/*******************************************************************************************
\brief
\param
\return
\brief

\param

\return
********************************************************************************************/
.section .vector
.type _InterruptVectorTable, @function
.align 4
.extern _IRQ_VECTORS
.globl _InterruptVectorTable

_InterruptVectorTable:
/* reset vector */
j _start

/* reset vector */
.org _InterruptVectorTable + 0x00
j _start

.org _InterruptVectorTable + 0x0C
AlignmentDummy:
nop // 2-byte op
nop // 2-byte op
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@
******************************************************************************************/

/*******************************************************************************************
\brief
\param
\return
\brief

\param

\return
********************************************************************************************/
.section .boot
.type _start, @function
.align 4
.extern __STACK_TOP
.extern Startup_Init
.extern __my_startup
.globl _start

_start:
/* setup the stack pointer */
la sp, __STACK_TOP

/* setup C/C++ runtime environment */
j Startup_Init
j __my_startup

.size _start, .-_start
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ extern "C"
{
extern auto main() -> int;

void Startup_Init() __attribute__((used, noinline));
void __my_startup() __attribute__((used, noinline));
}

void Startup_Init()
void __my_startup()
{
// Initialize statics from ROM to RAM.
// Zero-clear default-initialized static RAM.
Expand Down