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

ATmega4809 scaffold support #62 #63

Merged
merged 8 commits into from
Dec 3, 2020
Merged

Conversation

explicite
Copy link
Contributor

@explicite explicite commented Nov 18, 2020

Scaffold for #62

@Rahix Rahix linked an issue Nov 18, 2020 that may be closed by this pull request
svd/atmega4809.svd Outdated Show resolved Hide resolved
@Rahix
Copy link
Owner

Rahix commented Nov 18, 2020

For some reason, CI is failing right now ... I'm not quite sure why, maybe you can take a look and check whether this is also happening for you locally?

@explicite
Copy link
Contributor Author

make: *** No rule to make target 'src/devices/atmega4809/mod.rs', needed by 'atmega4809'. Stop.
From CI and on local machine.

Should I run svd2rust on svd and then copy mod.rs?

@Rahix
Copy link
Owner

Rahix commented Nov 19, 2020

Ah, I see. I think the issue is that you must add a patch/atmega4809.yaml file for the Makefile to work right now ...

@explicite
Copy link
Contributor Author

patch/atmega4809.yaml added. I was able to define ports from common. make pass. Still spot some problems with keaywords on rs

error: expected identifier, found keyword `async`
   --> src/devices/atmega4809/tcb0/ctrlb.rs:248:12
    |
248 |     pub fn async(&self) -> ASYNC_R {
    |            ^^^^^ expected identifier, found keyword
    |
help: you can escape reserved keywords to use them as identifiers
    |
248 |     pub fn r#async(&self) -> ASYNC_R {
    |            ^^^^^^^

Will try to dig into patching.

@Rahix
Copy link
Owner

Rahix commented Nov 22, 2020

Newer versions (built from git) of svd2rust automatically sanitize names that are keywords in rust. But using those is currently blocked on Rahix/atdf2svd#13 ...

@explicite
Copy link
Contributor Author

@Rahix make pass with common patch for ports. Should I fix something more in https://github.com/Rahix/atdf2svd?
Looks like we need to release it and then I can back to this and refine patches.

@Rahix
Copy link
Owner

Rahix commented Nov 25, 2020

I just released version 0.2.0 of atdf2svd so you're good to go! I recommend working with the git version of svd2rust as well

@explicite
Copy link
Contributor Author

I started with AC. Still not sure what is the logic. @Rahix do we have any guide for this?
First diff which I spotted are modes for AC. From read-write we moved to read-only
Screenshot from 2020-11-26 22-09-24

@Rahix
Copy link
Owner

Rahix commented Nov 27, 2020

The right version is the patched one so the move was from read-only to read-write actually.

I'd take a look at the patches in common/ and check if the changes that are done in each one also look necessary for ATmega4809. If yes, include the patch. Similarly for the timers, but you'll have to check which type of timers are used in your MCU.

Don't worry about patching everything from the get-go. If all the common patches which apply are included, this is already a pretty good foundation and hopefully enough to make a HAL implementation work.

@explicite
Copy link
Contributor Author

Only common/ports.yaml works without any changes. For rest I need to create custom patches. Should this be done with mcu suffix or in nested dir?

common/usart.yaml

svdtools.patch.MissingRegisterError: Could not find USART0:UCSR?A

common/as.yaml

svdtools.patch.MissingPeripheralError: Could not find AC

common/adc.yaml

svdtools.patch.MissingPeripheralError: Could not find ADC

common/spi.yaml

svdtools.patch.MissingRegisterError: Could not find SPI0:SPSR

common/twi.yaml

svdtools.patch.MissingRegisterError: Could not find TWI0:TWCR

common/usart.yaml

svdtools.patch.MissingRegisterError: Could not find USART0:UCSR?A

common/wdt.yaml

svdtools.patch.MissingRegisterError: Could not find WDT:WDTCSR,WDTCR

@Rahix
Copy link
Owner

Rahix commented Dec 2, 2020

hmm, I'd create a subdir atmega_0x/.

But it looks like the peripherals differ substantially from the ones we currently have on the other MCUs. So it's probably not directly obvious what needs to be patches unless you want to go through the datasheet line by line ...

I'd actually keep patching to a minimun for now, and check back later, while doing the HAL implementation to see where changes are necessary.

patch/atmega4809.yaml Outdated Show resolved Hide resolved
patch/atmega4809.yaml Outdated Show resolved Hide resolved
@explicite explicite changed the title ATmega4809 support #62 ATmega4809 scaffold support #62 Dec 3, 2020
@explicite explicite marked this pull request as ready for review December 3, 2020 10:07
patch/atmega4809.yaml Outdated Show resolved Hide resolved
Co-authored-by: Rahix <rahix@rahix.de>
Copy link
Owner

@Rahix Rahix left a comment

Choose a reason for hiding this comment

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

Okay, remaining CI failures are because CI is using an old version of svd2rust. I'm going to fix that later today, after that this branch should be ready to merge :)

@Rahix Rahix added the mcu-support Support for a new microcontroller label Dec 3, 2020
@Rahix Rahix merged commit d1eed41 into Rahix:master Dec 3, 2020
@Rahix
Copy link
Owner

Rahix commented Dec 3, 2020

Thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mcu-support Support for a new microcontroller
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ATmega4809 support
2 participants