Custom board/ethernet PHY: advice required on best approach

I’ve developed a custom board which is similar to the Nucleo F207 board but uses a Ti DP83825 PHY.

To get the DP83825 PHY working with STM32Ethernet I have had to make a number of modifications. Most of these can be handled elegantly using the custom boards approach and redefining weakly defined functions.

I have also had to modify stm32f2xx_hal_eth.c. At present, I have done this by editing stm32f2xx_hal_eth.c in .platformio/packages/framework-arduinoststm32/system/Drivers/STM32F2xx_HAL_Driver/Src/ but these mods will be gone if/when I do a stm32 platform upgrade.

What is the best approach to having a custom stm32f2xx_hal_eth.c?

You can just copy or upload your modified framework-arduinoststm32 folder somewhere then reference it as a the source of the framework-arduinoststm32 package per platform_packages — PlatformIO latest documentation.

Fantastic. That’s exactly what I needed to know. Many thanks @maxgerhardt .

I’ve copied my modified framework-arduinoststm32 folder to another location on my hard drive (C:\Frameworks\framework-arduinoststm32) and modified my platformio.ini file by adding the following section

[env:external_package]
platform = ststm32
platform_packages = framework-arduinoststm32@C:\Frameworks\framework-arduinoststm32

And I get the following error:

“Error: VCS: Unknown repository type C:\Frameworks\framework-arduinoststm32”

Any ideas?

Sorry. I’m a twit. I needed file:// in front of the path.

That will make a copy of the folder into the PlatformIO packages folder (C:\Users\<user>\.platformio\packages\<package>). It’s more efficient to do a symbolic link, that’s zero-copy by using symlink://. See docs

https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_install.html#local-folder

The symlink would be a better approach but I’ve just given symlink:// a try and get an error message of

TypeError: expected str, bytes or os.PathLike object, not NoneType:

from platformio\builder\main.py. I’m on Windows 11.

Also, for additional context, I removed the [env:external_package] section from platformio.ini and added platform_packages into my [env:customboard] section.

And you’re using

platform_packages =
   framework-arduinoststm32@symlink://C:/Frameworks/framework-arduinoststm32

?

Yes.

platform_packages = framework-arduinoststm32@file://C:\Frameworks\framework-arduinoststm32

works as expected but

platform_packages = framework-arduinoststm32@symlink://C:\Frameworks\framework-arduinoststm32

gives me the error.

I see that a framework-arduinoststm32.pio-link file is created in C:\Users\<user>\.platformio\packages and it looks to have the correct contents:

{“cwd”: “c:\Users\\Documents\PlatformIO\Projects\<project_name>”, “spec”: {“owner”: “platformio”, “id”: null, “name”: “framework-arduinoststm32”, “requirements”: null, “uri”: “symlink://C:\\Frameworks\\framework-arduinoststm32”}}

Does this folder already contain a .piopm file? If yes that should be deleted. Also I used / instead of \ as my path separator, this should also work on Windows.

Many thanks. The framework-arduinoststm32 folder did contain a .piopm file. Deleting it then made the change symlink:// work without issue.

Out of interest, what is the purpose of the .piopm file?

I think it’s PlatformIO’s package-manager (piopm) metadata file and the info inside it may have pointed to old info, wheres with file:// it may have been regenerated – though I really am not familiar with the code behind it.

In any case, just know that you can also point at git repositories and ZIP download links with platform_packages, so if you upload the framework folder somewhere and point to it in the platformio.ini, the project is 100% distributable to other computers without relying on local paths.

1 Like