-
Notifications
You must be signed in to change notification settings - Fork 1.3k
stm32l4r5 Swan support #5403
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
stm32l4r5 Swan support #5403
Conversation
hihi please run pre-commit or fix up formattin' so we can pass CI |
Should be good now. :-) 2 commits were needed - for some reason running the pre-commit hook locally didn't fixup all the problems. I made commit fbf8159 by running the formatter directly on the files affected. |
complete pin mapping for Feather pins stubbed out files needed for complilation. still to be modified 0 out all CPY modules in mpconfigboard.mk until we get the build running add csv for pin generation for STM32L4R5 add F4R5 references in peripherals files refactored out board files BECAUSE I AM AN IDIOT; add L4 series system clocks file from CubeMX took a guess at the number of USB endpoint pairs to get the build done guess was close, but wrong. It is 8 clean up peripheral DEFs Fixes build error: ``` In file included from ../../py/mpstate.h:33, from ../../py/mpstate.c:27: ../../py/misc.h: In function 'vstr_str': ../../py/misc.h:196:1: sorry, unimplemented: Thumb-1 hard-float VFP ABI static inline char *vstr_str(vstr_t *vstr) { ^~~~~~ ``` Sleuthing steps: * verify that the feather_stm32f4_express board builds correctly * put a `#error` at the bottom of the `mpstate.c` file. * build for the feather and swan boards, with V=2 to capture the build command for that file. * use a differencing tool to inspect the differences between the two invocations * inspecting the differences, I saw a missing `-mcpu=cortex-m4` I tested by adding that to the Swan build command. The file built fine (stopping at the hard error, but no other warnings.) A grep through the sources revealed where this flag was being set for the stm ports. With this commit, the build gets further, but does not complete. The next exciting episode in this unfolding coding saga is just a commit away! working build with minimal set of modules for the Blues Swan r5 chore:change header copyright name to Blues Wireless Contributors USB operational. Fixed up clocks to be hardwired for LSE no HSE case. (Trying to combine HSE in there made the code much more complex, and I don't have a board to test it out on.) USART working adds support for `ENABLE_3V3` and `DISCHARGE_3V3` pins. I am surprised that pin definitions are quite low-level and don't include default direction and state, so the code currently has to initialize `ENABLE_3V3` pin as output. The LED takes over a second to discharge, so I wonder if the board startup code is not having the desired affect. short circuit implementation of backup memory for the STM32L4 all the ports remove company name from board name to be consistent with the Arduino board definition. add default pins for I2C, SPI and UART, so that `board.I2C` et al. works as expected. Confirmed I2C timing. fix board name fix incorrect pin definition. add test to allow manual check of each output pin analog IO code changes for WebUSB. Doesn't appear to work, will revisit later. ensure that `sys.platform` is available checkin missing file feat: make room for a larger filesystem so the sensor tutorial will fit on the device. fix:(stm32l4r5zi.csv): merged AF0-7 and AF8-15 into single lines and removed extraneous headers mixed in with the data. fix(parse_af_csv.py): pin index in the csv is 0 not 1, and AF index made 1 larger chore(Swan R5): update peripherals pins from `parse_af_csv.py` output optimize flash sector access
…o match peripheral with interrupt handler index.
…lable on the L4R5, they aren't used. This fixes a build error on the stm32f412zg_discovery.
fbf8159
to
1c1eb49
Compare
|
||
#if CIRCUITPY_USB_VENDOR | ||
#include "usb_vendor_descriptors.h" | ||
|
||
#define BOS_TOTAL_LEN (TUD_BOS_DESC_LEN + TUD_BOS_WEBUSB_DESC_LEN + TUD_BOS_MICROSOFT_OS_DESC_LEN) | ||
|
||
#define MS_OS_20_DESC_LEN 0xB2 | ||
|
||
// BOS Descriptor is required for webUSB | ||
uint8_t const desc_bos[] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The USB Vendor stuff was added by a contributor for 6.x. I did not attempt to redo this for 7, and I assumed it needed to be reworked.
WebUSB is more complicated than WebSerial, and I'd recommend trying to use that if possible.
@bsatrom Did you test webUSB? Are you using it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there @dhalbert! We have not yet done thorough testing, but I have seen the device accessible from the browser - I plan to circle back on this over the coming days.
Because it is conditional code, I thought it would be ok including it so others can build on what is done here, but I'm happy to remove those changes if they are blocking approval of the PR. They are not needed for this board at present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks - I'd say leave it in, maybe with a comment caveat that it's not fully tested, since we only turn this on for one other board right now.
|
||
if (ms_os_20_descriptor_template[MS_OS_20_ITF_NUM_OFFSET] == MS_OS_20_ITF_NUM_MAGIC) { | ||
ms_os_20_descriptor_allocation = | ||
allocate_memory(align32_size(sizeof(ms_os_20_descriptor_template)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all new sites of allocate_memory
need to be accounted for in the macro CIRCUITPY_SUPERVISOR_IMMOVABLE_ALLOC_COUNT or CIRCUITPY_SUPERVISOR_MOVABLE_ALLOC_COUNT in supervisor/shared/memory.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that. I'll add to the enum. I won't push until we have a clearer idea of what we're doing with the WebUSB support, since the CI build is quite expensive. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes pushed to track the non-movable memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the bit I was concerned about is resolved, thanks!
This branch adds support for the STM32L4 family, specifically the STM32L4R5-based Swan board. The board is located at
ports/stm/boards/swan_r5
The changes are almost entirely compile time conditional and so should have minimal impact on other STM boards in the port.
Most of the commits during development have been squished into a single commit - this was to make it easier to rebase onto the upstream repo.
I made an attempt at implementing WebUSB by factoring in the tinyUSB examples and working the Vendor class descriptor into the dynamic set of USB descriptors. It's not presently working as far as I can see, but also does no harm when activated via
CIRCUITPY_USB_VENDOR
. I will continue investigating this over the coming days, and welcome any help from the community. Since it is compile time conditional, and thus optional, I hope this doesn't hinder merging of this PR.Modules tested