-
Notifications
You must be signed in to change notification settings - Fork 243
Updates and fixes for stm32g4xx: FDCAN, FLASH, TIM #668
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
base: master
Are you sure you want to change the base?
Conversation
Gah. I'm seeing some failures in the presubmits, but I can't seem to replicate them on my end...? The pip version of svdtools doesn't seem to fail D: |
HPMS: | ||
_modify: | ||
FIDX: | ||
msb: 12 |
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.
STM32 usually use bitOffset/bitWidth
instead of msb/lsb
Thanks for the PR and your other recent G4 work! The failures are coming from the linter which checks the generated SVD complies with the CMSIS-SVD schema: if you run I think the main problem is that where you've used Besides that, on lines like: accept_rx_fifo0: [0b00, accept_rx_fifo0] the last item should be a string description of the field, not just its name repeated: something like
Yep, this is pretty tough to track as the project evolved! The gist is that anything "structural" i.e. changing registers or fields should go into |
7258952
to
d26d42f
Compare
My pleasure! Seeing as the G4 is likely the only chip I have I've updated the PR and run the linter. PTAL! :) |
d26d42f
to
4241df6
Compare
1) Add missing fields and enumerations to FDCAN via fdcan_g4.yaml 2) Add registers for FLASH handling. Note that there are some commented out since different devices have different support for secure flash based on their device ID and flash capacity. 3) Fixes for some timer values. In particular, lower non-32-bit timers back down to 16 bit, since 20 bit is only enabled via dithering.
4241df6
to
c27c618
Compare
Let me know if there's something I need to do to trigger the review notification again (happened last time I submitted a PR too, so I'm probably just missing a step in the flow somewhere, apologies!) |
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.
Don't worry, this PR hasn't been forgotten! I had a look through, and I didn't spot any errors compared to RM0440 🎉 Nice work!
I've noted where declarations be moved to match the rules Adam mentioned earlier, and we need to decide what to do with those flash CR / OPTR bits that only appear based on yet another configuration item
ANFS: | ||
accept_rx_fifo0: [0b00, "Accept non-matching standard frames in Rx FIFO 0"] | ||
accept_rx_fifo1: [0b01, "Accept non-matching standard frames in Rx FIFO 1"] | ||
reject: [0b10, "Reject non-matching standard frames"] | ||
reject_: [0b11, "Reject non-matching standard frames"] | ||
ANFE: | ||
accept_rx_fifo0: [0b00, "Accept non-matching extended frames in Rx FIFO 0"] | ||
accept_rx_fifo1: [0b01, "Accept non-matching extended frames in Rx FIFO 1"] | ||
reject: [0b10, "Reject non-matching extended frames"] | ||
reject_: [0b11, "Reject non-matching extended frames"] | ||
RRFS: | ||
filter: [0b0, "Filter remote frames with 11-bit standard IDs"] | ||
reject: [0b1, "Reject all remote frames with 11-bit standard IDs"] | ||
RRFE: | ||
filter: [0b0, "Filter remote frames with 29-bit standard IDs"] | ||
reject: [0b1, "Reject remote frames with 29-bit standard IDs"] |
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.
This is one of those blocks that belongs in peripherals/
because it adds enumerated values (or permitted write ranges) to a field
bitWidth: 2 | ||
TFGI: | ||
bitOffset: 8 |
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 these two new bitOffset
values don't change anything since these fields were already at this offset already. Don't think it's a problem, just harder to review
CR1: | ||
CKD: | ||
Div1: [0, "t_DTS = t_CK_INT"] | ||
Div2: [1, "t_DTS = 2 × t_CK_INT"] | ||
Div4: [2, "t_DTS = 4 × t_CK_INT"] | ||
CMS: | ||
EdgeAligned: [0, "The counter counts up or down depending on the direction bit"] | ||
CenterAligned1: [1, "The counter counts up and down alternatively. Output compare interrupt flags are set only when the counter is counting down."] | ||
CenterAligned2: [2, "The counter counts up and down alternatively. Output compare interrupt flags are set only when the counter is counting up."] | ||
CenterAligned3: [3, "The counter counts up and down alternatively. Output compare interrupt flags are set both when the counter is counting up or down."] | ||
DIR: | ||
Up: [0, "Counter used as upcounter"] | ||
Down: [1, "Counter used as downcounter"] | ||
CEN: | ||
Disabled: [0, "Counter disabled"] | ||
Enabled: [1, "Counter enabled"] | ||
|
||
CCMR1_Output: | ||
OC2PE: | ||
Disabled: [0, "Preload register on CCR2 disabled. New values written to CCR2 are taken into account immediately"] | ||
Enabled: [1, "Preload register on CCR2 enabled. Preload value is loaded into active register on each update event"] | ||
CC2S: | ||
Output: [0, "CC2 channel is configured as output"] | ||
OC1PE: | ||
Disabled: [0, "Preload register on CCR1 disabled. New values written to CCR1 are taken into account immediately"] | ||
Enabled: [1, "Preload register on CCR1 enabled. Preload value is loaded into active register on each update event"] | ||
CC1S: | ||
Output: [0, "CC1 channel is configured as output"] | ||
|
||
CCMR2_Output: | ||
OC4PE: | ||
Disabled: [0, "Preload register on CCR4 disabled. New values written to CCR4 are taken into account immediately"] | ||
Enabled: [1, "Preload register on CCR4 enabled. Preload value is loaded into active register on each update event"] | ||
CC4S: | ||
Output: [0, "CC4 channel is configured as output"] | ||
OC3PE: | ||
Disabled: [0, "Preload register on CCR3 disabled. New values written to CCR3 are taken into account immediately"] | ||
Enabled: [1, "Preload register on CCR3 enabled. Preload value is loaded into active register on each update event"] | ||
CC3S: | ||
Output: [0, "CC3 channel is configured as output"] | ||
|
||
DIER: | ||
TDE: | ||
Disabled: [0, "Trigger DMA request disabled"] | ||
Enabled: [1, "Trigger DMA request enabled"] | ||
"CC?DE": | ||
Disabled: [0, "CCx DMA request disabled"] | ||
Enabled: [1, "CCx DMA request enabled"] | ||
UDE: | ||
Disabled: [0, "Update DMA request disabled"] | ||
Enabled: [1, "Update DMA request enabled"] | ||
TIE: | ||
Disabled: [0, "Trigger interrupt disabled"] | ||
Enabled: [1, "Trigger interrupt enabled"] | ||
"CC?IE": | ||
Disabled: [0, "CCx interrupt disabled"] | ||
Enabled: [1, "CCx interrupt enabled"] | ||
UIE: | ||
Disabled: [0, "Update interrupt disabled"] | ||
Enabled: [1, "Update interrupt enabled"] |
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.
This is one of those blocks that belongs in peripherals/ because it adds enumerated values (or permitted write ranges) to a field
TFQM: | ||
fifo: [0b0, "Tx FIFO operation"] | ||
queue: [0b1, "Tx queue operation"] |
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.
A little block that belongs in peripherals/ because it adds enumerated values (or permitted write ranges) to a field
CR: | ||
_add: | ||
SEC_PROT2: | ||
description: Securable memory area protection bank 2 | ||
bitOffset: 29 | ||
bitWidth: 1 | ||
MER2: | ||
description: Bank 2 mass erase | ||
bitOffset: 15 | ||
bitWidth: 1 | ||
BKER: | ||
description: Bank erase | ||
bitOffset: 11 | ||
bitWidth: 1 | ||
OPTR: | ||
_modify: | ||
SRAM2_RST: | ||
name: CCMSRAM_RST | ||
description: CCM SRAM Erase when system reset | ||
SRAM2_PE: | ||
name: SRAM_PE | ||
_add: | ||
DBANK: | ||
description: Single or dual bank mode | ||
bitOffset: 22 | ||
bitWidth: 1 | ||
BFB2: | ||
description: Dual-bank boot | ||
bitOffset: 20 | ||
bitWidth: 1 |
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.
This section is "structural" i.e. changing registers or fields, so belongs in common_patches
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.
These bits are also quite annoying because their presence depends on the category of the device (Section 3, 4 or 5 of RM0440). OPTR bit 20 even gets re-used for two different functions 🤦
I would at least put them in a separate file under common_patches
and include "category_3" in the name so we can decide what to do with them
normal: [0b0, "Normal operation, register TEST holds reset values"] | ||
test: [0b1, "Test Mode, write access to register TEST enabled"] | ||
DAR: | ||
retransmit: [0b0, "Automatric retransmission of messages not transmitted successfully enabled"] |
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.
Automatic
@timblakely do you plan to finish the PR? |
Let me know if you prefer these to be in a different location; kind of hard for me to grok what goes where in terms of peripheral and register updates/modifications 😅