From 9c5001223f50778c0c83e516b8bcf65697184879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Fri, 26 Jul 2019 15:27:17 +0100 Subject: [PATCH] Add network default config to F4 and F7 boards - Following nanoframework/nf-interpreter#1422. --- .../common/CMakeLists.txt | 1 + .../common/targetHAL_ConfigurationManager.cpp | 35 +++++++++++++++++++ .../common/CMakeLists.txt | 1 + .../common/targetHAL_ConfigurationManager.cpp | 35 +++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100644 targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F469_NF/common/targetHAL_ConfigurationManager.cpp create mode 100644 targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F769_NF/common/targetHAL_ConfigurationManager.cpp diff --git a/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F469_NF/common/CMakeLists.txt b/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F469_NF/common/CMakeLists.txt index aa7f1d543b..c4291c25da 100644 --- a/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F469_NF/common/CMakeLists.txt +++ b/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F469_NF/common/CMakeLists.txt @@ -6,6 +6,7 @@ # append common source files list(APPEND COMMON_PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/usbcfg.c") list(APPEND COMMON_PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Device_BlockStorage$<$,$>:-DEBUG>.c") +list(APPEND COMMON_PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/targetHAL_ConfigurationManager.cpp") # make var global set(COMMON_PROJECT_SOURCES ${COMMON_PROJECT_SOURCES} CACHE INTERNAL "make global") diff --git a/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F469_NF/common/targetHAL_ConfigurationManager.cpp b/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F469_NF/common/targetHAL_ConfigurationManager.cpp new file mode 100644 index 0000000000..178f6aa783 --- /dev/null +++ b/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F469_NF/common/targetHAL_ConfigurationManager.cpp @@ -0,0 +1,35 @@ +// +// Copyright (c) 2019 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +#include +#include +#include +#include + +// Default initialisation for Network interface config blocks +// strong implementation replacing ChibiOS 'weak' one +bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface * pconfig, uint32_t configurationIndex) +{ + (void)configurationIndex; + + // make sure the config block marker is set + memcpy(pconfig->Marker, c_MARKER_CONFIGURATION_NETWORK_V1, sizeof(c_MARKER_CONFIGURATION_NETWORK_V1)); + + pconfig->InterfaceType = NetworkInterfaceType_Ethernet; + pconfig->StartupAddressMode = AddressMode_DHCP; + pconfig->AutomaticDNS = 1; + pconfig->SpecificConfigId = 0; + + // set MAC address with ST provided MAC for development boards + // 00:80:E1:01:35:D1 + pconfig->MacAddress[0] = 0x00; + pconfig->MacAddress[1] = 0x80; + pconfig->MacAddress[2] = 0xE1; + pconfig->MacAddress[3] = 0x01; + pconfig->MacAddress[4] = 0x35; + pconfig->MacAddress[5] = 0xD1; + + return true; +} diff --git a/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F769_NF/common/CMakeLists.txt b/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F769_NF/common/CMakeLists.txt index 117789309b..a3fc3f8488 100644 --- a/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F769_NF/common/CMakeLists.txt +++ b/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F769_NF/common/CMakeLists.txt @@ -6,6 +6,7 @@ # append common source files list(APPEND COMMON_PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/usbcfg.c") list(APPEND COMMON_PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/Device_BlockStorage$<$,$>:-DEBUG>.c") +list(APPEND COMMON_PROJECT_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/targetHAL_ConfigurationManager.cpp") # make var global set(COMMON_PROJECT_SOURCES ${COMMON_PROJECT_SOURCES} CACHE INTERNAL "make global") diff --git a/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F769_NF/common/targetHAL_ConfigurationManager.cpp b/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F769_NF/common/targetHAL_ConfigurationManager.cpp new file mode 100644 index 0000000000..178f6aa783 --- /dev/null +++ b/targets/CMSIS-OS/ChibiOS/ORGPAL_PAL3_STM32F769_NF/common/targetHAL_ConfigurationManager.cpp @@ -0,0 +1,35 @@ +// +// Copyright (c) 2019 The nanoFramework project contributors +// See LICENSE file in the project root for full license information. +// + +#include +#include +#include +#include + +// Default initialisation for Network interface config blocks +// strong implementation replacing ChibiOS 'weak' one +bool InitialiseNetworkDefaultConfig(HAL_Configuration_NetworkInterface * pconfig, uint32_t configurationIndex) +{ + (void)configurationIndex; + + // make sure the config block marker is set + memcpy(pconfig->Marker, c_MARKER_CONFIGURATION_NETWORK_V1, sizeof(c_MARKER_CONFIGURATION_NETWORK_V1)); + + pconfig->InterfaceType = NetworkInterfaceType_Ethernet; + pconfig->StartupAddressMode = AddressMode_DHCP; + pconfig->AutomaticDNS = 1; + pconfig->SpecificConfigId = 0; + + // set MAC address with ST provided MAC for development boards + // 00:80:E1:01:35:D1 + pconfig->MacAddress[0] = 0x00; + pconfig->MacAddress[1] = 0x80; + pconfig->MacAddress[2] = 0xE1; + pconfig->MacAddress[3] = 0x01; + pconfig->MacAddress[4] = 0x35; + pconfig->MacAddress[5] = 0xD1; + + return true; +}