kinetis: Support all models in one directory#7882
Conversation
|
Nice one! Exceptional diff -> |
|
I agree, really nice work @gebart! Do you use newer vendor headers, because I saw |
|
tried to flash |
|
I commented the watchdog part in |
|
I will update this PR when #7878 is merged. |
8c03723 to
4895dcb
Compare
bb1e7a5 to
ec61890
Compare
|
rebased, waiting for #7362 |
c1390d6 to
c487373
Compare
|
Deps have been merged. Ready for review |
smlng
left a comment
There was a problem hiding this comment.
Looks good to me, tested successfully with PhyNode (pba-d-01-kw2x).
Just one question, see comment - applies to all usages of $(CPU).
boards/frdm-k22f/Makefile.dep
Outdated
| endif | ||
|
|
||
| -include $(RIOTCPU)/k22f/Makefile.dep | ||
| include $(RIOTCPU)/$(CPU)/Makefile.dep |
There was a problem hiding this comment.
why use $(CPU) here instead of kinetis as in all other places, e.g., Makefile.features
There was a problem hiding this comment.
I mean, why not use $(CPU) when it is available? The reason for hard coding the name in Makefile.features is that it is loaded before Makefile.include in the board directory, so CPU has not been assigned a value yet.
|
please fix Murdock warnings and squash. Some more test reports with other boards would be great, too. |
5807575 to
9ed62ec
Compare
smlng
left a comment
There was a problem hiding this comment.
IMHO moving xtimer config from board to cpu is not a good idea and violates RIOTs common config scheme, hence I'd say this should remain with the board.
9ed62ec to
6c22fd9
Compare
|
@smlng you are right, let's have that discussion in a separate PR. |
| #endif /* defined(KINETIS_SERIES_x) */ | ||
|
|
||
| #ifndef MCU_MEM_MAP_VERSION | ||
| #error Missing vendor header for the chosen CPU_MODEL |
There was a problem hiding this comment.
Maybe make this a simple #else fallback error case above?
There was a problem hiding this comment.
I used this to avoid having to repeat the same else condition in each of the cpu_conf_kinetis_x.h files. The macro MCU_MEM_MAP_VERSION is defined for all Kinetis vendor memory map headers regardless of family or series.
cpu/kinetis/kinetis-info.mk
Outdated
| @@ -0,0 +1,146 @@ | |||
| # Split the part number into qualification, family, subfamily, core, memory, temperature, package, speed | |||
| KINETIS_INFO := $(shell printf '%s' '$(CPU_MODEL)' | tr 'a-z' 'A-Z' |sed -E -e 's/^(M|K|S9)K([ELMSVW]?|EA)([0-9]?)([0-9]?)([A-Z])([NX]?)([0-9][0-9M]?[0-9]?)([ABZ]?)(.*)$$/\1 \2 \3 \4 \5 \6 \7 \8:\9/' -e 's/^([^ ]*) /\1 K /' -e 's/^([^:]*):([CMV])(..)([0-9]*).*$$/\1 \2 \3 \4/' -e 's/ / _ /g' -e 's/ / _ /g') | |||
| #endif | ||
|
|
||
| #endif /* CPU_CONF_H */ | ||
| #endif /* CPU_CONF_KINETIS_K_H */ |
There was a problem hiding this comment.
copy-paste: /CPU_CONF_KINETIS_K_H/CPU_CONF_KINETIS_L_H/
| } | ||
| #endif | ||
|
|
||
| #endif /* CPU_CONF_KINETIS_K_H */ |
There was a problem hiding this comment.
dito, should be CPU_CONF_KINETIS_M_H
| } | ||
| #endif | ||
|
|
||
| #endif /* CPU_CONF_KINETIS_K_H */ |
| } | ||
| #endif | ||
|
|
||
| #endif /* CPU_CONF_KINETIS_K_H */ |
cpu/kinetis/kinetis-info.mk
Outdated
| @@ -0,0 +1,146 @@ | |||
| # Split the part number into qualification, family, subfamily, core, memory, temperature, package, speed | |||
| KINETIS_INFO := $(shell printf '%s' '$(CPU_MODEL)' | tr 'a-z' 'A-Z' |sed -E -e 's/^(M|K|S9)K([ELMSVW]?|EA)([0-9]?)([0-9]?)([A-Z])([NX]?)([0-9][0-9M]?[0-9]?)([ABZ]?)(.*)$$/\1 \2 \3 \4 \5 \6 \7 \8:\9/' -e 's/^([^ ]*) /\1 K /' -e 's/^([^:]*):([CMV])(..)([0-9]*).*$$/\1 \2 \3 \4/' -e 's/ / _ /g' -e 's/ / _ /g') | |||
There was a problem hiding this comment.
wow, nice but rather long one-line command. First thought: missing space between | sed, second: maybe put this into a script in cpu/kinetis/dist/? The latter is a non-blocking suggestion 😄
There was a problem hiding this comment.
fixed the space. I would still prefer to keep this inline inside the makefile. It's only a oneliner and it is easier to have everything in one place, since all the parsing of that processed line also happen in kinetis-info.mk
| $(info Max speed: $(KINETIS_SPEED)) | ||
| $(info Temperature range: $(KINETIS_MASKREV)) | ||
| $(info Revision: $(KINETIS_MASKREV)) | ||
| $(info Package code: $(KINETIS_PACKAGE)) |
There was a problem hiding this comment.
btw output for PhyNode pba-d-01-kw2x is
Kinetis CPU info: M W 2 1 D _ 256 _ V HA 5
Qualification: M
Core: D
Series: W
Family: 2
Subfamily: 1
ROM size: 256
RAM size: 32 (256/8)
SRAM_L: 16 (256/8/2)
Max speed: 5
Temperature range: _
Revision: _
Package code: HA
Is qualification M correct, would've thought it should be K, because series and family do match
There was a problem hiding this comment.
Qualification is M for mainstream parts, P for prerelease/preliminary, and some others for different certifications, for example the automotive parts have some other code there.
There was a problem hiding this comment.
btw, fixed the Temperature range debug print. It is supposed to be "V" for the mkw21d256vha5 (V is -40 -- +105 C)
cpu/kinetis/ldscripts/kinetis.ld
Outdated
| { | ||
| vectors (rx) : ORIGIN = _rom_start_addr, LENGTH = 0x400 | ||
| flashsec (rx) : ORIGIN = _rom_start_addr + 0x400, LENGTH = 0x10 | ||
| rom (rx) : ORIGIN = _rom_start_addr + 0x410, LENGTH = _rom_length - 0x410 |
There was a problem hiding this comment.
wouldn't it be better/nicer to use variables and expressions (+) here instead of repeating magic numbers, i.e., to ease changes. Something like _vectors_len = 0x400, _flashsec_len = 0x10, and _rom_offset = _vectors_len + _flashsec_len.
There was a problem hiding this comment.
good suggestion, will update
|
While we are cleaning up the Kinetis directory, I removed the xxx_NUMOF guards in the periph drivers according to #7981 |
6ef755a to
b73eb67
Compare
|
tested again with PhyNode, pba-d-01-kw2x -> still good. |
|
please squash reasonably |
b73eb67 to
33e751e
Compare
|
@smlng squashed |
|
PhyNode still works, ACK & GO! |
|
@smlng @kaspar030 @haukepetersen Thanks for a very good review effort 🎉 |
The purpose of this PR is to reduce code duplication, and reduce the effort required to add support for new boards using different NXP Kinetis CPUs.
Parts of the header files are script generated, which will make it easier to add new CPUs using only the vendor header.
Based on
#7878#7761#7362