Skip to content

Conversation

haukepetersen
Copy link
Contributor

the sam21_common was not utilized fully for both the samd21 and the saml21 implementations, leading to confusion and code duplication. With this PR both implementations use the shared code in the same manner.

I also renamed the shared folder to sam0_common, as the old name was somehow misleading and this seems to be the more precise naming scheme used also by Atmel for that family of devices.

For the future, we might even think about merging all the samd/saml code into the sam0 tree?! But another day...

@haukepetersen haukepetersen added Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Dec 15, 2016
@haukepetersen haukepetersen added this to the Release 2017.01 milestone Dec 15, 2016
@ant9000
Copy link
Contributor

ant9000 commented Dec 15, 2016

I've been skimming through Atmel xdk-asf files (see http://asf.atmel.com/docs/latest/download.html).

The includes under cpu/saml21/include/atmel/ seem to come from an old ASF package, partially reviewed and modified. Code for various boards in RIOT use these includes.

The directory at cpu/sam21_common/include/cmsis/saml21/, instead, is a complete copy of ASF
sam0/utils/cmsis/saml21/. I've used a README.md comparable to ones for samd21 and samr21, that states explicitly where the files come from and how they have been modified. AFAIKT, the only code that makes use of this copy is my modified I2C driver.

I've been thinking over the changes you propone in this PR: I do not feel easy in moving single includes from cpu/saml21/include/atmel/ to cpu/sam21_common/include/cmsis/saml21/.

I'd rather remove cpu/saml21/include/atmel/ entirely (since it is contains files coming from an older version of ASF) and then try to fix things that break.

What do you think?

@haukepetersen
Copy link
Contributor Author

I didn't check any version of the saml21 vendor header, I simply copied the existing ones from the saml21 folder into the sam0_common include dir.

I propose the following: we should merge this PR first, as i think the re-structuring makes much much sense. And second, you add a commit to your PR, updating the vendor headers under sam0_common/include/cmsis/saml21/ with the current version that you need for the I2C implementation. Sonds good to you?!

@keestux
Copy link
Contributor

keestux commented Dec 15, 2016

Great. I like this approach. Small steps, but with a goal in mind to unify the common code for the sam0 variants (samd21, saml21, etc)
Also to administrate (in the README's) where the files come from, which versions of ASF and what we did to them to integrate them into RIOT. (That is why I wrote those README's for samd21 and samr21.)

Let's add the README for saml21 and start documenting it like I did for the other parts.

@dylad
Copy link
Member

dylad commented Dec 15, 2016

This PR makes sense. I think it is a better approach in order to add support for the whole cortex M0 Atmel portfolio. the sam21_common folder was confusing, I mean if we want to add support for SAMDxx or SAML22 it is better to have a sam0_common rather than sam21_common.
As @haukepetersen proposed, samd/saml folder should be merged into sam0 folder in a near future.

@keestux
Copy link
Contributor

keestux commented Dec 15, 2016

FYI
The current saml21 include files are from ASF 3.22, with two sets of modifications: the white space at the end-of-line removed, and the #ifdef's for LITTLE_ENDIAN

@haukepetersen
Copy link
Contributor Author

Nice, seems we get to a consensus here.

About the README.md file: I have obviously no idea about the versioning/modifications to the Atmel ASF packages.

So how about: I will not add a README.md for the saml21 in this PR, as I simply copied the files from the saml21 directory. Instead, @ant9000 will add that file when updating the ASF version for saml21, as for this he probably knows what he edited and which number version is used.

@ant9000, @keestux: Does this work for you?

@keestux
Copy link
Contributor

keestux commented Dec 15, 2016

Well, OK.
On the other hand, I did already write a brief README which reflects the current status (as far as I can tell). It can be used and edited when updating. Whatever @ant9000 thinks is convenient, that's fine with me.

@ant9000
Copy link
Contributor

ant9000 commented Dec 16, 2016

I'm fine with checking in this PR and then updating what is needed.

@haukepetersen
Copy link
Contributor Author

Cool, then all we need is an ACK...

Copy link
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

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

sam0 it is finally... ;) ACK!

@kaspar030 kaspar030 merged commit 2c02520 into RIOT-OS:master Dec 16, 2016
@haukepetersen haukepetersen deleted the opt_samxyz21_structure branch December 16, 2016 08:10
@ant9000
Copy link
Contributor

ant9000 commented Dec 19, 2016

I've created #6240 , which only adds the correct README file (as @keestux suggested).

Now, to further you work I would like to update the CMSIS includes. The first ASF XDK including CMSIS definitions for SAML21 version B (the CPU I use is a SAML21E18b) is 3.26.0:

xdk-asf-3.26.0/sam0/utils/cmsis/saml21/
├── include
│   ├── component
│   ├── instance
│   └── pio
├── include_b
│   ├── component
│   ├── instance
│   └── pio
└── source
├── gcc
└── iar

My problem is that a simple substitution of the include / include_b directories breaks quite a few of the drivers.

I've published a version here (a branch on my fork but not a PR, since it does not compile):

https://github.com/ant9000/RIOT/tree/saml21_update_to_xdk3.33

When you try to compile examples/default for BOARD=saml21-xpro, the result is:
error.txt

Any hints on how to proceed from here?

Antonio

@ant9000
Copy link
Contributor

ant9000 commented Dec 19, 2016

Found my way around the drivers, now my branch compiles: I'll do a few tests on real hw, will submit a PR soon.

@ant9000
Copy link
Contributor

ant9000 commented Dec 19, 2016

AFAIKT, things do work correctly - so I've created #6242 .

@keestux
Copy link
Contributor

keestux commented Dec 19, 2016

I've noticed these compiler errors too when I was trying to update the SAML21 files. It is because of
the added __I and __O and __IO prefixes. Compiling with GCC does not succeed. I wonder if it compiler with IAR.

Anyway, I'd be interested to know what you did to achieve "Found my way around the drivers, now my branch compiles".

@ant9000
Copy link
Contributor

ant9000 commented Dec 19, 2016

Trying to match ASF driver code was not immediate - it's very far from RIOT sources. Anyway, what seems to work is this:

ant9000@9421152

As you can see, it was no big deal once I got a hang on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants