Skip to content

Conversation

@rahul-arasikere
Copy link
Contributor

I have been developing with the Arduino Portenta H7 with the machine controller shield and I had noticed some of the peripherals were not enabled in the device tree. As such I have enabled a few of them and done some basic testing to ensure they work.

I have opened this pull request to see if there was any interest in merging them upstream and plan to in the coming few weeks to add support for the additional features of the board in a seperate pull request.

This pull request adds support for the following:

  • Enables the external LSE (32.768 KHz) and HSE (25 MHz) clocks
  • Modifies the clock tree to change the SYSCLK from 96 MHz to 480 Mhz for the M7 core and 240 MHz for M4 Core
  • Enables the external SDRAM
  • Enables the external QuadSPI Flash
  • Enables the ethernet port
  • Enables the high speed USB peripheral over the full speed usb peripheral. This also enables the CDC ACM driver for serial output.
  • Rearranges the flash partition to eventually support mcuboot

The remaining work required to fully support this board is the following:

  • Support the NXP PF1550 PMIC
  • Support the Murata 1DX Wi-FI / BLE Co-Processor
  • Support the NXP SE050 Secure Element
  • Support the Analogix ANX7625 DisplayPort over USB C peripheral

I would appreciate any feedback or comments on this pull request. Thanks.

@rahul-arasikere rahul-arasikere force-pushed the add-arduino-portenta-h7-nodes branch 2 times, most recently from 45dd141 to a629842 Compare March 21, 2024 02:44
@rahul-arasikere
Copy link
Contributor Author

After further testing, num-bidir-endpoints of usbotg-hs node can be set to 9 on the latest zephyr version. I think they fixed the rx fifo issue I noticed on the previous versions.

@pillo79
Copy link
Contributor

pillo79 commented Apr 4, 2024

Hello, sorry for the delay. Tried your PR on a Portenta H7 and could not get the clock to stabilize. This is the backtrace from a west debug:

^C
Program received signal SIGINT, Interrupt.
0x08043046 in LL_RCC_HSE_IsReady () at modules/hal/stm32/stm32cube/stm32h7xx/drivers/include/stm32h7xx_ll_rcc.h:1688
1688      return ((READ_BIT(RCC->CR, RCC_CR_HSERDY) == (RCC_CR_HSERDY)) ? 1UL : 0UL);

(gdb) bt
#0  0x08043046 in LL_RCC_HSE_IsReady () at modules/hal/stm32/stm32cube/stm32h7xx/drivers/include/stm32h7xx_ll_rcc.h:1688
#1  set_up_fixed_clock_sources () at zephyr/drivers/clock_control/clock_stm32_ll_h7.c:587
#2  stm32_clock_control_init (dev=<optimized out>) at zephyr/drivers/clock_control/clock_stm32_ll_h7.c:850
#3  0x08044d08 in z_sys_init_run_level (level=level@entry=INIT_LEVEL_PRE_KERNEL_1) at zephyr/kernel/init.c:338
#4  0x08044efc in z_cstart () at zephyr/kernel/init.c:629
#5  0x08042320 in z_prep_c () at zephyr/arch/arm/core/cortex_m/prep_c.c:196
#6  0x0804218a in z_arm_reset () at zephyr/arch/arm/core/cortex_m/reset.S:169

This was after doing this:

west build -p -b arduino_portenta_h7//m7 samples/basic/blinky && west flash

The board has the Arduino bootloader which is unaffected. The Portenta H7 is on a Portenta Max Carrier, but I see the same behavior also if I don't connect anything.
Reverting the first commit ("enable 480M") does not build due to a SYSCLK definition error.
Any idea what I might do wrong or what should I test?

@rahul-arasikere
Copy link
Contributor Author

rahul-arasikere commented Apr 4, 2024

Hello, sorry for the delay. Tried your PR on a Portenta H7 and could not get the clock to stabilize. This is the backtrace from a west debug:

^C
Program received signal SIGINT, Interrupt.
0x08043046 in LL_RCC_HSE_IsReady () at modules/hal/stm32/stm32cube/stm32h7xx/drivers/include/stm32h7xx_ll_rcc.h:1688
1688      return ((READ_BIT(RCC->CR, RCC_CR_HSERDY) == (RCC_CR_HSERDY)) ? 1UL : 0UL);

(gdb) bt
#0  0x08043046 in LL_RCC_HSE_IsReady () at modules/hal/stm32/stm32cube/stm32h7xx/drivers/include/stm32h7xx_ll_rcc.h:1688
#1  set_up_fixed_clock_sources () at zephyr/drivers/clock_control/clock_stm32_ll_h7.c:587
#2  stm32_clock_control_init (dev=<optimized out>) at zephyr/drivers/clock_control/clock_stm32_ll_h7.c:850
#3  0x08044d08 in z_sys_init_run_level (level=level@entry=INIT_LEVEL_PRE_KERNEL_1) at zephyr/kernel/init.c:338
#4  0x08044efc in z_cstart () at zephyr/kernel/init.c:629
#5  0x08042320 in z_prep_c () at zephyr/arch/arm/core/cortex_m/prep_c.c:196
#6  0x0804218a in z_arm_reset () at zephyr/arch/arm/core/cortex_m/reset.S:169

This was after doing this:

west build -p -b arduino_portenta_h7//m7 samples/basic/blinky && west flash

The board has the Arduino bootloader which is unaffected. The Portenta H7 is on a Portenta Max Carrier, but I see the same behavior also if I don't connect anything. Reverting the first commit ("enable 480M") does not build due to a SYSCLK definition error. Any idea what I might do wrong or what should I test?

So just tried running the sample against the commit and it is working:

LED state: OFF
LED state: ON
LED state: OFF
LED state: ON

During development I noticed that the oscillator enable pin & ethernet release pins would not getting toggled correctly. This is done via the device tree via the regulator enable pin. Can you try completely powering the board off and turning it on after flashing? @pillo79 Thanks.

@pillo79
Copy link
Contributor

pillo79 commented Apr 4, 2024

Can you try completely powering the board off and turning it on after flashing?

Already done, no difference.

  • With main, the RGB LED blinks quickly green only once, then it blinks red slowly (as per the blinky sample).
    I believe the bootloader leaves the green LED on, and it gets reset by the Zephyr init code.
  • With your PR, the green LED stays on constantly and I see that backtrace.

In either case, a double tap allows me to enter bootloader and reflash.
Do you have the Arduino bootloader installed? Just so we are in sync, can you update to the latest one (I'm using mbed_portenta 4.1.1) and test again?
Thanks for the feedback!

@rahul-arasikere
Copy link
Contributor Author

Can you try completely powering the board off and turning it on after flashing?

Already done, no difference.

  • With main, the RGB LED blinks quickly green only once, then it blinks red slowly (as per the blinky sample).
    I believe the bootloader leaves the green LED on, and it gets reset by the Zephyr init code.
  • With your PR, the green LED stays on constantly and I see that backtrace.

In either case, a double tap allows me to enter bootloader and reflash. Do you have the Arduino bootloader installed? Just so we are in sync, can you update to the latest one (I'm using mbed_portenta 4.1.1) and test again? Thanks for the feedback!

I am using the arduino bootloader based out of the 4.1.1 sdk. I believe my bootloader version is v25. If you revert the first commit, you need to ensure the clock speed is set correctly in the rcc node I believe. Could you probe using an oscillator to see if you can see a 25 Mhz clock signal?

@rahul-arasikere
Copy link
Contributor Author

@pillo79 what version of zephyr sdk are you using? Have you tried running the blinky sample without any carrier board? I only use the breakout board for ethernet port access.

@kartben
Copy link
Contributor

kartben commented May 16, 2024

@pillo79 would it make sense to add Arduino platforms to the MAINTAINERS files so that boards' PRs are correctly assigned? If you think it's a good idea, could you please take care of this? :)

@rahul-arasikere
Copy link
Contributor Author

After looking into zephyr a little more, I realized the Murata 1DX chip is supported by hal-infineon: look at drivers/wifi/infineon/Kconfig.airoc:100 as well as driver/bluetooth/hci/Kconfig.infineon:75.

If there is interest in trying to get this PR merged, I can spend some time and try to get that working as well.

@erwango
Copy link
Member

erwango commented May 17, 2024

After looking into zephyr a little more, I realized the Murata 1DX chip is supported by hal-infineon: look at drivers/wifi/infineon/Kconfig.airoc:100 as well as driver/bluetooth/hci/Kconfig.infineon:75.

If there is interest in trying to get this PR merged, I can spend some time and try to get that working as well.

Sure, but let keep this for another PR. Let's complete review on this one first.

Copy link
Contributor

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies @rahul-arasikere for dropping the ball on this.

I discussed this internally with the Portenta H7 folks and did some experiments this week on different boards. The issue I was having is related to the missing LSE clock on my board (see comment).

I can confirm that the PR works fine on a fully-populated board; however, there are a few changes to be made to clocks to keep in the design parameters.

@rahul-arasikere rahul-arasikere force-pushed the add-arduino-portenta-h7-nodes branch from a629842 to 80ce426 Compare May 23, 2024 20:20
@rahul-arasikere
Copy link
Contributor Author

@pillo79 I have implemented the requested changes, let me know if I need to change anything.

Copy link
Contributor

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates and your effort. Found some minor issues that are easily fixable.

Copy link
Contributor

@pillo79 pillo79 May 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to add a paragraph on the different board revisions and LSE. Something along these lines (not a native speaker so feel free to adapt!):

The high precision low speed external (LSE) clock is only fully supported on boards with hardware revision 4.10 or greater. By default the internal source is used; to enable the use of the external oscillator, manually specify the hardware revision at build time (see :ref:`application_board_version` for information on how to build for specific revisions of the board).

Also, probably an empty line is required after the table? CI doc builds are down currently so I'm not sure 🤷‍♂️

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, how to check the board revision we have on hand?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is easy using the Arduino IDE and mbed_portenta core: just print out the output from boardRevision() (it's a uint16-packed major.minor combo).

In Zephyr, though, this functionality is not yet available. To get this information directly, you have to read the contents of the revision field of the PortentaBoardInfo structure that is flashed at memory address 0x801F000.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks, this might be added to the documentation.
Interestingly, running the STM32H747_getBootloaderInfo Arduino sketch does print a lot of information but not the board revision if we are not in Secure mode (magic == 0x85)

Previous clock frequencies were taken directly from the arduino example
and were limited to 96 MHz and 48 Mhz for the CM7 and CM4 respectively.
Updated the clock tree to take advantage of the faster clock speeds.

Introduced two board revisions as revision 1 of the portenta board does
not have the external LSE oscillator populated (default) and version 4.1
onwards does have the external oscillator populated. The user can choose
to build support for the required clock configuration using the revision
scheme built in to west. Updated the docs to reflect the same.

Signed-off-by: Rahul Arasikere <arasikere.rahul@gmail.com>
@rahul-arasikere rahul-arasikere force-pushed the add-arduino-portenta-h7-nodes branch from 80ce426 to 4ed2c58 Compare May 24, 2024 12:27
@romainreignier
Copy link

I have tested this PR on my Arduino Portenta H7.
I was able to successful run some samples:

samples/hello_world
samples/basic/blinky
samples/subsys/usb/cdc_acm
samples/subsys/console/echo

But I have noticed this warning:

/home/user/zephyrproject/zephyr/build/zephyr/zephyr.dts:1372.29-1405.5: Warning (spi_bus_bridge): /soc/quadspi@52005000: node name for SPI buses should be 'spi'
<stdout>: Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge'

warning: USB_DFU_CLASS (defined at subsys/usb/device/class/dfu/Kconfig:4) was assigned the value 'y'
but got the value 'n'. Check these unsatisfied dependencies: IMG_MANAGER (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_USB_DFU_CLASS and/or look up USB_DFU_CLASS
in the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

With the Arduino Portenta Breakout board, I have managed to test Ethernet by adding:

if NETWORKING

config NET_L2_ETHERNET
       default y

endif # NETWORKING

and

&mac {
       status = "okay";
};

I could run the following samples:

samples/net/sockets/echo
samples/net/telnet

I am curious about this line in the defconfig:

CONFIG_USB_DFU_CLASS=y

What is it supposed to provide?

Isn't the CONFIG_USB_DEVICE_DFU_PID needed then?

An nice addition for a new PR would be to automatically go to the bootloader when the serial baudrate is set to 1200 bauds, as done by the Arduino IDE.

@rahul-arasikere
Copy link
Contributor Author

I have tested this PR on my Arduino Portenta H7. I was able to successful run some samples:

samples/hello_world
samples/basic/blinky
samples/subsys/usb/cdc_acm
samples/subsys/console/echo

But I have noticed this warning:

/home/user/zephyrproject/zephyr/build/zephyr/zephyr.dts:1372.29-1405.5: Warning (spi_bus_bridge): /soc/quadspi@52005000: node name for SPI buses should be 'spi'
<stdout>: Warning (spi_bus_reg): Failed prerequisite 'spi_bus_bridge'

warning: USB_DFU_CLASS (defined at subsys/usb/device/class/dfu/Kconfig:4) was assigned the value 'y'
but got the value 'n'. Check these unsatisfied dependencies: IMG_MANAGER (=n). See
http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_USB_DFU_CLASS and/or look up USB_DFU_CLASS
in the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.

With the Arduino Portenta Breakout board, I have managed to test Ethernet by adding:

if NETWORKING

config NET_L2_ETHERNET
       default y

endif # NETWORKING

and

&mac {
       status = "okay";
};

I could run the following samples:

samples/net/sockets/echo
samples/net/telnet

I am curious about this line in the defconfig:

CONFIG_USB_DFU_CLASS=y

What is it supposed to provide?

Isn't the CONFIG_USB_DEVICE_DFU_PID needed then?

An nice addition for a new PR would be to automatically go to the bootloader when the serial baudrate is set to 1200 bauds, as done by the Arduino IDE.

That must be a holdover from when I was trying to build mcuboot. However I would first need to support the nxp pmic first as I learned from soft bricking one board.

Comment on lines 188 to 194
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Odd indentation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Odd indentation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Odd indentation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Odd indentation

Comment on lines 212 to 214
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, there is now a new usage of reg property to encode the actual memory address mapping to be taken into account.
See #68274

		reg = <0x90000000 DT_SIZE_M(16)>; /* 128 Mbits */

Note also the unit that might need to be fixed. I let you check this part

Comment on lines 39 to 45
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling the USB stack is application responsibility. I propose to provide USB settings in .defconfig file under if USB_DEVICE_STACK condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the arduino IDE you would use the USB stack to talk to Serial port. Would it not make sense to have the USB enabled by default for this board?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix this long line

@rahul-arasikere
Copy link
Contributor Author

@romainreignier that is a good tip about the L2_ETHERNET config, I have added the if ETHERNET config to Kconfig.portenta_h7 file.

pillo79
pillo79 previously approved these changes Jun 3, 2024
Copy link
Contributor

@pillo79 pillo79 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rahul-arasikere for this contribution! Tested on both board revisions with no issues.

@rahul-arasikere rahul-arasikere requested a review from erwango June 3, 2024 18:59
@erwango erwango requested a review from FRASTM June 4, 2024 07:33
fabiobaltieri
fabiobaltieri previously approved these changes Jun 4, 2024
@fabiobaltieri
Copy link
Member

@erwango can you take another look?

@npal-cy
Copy link
Contributor

npal-cy commented Jun 4, 2024

After looking into zephyr a little more, I realized the Murata 1DX chip is supported by hal-infineon: look at drivers/wifi/infineon/Kconfig.airoc:100 as well as driver/bluetooth/hci/Kconfig.infineon:75.

If there is interest in trying to get this PR merged, I can spend some time and try to get that working as well.

For BLE enabling - you can refer to arduino/giga_r1:

and

For Wi-Fi part, so far it is not supported for STM32H7 because of missing SDHC driver for this platform.

@rahul-arasikere
Copy link
Contributor Author

@npal-cy I notice that the st chip has a sdmmc driver, would that not work with the wi-fi driver? I have not looked too hard at it yet.

@npal-cy
Copy link
Contributor

npal-cy commented Jun 6, 2024

@npal-cy I notice that the st chip has a sdmmc driver, would that not work with the wi-fi driver? I have not looked too hard at it yet.

It will not work. it should be sdhc driver. stm32 disk driver does not have needed API.

@rahul-arasikere rahul-arasikere dismissed stale reviews from fabiobaltieri and pillo79 via ebdd1f7 June 7, 2024 12:22
@rahul-arasikere rahul-arasikere force-pushed the add-arduino-portenta-h7-nodes branch 2 times, most recently from ebdd1f7 to 46fe41d Compare June 7, 2024 12:31
@rahul-arasikere
Copy link
Contributor Author

rahul-arasikere commented Jun 7, 2024

Should have got all the formatting issues in the devicetree files. @erwango

@rahul-arasikere rahul-arasikere force-pushed the add-arduino-portenta-h7-nodes branch from 46fe41d to 75c156a Compare June 7, 2024 15:13
Comment on lines 101 to 109
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one was correct

@rahul-arasikere rahul-arasikere force-pushed the add-arduino-portenta-h7-nodes branch 2 times, most recently from d553d9f to 475c55e Compare June 7, 2024 15:52
Enabled the flash memory controller node along with the necessary pin
muxing. This allows us to interface with the additional 8MB of external
SDRAM available on the Portenta H7 board.

This has been tested minimally with the tests/drivers/memc/ram test.

Signed-off-by: Rahul Arasikere <arasikere.rahul@gmail.com>
@rahul-arasikere rahul-arasikere force-pushed the add-arduino-portenta-h7-nodes branch from 475c55e to accad55 Compare June 7, 2024 15:57
Enabled the QuadSPI node and necessary pin muxing to enable interfacing
with the external flash chip on the Portenta H7 board. The jedec data was
validated with the samples/drivers/jesd216 project to extract the
JEDEC data.
Additionally added `flash` to the list of ignored tags as the flash driver
should not be built on the M4 CPU domain.

Signed-off-by: Rahul Arasikere <arasikere.rahul@gmail.com>
Enable the mac node along with the necessary pinmuxing to enable the
ethernet and usb hs peripheral. I additionally defined the
`ethernet_phy_en` node the uses a fixed regulator to release
the PHY reset.

Additionally an usb_cdc_acm node was defined to enable serial over usb for
the console.

Signed-off-by: Rahul Arasikere <arasikere.rahul@gmail.com>
Updated the docs to reflect changes to devicetree files.

Signed-off-by: Rahul Arasikere <arasikere.rahul@gmail.com>
@rahul-arasikere rahul-arasikere force-pushed the add-arduino-portenta-h7-nodes branch from accad55 to 57663c3 Compare June 7, 2024 18:21
@rahul-arasikere rahul-arasikere requested a review from pillo79 June 10, 2024 17:15
@fabiobaltieri fabiobaltieri merged commit 63cf8e4 into zephyrproject-rtos:main Jun 11, 2024
@rahul-arasikere rahul-arasikere deleted the add-arduino-portenta-h7-nodes branch June 11, 2024 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants