[DEV] STM32H7xx support (new)

This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
mikeprotts
Posts: 144
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 16 times
Been thanked: 21 times

Re: [DEV] STM32H7xx support (new)

Postby mikeprotts » Tue Jul 21, 2020 9:21 am

No functional changes, just tidied up and unused code removed. Files attached. I'm happy to repackage as a patch if preferred.

I've not included the changes to the board file as I've not worked out how to use the config generator yet. The only changes are the board voltage (not needed for the MACv2 work) and a few pins changed to FLOATING which I think is the correct

Code: Select all

diff ./changed/ChibiOS_20.3.1/os/hal/boards/ST_NUCLEO144_H743ZI/board.h ./original/ChibiOS_20.3.1/os/hal/boards/ST_NUCLEO144_H743ZI/board.h
65,70d64
<  /*
<  * Board voltages.
<  * Required for performance limits calculation.
<  */
< #define STM32_VDD                   330U
417c411
<                                      PIN_PUPDR_FLOATING(GPIOA_RMII_MDIO) |    \
---
>                                      PIN_PUPDR_PULLUP(GPIOA_RMII_MDIO) |    \
422c416
<                                      PIN_PUPDR_FLOATING(GPIOA_RMII_CRS_DV) |  \
---
>                                      PIN_PUPDR_PULLUP(GPIOA_RMII_CRS_DV) |  \
545c539
<                                      PIN_PUPDR_FLOATING(GPIOB_RMII_TXD1) |    \
---
>                                      PIN_PUPDR_PULLUP(GPIOB_RMII_TXD1) |    \


Mike
Attachments
MACv2.tar.bz2
(10.53 KiB) Downloaded 9 times

User avatar
Giovanni
Site Admin
Posts: 13008
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 742 times
Been thanked: 620 times
Contact:

Re: [DEV] STM32H7xx support (new)

Postby Giovanni » Tue Jul 21, 2020 9:24 am

Note that changes to board files have to be done in board.chcfg then generate the other files. I cannot commit just a modified board.h, it would be overwritten on next mass update.

Giovanni

mikeprotts
Posts: 144
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 16 times
Been thanked: 21 times

Re: [DEV] STM32H7xx support (new)

Postby mikeprotts » Tue Jul 21, 2020 12:19 pm

Giovanni wrote:Note that changes to board files have to be done in board.chcfg then generate the other files. I cannot commit just a modified board.h, it would be overwritten on next mass update.

Giovanni

That's what I thought, and why I haven't included the board file in the archive. I've made the changes to the board.chcfg file:

Code: Select all

diff -c --exclude build --exclude .dep -rwb ./original/ChibiOS_20.3.1/os/hal/boards/ST_NUCLEO144_H743ZI/cfg/board.chcfg ./changed/ChibiOS_20.3.1/o
s/hal/boards/ST_NUCLEO144_H743ZI/cfg/board.chcfg
*** ./original/ChibiOS_20.3.1/os/hal/boards/ST_NUCLEO144_H743ZI/cfg/board.chcfg 2020-01-30 17:50:59.000000000 +0000
--- ./changed/ChibiOS_20.3.1/os/hal/boards/ST_NUCLEO144_H743ZI/cfg/board.chcfg  2020-07-21 12:03:18.045089019 +0100
***************
*** 22,28 ****
      HSEBypass="true"
      LSEFrequency="32768"
      LSEBypass="false"
!     VDD="300"
      LSEDrive="3 High Drive (default)" />
    <ports>
      <GPIOA>
--- 22,28 ----
      HSEBypass="true"
      LSEFrequency="32768"
      LSEBypass="false"
!     VDD="330"
      LSEDrive="3 High Drive (default)" />
    <ports>
      <GPIOA>
***************
*** 47,53 ****
          Type="PushPull"
          Level="High"
          Speed="Maximum"
!         Resistor="PullUp"
          Mode="Alternate"
          Alternate="11" />
        <pin3
--- 47,53 ----
          Type="PushPull"
          Level="High"
          Speed="Maximum"
!         Resistor="Floating"
          Mode="Alternate"
          Alternate="11" />
        <pin3
***************
*** 87,93 ****
          Type="PushPull"
          Level="High"
          Speed="Maximum"
!         Resistor="PullUp"
          Mode="Alternate"
          Alternate="11" />
        <pin8
--- 87,93 ----
          Type="PushPull"
          Level="High"
          Speed="Maximum"
!         Resistor="Floating"
          Mode="Alternate"
          Alternate="11" />
        <pin8
***************
*** 265,271 ****
          Type="PushPull"
          Level="High"
          Speed="Maximum"
!         Resistor="PullUp"
          Mode="Alternate"
          Alternate="11" />
        <pin14
--- 265,271 ----
          Type="PushPull"
          Level="High"
          Speed="Maximum"
!         Resistor="Floating"
          Mode="Alternate"
          Alternate="11" />
        <pin14



Mike

geebee
Posts: 16
Joined: Thu Dec 06, 2018 10:22 pm
Has thanked: 3 times
Been thanked: 13 times

