diff --git a/ref_app/src/mcal/xtensa_esp32_s3/mcal_cpu.h b/ref_app/src/mcal/xtensa_esp32_s3/mcal_cpu.h index 71d88a151..a90f16552 100644 --- a/ref_app/src/mcal/xtensa_esp32_s3/mcal_cpu.h +++ b/ref_app/src/mcal/xtensa_esp32_s3/mcal_cpu.h @@ -11,7 +11,6 @@ #define MY_PROGMEM #include - #include namespace mcal { namespace cpu { diff --git a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_cpu.cpp b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_cpu.cpp index 818e30bca..a58cc9f38 100644 --- a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_cpu.cpp +++ b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_cpu.cpp @@ -6,11 +6,13 @@ // #include - -auto mcal::cpu::post_init() noexcept -> void -{ -} +#include +#include +#include auto mcal::cpu::init() -> void { + mcal::wdg::init(nullptr); + mcal::port::init(nullptr); + mcal::osc::init(nullptr); } diff --git a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_cpu.h b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_cpu.h index 71d88a151..e9ba7c902 100644 --- a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_cpu.h +++ b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_cpu.h @@ -11,13 +11,12 @@ #define MY_PROGMEM #include - #include namespace mcal { namespace cpu { auto init() -> void; - auto post_init() noexcept -> void; + inline auto post_init() noexcept -> void { } inline auto nop() noexcept -> void { asm volatile("nop"); } diff --git a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_osc.cpp b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_osc.cpp index 9b6683c14..f189fe53a 100644 --- a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_osc.cpp +++ b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_osc.cpp @@ -10,4 +10,11 @@ void mcal::osc::init(const config_type*) { + // Set the core clock to 240 MHz and APB clock to 80 MHz. + + // SYSTEM->CPU_PERI_CLK_EN.reg = 7; + mcal::reg::reg_access_static(UINT32_C(7))>::reg_set(); + + //SYSTEM->SYSCLK_CONF.reg = 0x401; + mcal::reg::reg_access_static(UINT32_C(0x00000401))>::reg_set(); } diff --git a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_reg.h b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_reg.h index 332f54c8e..044eeb361 100644 --- a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_reg.h +++ b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_reg.h @@ -14,12 +14,182 @@ { namespace reg { + namespace system + { + constexpr std::uint32_t system_base { UINT32_C(0x600C0000) }; + constexpr std::uint32_t core_1_control_0 { system_base + UINT32_C(0x00000000) }; + constexpr std::uint32_t core_1_control_1 { system_base + UINT32_C(0x00000004) }; + constexpr std::uint32_t cpu_peri_clk_en { system_base + UINT32_C(0x00000008) }; + constexpr std::uint32_t cpu_peri_rst_en { system_base + UINT32_C(0x0000000C) }; + constexpr std::uint32_t cpu_per_conf { system_base + UINT32_C(0x00000010) }; + constexpr std::uint32_t mem_pd_mask { system_base + UINT32_C(0x00000014) }; + constexpr std::uint32_t perip_clk_en0 { system_base + UINT32_C(0x00000018) }; + constexpr std::uint32_t perip_clk_en1 { system_base + UINT32_C(0x0000001C) }; + constexpr std::uint32_t perip_rst_en0 { system_base + UINT32_C(0x00000020) }; + constexpr std::uint32_t perip_rst_en1 { system_base + UINT32_C(0x00000024) }; + constexpr std::uint32_t bt_lpck_div_int { system_base + UINT32_C(0x00000028) }; + constexpr std::uint32_t bt_lpck_div_frac { system_base + UINT32_C(0x0000002C) }; + constexpr std::uint32_t cpu_intr_from_cpu_0 { system_base + UINT32_C(0x00000030) }; + constexpr std::uint32_t cpu_intr_from_cpu_1 { system_base + UINT32_C(0x00000034) }; + constexpr std::uint32_t cpu_intr_from_cpu_2 { system_base + UINT32_C(0x00000038) }; + constexpr std::uint32_t cpu_intr_from_cpu_3 { system_base + UINT32_C(0x0000003C) }; + constexpr std::uint32_t rsa_pd_ctrl { system_base + UINT32_C(0x00000040) }; + constexpr std::uint32_t edma_ctrl { system_base + UINT32_C(0x00000044) }; + constexpr std::uint32_t cache_control { system_base + UINT32_C(0x00000048) }; + constexpr std::uint32_t external_device_encrypt_decrypt_control { system_base + UINT32_C(0x0000004C) }; + constexpr std::uint32_t rtc_fastmem_config { system_base + UINT32_C(0x00000050) }; + constexpr std::uint32_t rtc_fastmem_crc { system_base + UINT32_C(0x00000054) }; + constexpr std::uint32_t redundant_eco_ctrl { system_base + UINT32_C(0x00000058) }; + constexpr std::uint32_t clock_gate { system_base + UINT32_C(0x0000005C) }; + constexpr std::uint32_t sysclk_conf { system_base + UINT32_C(0x00000060) }; + } // namespace system + + namespace rtc_cntl + { + constexpr std::uint32_t rtc_cntl_base { UINT32_C(0x60008000) }; + constexpr std::uint32_t options0 { rtc_cntl_base + UINT32_C(0x00000000) }; + constexpr std::uint32_t slp_timer0 { rtc_cntl_base + UINT32_C(0x00000004) }; + constexpr std::uint32_t slp_timer1 { rtc_cntl_base + UINT32_C(0x00000008) }; + constexpr std::uint32_t time_update { rtc_cntl_base + UINT32_C(0x0000000C) }; + constexpr std::uint32_t time_low0 { rtc_cntl_base + UINT32_C(0x00000010) }; + constexpr std::uint32_t time_high0 { rtc_cntl_base + UINT32_C(0x00000014) }; + constexpr std::uint32_t state0 { rtc_cntl_base + UINT32_C(0x00000018) }; + constexpr std::uint32_t timer1 { rtc_cntl_base + UINT32_C(0x0000001C) }; + constexpr std::uint32_t timer2 { rtc_cntl_base + UINT32_C(0x00000020) }; + constexpr std::uint32_t timer3 { rtc_cntl_base + UINT32_C(0x00000024) }; + constexpr std::uint32_t timer4 { rtc_cntl_base + UINT32_C(0x00000028) }; + constexpr std::uint32_t timer5 { rtc_cntl_base + UINT32_C(0x0000002C) }; + constexpr std::uint32_t timer6 { rtc_cntl_base + UINT32_C(0x00000030) }; + constexpr std::uint32_t ana_conf { rtc_cntl_base + UINT32_C(0x00000034) }; + constexpr std::uint32_t reset_state { rtc_cntl_base + UINT32_C(0x00000038) }; + constexpr std::uint32_t wakeup_state { rtc_cntl_base + UINT32_C(0x0000003C) }; + constexpr std::uint32_t int_ena_rtc { rtc_cntl_base + UINT32_C(0x00000040) }; + constexpr std::uint32_t int_raw_rtc { rtc_cntl_base + UINT32_C(0x00000044) }; + constexpr std::uint32_t int_st_rtc { rtc_cntl_base + UINT32_C(0x00000048) }; + constexpr std::uint32_t int_clr_rtc { rtc_cntl_base + UINT32_C(0x0000004C) }; + constexpr std::uint32_t store0 { rtc_cntl_base + UINT32_C(0x00000050) }; + constexpr std::uint32_t store1 { rtc_cntl_base + UINT32_C(0x00000054) }; + constexpr std::uint32_t store2 { rtc_cntl_base + UINT32_C(0x00000058) }; + constexpr std::uint32_t store3 { rtc_cntl_base + UINT32_C(0x0000005C) }; + constexpr std::uint32_t ext_xtl_conf { rtc_cntl_base + UINT32_C(0x00000060) }; + constexpr std::uint32_t ext_wakeup_conf { rtc_cntl_base + UINT32_C(0x00000064) }; + constexpr std::uint32_t slp_reject_conf { rtc_cntl_base + UINT32_C(0x00000068) }; + constexpr std::uint32_t cpu_period_conf { rtc_cntl_base + UINT32_C(0x0000006C) }; + constexpr std::uint32_t sdio_act_conf { rtc_cntl_base + UINT32_C(0x00000070) }; + constexpr std::uint32_t clk_conf { rtc_cntl_base + UINT32_C(0x00000074) }; + constexpr std::uint32_t slow_clk_conf { rtc_cntl_base + UINT32_C(0x00000078) }; + constexpr std::uint32_t sdio_conf { rtc_cntl_base + UINT32_C(0x0000007C) }; + constexpr std::uint32_t bias_conf { rtc_cntl_base + UINT32_C(0x00000080) }; + constexpr std::uint32_t rtc { rtc_cntl_base + UINT32_C(0x00000084) }; + constexpr std::uint32_t pwc { rtc_cntl_base + UINT32_C(0x00000088) }; + constexpr std::uint32_t regulator_drv_ctrl { rtc_cntl_base + UINT32_C(0x0000008C) }; + constexpr std::uint32_t dig_pwc { rtc_cntl_base + UINT32_C(0x00000090) }; + constexpr std::uint32_t dig_iso { rtc_cntl_base + UINT32_C(0x00000094) }; + constexpr std::uint32_t wdtconfig0 { rtc_cntl_base + UINT32_C(0x00000098) }; + constexpr std::uint32_t wdtconfig1 { rtc_cntl_base + UINT32_C(0x0000009C) }; + constexpr std::uint32_t wdtconfig2 { rtc_cntl_base + UINT32_C(0x000000A0) }; + constexpr std::uint32_t wdtconfig3 { rtc_cntl_base + UINT32_C(0x000000A4) }; + constexpr std::uint32_t wdtconfig4 { rtc_cntl_base + UINT32_C(0x000000A8) }; + constexpr std::uint32_t wdtfeed { rtc_cntl_base + UINT32_C(0x000000AC) }; + constexpr std::uint32_t wdtwprotect { rtc_cntl_base + UINT32_C(0x000000B0) }; + constexpr std::uint32_t swd_conf { rtc_cntl_base + UINT32_C(0x000000B4) }; + constexpr std::uint32_t swd_wprotect { rtc_cntl_base + UINT32_C(0x000000B8) }; + constexpr std::uint32_t sw_cpu_stall { rtc_cntl_base + UINT32_C(0x000000BC) }; + constexpr std::uint32_t store4 { rtc_cntl_base + UINT32_C(0x000000C0) }; + constexpr std::uint32_t store5 { rtc_cntl_base + UINT32_C(0x000000C4) }; + constexpr std::uint32_t store6 { rtc_cntl_base + UINT32_C(0x000000C8) }; + constexpr std::uint32_t store7 { rtc_cntl_base + UINT32_C(0x000000CC) }; + constexpr std::uint32_t low_power_st { rtc_cntl_base + UINT32_C(0x000000D0) }; + constexpr std::uint32_t diag0 { rtc_cntl_base + UINT32_C(0x000000D4) }; + constexpr std::uint32_t pad_hold { rtc_cntl_base + UINT32_C(0x000000D8) }; + constexpr std::uint32_t dig_pad_hold { rtc_cntl_base + UINT32_C(0x000000DC) }; + constexpr std::uint32_t ext_wakeup1 { rtc_cntl_base + UINT32_C(0x000000E0) }; + constexpr std::uint32_t ext_wakeup1_status { rtc_cntl_base + UINT32_C(0x000000E4) }; + constexpr std::uint32_t brown_out { rtc_cntl_base + UINT32_C(0x000000E8) }; + constexpr std::uint32_t time_low1 { rtc_cntl_base + UINT32_C(0x000000EC) }; + constexpr std::uint32_t time_high1 { rtc_cntl_base + UINT32_C(0x000000F0) }; + constexpr std::uint32_t xtal32k_clk_factor { rtc_cntl_base + UINT32_C(0x000000F4) }; + constexpr std::uint32_t xtal32k_conf { rtc_cntl_base + UINT32_C(0x000000F8) }; + constexpr std::uint32_t ulp_cp_timer { rtc_cntl_base + UINT32_C(0x000000FC) }; + constexpr std::uint32_t ulp_cp_ctrl { rtc_cntl_base + UINT32_C(0x00000100) }; + constexpr std::uint32_t cocpu_ctrl { rtc_cntl_base + UINT32_C(0x00000104) }; + } // namespace rtc_cntl + + namespace timg0 + { + constexpr std::uint32_t timg0_base { UINT32_C(0x6001F000) }; + constexpr std::uint32_t t0config { timg0_base + UINT32_C(0x00000000) }; + constexpr std::uint32_t t0lo { timg0_base + UINT32_C(0x00000004) }; + constexpr std::uint32_t t0hi { timg0_base + UINT32_C(0x00000008) }; + constexpr std::uint32_t t0update { timg0_base + UINT32_C(0x0000000C) }; + constexpr std::uint32_t t0alarmlo { timg0_base + UINT32_C(0x00000010) }; + constexpr std::uint32_t t0alarmhi { timg0_base + UINT32_C(0x00000014) }; + constexpr std::uint32_t t0loadlo { timg0_base + UINT32_C(0x00000018) }; + constexpr std::uint32_t t0loadhi { timg0_base + UINT32_C(0x0000001C) }; + constexpr std::uint32_t t0load { timg0_base + UINT32_C(0x00000020) }; + constexpr std::uint32_t reserved0_00 { timg0_base + UINT32_C(0x00000024) }; + constexpr std::uint32_t reserved0_01 { timg0_base + UINT32_C(0x00000028) }; + constexpr std::uint32_t reserved0_02 { timg0_base + UINT32_C(0x0000002C) }; + constexpr std::uint32_t reserved0_03 { timg0_base + UINT32_C(0x00000030) }; + constexpr std::uint32_t reserved0_04 { timg0_base + UINT32_C(0x00000034) }; + constexpr std::uint32_t reserved0_05 { timg0_base + UINT32_C(0x00000038) }; + constexpr std::uint32_t reserved0_06 { timg0_base + UINT32_C(0x0000003C) }; + constexpr std::uint32_t reserved0_07 { timg0_base + UINT32_C(0x00000040) }; + constexpr std::uint32_t reserved0_08 { timg0_base + UINT32_C(0x00000044) }; + constexpr std::uint32_t wdtconfig0 { timg0_base + UINT32_C(0x00000048) }; + constexpr std::uint32_t wdtconfig1 { timg0_base + UINT32_C(0x0000004C) }; + constexpr std::uint32_t wdtconfig2 { timg0_base + UINT32_C(0x00000050) }; + constexpr std::uint32_t wdtconfig3 { timg0_base + UINT32_C(0x00000054) }; + constexpr std::uint32_t wdtconfig4 { timg0_base + UINT32_C(0x00000058) }; + constexpr std::uint32_t wdtconfig5 { timg0_base + UINT32_C(0x0000005C) }; + constexpr std::uint32_t wdtfeed { timg0_base + UINT32_C(0x00000060) }; + constexpr std::uint32_t wdtwprotect { timg0_base + UINT32_C(0x00000064) }; + constexpr std::uint32_t rtccalicfg { timg0_base + UINT32_C(0x00000068) }; + constexpr std::uint32_t rtccalicfg1 { timg0_base + UINT32_C(0x0000006C) }; + constexpr std::uint32_t int_ena_timers { timg0_base + UINT32_C(0x00000070) }; + constexpr std::uint32_t int_raw_timers { timg0_base + UINT32_C(0x00000074) }; + constexpr std::uint32_t int_st_timers { timg0_base + UINT32_C(0x00000078) }; + constexpr std::uint32_t int_clr_timers { timg0_base + UINT32_C(0x0000007C) }; + constexpr std::uint32_t rtccalicfg2 { timg0_base + UINT32_C(0x00000080) }; + constexpr std::uint32_t reserved1_00 { timg0_base + UINT32_C(0x00000084) }; + constexpr std::uint32_t reserved1_01 { timg0_base + UINT32_C(0x00000088) }; + constexpr std::uint32_t reserved1_02 { timg0_base + UINT32_C(0x0000008C) }; + constexpr std::uint32_t t1config { timg0_base + UINT32_C(0x00000090) }; + constexpr std::uint32_t t1lo { timg0_base + UINT32_C(0x00000094) }; + constexpr std::uint32_t t1hi { timg0_base + UINT32_C(0x00000098) }; + constexpr std::uint32_t t1update { timg0_base + UINT32_C(0x0000009C) }; + constexpr std::uint32_t t1alarmlo { timg0_base + UINT32_C(0x000000A0) }; + constexpr std::uint32_t t1alarmhi { timg0_base + UINT32_C(0x000000A4) }; + constexpr std::uint32_t t1loadlo { timg0_base + UINT32_C(0x000000A8) }; + constexpr std::uint32_t t1loadhi { timg0_base + UINT32_C(0x000000AC) }; + constexpr std::uint32_t t1load { timg0_base + UINT32_C(0x000000B0) }; + constexpr std::uint32_t reserved2_00 { timg0_base + UINT32_C(0x000000B4) }; + constexpr std::uint32_t reserved2_01 { timg0_base + UINT32_C(0x000000B8) }; + constexpr std::uint32_t reserved2_02 { timg0_base + UINT32_C(0x000000BC) }; + constexpr std::uint32_t reserved2_03 { timg0_base + UINT32_C(0x000000C0) }; + constexpr std::uint32_t reserved2_04 { timg0_base + UINT32_C(0x000000C4) }; + constexpr std::uint32_t reserved2_05 { timg0_base + UINT32_C(0x000000C8) }; + constexpr std::uint32_t reserved2_06 { timg0_base + UINT32_C(0x000000CC) }; + constexpr std::uint32_t reserved2_07 { timg0_base + UINT32_C(0x000000D0) }; + constexpr std::uint32_t reserved2_08 { timg0_base + UINT32_C(0x000000D4) }; + constexpr std::uint32_t reserved2_09 { timg0_base + UINT32_C(0x000000D8) }; + constexpr std::uint32_t reserved2_10 { timg0_base + UINT32_C(0x000000DC) }; + constexpr std::uint32_t reserved2_11 { timg0_base + UINT32_C(0x000000E0) }; + constexpr std::uint32_t reserved2_12 { timg0_base + UINT32_C(0x000000E4) }; + constexpr std::uint32_t reserved2_13 { timg0_base + UINT32_C(0x000000E8) }; + constexpr std::uint32_t reserved2_14 { timg0_base + UINT32_C(0x000000EC) }; + constexpr std::uint32_t reserved2_15 { timg0_base + UINT32_C(0x000000F0) }; + constexpr std::uint32_t reserved2_16 { timg0_base + UINT32_C(0x000000F4) }; + constexpr std::uint32_t ntimers_date { timg0_base + UINT32_C(0x000000F8) }; + constexpr std::uint32_t regclk { timg0_base + UINT32_C(0x000000FC) }; + } // namespace timg0 + namespace gpio { constexpr std::uint32_t rtc_gpio_base { UINT32_C(0x0000A400) }; constexpr std::uint32_t rtc_gpio_out_reg { rtc_gpio_base + UINT32_C(0x00000000) }; constexpr std::uint32_t rtc_gpio_enable_reg { rtc_gpio_base + UINT32_C(0x0000000C) }; - } + } // namespace gpio } } diff --git a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_wdg.cpp b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_wdg.cpp index 13c92eedc..051113977 100644 --- a/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_wdg.cpp +++ b/ref_app/src/mcal/xtensa_esp32_s3_riscv_cop/mcal_wdg.cpp @@ -12,6 +12,25 @@ void mcal::wdg::init(const config_type*) { + // Disable the super watchdog. + + // RTC_CNTL->SWD_WPROTECT.reg = 0x8F1D312A; + // RTC_CNTL->WDTCONFIG1.reg = 0; + // RTC_CNTL->SWD_CONF.reg = (1ul << 30); + // RTC_CNTL->SWD_WPROTECT.reg = 0; + mcal::reg::reg_access_static(UINT32_C(0x8F1D312A))>::reg_set(); + mcal::reg::reg_access_static(UINT32_C(0x00000000))>::reg_set(); + mcal::reg::reg_access_static(UINT32_C(0x40000000))>::reg_set(); + mcal::reg::reg_access_static(UINT32_C(0x00000000))>::reg_set(); + + // Disable Timer Group 0 WDT. + + // TIMG0->WDTWPROTECT.reg = 0x50D83AA1; + // TIMG0->WDTCONFIG0.reg = 0; + // TIMG0->WDTWPROTECT.reg = 0; + mcal::reg::reg_access_static(UINT32_C(0x50D83AA1))>::reg_set(); + mcal::reg::reg_access_static(UINT32_C(0x00000000))>::reg_set(); + mcal::reg::reg_access_static(UINT32_C(0x00000000))>::reg_set(); } void mcal::wdg::secure::trigger() diff --git a/ref_app/target.vcxproj b/ref_app/target.vcxproj index 334291a46..d8558f7ae 100644 --- a/ref_app/target.vcxproj +++ b/ref_app/target.vcxproj @@ -1041,9 +1041,9 @@ - - - + + + @@ -1148,10 +1148,10 @@ - - - - + + + + diff --git a/ref_app/target.vcxproj.filters b/ref_app/target.vcxproj.filters index e4e5971d0..e1797447c 100644 --- a/ref_app/target.vcxproj.filters +++ b/ref_app/target.vcxproj.filters @@ -289,19 +289,7 @@ {a71738e7-0c88-4bb9-a1bd-3a5ffd125490} - - {bb1fed00-c4cd-4e52-833d-16cf0f69bc10} - - - {de099968-fa17-4f75-b098-50ed5325d04f} - - - {7b9aadde-8fde-47da-bd4b-d348e1b2778d} - - - {66ae9aa3-915d-4366-9492-87cdb30add93} - - + {1a0b187b-0ef0-4365-b263-303097393b67} @@ -684,17 +672,17 @@ micros\xtensa_esp32_s3_riscv_cop\make - - micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup + + micros\xtensa_esp32_s3\startup - - micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup + + micros\xtensa_esp32_s3_riscv_cop\startup\Scripts - - micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Scripts + + micros\xtensa_esp32_s3_riscv_cop\startup - - micros\xtensa_esp32_s3\startup + + micros\xtensa_esp32_s3_riscv_cop\startup @@ -1004,17 +992,17 @@ micros\xtensa_esp32_s3\startup\Std - - micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Appli + + micros\xtensa_esp32_s3_riscv_cop\startup - - micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup + + micros\xtensa_esp32_s3_riscv_cop\startup - - micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup + + micros\xtensa_esp32_s3_riscv_cop\startup - - micros\xtensa_esp32_s3_riscv_cop\startup\from_no_sdk\Code\Startup + + micros\xtensa_esp32_s3_riscv_cop\startup diff --git a/ref_app/target/micros/xtensa_esp32_s3/make/xtensa_esp32_s3_flags.gmk b/ref_app/target/micros/xtensa_esp32_s3/make/xtensa_esp32_s3_flags.gmk index 7b1009a40..2a3232d50 100644 --- a/ref_app/target/micros/xtensa_esp32_s3/make/xtensa_esp32_s3_flags.gmk +++ b/ref_app/target/micros/xtensa_esp32_s3/make/xtensa_esp32_s3_flags.gmk @@ -15,20 +15,6 @@ GCC_PREFIX = xtensa-esp32s3-elf TGT_SUFFIX = elf -WARN_FLAGS := -Wall \ - -Wextra \ - -Wpointer-arith \ - -Wno-maybe-uninitialized \ - -Wno-unused-function \ - -Wno-unused-but-set-variable \ - -Wno-unused-variable \ - -Wno-deprecated-declarations \ - -Wno-unused-parameter \ - -Wno-unused-but-set-parameter \ - -Wno-missing-field-initializers \ - -Wno-sign-compare \ - -Wno-main - include $(PATH_TGT_MAKE)/$(TGT)_flags_extra.gmk @@ -47,6 +33,7 @@ TGT_ALLFLAGS = -O1 -fno-stack-protector \ -nostdlib \ -gdwarf-4 \ + -ffreestanding \ -DCONFIG_IDF_TARGET_ESP32S3 \ -DI_KNOW_WHAT_I_AM_DOING diff --git a/ref_app/target/micros/xtensa_esp32_s3/startup/Std/StdLib.cpp b/ref_app/target/micros/xtensa_esp32_s3/startup/Std/StdLib.cpp index 2b5b178c9..2db04f1e3 100644 --- a/ref_app/target/micros/xtensa_esp32_s3/startup/Std/StdLib.cpp +++ b/ref_app/target/micros/xtensa_esp32_s3/startup/Std/StdLib.cpp @@ -23,6 +23,7 @@ ******************************************************************************************/ +#include #include #include @@ -32,13 +33,15 @@ typedef signed long long DItype __attribute__((mode (DI))); typedef unsigned long long UDItype __attribute__((mode (DI))); typedef unsigned int USItype __attribute__((mode (SI))); -extern int __builtin_clzll(long long unsigned int); +extern int __builtin_clzll(unsigned long long); #define DWtype DItype #define UDWtype UDItype #define UWtype USItype +UDWtype __udivdi3 (UDWtype n, UDWtype d); UDWtype __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp); +UDWtype __umoddi3 (UDWtype u, UDWtype v); UDWtype __udivdi3 (UDWtype n, UDWtype d) { @@ -69,8 +72,8 @@ UDWtype __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) if (y <= r) { - lz1 = __builtin_clzll (d); - lz2 = __builtin_clzll (n); + lz1 = static_cast(__builtin_clzll(static_cast(d))); + lz2 = static_cast(__builtin_clzll(static_cast(n))); k = lz1 - lz2; y = (y << k); @@ -128,39 +131,48 @@ UDWtype __udivmoddi4 (UDWtype n, UDWtype d, UDWtype *rp) return q; } +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-align" +#endif + void* memset(void* str, int c, size_t n) { - uint8_t *ptr = (uint8_t*) str; - uint32_t value = (uint8_t) c; + std::uint8_t* ptr { reinterpret_cast(str) }; + + const std::uint8_t uc { static_cast(c) }; + + std::uint32_t value = static_cast(uc); // Set value to repeat the byte across a 32-bit word. - value |= value << 8; - value |= value << 16; + value |= value << unsigned { UINT8_C( 8) }; + value |= value << unsigned { UINT8_C(16) }; // Align to the next 32-bit boundary. - while (((uintptr_t)ptr & 3) && n > 0) + while ( (static_cast(reinterpret_cast(ptr) & unsigned { UINT8_C(3) }) != 0U) + && (n > std::size_t { UINT8_C(0) })) { - *ptr++ = (uint8_t) c; + *ptr++ = uc; --n; } // Set memory in 32-bit chunks. - uint32_t* ptr32 = (uint32_t*) ptr; + std::uint32_t* ptr32 { reinterpret_cast(ptr) }; - while (n >= 4) + while (n >= std::size_t { UINT8_C(4) }) { *ptr32++ = value; - n -= 4; + n -= std::size_t { UINT8_C(4) }; } // Handle any remaining bytes. - ptr = (uint8_t*) ptr32; + ptr = reinterpret_cast(ptr32); - while (n > 0) + while (n > std::size_t { UINT8_C(0) }) { - *ptr++ = (uint8_t) c; + *ptr++ = uc; --n; } @@ -170,8 +182,8 @@ void* memset(void* str, int c, size_t n) void* memcpy (void* dest, const void* src, size_t n) { - uint8_t *d = (uint8_t*) dest; - const uint8_t* s = (const uint8_t*) src; + std::uint8_t* d { reinterpret_cast(dest) }; + const std::uint8_t* s { reinterpret_cast(src) }; // Align destination to the next 32-bit boundary. while (((uintptr_t) d & 3) && n > 0) @@ -183,8 +195,8 @@ void* memcpy (void* dest, const void* src, size_t n) // Copy memory in 32-bit chunks. - uint32_t *d32 = (uint32_t*) d; - const uint32_t* s32 = (const uint32_t*) s; + std::uint32_t* d32 { reinterpret_cast(d) }; + const std::uint32_t* s32 { reinterpret_cast(s) }; while (n >= 4) { @@ -195,8 +207,8 @@ void* memcpy (void* dest, const void* src, size_t n) // Handle any remaining bytes. - d = (uint8_t*) d32; - s = (const uint8_t*) s32; + d = reinterpret_cast(d32); + s = reinterpret_cast(s32); while (n > 0) { @@ -208,4 +220,8 @@ void* memcpy (void* dest, const void* src, size_t n) return dest; } +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + } // extern "C" diff --git a/ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S b/ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S index dd1ba8893..bf7b75c0a 100644 --- a/ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S +++ b/ref_app/target/micros/xtensa_esp32_s3/startup/coprocessor_binary.S @@ -2,8 +2,8 @@ .global coprocessor_bin coprocessor_bin: .byte 0x6F, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00 - .byte 0x17, 0x11, 0x00, 0x00, 0x13, 0x01, 0x01, 0x4B, 0x6F, 0x00, 0x80, 0x21, 0x41, 0x11, 0x06, 0xC6 - .byte 0x21, 0x22, 0xB2, 0x40, 0x41, 0x01, 0x82, 0x80, 0xB7, 0x16, 0x00, 0x50, 0x03, 0xA7, 0xC6, 0x09 + .byte 0x17, 0x11, 0x00, 0x00, 0x13, 0x01, 0x01, 0x4B, 0x6F, 0x00, 0x80, 0x30, 0x41, 0x11, 0x06, 0xC6 + .byte 0x31, 0x2A, 0xB2, 0x40, 0x41, 0x01, 0x82, 0x80, 0xB7, 0x16, 0x00, 0x50, 0x03, 0xA7, 0xC6, 0x09 .byte 0xB7, 0x17, 0x00, 0x50, 0x93, 0x87, 0x07, 0x0B, 0x3A, 0x95, 0x63, 0x74, 0xF5, 0x00, 0x23, 0xAE .byte 0xA6, 0x08, 0x3A, 0x85, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00 .byte 0x01, 0x00, 0xFD, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00 @@ -17,36 +17,42 @@ coprocessor_bin: .byte 0x7D, 0x55, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80 .byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00 .byte 0x01, 0x11, 0x2E, 0xC2, 0x32, 0xC4, 0x36, 0xC6, 0x3A, 0xC8, 0x3E, 0xCA, 0x42, 0xCC, 0x46, 0xCE - .byte 0x01, 0xA0, 0x00, 0x00, 0x37, 0x15, 0x00, 0x50, 0x13, 0x05, 0x05, 0x0B, 0x82, 0x80, 0x00, 0x00 - .byte 0x41, 0x11, 0x06, 0xC6, 0xC5, 0x3F, 0x83, 0x47, 0x05, 0x00, 0x81, 0xE7, 0x85, 0x47, 0x23, 0x00 - .byte 0xF5, 0x00, 0xB2, 0x40, 0x41, 0x01, 0x82, 0x80, 0x01, 0x45, 0x81, 0x45, 0x82, 0x80, 0x00, 0x00 - .byte 0x82, 0x80, 0x00, 0x00, 0x05, 0x45, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x23, 0x14, 0xB5, 0x00 - .byte 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0xB1, 0x45, 0x09, 0xB7, 0x41, 0x11, 0x01, 0x45 - .byte 0x06, 0xC6, 0xF9, 0x3F, 0xB2, 0x40, 0x01, 0x45, 0x41, 0x01, 0x5D, 0xBF, 0x00, 0x00, 0x00, 0x00 - .byte 0x41, 0x11, 0x06, 0xC6, 0xE5, 0x37, 0x37, 0x17, 0x00, 0x50, 0x13, 0x07, 0x47, 0x0B, 0x83, 0x57 - .byte 0x67, 0x00, 0x83, 0x55, 0x47, 0x00, 0xB7, 0x1E, 0x00, 0x50, 0xA9, 0x66, 0x37, 0x08, 0x00, 0xF8 - .byte 0x93, 0x8E, 0x8E, 0x01, 0x93, 0x86, 0x06, 0x40, 0x7D, 0x18, 0x05, 0x43, 0x01, 0x4E, 0xB7, 0x08 - .byte 0x00, 0x08, 0x13, 0x05, 0x00, 0x10, 0x11, 0x67, 0x6D, 0x07, 0x85, 0x07, 0xC2, 0x07, 0x90, 0x42 - .byte 0xC1, 0x83, 0x63, 0xE5, 0xF5, 0x02, 0x33, 0x66, 0x16, 0x01, 0x90, 0xC2, 0x7D, 0x17, 0x63, 0x8B - .byte 0xA7, 0x00, 0x65, 0xF7, 0x05, 0x0E, 0x13, 0x77, 0xFE, 0x03, 0x06, 0x07, 0x76, 0x97, 0x03, 0x53 - .byte 0x07, 0x00, 0xD1, 0xBF, 0x9A, 0x85, 0x81, 0x47, 0x69, 0xFB, 0xED, 0xB7, 0x33, 0x76, 0x06, 0x01 - .byte 0x90, 0xC2, 0xE9, 0xBF, 0x37, 0x17, 0x00, 0x50, 0xB7, 0x16, 0x00, 0x50, 0xA9, 0x67, 0x13, 0x07 - .byte 0x47, 0x0B, 0x93, 0x86, 0x86, 0x00, 0x14, 0xC3, 0x83, 0xA6, 0x07, 0x40, 0x37, 0x06, 0x00, 0xF8 - .byte 0x7D, 0x16, 0xF1, 0x8E, 0x23, 0xA0, 0xD7, 0x40, 0x03, 0xA5, 0x87, 0x4C, 0x37, 0x08, 0x08, 0x00 - .byte 0xBE, 0x86, 0x33, 0x65, 0x05, 0x01, 0x23, 0xA4, 0xA7, 0x4C, 0x83, 0xA5, 0x07, 0x40, 0x37, 0x05 - .byte 0x00, 0x08, 0x6D, 0x8E, 0x23, 0xA0, 0xC7, 0x40, 0x83, 0xA7, 0xC7, 0x40, 0x23, 0x22, 0x07, 0x00 - .byte 0x23, 0x14, 0x07, 0x00, 0xC9, 0x8F, 0x23, 0xA6, 0xF6, 0x40, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00 - .byte 0x41, 0x11, 0x06, 0xC6, 0x31, 0x20, 0xAD, 0x20, 0x25, 0x37, 0x01, 0x00, 0x01, 0x00, 0xF5, 0xBF - .byte 0xB7, 0x16, 0x00, 0x50, 0x37, 0x17, 0x00, 0x50, 0x93, 0x86, 0x06, 0x0A, 0x93, 0x05, 0xC7, 0x09 - .byte 0xB7, 0x17, 0x00, 0x50, 0x33, 0x85, 0xB6, 0x40, 0x13, 0x86, 0xC7, 0x09, 0x2A, 0x96, 0x63, 0x8D - .byte 0xB6, 0x00, 0x13, 0x07, 0xC7, 0x09, 0x93, 0x87, 0xC7, 0x09, 0x94, 0x43, 0x91, 0x07, 0x11, 0x07 - .byte 0x23, 0x2E, 0xD7, 0xFE, 0xE3, 0x1B, 0xF6, 0xFE, 0xB7, 0x17, 0x00, 0x50, 0x37, 0x17, 0x00, 0x50 - .byte 0x93, 0x86, 0x07, 0x0A, 0x13, 0x07, 0x07, 0x0C, 0x63, 0x89, 0xE6, 0x00, 0x93, 0x87, 0x07, 0x0A - .byte 0x23, 0xA0, 0x07, 0x00, 0x91, 0x07, 0xE3, 0x9D, 0xE7, 0xFE, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00 - .byte 0x41, 0x11, 0x22, 0xC4, 0x26, 0xC2, 0x37, 0x14, 0x00, 0x50, 0xB7, 0x14, 0x00, 0x50, 0x06, 0xC6 - .byte 0x93, 0x07, 0xC4, 0x09, 0x93, 0x84, 0x84, 0x09, 0x63, 0x8A, 0x97, 0x00, 0x13, 0x04, 0xC4, 0x09 - .byte 0x83, 0x27, 0xC4, 0xFF, 0x71, 0x14, 0x82, 0x97, 0xE3, 0x1C, 0x94, 0xFE, 0xB2, 0x40, 0x22, 0x44 - .byte 0x92, 0x44, 0x41, 0x01, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + .byte 0x01, 0xA0, 0x00, 0x00, 0x41, 0x11, 0x01, 0x45, 0x06, 0xC6, 0x89, 0x28, 0x01, 0x45, 0xA9, 0x20 + .byte 0xB2, 0x40, 0x01, 0x45, 0x41, 0x01, 0x3D, 0xA0, 0x37, 0x15, 0x00, 0x50, 0x13, 0x05, 0x05, 0x0B + .byte 0x82, 0x80, 0x00, 0x00, 0x41, 0x11, 0x06, 0xC6, 0xC5, 0x3F, 0x83, 0x47, 0x05, 0x00, 0x81, 0xE7 + .byte 0x85, 0x47, 0x23, 0x00, 0xF5, 0x00, 0xB2, 0x40, 0x41, 0x01, 0x82, 0x80, 0x01, 0x45, 0x81, 0x45 + .byte 0x82, 0x80, 0x00, 0x00, 0x37, 0x07, 0x0C, 0x60, 0x9D, 0x46, 0xBA, 0x87, 0x14, 0xC7, 0x13, 0x07 + .byte 0x10, 0x40, 0xB8, 0xD3, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0xB7, 0x37, 0x1D, 0x8F + .byte 0x37, 0x87, 0x00, 0x60, 0x93, 0x87, 0xA7, 0x12, 0x23, 0x2C, 0xF7, 0x0A, 0x23, 0x2E, 0x07, 0x08 + .byte 0xB7, 0x06, 0x00, 0x40, 0x23, 0x2A, 0xD7, 0x0A, 0xB7, 0x46, 0xD8, 0x50, 0xB7, 0xF7, 0x01, 0x60 + .byte 0x23, 0x2C, 0x07, 0x0A, 0x93, 0x86, 0x16, 0xAA, 0xF4, 0xD3, 0x23, 0xA4, 0x07, 0x04, 0x23, 0xA2 + .byte 0x07, 0x06, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00, 0x05, 0x45, 0x82, 0x80 + .byte 0x00, 0x00, 0x00, 0x00, 0x23, 0x14, 0xB5, 0x00, 0x82, 0x80, 0x00, 0x00, 0x82, 0x80, 0x00, 0x00 + .byte 0xB1, 0x45, 0x69, 0xBD, 0x41, 0x11, 0x01, 0x45, 0x06, 0xC6, 0xAD, 0x37, 0x37, 0x17, 0x00, 0x50 + .byte 0x13, 0x07, 0x47, 0x0B, 0x83, 0x57, 0x67, 0x00, 0x83, 0x55, 0x47, 0x00, 0xB7, 0x1E, 0x00, 0x50 + .byte 0xA9, 0x66, 0x37, 0x08, 0x00, 0xF8, 0x93, 0x8E, 0x8E, 0x01, 0x93, 0x86, 0x06, 0x40, 0x7D, 0x18 + .byte 0x05, 0x43, 0x01, 0x4E, 0xB7, 0x08, 0x00, 0x08, 0x13, 0x05, 0x00, 0x10, 0x11, 0x67, 0x6D, 0x07 + .byte 0x85, 0x07, 0xC2, 0x07, 0x90, 0x42, 0xC1, 0x83, 0x63, 0xE5, 0xF5, 0x02, 0x33, 0x66, 0x16, 0x01 + .byte 0x90, 0xC2, 0x7D, 0x17, 0x63, 0x8B, 0xA7, 0x00, 0x65, 0xF7, 0x05, 0x0E, 0x13, 0x77, 0xFE, 0x03 + .byte 0x06, 0x07, 0x76, 0x97, 0x03, 0x53, 0x07, 0x00, 0xD1, 0xBF, 0x9A, 0x85, 0x81, 0x47, 0x69, 0xFB + .byte 0xED, 0xB7, 0x33, 0x76, 0x06, 0x01, 0x90, 0xC2, 0xE9, 0xBF, 0x00, 0x00, 0x37, 0x17, 0x00, 0x50 + .byte 0xB7, 0x16, 0x00, 0x50, 0xA9, 0x67, 0x13, 0x07, 0x47, 0x0B, 0x93, 0x86, 0x86, 0x00, 0x14, 0xC3 + .byte 0x83, 0xA6, 0x07, 0x40, 0x37, 0x06, 0x00, 0xF8, 0x7D, 0x16, 0xF1, 0x8E, 0x23, 0xA0, 0xD7, 0x40 + .byte 0x03, 0xA5, 0x87, 0x4C, 0x37, 0x08, 0x08, 0x00, 0xBE, 0x86, 0x33, 0x65, 0x05, 0x01, 0x23, 0xA4 + .byte 0xA7, 0x4C, 0x83, 0xA5, 0x07, 0x40, 0x37, 0x05, 0x00, 0x08, 0x6D, 0x8E, 0x23, 0xA0, 0xC7, 0x40 + .byte 0x83, 0xA7, 0xC7, 0x40, 0x23, 0x22, 0x07, 0x00, 0x23, 0x14, 0x07, 0x00, 0xC9, 0x8F, 0x23, 0xA6 + .byte 0xF6, 0x40, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0xB7, 0x16, 0x00, 0x50, 0x37, 0x17, 0x00, 0x50 + .byte 0x93, 0x86, 0x06, 0x0A, 0x93, 0x05, 0xC7, 0x09, 0xB7, 0x17, 0x00, 0x50, 0x33, 0x85, 0xB6, 0x40 + .byte 0x13, 0x86, 0xC7, 0x09, 0x2A, 0x96, 0x63, 0x8D, 0xB6, 0x00, 0x13, 0x07, 0xC7, 0x09, 0x93, 0x87 + .byte 0xC7, 0x09, 0x94, 0x43, 0x91, 0x07, 0x11, 0x07, 0x23, 0x2E, 0xD7, 0xFE, 0xE3, 0x1B, 0xF6, 0xFE + .byte 0xB7, 0x17, 0x00, 0x50, 0x37, 0x17, 0x00, 0x50, 0x93, 0x86, 0x07, 0x0A, 0x13, 0x07, 0x07, 0x0C + .byte 0x63, 0x89, 0xE6, 0x00, 0x93, 0x87, 0x07, 0x0A, 0x23, 0xA0, 0x07, 0x00, 0x91, 0x07, 0xE3, 0x9D + .byte 0xE7, 0xFE, 0x82, 0x80, 0x00, 0x00, 0x00, 0x00, 0x41, 0x11, 0x22, 0xC4, 0x26, 0xC2, 0x37, 0x14 + .byte 0x00, 0x50, 0xB7, 0x14, 0x00, 0x50, 0x06, 0xC6, 0x93, 0x07, 0xC4, 0x09, 0x93, 0x84, 0x84, 0x09 + .byte 0x63, 0x8A, 0x97, 0x00, 0x13, 0x04, 0xC4, 0x09, 0x83, 0x27, 0xC4, 0xFF, 0x71, 0x14, 0x82, 0x97 + .byte 0xE3, 0x1C, 0x94, 0xFE, 0xB2, 0x40, 0x22, 0x44, 0x92, 0x44, 0x41, 0x01, 0x82, 0x80, 0x00, 0x00 + .byte 0x41, 0x11, 0x06, 0xC6, 0xC5, 0x33, 0x8D, 0x37, 0xC1, 0x37, 0x6F, 0xF0, 0xBF, 0xE8, 0xAD, 0x35 + .byte 0xFD, 0xBF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 @@ -251,14 +257,8 @@ coprocessor_bin: .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 - .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x01, 0x00, 0x50, 0x48, 0x01, 0x00, 0x50 - .byte 0x34, 0x01, 0x00, 0x50, 0x3C, 0x01, 0x00, 0x50, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00 + .byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAC, 0x01, 0x00, 0x50, 0xB0, 0x01, 0x00, 0x50 + .byte 0x9C, 0x01, 0x00, 0x50, 0xA4, 0x01, 0x00, 0x50, 0x01, 0x00, 0x02, 0x00, 0x03, 0x00, 0x04, 0x00 .byte 0x05, 0x00, 0x06, 0x00, 0x07, 0x00, 0x08, 0x00, 0x09, 0x00, 0x0A, 0x00, 0x0B, 0x00, 0x0C, 0x00 .byte 0x0D, 0x00, 0x0E, 0x00, 0x0F, 0x00, 0x10, 0x00, 0x11, 0x00, 0x12, 0x00, 0x13, 0x00, 0x14, 0x00 .byte 0x15, 0x00, 0x16, 0x00, 0x17, 0x00, 0x18, 0x00, 0x19, 0x00, 0x1A, 0x00, 0x1B, 0x00, 0x1C, 0x00 @@ -266,4 +266,4 @@ coprocessor_bin: .byte 0x28, 0x00, 0x2A, 0x00, 0x2C, 0x00, 0x2E, 0x00, 0x30, 0x00, 0x32, 0x00, 0x34, 0x00, 0x36, 0x00 .byte 0x38, 0x00, 0x3A, 0x00, 0x3C, 0x00, 0x3E, 0x00, 0x40, 0x00, 0x44, 0x00, 0x48, 0x00, 0x4C, 0x00 .byte 0x50, 0x00, 0x54, 0x00, 0x58, 0x00, 0x60, 0x00, 0x70, 0x00, 0x80, 0x00, 0x90, 0x00, 0xA0, 0x00 - .byte 0xB0, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0x00, 0x01, 0xD4, 0x01, 0x00, 0x50, 0xA8, 0x10, 0x00, 0x50 + .byte 0xB0, 0x00, 0xC0, 0x00, 0xE0, 0x00, 0x00, 0x01, 0x2C, 0x02, 0x00, 0x50, 0xA8, 0x10, 0x00, 0x50 diff --git a/ref_app/target/micros/xtensa_esp32_s3/startup/crt0.cpp b/ref_app/target/micros/xtensa_esp32_s3/startup/crt0.cpp index 734c557c2..858fbed6d 100644 --- a/ref_app/target/micros/xtensa_esp32_s3/startup/crt0.cpp +++ b/ref_app/target/micros/xtensa_esp32_s3/startup/crt0.cpp @@ -17,6 +17,8 @@ namespace crt extern "C" { + asm(".extern main"); + extern auto main() -> int; void __my_startup() __attribute__((used, noinline)); @@ -42,7 +44,7 @@ void __my_startup() mcal::wdg::secure::trigger(); // Jump to main (and never return). - static_cast(main()); + asm volatile("j main"); // Catch an unexpected return from main. for(;;) diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_files.gmk b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_files.gmk index 4ab802a2b..81f51e798 100644 --- a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_files.gmk +++ b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_files.gmk @@ -12,11 +12,14 @@ FILES_CPP := FILES_TGT := $(PATH_APP)/mcal/mcal_gcc_cxx_completion \ + $(PATH_APP)/mcal/$(TGT)/mcal_cpu \ $(PATH_APP)/mcal/$(TGT)/mcal_gpt \ + $(PATH_APP)/mcal/$(TGT)/mcal_osc \ $(PATH_APP)/mcal/$(TGT)/mcal_port \ - $(PATH_TGT)/startup/from_no_sdk/Code/Appli/main \ - $(PATH_TGT)/startup/from_no_sdk/Code/Startup/boot \ - $(PATH_TGT)/startup/from_no_sdk/Code/Startup/IntVectTable \ - $(PATH_TGT)/startup/from_no_sdk/Code/Startup/crt0 \ - $(PATH_TGT)/startup/from_no_sdk/Code/Startup/crt0_init_ram \ - $(PATH_TGT)/startup/from_no_sdk/Code/Startup/crt1 + $(PATH_APP)/mcal/$(TGT)/mcal_wdg \ + $(PATH_TGT)/startup/main \ + $(PATH_TGT)/startup/boot \ + $(PATH_TGT)/startup/IntVectTable \ + $(PATH_TGT)/startup/crt0 \ + $(PATH_TGT)/startup/crt0_init_ram \ + $(PATH_TGT)/startup/crt1 diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk index 2bb9eee84..146a36ab0 100644 --- a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk +++ b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/make/xtensa_esp32_s3_riscv_cop_flags.gmk @@ -15,18 +15,7 @@ GCC_VERSION := 14.2.0 TGT_SUFFIX = elf -WARN_FLAGS := -Wall \ - -Wextra \ - -Wconversion \ - -Wsign-conversion \ - -Wunused-parameter \ - -Wuninitialized \ - -Wmissing-declarations \ - -Wshadow \ - -Wunreachable-code \ - -Wmissing-include-dirs \ - -Wpointer-arith \ - -Wno-main +WARN_FLAGS := TGT_ALLFLAGS = -O2 \ @@ -37,7 +26,6 @@ TGT_ALLFLAGS = -O2 \ -msmall-data-limit=0 \ -falign-functions=4 \ -fomit-frame-pointer \ - -DI_KNOW_WHAT_I_AM_DOING \ -ffreestanding @@ -99,8 +87,8 @@ endif PYTHON := python RULE_SPECIAL_MAKE_IMAGE_FILE_PART01 := $(OBJCOPY) $(APP).$(TGT_SUFFIX) -O binary $(APP).bin -RULE_SPECIAL_MAKE_IMAGE_FILE_PART02 := $(PYTHON) $(PATH_TGT)/startup/from_no_sdk/Scripts/bin2asm.py -i $(APP).bin -o $(PATH_BIN)/coprocessor_binary.S -s ".coprocessor" -l 16 -g coprocessor_bin -RULE_SPECIAL_MAKE_IMAGE_FILE_PART03 := $(PYTHON) $(PATH_TGT)/startup/from_no_sdk/Scripts/bin2asm.py -i $(APP).bin -o $(PATH_TGT)/../xtensa_esp32_s3/startup/coprocessor_binary.S -s ".coprocessor" -l 16 -g coprocessor_bin +RULE_SPECIAL_MAKE_IMAGE_FILE_PART02 := $(PYTHON) $(PATH_TGT)/startup/Scripts/bin2asm.py -i $(APP).bin -o $(PATH_BIN)/coprocessor_binary.S -s ".coprocessor" -l 16 -g coprocessor_bin +RULE_SPECIAL_MAKE_IMAGE_FILE_PART03 := $(PYTHON) $(PATH_TGT)/startup/Scripts/bin2asm.py -i $(APP).bin -o $(PATH_TGT)/../xtensa_esp32_s3/startup/coprocessor_binary.S -s ".coprocessor" -l 16 -g coprocessor_bin RULE_SPECIAL_MAKE_IMAGE_FILE := $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART01) \ && $(RULE_SPECIAL_MAKE_IMAGE_FILE_PART02) \ diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/IntVectTable.S b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/IntVectTable.S similarity index 100% rename from ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/IntVectTable.S rename to ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/IntVectTable.S diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Scripts/bin2asm.py b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/Scripts/bin2asm.py similarity index 100% rename from ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Scripts/bin2asm.py rename to ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/Scripts/bin2asm.py diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/boot.S b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/boot.S similarity index 98% rename from ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/boot.S rename to ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/boot.S index c1ed6e6b7..4166d04e8 100644 --- a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/boot.S +++ b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/boot.S @@ -42,6 +42,6 @@ _start: la sp, __STACK_TOP /* setup C/C++ runtime environment */ - j __my_startup + j __my_startup .size _start, .-_start diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/crt0.cpp b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/crt0.cpp similarity index 70% rename from ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/crt0.cpp rename to ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/crt0.cpp index 9aa031e8e..dde7f484b 100644 --- a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/crt0.cpp +++ b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/crt0.cpp @@ -8,6 +8,7 @@ // Generic code. #include +#include namespace crt { @@ -17,13 +18,21 @@ namespace crt extern "C" { - extern auto main() -> int; + asm(".extern main"); void __my_startup() __attribute__((used, noinline)); } void __my_startup() { + // Load the stack pointer. + // The stack pointer has already been loaded + // in the subroutine _start in the file boot.S. + // So we do nothing here. + + // Chip init: Watchdog, port, and oscillator. + mcal::cpu::init(); + // Initialize statics from ROM to RAM. // Zero-clear default-initialized static RAM. crt::init_ram(); @@ -32,12 +41,12 @@ void __my_startup() crt::init_ctors(); // Jump to main (and never return). - static_cast(main()); + asm volatile("j main"); // Catch an unexpected return from main. for(;;) { // Replace with a loud error if desired. - mcal::cpu::nop(); + mcal::wdg::secure::trigger(); } } diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/crt0_init_ram.cpp b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/crt0_init_ram.cpp similarity index 100% rename from ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/crt0_init_ram.cpp rename to ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/crt0_init_ram.cpp diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/crt1.cpp b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/crt1.cpp similarity index 100% rename from ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Startup/crt1.cpp rename to ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/crt1.cpp diff --git a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Appli/main.cpp b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/main.cpp similarity index 93% rename from ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Appli/main.cpp rename to ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/main.cpp index 96a8054bc..f2f42b351 100644 --- a/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/from_no_sdk/Code/Appli/main.cpp +++ b/ref_app/target/micros/xtensa_esp32_s3_riscv_cop/startup/main.cpp @@ -31,17 +31,6 @@ extern "C" auto main() -> int; -namespace mcal -{ - auto init() -> void; - - auto init() -> void - { - mcal::port::init(nullptr); - mcal::gpt::init(nullptr); - } -} - namespace { using pwm_port_type = mcal::port::port_pin; @@ -76,7 +65,7 @@ namespace extern "C" auto main() -> int { - mcal::init(); + mcal::gpt::init(nullptr); static_cast(my_pwm.init());