-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Add initial chip structure #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Dzarda7
wants to merge
1
commit into
master
Choose a base branch
from
feat/add_initial_target_structure
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| cmake_minimum_required(VERSION 3.28) | ||
|
|
||
| add_library(soc STATIC) | ||
|
|
||
| target_sources(soc PRIVATE | ||
| common/soc.c | ||
| common/watchdog_common.c | ||
| ) | ||
|
|
||
| target_sources(soc PRIVATE targets/${TARGET_CHIP}.c) | ||
|
|
||
| # Include directories | ||
| target_include_directories(soc PUBLIC | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/include | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| */ | ||
|
|
||
| #include <stddef.h> | ||
| #include "soc.h" | ||
|
|
||
| /* | ||
| * Single SoC info structure - chip-specific file provides this | ||
| * Chip selected at compile time | ||
| */ | ||
| extern const struct soc_info g_soc_info; | ||
|
|
||
| const struct soc_info* soc_get_info(void) | ||
| { | ||
| return &g_soc_info; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| */ | ||
|
|
||
| #include "soc.h" | ||
|
|
||
| void disable_watchdogs(void) | ||
| { | ||
| const struct watchdog *watchdog = soc_get_peripherals()->watchdog; | ||
| if (watchdog->wdt_disable) { | ||
| watchdog->wdt_disable(); | ||
| } | ||
| } | ||
|
|
||
| void enable_watchdogs(void) | ||
| { | ||
| const struct watchdog *watchdog = soc_get_peripherals()->watchdog; | ||
| if (watchdog->wdt_enable) { | ||
| watchdog->wdt_enable(); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /* USB OTG peripheral structure */ | ||
| struct usb_otg { | ||
| uint32_t usb_otg_intr_map_reg; /* USB OTG interrupt mapping */ | ||
| uint32_t hp_sys_usbotg20_ctrl_reg; /* USB OTG control register */ | ||
| uint32_t usb_inum; /* USB interrupt number */ | ||
| uint32_t clic_ext_intr_num_offset; /* RISC-V CLIC interrupt offset */ | ||
| }; | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <stdint.h> | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /* Watchdog peripheral structure */ | ||
| struct watchdog { | ||
| /* Register offsets */ | ||
| uint32_t option1_reg; | ||
| uint32_t wdtconfig0_reg; | ||
| uint32_t wdtwprotect_reg; | ||
| uint32_t swd_conf_reg; | ||
| uint32_t swd_wprotect_reg; | ||
| uint32_t cpu_per_conf_reg; | ||
| uint32_t sysclk_conf_reg; | ||
|
|
||
| /* Chip-specific values */ | ||
| uint32_t swd_wkey; | ||
| uint32_t wdt_wkey; | ||
| uint32_t swd_auto_feed_en_bit; | ||
| uint32_t force_download_boot_bit; | ||
| uint32_t cpuperiod_sel_mask; | ||
Dzarda7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| uint32_t cpuperiod_sel_shift; | ||
| uint32_t cpuperiod_max; | ||
| uint32_t soc_clk_sel_mask; | ||
| uint32_t soc_clk_sel_shift; | ||
| uint32_t soc_clk_max; | ||
|
|
||
| /* Function pointers for RTC-specific operations */ | ||
| void (*wdt_disable)(void); | ||
| void (*wdt_enable)(void); | ||
| }; | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include "peripherals/usb_otg.h" | ||
| #include "peripherals/watchdog.h" | ||
|
|
||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif | ||
|
|
||
| /* Essential SoC Capabilities for flasher stub */ | ||
| struct soc_capabilities { | ||
| bool is_riscv; /* RISC-V architecture (affects interrupt handling) */ | ||
| }; | ||
|
|
||
| /* Essential peripherals for flasher stub */ | ||
| struct soc_peripherals { | ||
| const struct usb_otg *usb_otg; /* USB-OTG communication */ | ||
| const struct watchdog *watchdog; /* Watchdog and power management */ | ||
| }; | ||
|
|
||
| /* Main SoC structure */ | ||
| struct soc_info { | ||
| const struct soc_capabilities *capabilities; | ||
| const struct soc_peripherals *peripherals; | ||
| uint8_t security_info_bytes; | ||
| }; | ||
|
|
||
| const struct soc_info* soc_get_info(void); | ||
|
|
||
| /* Convenience accessors */ | ||
| static inline const struct soc_capabilities* soc_get_capabilities(void) | ||
| { | ||
| return soc_get_info()->capabilities; | ||
| } | ||
|
|
||
| static inline const struct soc_peripherals* soc_get_peripherals(void) | ||
| { | ||
| return soc_get_info()->peripherals; | ||
| } | ||
|
|
||
| #ifdef __cplusplus | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| */ | ||
|
|
||
| #include <stddef.h> | ||
| #include "soc.h" | ||
|
|
||
| /* ESP32 capabilities */ | ||
| static const struct soc_capabilities esp32_capabilities = { | ||
| .is_riscv = false, | ||
| }; | ||
|
|
||
| /* ESP32 USB-OTG peripheral */ | ||
| static const struct usb_otg esp32_usb_otg = { | ||
| .usb_otg_intr_map_reg = 0, | ||
| .hp_sys_usbotg20_ctrl_reg = 0, | ||
| .usb_inum = 0, | ||
| .clic_ext_intr_num_offset = 0, | ||
| }; | ||
Dzarda7 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /* ESP32 Watchdog peripheral */ | ||
| static const struct watchdog esp32_watchdog = { | ||
| .option1_reg = 0, | ||
| .wdtconfig0_reg = 0, | ||
| .wdtwprotect_reg = 0, | ||
| .swd_conf_reg = 0, | ||
| .swd_wprotect_reg = 0, | ||
| .cpu_per_conf_reg = 0, | ||
| .sysclk_conf_reg = 0, | ||
| .swd_wkey = 0, | ||
| .wdt_wkey = 0, | ||
| .swd_auto_feed_en_bit = 0, | ||
| .force_download_boot_bit = 0, | ||
| .cpuperiod_sel_mask = 0, | ||
| .cpuperiod_sel_shift = 0, | ||
| .cpuperiod_max = 0, | ||
| .soc_clk_sel_mask = 0, | ||
| .soc_clk_sel_shift = 0, | ||
| .soc_clk_max = 0, | ||
| .wdt_disable = NULL, | ||
| .wdt_enable = NULL, | ||
| }; | ||
|
|
||
| /* ESP32 peripherals structure */ | ||
| static const struct soc_peripherals esp32_peripherals = { | ||
| .usb_otg = &esp32_usb_otg, | ||
| .watchdog = &esp32_watchdog, | ||
| }; | ||
|
|
||
| /* ESP32 SoC info */ | ||
| const struct soc_info g_soc_info = { | ||
| .capabilities = &esp32_capabilities, | ||
| .peripherals = &esp32_peripherals, | ||
| .security_info_bytes = 0, | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| */ | ||
|
|
||
| #include <stddef.h> | ||
| #include "soc.h" | ||
|
|
||
| /* ESP32C2 capabilities */ | ||
| static const struct soc_capabilities esp32c2_capabilities = { | ||
| .is_riscv = true, | ||
| }; | ||
|
|
||
| /* ESP32C2 USB-OTG peripheral */ | ||
| static const struct usb_otg esp32c2_usb_otg = { | ||
| .usb_otg_intr_map_reg = 0, | ||
| .hp_sys_usbotg20_ctrl_reg = 0, | ||
| .usb_inum = 0, | ||
| .clic_ext_intr_num_offset = 0, | ||
| }; | ||
|
|
||
| /* ESP32C2 Watchdog peripheral */ | ||
| static const struct watchdog esp32c2_watchdog = { | ||
| .option1_reg = 0, | ||
| .wdtconfig0_reg = 0, | ||
| .wdtwprotect_reg = 0, | ||
| .swd_conf_reg = 0, | ||
| .swd_wprotect_reg = 0, | ||
| .cpu_per_conf_reg = 0, | ||
| .sysclk_conf_reg = 0, | ||
| .swd_wkey = 0, | ||
| .wdt_wkey = 0, | ||
| .swd_auto_feed_en_bit = 0, | ||
| .force_download_boot_bit = 0, | ||
| .cpuperiod_sel_mask = 0, | ||
| .cpuperiod_sel_shift = 0, | ||
| .cpuperiod_max = 0, | ||
| .soc_clk_sel_mask = 0, | ||
| .soc_clk_sel_shift = 0, | ||
| .soc_clk_max = 0, | ||
| .wdt_disable = NULL, | ||
| .wdt_enable = NULL, | ||
| }; | ||
|
|
||
| /* ESP32C2 peripherals structure */ | ||
| static const struct soc_peripherals esp32c2_peripherals = { | ||
| .usb_otg = &esp32c2_usb_otg, | ||
| .watchdog = &esp32c2_watchdog, | ||
| }; | ||
|
|
||
| /* ESP32C2 SoC info */ | ||
| const struct soc_info g_soc_info = { | ||
| .capabilities = &esp32c2_capabilities, | ||
| .peripherals = &esp32c2_peripherals, | ||
| .security_info_bytes = 0, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 OR MIT | ||
| */ | ||
|
|
||
| #include <stddef.h> | ||
| #include "soc.h" | ||
|
|
||
| /* ESP32C3 capabilities */ | ||
| static const struct soc_capabilities esp32c3_capabilities = { | ||
| .is_riscv = true, | ||
| }; | ||
|
|
||
| /* ESP32C3 USB-OTG peripheral */ | ||
| static const struct usb_otg esp32c3_usb_otg = { | ||
| .usb_otg_intr_map_reg = 0, | ||
| .hp_sys_usbotg20_ctrl_reg = 0, | ||
| .usb_inum = 0, | ||
| .clic_ext_intr_num_offset = 0, | ||
| }; | ||
|
|
||
| /* ESP32C3 Watchdog peripheral */ | ||
| static const struct watchdog esp32c3_watchdog = { | ||
| .option1_reg = 0, | ||
| .wdtconfig0_reg = 0, | ||
| .wdtwprotect_reg = 0, | ||
| .swd_conf_reg = 0, | ||
| .swd_wprotect_reg = 0, | ||
| .cpu_per_conf_reg = 0, | ||
| .sysclk_conf_reg = 0, | ||
| .swd_wkey = 0, | ||
| .wdt_wkey = 0, | ||
| .swd_auto_feed_en_bit = 0, | ||
| .force_download_boot_bit = 0, | ||
| .cpuperiod_sel_mask = 0, | ||
| .cpuperiod_sel_shift = 0, | ||
| .cpuperiod_max = 0, | ||
| .soc_clk_sel_mask = 0, | ||
| .soc_clk_sel_shift = 0, | ||
| .soc_clk_max = 0, | ||
| .wdt_disable = NULL, | ||
| .wdt_enable = NULL, | ||
| }; | ||
|
|
||
| /* ESP32C3 peripherals structure */ | ||
| static const struct soc_peripherals esp32c3_peripherals = { | ||
| .usb_otg = &esp32c3_usb_otg, | ||
| .watchdog = &esp32c3_watchdog, | ||
| }; | ||
|
|
||
| /* ESP32C3 SoC info */ | ||
| const struct soc_info g_soc_info = { | ||
| .capabilities = &esp32c3_capabilities, | ||
| .peripherals = &esp32c3_peripherals, | ||
| .security_info_bytes = 0, | ||
| }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.