Skip to content

Commit

Permalink
build for an ESP32-P4 target
Browse files Browse the repository at this point in the history
  • Loading branch information
lyusupov committed Nov 12, 2024
1 parent 3f58f17 commit a236e30
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 15 deletions.
1 change: 1 addition & 0 deletions software/firmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
* OpenDroneID library is developed by **Steve Jack**
* WiFiWebServer and Functional-Vlpp libraries are developed by **Khoi Hoang**
* QMA6100P library is developed by **Tristan Alderson**
* RadioLib library is developed by **Jan Gromes**
1 change: 1 addition & 0 deletions software/firmware/source/SoftRF/SoftRF.ino
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
* OpenDroneID library is developed by Steve Jack
* WiFiWebServer and Functional-Vlpp libraries are developed by Khoi Hoang
* QMA6100P library is developed by Tristan Alderson
* RadioLib library is developed by Jan Gromes
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down
33 changes: 25 additions & 8 deletions software/firmware/source/SoftRF/src/platform/ESP32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
#include <SPI.h>
#include <esp_err.h>
#include <esp_wifi.h>
#if !defined(CONFIG_IDF_TARGET_ESP32S2)
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32P4)
#include <esp_bt.h>
#include <BLEDevice.h>
#endif /* CONFIG_IDF_TARGET_ESP32S2 */
#if !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2)
#if !defined(CONFIG_IDF_TARGET_ESP32C6) && \
!defined(CONFIG_IDF_TARGET_ESP32H2) && \
!defined(CONFIG_IDF_TARGET_ESP32P4)
#include <soc/rtc_cntl_reg.h>
#endif /* CONFIG_IDF_TARGET_ESP32C6 || H2 */
#endif /* CONFIG_IDF_TARGET_ESP32C6 || H2 || P4 */
#include <soc/efuse_reg.h>
#include <Wire.h>
#include <rom/rtc.h>
Expand Down Expand Up @@ -624,6 +626,9 @@ static void ESP32_setup()
#elif defined(CONFIG_IDF_TARGET_ESP32H2)
default:
esp32_board = ESP32_H2_DEVKIT;
#elif defined(CONFIG_IDF_TARGET_ESP32P4)
default:
esp32_board = ESP32_P4_DEVKIT;
#else
#error "This ESP32 family build variant is not supported!"
#endif
Expand Down Expand Up @@ -1535,7 +1540,8 @@ static void ESP32_setup()
#elif ARDUINO_USB_CDC_ON_BOOT && \
(defined(CONFIG_IDF_TARGET_ESP32C3) || \
defined(CONFIG_IDF_TARGET_ESP32C6) || \
defined(CONFIG_IDF_TARGET_ESP32H2))
defined(CONFIG_IDF_TARGET_ESP32H2) || \
defined(CONFIG_IDF_TARGET_ESP32P4))

Serial.begin(SERIAL_OUT_BR);

Expand Down Expand Up @@ -2537,6 +2543,7 @@ static void* ESP32_getResetInfoPtr()
switch (rtc_get_reset_reason(0))
{
case POWERON_RESET : reset_info.reason = REASON_DEFAULT_RST; break;
#if !defined(CONFIG_IDF_TARGET_ESP32P4)
case DEEPSLEEP_RESET : reset_info.reason = REASON_DEEP_SLEEP_AWAKE; break;
case TG0WDT_SYS_RESET : reset_info.reason = REASON_WDT_RST; break;
#if !defined(CONFIG_IDF_TARGET_ESP32C2)
Expand All @@ -2554,7 +2561,8 @@ static void* ESP32_getResetInfoPtr()
reset_info.reason = REASON_DEFAULT_RST;
else
reset_info.reason = REASON_WDT_RST;
break;
break;
#endif /* CONFIG_IDF_TARGET_ESP32P4 */
#if defined(CONFIG_IDF_TARGET_ESP32)
case SW_RESET : reset_info.reason = REASON_SOFT_RESTART; break;
case OWDT_RESET : reset_info.reason = REASON_WDT_RST; break;
Expand All @@ -2574,6 +2582,7 @@ static String ESP32_getResetInfo()
switch (rtc_get_reset_reason(0))
{
case POWERON_RESET : return F("Vbat power on reset");
#if !defined(CONFIG_IDF_TARGET_ESP32P4)
case DEEPSLEEP_RESET : return F("Deep Sleep reset digital core");
case TG0WDT_SYS_RESET : return F("Timer Group0 Watch dog reset digital core");
#if !defined(CONFIG_IDF_TARGET_ESP32C2)
Expand All @@ -2586,6 +2595,7 @@ static String ESP32_getResetInfo()
case RTCWDT_CPU_RESET : return F("RTC Watch dog Reset CPU");
case RTCWDT_BROWN_OUT_RESET : return F("Reset when the vdd voltage is not stable");
case RTCWDT_RTC_RESET : return F("RTC Watch dog reset digital core and rtc module");
#endif /* CONFIG_IDF_TARGET_ESP32P4 */
#if defined(CONFIG_IDF_TARGET_ESP32)
case SW_RESET : return F("Software reset digital core");
case OWDT_RESET : return F("Legacy watch dog reset digital core");
Expand All @@ -2604,6 +2614,7 @@ static String ESP32_getResetReason()
switch (rtc_get_reset_reason(0))
{
case POWERON_RESET : return F("POWERON_RESET");
#if !defined(CONFIG_IDF_TARGET_ESP32P4)
case DEEPSLEEP_RESET : return F("DEEPSLEEP_RESET");
case TG0WDT_SYS_RESET : return F("TG0WDT_SYS_RESET");
#if !defined(CONFIG_IDF_TARGET_ESP32C2)
Expand All @@ -2616,6 +2627,7 @@ static String ESP32_getResetReason()
case RTCWDT_CPU_RESET : return F("RTCWDT_CPU_RESET");
case RTCWDT_BROWN_OUT_RESET : return F("RTCWDT_BROWN_OUT_RESET");
case RTCWDT_RTC_RESET : return F("RTCWDT_RTC_RESET");
#endif /* CONFIG_IDF_TARGET_ESP32P4 */
#if defined(CONFIG_IDF_TARGET_ESP32)
case SW_RESET : return F("SW_RESET");
case OWDT_RESET : return F("OWDT_RESET");
Expand Down Expand Up @@ -4145,7 +4157,7 @@ static void ESP32_Battery_setup()
} else {
calibrate_voltage(SOC_GPIO_PIN_C6_BATTERY);
}
#elif defined(CONFIG_IDF_TARGET_ESP32H2)
#elif defined(CONFIG_IDF_TARGET_ESP32H2) || defined(CONFIG_IDF_TARGET_ESP32P4)
/* TBD */
#else
#error "This ESP32 family build variant is not supported!"
Expand Down Expand Up @@ -5103,7 +5115,8 @@ IODev_ops_t ESP32SX_USBSerial_ops = {
#if ARDUINO_USB_MODE && \
(defined(CONFIG_IDF_TARGET_ESP32C3) || \
defined(CONFIG_IDF_TARGET_ESP32C6) || \
defined(CONFIG_IDF_TARGET_ESP32H2))
defined(CONFIG_IDF_TARGET_ESP32H2) || \
defined(CONFIG_IDF_TARGET_ESP32P4))

#define USB_TX_FIFO_SIZE (MAX_TRACKING_OBJECTS * 65 + 75 + 75 + 42 + 20)
#define USB_RX_FIFO_SIZE (256)
Expand Down Expand Up @@ -5317,6 +5330,9 @@ const SoC_ops_t ESP32_ops = {
#elif defined(CONFIG_IDF_TARGET_ESP32H2)
SOC_ESP32H2,
"ESP32-H2",
#elif defined(CONFIG_IDF_TARGET_ESP32P4)
SOC_ESP32P4,
"ESP32-P4",
#else
#error "This ESP32 family build variant is not supported!"
#endif /* CONFIG_IDF_TARGET_ESP32-S2-S3-C3-C6-H2 */
Expand Down Expand Up @@ -5359,7 +5375,8 @@ const SoC_ops_t ESP32_ops = {
#elif ARDUINO_USB_MODE && \
(defined(CONFIG_IDF_TARGET_ESP32C3) || \
defined(CONFIG_IDF_TARGET_ESP32C6) || \
defined(CONFIG_IDF_TARGET_ESP32H2))
defined(CONFIG_IDF_TARGET_ESP32H2) || \
defined(CONFIG_IDF_TARGET_ESP32P4))
&ESP32CX_USBSerial_ops,
#else
NULL,
Expand Down
22 changes: 18 additions & 4 deletions software/firmware/source/SoftRF/src/platform/ESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
#elif defined(CONFIG_IDF_TARGET_ESP32C2) || \
defined(CONFIG_IDF_TARGET_ESP32C3) || \
defined(CONFIG_IDF_TARGET_ESP32C6) || \
defined(CONFIG_IDF_TARGET_ESP32H2)
defined(CONFIG_IDF_TARGET_ESP32H2) || \
defined(CONFIG_IDF_TARGET_ESP32P4)
#if ARDUINO_USB_CDC_ON_BOOT
#define UATSerial Serial0
#undef SerialOutput
Expand Down Expand Up @@ -93,7 +94,9 @@
*/
#if defined(CONFIG_IDF_TARGET_ESP32C2)
#define EXCLUDE_LED_RING
#elif !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2)
#elif !defined(CONFIG_IDF_TARGET_ESP32C6) && \
!defined(CONFIG_IDF_TARGET_ESP32H2) && \
!defined(CONFIG_IDF_TARGET_ESP32P4)
#define USE_NEOPIXELBUS_LIBRARY
#else
#define USE_ADAFRUIT_NEO_LIBRARY
Expand Down Expand Up @@ -148,6 +151,8 @@ extern Adafruit_NeoPixel strip;
#define SOC_GPIO_PIN_LED 3 /* D1 */
#elif defined(CONFIG_IDF_TARGET_ESP32H2)
#define SOC_GPIO_PIN_LED SOC_UNUSED_PIN /* TBD */
#elif defined(CONFIG_IDF_TARGET_ESP32P4)
#define SOC_GPIO_PIN_LED SOC_UNUSED_PIN /* TBD */
#else
#error "This ESP32 family build variant is not supported!"
#endif
Expand Down Expand Up @@ -275,6 +280,7 @@ enum esp32_board_id {
ESP32_C3_DEVKIT,
ESP32_C6_DEVKIT,
ESP32_H2_DEVKIT,
ESP32_P4_DEVKIT,
ESP32_TTGO_V2_OLED,
ESP32_HELTEC_OLED,
ESP32_TTGO_T_BEAM,
Expand Down Expand Up @@ -427,12 +433,14 @@ extern const USB_Device_List_t supported_USB_devices[];
#elif defined(CONFIG_IDF_TARGET_ESP32C2) || \
defined(CONFIG_IDF_TARGET_ESP32C3) || \
defined(CONFIG_IDF_TARGET_ESP32C6) || \
defined(CONFIG_IDF_TARGET_ESP32H2)
defined(CONFIG_IDF_TARGET_ESP32H2) || \
defined(CONFIG_IDF_TARGET_ESP32P4)
#undef USE_OLED
#undef USE_TFT
#if defined(CONFIG_IDF_TARGET_ESP32C2) || \
defined(CONFIG_IDF_TARGET_ESP32C6) || \
defined(CONFIG_IDF_TARGET_ESP32H2)
defined(CONFIG_IDF_TARGET_ESP32H2) || \
defined(CONFIG_IDF_TARGET_ESP32P4)
#define EXCLUDE_EGM96
#define EXCLUDE_TEST_MODE
#define EXCLUDE_WATCHOUT_MODE
Expand Down Expand Up @@ -473,6 +481,12 @@ extern const USB_Device_List_t supported_USB_devices[];
#undef NMEA_TCP_SERVICE
#endif /* H2 */

#if defined(CONFIG_IDF_TARGET_ESP32P4)
#define EXCLUDE_BLUETOOTH
#define EXCLUDE_WIFI
#undef NMEA_TCP_SERVICE
#endif /* P4 */

#define POWER_SAVING_WIFI_TIMEOUT 600000UL /* 10 minutes */

//#define PMK2_SLEEP_MODE 1 // 0.6 mA : esp_deep_sleep_start()
Expand Down
1 change: 1 addition & 0 deletions software/firmware/source/SoftRF/src/system/SoC.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ enum
SOC_ESP32C3,
SOC_ESP32C6,
SOC_ESP32H2,
SOC_ESP32P4,
SOC_RPi,
SOC_CC13X0,
SOC_CC13X2,
Expand Down
5 changes: 3 additions & 2 deletions software/firmware/source/libraries/LibAPRS_ESP32/AFSK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

#if !defined(CONFIG_IDF_TARGET_ESP32C2) && \
!defined(CONFIG_IDF_TARGET_ESP32C6) && \
!defined(CONFIG_IDF_TARGET_ESP32H2)
!defined(CONFIG_IDF_TARGET_ESP32H2) && \
!defined(CONFIG_IDF_TARGET_ESP32P4)
extern "C"
{
#include "soc/syscon_reg.h"
#include "soc/syscon_struct.h"
}
#endif /* CONFIG_IDF_TARGET_ESP32C2 || C6 || H2 */
#endif /* CONFIG_IDF_TARGET_ESP32C2 || C6 || H2 || P4 */
#endif /* I2S_INTERNAL */

#define DEBUG_TNC
Expand Down
3 changes: 2 additions & 1 deletion software/firmware/source/libraries/LibAPRS_ESP32/FIFO.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
!defined(CONFIG_IDF_TARGET_ESP32C2) && \
!defined(CONFIG_IDF_TARGET_ESP32C3) && \
!defined(CONFIG_IDF_TARGET_ESP32C6) && \
!defined(CONFIG_IDF_TARGET_ESP32H2)
!defined(CONFIG_IDF_TARGET_ESP32H2) && \
!defined(CONFIG_IDF_TARGET_ESP32P4)
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)); state;}))
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")

Expand Down

0 comments on commit a236e30

Please sign in to comment.