Re: [DEV] STM32H7xx support (new)

Postby geebee » Tue Aug 04, 2020 11:12 pm

I think there is an issue with stalls/restarts, from compiler warnings. In hal_mac_lld, I believe you might want to do either

Code: Select all

--- a/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c
+++ b/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c
@@ -517,7 +517,7 @@ void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp) {
   __DSB();
 
   /* If the DMA engine is stalled then a restart request is issued.*/
-  if ((ETH->DMACSR & ETH_DMACSR_TPS) == ETH_DMADSR_TPS_SUSPENDED) {
+  if (ETH->DMACSR & ETH_DMACSR_TPS) {^M
     ETH->DMACSR   = ETH_DMACSR_TBU;
   }
   ETH->DMACTDTPR = 0;
@@ -594,7 +594,7 @@ void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp) {
   __DSB();
 
   /* If the DMA engine is stalled then a restart request is issued.*/
-  if ((ETH->DMACSR & ETH_DMACSR_RPS) == ETH_DMADSR_RPS_SUSPENDED) {
+  if (ETH->DMACSR & ETH_DMACSR_RPS) {^M
     ETH->DMACSR   = ETH_DMACSR_RBU;
   }
   ETH->DMACRDTPR = 0;

or

Code: Select all

--- a/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c
+++ b/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c
@@ -517,7 +517,7 @@ void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp) {
   __DSB();
 
   /* If the DMA engine is stalled then a restart request is issued.*/
-  if ((ETH->DMACSR & ETH_DMACSR_TPS) == ETH_DMADSR_TPS_SUSPENDED) {
+  if ((ETH->DMADSR & ETH_DMADSR_TPS) == ETH_DMADSR_TPS_SUSPENDED) {^M
     ETH->DMACSR   = ETH_DMACSR_TBU;
   }
   ETH->DMACTDTPR = 0;
@@ -594,7 +594,7 @@ void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp) {
   __DSB();
 
   /* If the DMA engine is stalled then a restart request is issued.*/
-  if ((ETH->DMACSR & ETH_DMACSR_RPS) == ETH_DMADSR_RPS_SUSPENDED) {
+  if ((ETH->DMADSR & ETH_DMADSR_RPS) == ETH_DMADSR_RPS_SUSPENDED) {^M
     ETH->DMACSR   = ETH_DMACSR_RBU;
   }
   ETH->DMACRDTPR = 0;


As it is, you are maksing DMACSR (single bit status) but comparing with the status constant for the debug register DMADSR (multiple values, at a different location), which is always false.

Aside from the compiler warnings I have not noticed any actual issue with it, so I don't think I ever put the MAC in a state to need that code. So far everything has worked just fine with your patch.

GB

mikeprotts
Posts: 144
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 16 times
Been thanked: 21 times

Re: [DEV] STM32H7xx support (new)

Postby mikeprotts » Wed Aug 05, 2020 2:40 pm

A good spot. I think it's the second option based on comparing with MACv1 code and the documentation.

STM32F76xx & STM32F77xx docs:
Ethernet DMA status register (ETH_DMASR)
Bits 22:20 TPS: Transmit process state
These bits indicate the Transmit DMA FSM state. This field does not generate an interrupt.
000: Stopped; Reset or Stop Transmit Command issued
001: Running; Fetching transmit transfer descriptor
010: Running; Waiting for status
011: Running; Reading Data from host memory buffer and queuing it to transmit buffer (TxFIFO)
100, 101: Reserved for future use
110: Suspended; Transmit descriptor unavailable or transmit buffer underflow <<<<<<<<<<<<<<<<<<<<<<<<<
111: Running; Closing transmit descriptor


STM32H742, STM32H743/753 & STM32H750 docs:
Debug status register (ETH_DMADSR)
TPS0[3:0]: DMA Channel Transmit Process State
This field indicates the Tx DMA FSM state for Channel:
000: Stopped (Reset or Stop Transmit Command issued)
001: Running (Fetching Tx Transfer Descriptor)
010: Running (Waiting for status)
011: Running (Reading Data from system memory buffer and queuing it to the Tx buffer (TxFIFO))
100: Timestamp write state
101: Reserved for future use
110: Suspended (Tx Descriptor Unavailable or Tx Buffer Underflow) <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
111: Running (Closing Tx Descriptor)
The MSB of this field always returns 0. This field does not generate an interrupt.


I don't think I've ever triggered this code, but I'll test with a breakpoint to see if it ever occurs.

Mike

mikeprotts
Posts: 144
Joined: Wed Jan 09, 2019 12:37 pm
Has thanked: 16 times
Been thanked: 21 times

Re: [DEV] STM32H7xx support (new)

Postby mikeprotts » Thu Aug 06, 2020 1:04 pm

Putting in breakpoints tells me the code is being run for both transmit & receive. I'm now running a longer test to check there are no other consequences,

Mike


Return to “Development and Feedback”

Who is online

Users browsing this forum: No registered users and 7 guests