@@ -153,7 +153,12 @@ bool AppendConfigBlock(
153153void ConfigurationManager_EnumerateConfigurationBlocks ()
154154{
155155 HAL_CONFIGURATION_NETWORK *networkConfigs = ConfigStorage_FindNetworkConfigurationBlocks ();
156- ESP_LOGI (TAG, " ConfigurationManager_EnumerateConfigurationBlocks %d" ,networkConfigs->Count );
156+ if (networkConfigs == NULL )
157+ {
158+ ESP_LOGE (TAG, " FindNetworkConfigurationBlocks returned NULL(out of memory)" );
159+ return ;
160+ }
161+
157162 // check network configs count
158163 if (networkConfigs->Count == 0 )
159164 {
@@ -178,8 +183,6 @@ ESP_LOGI(TAG, "ConfigurationManager_EnumerateConfigurationBlocks %d",networkConf
178183#if HAL_USE_THREAD == TRUE
179184 netTypes[networkCount++] = NetworkInterfaceType_Thread;
180185#endif
181- ESP_LOGI (TAG, " networkCount %d" , networkCount);
182-
183186 // allocate memory for ONE network configuration
184187 HAL_Configuration_NetworkInterface *networkConfig =
185188 (HAL_Configuration_NetworkInterface *)platform_malloc (sizeof (HAL_Configuration_NetworkInterface));
@@ -207,7 +210,7 @@ ESP_LOGI(TAG, "networkCount %d", networkCount);
207210
208211 // have to enumerate again to pick it up
209212 networkConfigs = ConfigStorage_FindNetworkConfigurationBlocks ();
210- ESP_LOGI (TAG, " networkCount %d/%d" , networkCount, networkConfigs->Count );
213+ ESP_LOGI (TAG, " networkCount %d/%d" , networkCount, networkConfigs->Count );
211214 }
212215
213216 // find wireless 80211 network configuration blocks
@@ -353,6 +356,8 @@ void InitialiseWirelessAPDefaultConfig(HAL_Configuration_WirelessAP *config, uin
353356// Default initialisation of Network interface config blocks for ESP32 targets
354357bool InitialiseNetworkDefaultConfig (HAL_Configuration_NetworkInterface *config, uint32_t configurationIndex)
355358{
359+ esp_err_t err = ESP_OK;
360+
356361 // make sure the config block marker is set
357362 memcpy (config->Marker , c_MARKER_CONFIGURATION_NETWORK_V1, sizeof (c_MARKER_CONFIGURATION_NETWORK_V1));
358363
@@ -364,7 +369,7 @@ bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface *config,
364369 config->SpecificConfigId = 0 ;
365370
366371 // get default MAC for interface
367- esp_read_mac (config->MacAddress , ESP_MAC_WIFI_STA);
372+ err = esp_read_mac (config->MacAddress , ESP_MAC_WIFI_STA);
368373 break ;
369374
370375 case NetworkInterfaceType_WirelessAP: // Wireless AP
@@ -376,15 +381,15 @@ bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface *config,
376381 // config->IPv4GatewayAddress
377382
378383 // get default MAC for interface
379- esp_read_mac (config->MacAddress , ESP_MAC_WIFI_SOFTAP);
384+ err = esp_read_mac (config->MacAddress , ESP_MAC_WIFI_SOFTAP);
380385 break ;
381386
382387 case NetworkInterfaceType_Ethernet: // Ethernet
383388 config->StartupAddressMode = AddressMode_DHCP;
384389 config->AutomaticDNS = 1 ;
385390
386391 // get default MAC for interface
387- esp_read_mac (config->MacAddress , ESP_MAC_ETH);
392+ err = esp_read_mac (config->MacAddress , ESP_MAC_ETH);
388393 break ;
389394
390395#if HAL_USE_THREAD == TRUE
@@ -398,6 +403,12 @@ bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface *config,
398403 break ;
399404 }
400405
406+ if (err != ESP_OK)
407+ {
408+ // On ESP32_P4 esp_read_mac can fail
409+ esp_efuse_mac_get_default (config->MacAddress );
410+ }
411+
401412 // always good
402413 return TRUE ;
403414}
0 commit comments