Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STM32: Add F7 and H7 Support #2735

Merged
merged 23 commits into from
Apr 17, 2020
Merged

STM32: Add F7 and H7 Support #2735

merged 23 commits into from
Apr 17, 2020

Conversation

hierophect
Copy link
Collaborator

@hierophect hierophect commented Mar 26, 2020

This PR restructures the STM port of Circuitpython to be more generic about the STM32 chip lines so as to support the F7 and H7 series of chips, which run on the Cortex M7 core at up to 480MHz with advanced peripherals including Camera and Ethernet modules. Changes so far include:

  • A new Packages directory to organize different chip layouts between lines.
  • Changes to the Makefile to condense board-level flags to the minimum and support the new chip series.
  • Minor stylistic changes throughout to remove references to the STM32F4
  • Adds H7 chip line to the Peripherals directory, changes the structure of the Peripherals API to make access more generic
  • Adds the STM32H743 Nucleo board definitions
  • Enable the DigitalIO, Microcontroller and Board modules for the STM32H7, and exclude all others due to HAL incompatibility.
  • New python tools used to generate peripheral text automatically in the tools/ directory.
  • A rework of the Flash system, to both include the H7 and add caching universally. Results in 10x+ write speedup across the entire STM32 line for boards using internal flash.

This PR is a work in progress. Remaining tasks include:

  • Add internal flash support to the H7, and enable MSC USB
  • Add support for the F7 chip series and the STM32F767ZI Nucleo
  • Add busio support, and other low-hanging fruit modules like Displayio, OS and Storage.
  • Consolidate linker files into shared format

Nevertheless, high level review is appreciated, along with any suggestions for new boards in the F7 and H7 to target for support.

Restructures the STM port of Circuitpython to be more generic about the STM32 chip lines to support
the F7 and H7 series of chips. Adds the new Packages directory to organize different chip layouts
between lines. Makes general changes to the Makefile to condense board-level flags to the minimum
and support the new chip series. Adds the new chip line to the Peripherals directory, along with
new python tools used to generate peripheral text automatically in the tools/ directory.
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Looks like you are downgrading ulab in this currently. Please make sure you have the commit that matches master's checked out.

@hierophect
Copy link
Collaborator Author

@tannewt whoops hopefully that's just a submodule update mixup

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Overall the package changes look really really good! I added a few comments about other stuff but nothing super major.

I believe you mean to add a board def for the STMH743 NUCLEO not the discovery.

ports/stm/Makefile Outdated Show resolved Hide resolved
ports/stm/peripherals/periph.h Outdated Show resolved Hide resolved
ports/stm/tools/parse_af_csv.py Show resolved Hide resolved
ports/stm/supervisor/port.c Show resolved Hide resolved
ports/stm/boards/STM32H743_fs.ld Outdated Show resolved Hide resolved
@hierophect hierophect requested a review from tannewt March 28, 2020 22:34
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

All stylistic. Massive amount of work, great!

ports/stm/Makefile Outdated Show resolved Hide resolved
ports/stm/boards/stm32h743zi2_discovery/mpconfigboard.h Outdated Show resolved Hide resolved
ports/stm/peripherals/stm32h7/stm32h743xx/clocks.c Outdated Show resolved Hide resolved
ports/stm/supervisor/internal_flash.c Outdated Show resolved Hide resolved
ports/stm/supervisor/internal_flash.h Outdated Show resolved Hide resolved
ports/stm/supervisor/usb.c Outdated Show resolved Hide resolved
ports/stm/system_stm32h7xx.c Outdated Show resolved Hide resolved
ports/stm/boards/STM32H743ZITx_FLASH.ld Outdated Show resolved Hide resolved
@hierophect
Copy link
Collaborator Author

@tannewt is there a way to automate the merging of the translations files? Going into each one and changing that single date that always conflicts is a bit of a chore.

@dhalbert
Copy link
Collaborator

dhalbert commented Apr 1, 2020

If we could get rid of the date entirely in the .po translation files, I think that might be just fine, since the files are tracked by git already.

@hierophect
Copy link
Collaborator Author

@dhalbert I was thinking the same thing, it's not a very useful line to include and it always prevents clean merges if you forget to pull from master beforehand.

@hierophect hierophect requested a review from dhalbert April 9, 2020 02:37
@hierophect
Copy link
Collaborator Author

Ok, @tannewt @dhalbert @jepler this is ready for another full review. Changes include:

  • Addition of the F767 Nucleo and general F7 support
  • An overhaul of the linker and startup file system to support TCM and reduce clutter. Optional startup code for TCM is in port.c, like the i.mx, but most boards still use the weakly declared startup versions.
  • Busio is now enabled for the F7 and H7, with some edits to support new peripheral scope.
  • Various requested style changes implemented (boolean preprocessor flags, boolean multibreaks)

