From 2a5425bd7e3087c9b00a84bc8fa963e5891acda7 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 9 Oct 2024 12:31:38 +0200 Subject: [PATCH 1/5] Support Portenta H7 with MID carrier Pro Demo kit --- src/Arduino_10BASE_T1S.h | 6 ++++++ src/MacAddress.cpp | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Arduino_10BASE_T1S.h b/src/Arduino_10BASE_T1S.h index 78d7306..8a60479 100644 --- a/src/Arduino_10BASE_T1S.h +++ b/src/Arduino_10BASE_T1S.h @@ -40,6 +40,12 @@ static int const IRQ_PIN = 2; static int const CS_PIN = 9; static int const RESET_PIN = 4; static int const IRQ_PIN = 2; +#elif defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) +/* Pro Demo kit on MID carrier, UNO form factor */ +#include "pinDefinitions.h" +static int const CS_PIN = PinNameToIndex(PH_6); +static int const RESET_PIN = PinNameToIndex(PJ_11); +static int const IRQ_PIN = PinNameToIndex(PC_7); #else # error "No pins defined for your board" #endif diff --git a/src/MacAddress.cpp b/src/MacAddress.cpp index fa7ab24..4cf6e57 100644 --- a/src/MacAddress.cpp +++ b/src/MacAddress.cpp @@ -101,7 +101,11 @@ void get_unique_chip_id_3(uint8_t * uid) bsp_unique_id_t const * renesas_unique_id = (bsp_unique_id_t *) BSP_FEATURE_BSP_UNIQUE_ID_POINTER; memcpy(uid, renesas_unique_id->unique_id_bytes, 3); } -#elif defined(ARDUINO_GIGA) +#elif defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) + { + uint32_t const stm32_uid = HAL_GetUIDw2(); + memcpy(uid, &stm32_uid, 3); + } { auto stm32_uid = HAL_GetUIDw2(); memcpy(uid, &stm32_uid, 3); From 1238ad3a8ce512b81dc808cab6e22acbf257b2d4 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Wed, 9 Oct 2024 12:49:52 +0200 Subject: [PATCH 2/5] Port to Portenta C33 and simplify uniqueID for Renesas platforms --- src/Arduino_10BASE_T1S.h | 5 +++++ src/MacAddress.cpp | 28 ++++++++++------------------ 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/Arduino_10BASE_T1S.h b/src/Arduino_10BASE_T1S.h index 8a60479..8f1d1a3 100644 --- a/src/Arduino_10BASE_T1S.h +++ b/src/Arduino_10BASE_T1S.h @@ -46,6 +46,11 @@ static int const IRQ_PIN = 2; static int const CS_PIN = PinNameToIndex(PH_6); static int const RESET_PIN = PinNameToIndex(PJ_11); static int const IRQ_PIN = PinNameToIndex(PC_7); +#elif defined(ARDUINO_PORTENTA_C33) +/* Pro Demo kit on MID carrier, UNO form factor */ +static int const CS_PIN = 25; +static int const RESET_PIN = 4; +static int const IRQ_PIN = 2; #else # error "No pins defined for your board" #endif diff --git a/src/MacAddress.cpp b/src/MacAddress.cpp index 4cf6e57..e284d9c 100644 --- a/src/MacAddress.cpp +++ b/src/MacAddress.cpp @@ -82,24 +82,10 @@ void get_unique_chip_id_3(uint8_t * uid) uint32_t const samd_uid = *(volatile uint32_t*)(0x0080A048); memcpy(uid, &samd_uid, 3); } -#elif defined(ARDUINO_MINIMA) || defined(ARDUINO_UNOWIFIR4) +#elif defined(ARDUINO_MINIMA) || defined(ARDUINO_UNOWIFIR4) || defined(ARDUINO_PORTENTA_C33) { - #define BSP_FEATURE_BSP_MCU_INFO_POINTER_LOCATION (0x407FB19C) - #define BSP_FEATURE_BSP_UNIQUE_ID_OFFSET (0x14) - #define BSP_FEATURE_BSP_UNIQUE_ID_POINTER ((*(uint32_t *) BSP_FEATURE_BSP_MCU_INFO_POINTER_LOCATION) \ - + \ - BSP_FEATURE_BSP_UNIQUE_ID_OFFSET) - typedef struct st_bsp_unique_id - { - union - { - uint32_t unique_id_words[4]; - uint8_t unique_id_bytes[16]; - }; - } bsp_unique_id_t; - - bsp_unique_id_t const * renesas_unique_id = (bsp_unique_id_t *) BSP_FEATURE_BSP_UNIQUE_ID_POINTER; - memcpy(uid, renesas_unique_id->unique_id_bytes, 3); + const bsp_unique_id_t* t = R_BSP_UniqueIdGet(); + memcpy(uid, t->unique_id_bytes, 3); } #elif defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4) { @@ -113,4 +99,10 @@ void get_unique_chip_id_3(uint8_t * uid) #else # error "Retrieving a unique chip ID for MAC generation is not supported on this platform." #endif -} \ No newline at end of file +} + +#if defined(ARDUINO_PORTENTA_C33) +extern "C" int LWIP_RAND() { + return rand(); +} +#endif \ No newline at end of file From 55f592f588c04a3e6904bf40c57b68a492ddb0bc Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 17 Oct 2024 09:43:53 +0200 Subject: [PATCH 3/5] Enable support for Portenta C33 by - using SPI1 in examples - adding CI build and - listing the architecture in library.properties . --- .github/workflows/compile-examples.yml | 3 +++ examples/UDP_Client/UDP_Client.ino | 2 +- examples/UDP_Server/UDP_Server.ino | 2 +- examples/iperf-client/iperf-client.ino | 2 +- examples/tools/Control-DIOx/Control-DIOx.ino | 2 +- .../tools/PoDL-Sink-Auto-TurnOff/PoDL-Sink-Auto-TurnOff.ino | 2 +- examples/tools/PoDL-Source/PoDL-Source.ino | 2 +- library.properties | 2 +- 8 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 980b3c1..6d47f41 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -42,6 +42,9 @@ jobs: - fqbn: arduino:renesas_uno:unor4wifi platforms: | - name: arduino:renesas_uno + - fqbn: arduino:renesas_portenta:portenta_c33 + platforms: | + - name: arduino:renesas_portenta - fqbn: arduino:mbed_giga:giga platforms: | - name: arduino:mbed_giga diff --git a/examples/UDP_Client/UDP_Client.ino b/examples/UDP_Client/UDP_Client.ino index a420f5e..e34eb4f 100644 --- a/examples/UDP_Client/UDP_Client.ino +++ b/examples/UDP_Client/UDP_Client.ino @@ -35,7 +35,7 @@ static uint16_t const UDP_SERVER_PORT = 8888; **************************************************************************************/ auto const tc6_io = new TC6::TC6_Io( -#ifdef ARDUINO_GIGA +#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33) SPI1 #else SPI diff --git a/examples/UDP_Server/UDP_Server.ino b/examples/UDP_Server/UDP_Server.ino index d694f4d..a552952 100644 --- a/examples/UDP_Server/UDP_Server.ino +++ b/examples/UDP_Server/UDP_Server.ino @@ -39,7 +39,7 @@ static uint16_t const UDP_SERVER_LOCAL_PORT = 8888; **************************************************************************************/ auto const tc6_io = new TC6::TC6_Io( -#ifdef ARDUINO_GIGA +#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33) SPI1 #else SPI diff --git a/examples/iperf-client/iperf-client.ino b/examples/iperf-client/iperf-client.ino index cb34ee6..086d700 100644 --- a/examples/iperf-client/iperf-client.ino +++ b/examples/iperf-client/iperf-client.ino @@ -42,7 +42,7 @@ static T1SMacSettings const t1s_mac_settings{MAC_PROMISCUOUS_MODE, MAC_TX_CUT_TH **************************************************************************************/ auto const tc6_io = new TC6::TC6_Io( -#ifdef ARDUINO_GIGA +#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33) SPI1 #else SPI diff --git a/examples/tools/Control-DIOx/Control-DIOx.ino b/examples/tools/Control-DIOx/Control-DIOx.ino index 86662aa..113f1b1 100644 --- a/examples/tools/Control-DIOx/Control-DIOx.ino +++ b/examples/tools/Control-DIOx/Control-DIOx.ino @@ -36,7 +36,7 @@ static auto const DIO_PIN = TC6::DIO::A0; **************************************************************************************/ auto const tc6_io = new TC6::TC6_Io( -#ifdef ARDUINO_GIGA +#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33) SPI1 #else SPI diff --git a/examples/tools/PoDL-Sink-Auto-TurnOff/PoDL-Sink-Auto-TurnOff.ino b/examples/tools/PoDL-Sink-Auto-TurnOff/PoDL-Sink-Auto-TurnOff.ino index 0ff5a67..4047e6a 100644 --- a/examples/tools/PoDL-Sink-Auto-TurnOff/PoDL-Sink-Auto-TurnOff.ino +++ b/examples/tools/PoDL-Sink-Auto-TurnOff/PoDL-Sink-Auto-TurnOff.ino @@ -33,7 +33,7 @@ static T1SMacSettings const t1s_default_mac_settings; **************************************************************************************/ auto const tc6_io = new TC6::TC6_Io( -#ifdef ARDUINO_GIGA +#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33) SPI1 #else SPI diff --git a/examples/tools/PoDL-Source/PoDL-Source.ino b/examples/tools/PoDL-Source/PoDL-Source.ino index eb866dd..6292f47 100644 --- a/examples/tools/PoDL-Source/PoDL-Source.ino +++ b/examples/tools/PoDL-Source/PoDL-Source.ino @@ -33,7 +33,7 @@ static T1SMacSettings const t1s_default_mac_settings; **************************************************************************************/ auto const tc6_io = new TC6::TC6_Io( -#ifdef ARDUINO_GIGA +#if defined(ARDUINO_GIGA) || defined(ARDUINO_PORTENTA_C33) SPI1 #else SPI diff --git a/library.properties b/library.properties index b949f3a..8914f47 100644 --- a/library.properties +++ b/library.properties @@ -6,4 +6,4 @@ sentence=Generic library for providing IP based 10BASE-T1S communication. paragraph=This Arduino library provides both low-level drivers and high-level abstractions to perform real-time communication via 10BASE-T1S, a multi-drop capable Ethernet standard. category=Communication url=https://github.com/arduino-libraries/Arduino_10BASE_T1S -architectures=samd,renesas_uno,mbed_giga \ No newline at end of file +architectures=samd,renesas_uno,renesas_portenta,mbed_giga \ No newline at end of file From ce62fb0283c97533ff03b7df76dd5bb536f7520b Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 17 Oct 2024 09:55:45 +0200 Subject: [PATCH 4/5] Enable support for Portenta H7 by - adding CI build and - listing the architecture in library.properties . --- .github/workflows/compile-examples.yml | 3 +++ library.properties | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/compile-examples.yml b/.github/workflows/compile-examples.yml index 6d47f41..2d2b7ed 100644 --- a/.github/workflows/compile-examples.yml +++ b/.github/workflows/compile-examples.yml @@ -48,6 +48,9 @@ jobs: - fqbn: arduino:mbed_giga:giga platforms: | - name: arduino:mbed_giga + - fqbn: arduino:mbed_portenta:envie_m7 + platforms: | + - name: arduino:mbed_portenta steps: - name: Checkout diff --git a/library.properties b/library.properties index 8914f47..c119f2c 100644 --- a/library.properties +++ b/library.properties @@ -6,4 +6,4 @@ sentence=Generic library for providing IP based 10BASE-T1S communication. paragraph=This Arduino library provides both low-level drivers and high-level abstractions to perform real-time communication via 10BASE-T1S, a multi-drop capable Ethernet standard. category=Communication url=https://github.com/arduino-libraries/Arduino_10BASE_T1S -architectures=samd,renesas_uno,renesas_portenta,mbed_giga \ No newline at end of file +architectures=samd,renesas_uno,renesas_portenta,mbed_giga,mbed_portenta \ No newline at end of file From ee39194b73503a53c2eb856b008264c07e61e50a Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 17 Oct 2024 09:57:00 +0200 Subject: [PATCH 5/5] Adding empty-line at end of library.properties and MacAddress.cpp. --- library.properties | 2 +- src/MacAddress.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library.properties b/library.properties index c119f2c..3ebb7a8 100644 --- a/library.properties +++ b/library.properties @@ -6,4 +6,4 @@ sentence=Generic library for providing IP based 10BASE-T1S communication. paragraph=This Arduino library provides both low-level drivers and high-level abstractions to perform real-time communication via 10BASE-T1S, a multi-drop capable Ethernet standard. category=Communication url=https://github.com/arduino-libraries/Arduino_10BASE_T1S -architectures=samd,renesas_uno,renesas_portenta,mbed_giga,mbed_portenta \ No newline at end of file +architectures=samd,renesas_uno,renesas_portenta,mbed_giga,mbed_portenta diff --git a/src/MacAddress.cpp b/src/MacAddress.cpp index e284d9c..682b9b9 100644 --- a/src/MacAddress.cpp +++ b/src/MacAddress.cpp @@ -105,4 +105,4 @@ void get_unique_chip_id_3(uint8_t * uid) extern "C" int LWIP_RAND() { return rand(); } -#endif \ No newline at end of file +#endif