Error in my new custom platform

I created a clone of platform-atmelsam and modified it to work with the Omzlo NoCAN CANZERO boards. I used the guide “Custom Development Platforms”.

The CANZERO board is essentially an Arduino MKR ZERO clone, but with a custom CAN-based network. The network is managed by a Raspberry-Pi HAT. The nocanc daemon runs on the Raspberry and exposes an API to the network.

A development machine can upload code using the nocanc binary through the raspberry using the NoCAN network directly to a CANZERO board.

Connected nodes can be listed with

./nocanc list-nodes
# Listing 1 nodes.
#7      f6:69:0f:c7:bd:35:19:65 connected       2022-11-29T13:51:28.34715333Z

The binary can be uploaded using

./nocanc upload nocan-blink.ino.omzlo_canzero.hex 7
Starting upload.
Progress: 98%, 5056 bytes, 8089 bps.
Done, uploaded 5088 bytes in 5.1 seconds.

I tried to make all the necessary changes, but now platform.io gives an error when I navigate to “Platforms” in VisualStudioCode (platform.io) on macOS.

PIO Core Call Error: "Error: Traceback (most recent call last):
[block removed because of new user link limit]
   .platformio/penv/lib/python3.9/site-packages/platformio/platform/factory.py\", line 77, in new
 platform_cls = getattr(
AttributeError: module 'platformio.platform.nocan' has no attribute 'NocanPlatform'

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
 `pip install -U platformio` command

============================================================"

What I am missing?

Full Error:

PIO Core Call Error: "Error: Traceback (most recent call last):
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/platformio/__main__.py\", line 102, in main
 cli() # pylint: disable=no-value-for-parameter
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/click/core.py\", line 1130, in __call__
 return self.main(*args, **kwargs)
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/click/core.py\", line 1055, in main
 rv = self.invoke(ctx)
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/platformio/cli.py\", line 71, in invoke
 return super().invoke(ctx)
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/click/core.py\", line 1657, in invoke
 return _process_result(sub_ctx.command.invoke(sub_ctx))
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/click/core.py\", line 1657, in invoke
 return _process_result(sub_ctx.command.invoke(sub_ctx))
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/click/core.py\", line 1404, in invoke
 return ctx.invoke(self.callback, **ctx.params)
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/click/core.py\", line 760, in invoke
 return __callback(*args, **kwargs)
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/click/decorators.py\", line 26, in new_func
 return f(get_current_context(), *args, **kwargs)
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/platformio/commands/platform.py\", line 121, in platform_list
 _get_installed_platform_data(pkg, with_boards=False, expose_packages=False)
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/platformio/commands/platform.py\", line 300, in _get_installed_platform_data
 p = PlatformFactory.new(platform)
 File \"/Users/dani/.platformio/penv/lib/python3.9/site-packages/platformio/platform/factory.py\", line 77, in new
 platform_cls = getattr(
AttributeError: module 'platformio.platform.nocan' has no attribute 'NocanPlatform'

============================================================

An unexpected error occurred. Further steps:

* Verify that you have the latest version of PlatformIO using
 `pip install -U platformio` command

* Try to find answer in FAQ Troubleshooting section
 https://docs.platformio.org/page/faq/index.html

* Report this problem to the developers
 https://github.com/platformio/platformio-core/issues

============================================================"

Link to the NoCAN documentation: Omzlo: The Omzlo CANZERO

Duplicate of Custom Platform no attribute for 'platformio.platform...'.

1 Like

Oh thanks! That was the solution, how could I not see it :upside_down_face:

Once you rename the platform, you need to give it that expected class name in platform.py too. Leaving it at