Tested on the H743 and F767 Nucleo boards with I2C (DRV2605), SPI (BMP280) and UART (char send/read), with a Feather F405 as a control.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Getting better and better! Linker clean up looks good! Will try this out by the weekend.

ports/stm/Makefile Outdated Show resolved Hide resolved
ports/stm/boards/nucleo_f767zi/mpconfigboard.mk Outdated Show resolved Hide resolved
ports/stm/common-hal/busio/I2C.c Outdated Show resolved Hide resolved
ports/stm/supervisor/internal_flash.c Outdated Show resolved Hide resolved
ports/stm/supervisor/internal_flash.c Outdated Show resolved Hide resolved
ports/stm/supervisor/port.c Outdated Show resolved Hide resolved
ports/stm/supervisor/usb.c Outdated Show resolved Hide resolved
supervisor/shared/stack.c Outdated Show resolved Hide resolved
ports/stm/boards/thunderpack/mpconfigboard.mk Outdated Show resolved Hide resolved
.github/workflows/build.yml Show resolved Hide resolved
@hierophect
Copy link
Collaborator Author

@dhalbert @tannewt Ok, all suggestions implemented. Please check out internal_flash.c for revised cache reading system.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

One comment. Will test and finish the review tomorrow.

ports/stm/Makefile Outdated Show resolved Hide resolved
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

I tried to test this on my Nucleo boards by dragging and dropping the .bin onto the NOD_* drives that appear. The F767 copied ok but I get nothing on the other USB port where I'd expect CIRCUITPY to appear. The H743's .bin is 402.7mb so Mac won't let me copy it over. Should I try using GDB to load with the H7?

ports/stm/supervisor/internal_flash.c Outdated Show resolved Hide resolved
ports/stm/supervisor/port.c Outdated Show resolved Hide resolved
ports/stm/supervisor/port.c Outdated Show resolved Hide resolved
ports/stm/supervisor/port.c Outdated Show resolved Hide resolved
@hierophect hierophect requested a review from tannewt April 15, 2020 18:43
@hierophect
Copy link
Collaborator Author

@tannewt Looks like we're all set on CI! Anything else you'd like to see wrapped up?

@tannewt
Copy link
Member

tannewt commented Apr 15, 2020

I still have to test it. Please reply to my top level comment from last time about what I tried.

@hierophect
Copy link
Collaborator Author

@tannewt I've been looking into the issues with startup on each board this morning. It looks like the H7 issue is contained to the .bin file - it loads just fine over GDB, which is why I didn't notice it, so you could try that for testing in the short term.

I'm not sure yet why the .bin is so bloated. It has to be something with the linker/port.c allocations - similar posts from other STM32 projects suggest this happens when data is accidentally mapped to RAM or other discontiguous memory spaces. Should we be compensating for the fact that ITCM, DTCM and AXI ram are at spaced addresses (0x00000000, 0x20000000 and 0x24000000 respectively)?. If I use the default linker (leaving out DTCM and ITCM) there's no issue with bin size (comes out as 532kb).

I'm not sure when the F767 crash snuck in... it was working fine when I tested busio but there have been a number of requested changes since then. It doesn't even hit main, so somethings pretty off.

@hierophect
Copy link
Collaborator Author

@tannewt fix is in for the F767, it was a startup file issue. Tested it again with my testbench and it seems all is well if you'd like to take a crack at it. Going back to poking around with the H743.

@hierophect
Copy link
Collaborator Author

@tannewt both H7 bin and F7 reset fixes should be in now.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Please add the objcopy flags for the hex too, then it'll be good to go!

ports/stm/Makefile Outdated Show resolved Hide resolved
ports/stm/Makefile Show resolved Hide resolved
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks!

@ladyada
Copy link
Member

ladyada commented Apr 17, 2020

amaze!

@ladyada
Copy link
Member

ladyada commented Apr 17, 2020

@tannewt the only stm32f7 boards' i have is openmv cam https://www.adafruit.com/product/4478 and a 32blit, can i test with either?

@hierophect
Copy link
Collaborator Author

@ladyada was going to add the H7 cam next week

@tannewt
Copy link
Member

tannewt commented Apr 17, 2020

@tannewt the only stm32f7 boards' i have is openmv cam https://www.adafruit.com/product/4478 and a 32blit, can i test with either?

I tested on the two Nucleo boards. I have a 32blit and would be keen to get it going there. I should focus on ESP32-S2 though.

@ladyada
Copy link
Member

ladyada commented Apr 17, 2020

lol agree. @tannewt keep esp32s2'ing :) @hierophect lemme know when the cam is ready, ill grab one from the office and we can try it out!

@hierophect
Copy link
Collaborator Author

@tannewt note that the H750 on the MicroBlit would require a little extra work since it only has 128k of flash, we'd have to do something like the i.mx has for loading code.

@hierophect hierophect deleted the stm32x7-setup branch April 29, 2020 17:30
@hierophect hierophect added the stm label May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants