Skip to content

Commit d99b4b8

Browse files
shripad621gitshubhamdp
authored andcommitted
[ESP32] Compilation fix when IPV4 is disabled. (project-chip#33085)
* Compilation fix when IPV4 is disabled. * Addressed review comments and documented the IPv4 disabled change * Update docs/guides/esp32/config_options.md Co-authored-by: Shubham Patil <shubham.patil@espressif.com> * Update docs/guides/esp32/config_options.md Co-authored-by: Shubham Patil <shubham.patil@espressif.com> * Resolved the build failure for m5-stack ipv6 only test --------- Co-authored-by: Shubham Patil <shubham.patil@espressif.com>
1 parent f2a9022 commit d99b4b8

File tree

11 files changed

+39
-1
lines changed

11 files changed

+39
-1
lines changed

config/esp32/components/chip/CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,11 @@ chip_gn_arg_append("chip_config_network_layer_ble" "false")
118118
endif()
119119

120120
if(CONFIG_DISABLE_IPV4)
121-
chip_gn_arg_append("chip_inet_config_enable_ipv4" "false")
121+
if(NOT CONFIG_LWIP_IPV4)
122+
chip_gn_arg_append("chip_inet_config_enable_ipv4" "false")
123+
else()
124+
message(FATAL_ERROR "Please also disable config option CONFIG_LWIP_IPV4")
125+
endif()
122126
endif()
123127

124128
if(CONFIG_DISABLE_READ_CLIENT)

docs/guides/esp32/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ example on ESP32 series of SoCs
1919
- [Generating and Using ESP Secure Cert Partition](secure_cert_partition.md)
2020
- [BLE Settings](ble_settings.md)
2121
- [Providers](providers.md)
22+
- [Configuration Options](config_options.md)

docs/guides/esp32/config_options.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Configuration options
2+
3+
This file lists down few config options to be configured through menuconfig for
4+
specific scenarios.
5+
6+
### Building with IPV4 Disabled
7+
8+
Configure below options through `idf.py menuconfig` and build the app.
9+
10+
```
11+
CONFIG_DISABLE_IPV4=y
12+
CONFIG_LWIP_IPV4=n
13+
```

examples/chef/chef.py

+4
Original file line numberDiff line numberDiff line change
@@ -706,9 +706,13 @@ def main() -> int:
706706
if sys.platform == "darwin":
707707
shell.run_cmd(
708708
"sed -i '' 's/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/CONFIG_DISABLE_IPV4=y/g' sdkconfig ")
709+
shell.run_cmd(
710+
"sed -i '' 's/CONFIG_LWIP_IPV4=y/#\\ CONFIG_LWIP_IPV4\\ is\\ not\\ set/g' sdkconfig ")
709711
else:
710712
shell.run_cmd(
711713
"sed -i 's/#\\ CONFIG_DISABLE_IPV4\\ is\\ not\\ set/CONFIG_DISABLE_IPV4=y/g' sdkconfig ")
714+
shell.run_cmd(
715+
"sed -i 's/CONFIG_LWIP_IPV4=y/#\\ CONFIG_LWIP_IPV4\\ is\\ not\\ set/g' sdkconfig ")
712716

713717
shell.run_cmd("idf.py build")
714718
shell.run_cmd("idf.py build flashing_script")

examples/chef/esp32/sdkconfig.defaults

+3
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ CONFIG_LWIP_IPV6_AUTOCONFIG=y
3939
# disable IPV4
4040
# CONFIG_DISABLE_IPV4 is not set
4141

42+
# lwip IPV4 config
43+
CONFIG_LWIP_IPV4=y
44+
4245
# Use a custom partition table
4346
CONFIG_PARTITION_TABLE_CUSTOM=y
4447
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"

examples/chef/esp32/sdkconfig_rpc.defaults

+3
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ CONFIG_LWIP_IPV6_AUTOCONFIG=y
3636
# disable IPV4
3737
# CONFIG_DISABLE_IPV4 is not set
3838

39+
# lwip configuration
40+
CONFIG_LWIP_IPV4=y
41+
3942
# Use a custom partition table
4043
CONFIG_PARTITION_TABLE_CUSTOM=y
4144
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"

examples/platform/esp32/Rpc.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,15 @@ class Esp32WiFi final : public WiFi
197197
return pw::OkStatus();
198198
}
199199

200+
#if CHIP_DEVICE_CONFIG_ENABLE_IPV4
200201
pw::Status GetIP4Address(const pw_protobuf_Empty & request, chip_rpc_IP4Address & response) override
201202
{
202203
esp_netif_ip_info_t ip_info;
203204
PW_TRY(EspToPwStatus(esp_netif_get_ip_info(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF"), &ip_info)));
204205
snprintf(response.address, sizeof(response.address), IPSTR, IP2STR(&ip_info.ip));
205206
return pw::OkStatus();
206207
}
208+
#endif
207209

208210
pw::Status GetIP6Address(const pw_protobuf_Empty & request, chip_rpc_IP6Address & response) override
209211
{

scripts/build/builders/esp32.py

+2
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ def generate(self):
197197
if not self.enable_ipv4:
198198
self._Execute(
199199
['bash', '-c', 'echo -e "\\nCONFIG_DISABLE_IPV4=y\\n" >>%s' % shlex.quote(defaults_out)])
200+
self._Execute(
201+
['bash', '-c', 'echo -e "\\nCONFIG_LWIP_IPV4=n\\n" >>%s' % shlex.quote(defaults_out)])
200202

201203
if self.enable_insights_trace:
202204
insights_flag = 'y'

scripts/build/testdata/dry_run_esp32-m5stack-all-clusters-minimal-rpc-ipv6only.txt

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ rm -f examples/all-clusters-minimal-app/esp32/sdkconfig
1010

1111
bash -c 'echo -e "\nCONFIG_DISABLE_IPV4=y\n" >>{out}/esp32-m5stack-all-clusters-minimal-rpc-ipv6only/sdkconfig.defaults'
1212

13+
bash -c 'echo -e "\nCONFIG_LWIP_IPV4=n\n" >>{out}/esp32-m5stack-all-clusters-minimal-rpc-ipv6only/sdkconfig.defaults'
14+
1315
bash -c 'echo -e "\nCONFIG_ESP_INSIGHTS_ENABLED=n\nCONFIG_ENABLE_ESP_INSIGHTS_TRACE=n\n" >>{out}/esp32-m5stack-all-clusters-minimal-rpc-ipv6only/sdkconfig.defaults'
1416

1517
bash -c 'source $IDF_PATH/export.sh; source scripts/activate.sh;

src/platform/ESP32/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import("//build_overrides/chip.gni")
1616

17+
import("${chip_root}/src/inet/inet.gni")
1718
import("${chip_root}/src/platform/device.gni")
1819

1920
assert(chip_device_platform == "esp32")
@@ -36,6 +37,7 @@ declare_args() {
3637

3738
defines = [
3839
"CHIP_CONFIG_SOFTWARE_VERSION_NUMBER=${chip_config_software_version_number}",
40+
"CHIP_DEVICE_CONFIG_ENABLE_IPV4=${chip_inet_config_enable_ipv4}",
3941
]
4042

4143
static_library("ESP32") {

src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void)
999999
// If the station interface has been assigned an IPv4 address, and has
10001000
// an IPv4 gateway, then presume that the device has IPv4 Internet
10011001
// connectivity.
1002+
#if CHIP_DEVICE_CONFIG_ENABLE_IPV4
10021003
if (!ip4_addr_isany_val(*netif_ip4_addr(netif)) && !ip4_addr_isany_val(*netif_ip4_gw(netif)))
10031004
{
10041005
haveIPv4Conn = true;
@@ -1013,6 +1014,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void)
10131014
IPAddress::FromString(addrStr, addr);
10141015
}
10151016
}
1017+
#endif
10161018

10171019
// Search among the IPv6 addresses assigned to the interface for a Global Unicast
10181020
// address (2000::/3) that is in the valid state. If such an address is found...

0 commit comments

Comments
 (0)