Skip to content

Commit

Permalink
S3 build logic
Browse files Browse the repository at this point in the history
  • Loading branch information
revk committed Aug 7, 2023
1 parent 54bd6f3 commit 4ee5af7
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 70 deletions.
13 changes: 11 additions & 2 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -352,14 +352,23 @@ menu "RevK"

config REVK_PICO
bool "ESP32-PICO"
sepends on IDF_TARGET_ESP32
default n
help
If this is built for ESP32-PICO
If this is built for ESP32-PICO - don't set this manually - it is normally set by Makefile (buildsuffix script)

config REVK_D4
bool "ESP32-D4"
sepends on IDF_TARGET_ESP32
default n
help
If this is built for ESP32-D4
If this is built for ESP32-D4 - don't set this manually - it is normally set by Makefile (buildsuffix script)

config REVK_MINI
bool "ESP32-MINI"
sepends on IDF_TARGET_ESP32S3
default n
help
If this is built for ESP32S3-MINI - don't set this manually - it is normally set by Makefile (buildsuffix script)

endmenu
81 changes: 49 additions & 32 deletions buildsuffix
Original file line number Diff line number Diff line change
Expand Up @@ -10,52 +10,69 @@ if(! -e "$SDKCONFIG") then
exit 0
endif

# processor/SDK family
set esp8266=0
# processor type
grep -q CONFIG_IDF_TARGET_ESP8266=y "$SDKCONFIG"
if (! $status) set esp8266=1

# Force build date/time
set app_desc="${IDF_PATH}/components/esp_app_format/esp_app_desc.c"
if($esp8266) set app_desc="${IDF_PATH}/components/app_update/esp_app_desc.c"
touch $app_desc
if (! $status) then
setenv SUFFIX "$SUFFIX-8266"
# ensure date/time set
touch "${IDF_PATH}/components/esp_app_format/esp_app_desc.c"
else
# ensure date/time set
touch "${IDF_PATH}/components/app_update/esp_app_desc.c"
endif

# processor type
grep -q CONFIG_IDF_TARGET_ESP32=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-S1"
grep -q CONFIG_IDF_TARGET_ESP32S2=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-S2"
grep -q CONFIG_IDF_TARGET_ESP32S3=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-S3"
grep -q CONFIG_IDF_TARGET_ESPC3=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-C3"
grep -q CONFIG_IDF_TARGET_ESPH2=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-H2"

if($esp8266) then
setenv SUFFIX "$SUFFIX-8266"
else
if(! $status) then
setenv SUFFIX "$SUFFIX-S1"
# Min rev build (default now V3)
#grep -q CONFIG_ESP32_REV_MIN_3=y "$SDKCONFIG"
#if(! $status) setenv SUFFIX "$SUFFIX-V3"
grep -q CONFIG_ESP32_REV_MIN_2=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-V2"
grep -q CONFIG_ESP32_REV_MIN_1=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-V1"
grep -q CONFIG_ESP32_REV_MIN_0=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-V0"
grep -q CONFIG_REVK_D4=y "$SDKCONFIG"
if(! $status) then
setenv SUFFIX "$SUFFIX-D4"
else
# ESP32 Single core
grep -q CONFIG_FREERTOS_UNICORE=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-SOLO"
grep -q CONFIG_REVK_PICO=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-PICO"
endif
endif

# Min rev build (default now V3)
#grep -q CONFIG_ESP32_REV_MIN_3=y "$SDKCONFIG"
#if(! $status) setenv SUFFIX "$SUFFIX-V3"
grep -q CONFIG_ESP32_REV_MIN_2=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-V2"
grep -q CONFIG_ESP32_REV_MIN_1=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-V1"
grep -q CONFIG_ESP32_REV_MIN_0=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-V0"
grep -q CONFIG_IDF_TARGET_ESP32S2=y "$SDKCONFIG"
if(! $status) then
setenv SUFFIX "$SUFFIX-S2"
endif

grep -q CONFIG_IDF_TARGET_ESP32S3=y "$SDKCONFIG"
if(! $status) then
setenv SUFFIX "$SUFFIX-S3"
grep -q CONFIG_ESP32S3_REV_MIN_2=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-V2"
grep -q CONFIG_ESP32S3_REV_MIN_1=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-V1"
grep -q CONFIG_REVK_MINI=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-MINI"
grep -q CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-N4"
grep -q CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y "$SDKCONFIG"
if(! $status) setenv SUFFIX "$SUFFIX-N8"
endif

grep -q CONFIG_IDF_TARGET_ESPC3=y "$SDKCONFIG"
if(! $status) then
setenv SUFFIX "$SUFFIX-C3"
endif

grep -q CONFIG_IDF_TARGET_ESPH2=y "$SDKCONFIG"
if(! $status) then
setenv SUFFIX "$SUFFIX-H2"
endif

set bs=(`grep _BUILD_SUFFIX_ sdkconfig | sed 's/.*\(CONFIG_[A-Z0-9_]*_BUILD_SUFFIX_[A-Z0-9]*\).*/\1/'`)
foreach c ($bs)
Expand Down
144 changes: 108 additions & 36 deletions setbuildsuffix
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,122 @@ if(! -e "$SDKCONFIG") then
exit 0
endif

# We don't seem to have any SoC variations with 8266
grep -q CONFIG_IDF_TARGET_ESP8266=y "$SDKCONFIG"
if(! $status) then
echo setbuildsuffix is not supported on ESP8266
exit 255
endif
# The variants are per silicon, e.g. 8266, ESP32, ESP32S1, ESP32S2, ESP32S3, ESP32C3, ESP32H2 can all have different options

set add=()
set rem=()
set part=""

if("$BUILDSUFFIX" =~ *-PICO*) then
set add=($add CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_8m.csv"
else if("$BUILDSUFFIX" =~ *-D4*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE CONFIG_REVK_D4)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO)
set part="components/ESP32-RevK/partitions_4m.csv"
else if("$BUILDSUFFIX" =~ *-SOLO*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_4m.csv"
if("$BUILDSUFFIX" =~ *-8622*) then
grep -q CONFIG_IDF_TARGET_ESP8266=y "$SDKCONFIG"
if($status) then
echo You need to manually set ESP8266 build environment
exit 1
endif
else
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_FREERTOS_UNICORE CONFIG_SPIRAM CONFIG_REVK_PICO CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_4m.csv"
grep -q CONFIG_IDF_TARGET_ESP8266=y "$SDKCONFIG"
if($status) then
echo This build environment is for ESP8266, change to ESP32 based
exit 1
endif
endif

if("$BUILDSUFFIX" =~ *-V3*) then
set add=($add CONFIG_ESP32_REV_MIN_3)
set rem=($rem CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V2*) then
set add=($add CONFIG_ESP32_REV_MIN_2)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V1*) then
set add=($add CONFIG_ESP32_REV_MIN_1)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V0*) then
set add=($add CONFIG_ESP32_REV_MIN_0)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else # Default is V3
set add=($add CONFIG_ESP32_REV_MIN_3)
set rem=($rem CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
if("$BUILDSUFFIX" =~ *-S1*) then
grep -q CONFIG_IDF_TARGET_ESP32=y "$SDKCONFIG"
if($status) idf.py set-target esp32

# The settings PICO/D4/SOLO impact flash and PSRAM

if("$BUILDSUFFIX" =~ *-PICO*) then
set add=($add CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_8m.csv"
else if("$BUILDSUFFIX" =~ *-D4*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE CONFIG_REVK_D4)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO)
set part="components/ESP32-RevK/partitions_4m.csv"
else if("$BUILDSUFFIX" =~ *-SOLO*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_SPIRAM CONFIG_REVK_PICO CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_4m.csv"
else
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB)
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_FREERTOS_UNICORE CONFIG_SPIRAM CONFIG_REVK_PICO CONFIG_REVK_D4)
set part="components/ESP32-RevK/partitions_4m.csv"
endif

if("$BUILDSUFFIX" =~ *-V3*) then
set add=($add CONFIG_ESP32_REV_MIN_3)
set rem=($rem CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V2*) then
set add=($add CONFIG_ESP32_REV_MIN_2)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V1*) then
set add=($add CONFIG_ESP32_REV_MIN_1)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V0*) then
set add=($add CONFIG_ESP32_REV_MIN_0)
set rem=($rem CONFIG_ESP32_REV_MIN_3 CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
else # Default is V3
set add=($add CONFIG_ESP32_REV_MIN_3)
set rem=($rem CONFIG_ESP32_REV_MIN_2 CONFIG_ESP32_REV_MIN_1 CONFIG_ESP32_REV_MIN_0 CONFIG_ESP32_REV_MIN_1_1 CONFIG_ESP32_REV_MIN_3_1)
endif
endif

if("$BUILDSUFFIX" =~ *-S2*) then
grep -q CONFIG_IDF_TARGET_ESP32S2=y "$SDKCONFIG"
if($status) idf.py set-target esp32s2

endif

if("$BUILDSUFFIX" =~ *-S3*) then
grep -q CONFIG_IDF_TARGET_ESP32S3=y "$SDKCONFIG"
if($status) idf.py set-target esp32s3

if("$BUILDSUFFIX" =~ *-V2*) then
set add=($add CONFIG_ESP32S3_REV_MIN_2)
set rem=($rem CONFIG_ESP32S3_REV_MIN_3 CONFIG_ESP32S3_REV_MIN_1 CONFIG_ESP32S3_REV_MIN_0 CONFIG_ESP32S3_REV_MIN_1_1 CONFIG_ESP32S3_REV_MIN_3_1)
else if("$BUILDSUFFIX" =~ *-V1*) then
set add=($add CONFIG_ESP32S3_REV_MIN_1)
set rem=($rem CONFIG_ESP32S3_REV_MIN_3 CONFIG_ESP32S3_REV_MIN_2 CONFIG_ESP32S3_REV_MIN_0 CONFIG_ESP32S3_REV_MIN_1_1 CONFIG_ESP32S3_REV_MIN_3_1)
else # Default is V0
set add=($add CONFIG_ESP32S3_REV_MIN_0)
set rem=($rem CONFIG_ESP32S3_REV_MIN_3 CONFIG_ESP32S3_REV_MIN_2 CONFIG_ESP32S3_REV_MIN_1 CONFIG_ESP32S3_REV_MIN_1_1 CONFIG_ESP32S3_REV_MIN_3_1)
endif

if("$BUILDSUFFIX" =~ *-MINI*) then
set add=($add CONFIG_REVK_PICO)
else
set rem=($rem CONFIG_REVK_PICO)
endif

if("$BUILDSUFFIX" =~ *-N4*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_4MB)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_8MB CONFIG_FREERTOS_UNICORE)
set part="components/ESP32-RevK/partitions_4m.csv"
else if("$BUILDSUFFIX" =~ *-N8*) then
set add=($add CONFIG_ESPTOOLPY_FLASHSIZE_8MB)
set rem=($rem CONFIG_ESPTOOLPY_FLASHSIZE_4MB CONFIG_FREERTOS_UNICORE)
set part="components/ESP32-RevK/partitions_8m.csv"
endif

if("$BUILDSUFFIX" =~ *-R2*) then
set add=($add CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_SPIRAM)
else
set rem=($rem CONFIG_ESP32_SPIRAM_SUPPORT CONFIG_SPIRAM)
endif
endif

if("$BUILDSUFFIX" =~ *-C3*) then
grep -q CONFIG_IDF_TARGET_ESP32C3=y "$SDKCONFIG"
if($status) idf.py set-target esp32c3

endif

if("$BUILDSUFFIX" =~ *-H2*) then
grep -q CONFIG_IDF_TARGET_ESP32H2=y "$SDKCONFIG"
if($status) idf.py set-target esp32h2

endif

set bs=(`grep _BUILD_SUFFIX_ sdkconfig | sed 's/.*\(CONFIG_[A-Z0-9_]*_BUILD_SUFFIX_[A-Z0-9]*\).*/\1/'`)
Expand Down

0 comments on commit 4ee5af7

Please sign in to comment.