Skip to content

kinetis: Support all models in one directory#7882

Merged
smlng merged 6 commits intoRIOT-OS:masterfrom
jnohlgard:pr/kinetis-one-cpu-dir
Nov 10, 2017
Merged

kinetis: Support all models in one directory#7882
smlng merged 6 commits intoRIOT-OS:masterfrom
jnohlgard:pr/kinetis-one-cpu-dir

Conversation

@jnohlgard
Copy link
Copy Markdown
Member

@jnohlgard jnohlgard commented Oct 26, 2017

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

@jnohlgard jnohlgard added Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Oct 26, 2017
@haukepetersen
Copy link
Copy Markdown
Contributor

Nice one! Exceptional diff -> +29,098 −51,264! Will look into the base PRs first, but looking forward to get this merged!

@smlng
Copy link
Copy Markdown
Member

smlng commented Oct 27, 2017

I agree, really nice work @gebart!

Do you use newer vendor headers, because I saw MK22F25612.h is remove with some >12K lines and reintroduces with >8K lines, while others stayed the same (e.g. MK22F51212.h) which git correctly identified to be moved.

@smlng
Copy link
Copy Markdown
Member

smlng commented Oct 27, 2017

tried to flash gnrc_networking onto PhyNode (pba-d-01-kw2x) and got an error for target make flash:

make: *** No rule to make target `/Volumes/devel/github/smlng/RIOT/cpu/kinetis_common/dist/wdog-disable.s', needed by `/Volumes/devel/github/smlng/RIOT/cpu/kinetis_common/dist/wdog-disable.bin'.  Stop.

@smlng
Copy link
Copy Markdown
Member

smlng commented Oct 27, 2017

I commented the watchdog part in cpu/kinetis/Makefile.include and also fixed PRE_FLASH_CHECK_SCRIPT in boards/pba-d-01-kwx2/Makefile.include to point to kinetis instead of kinetis_common. Now it works.

@jnohlgard
Copy link
Copy Markdown
Member Author

I will update this PR when #7878 is merged.

@jnohlgard jnohlgard added the State: waiting for other PR State: The PR requires another PR to be merged first label Oct 28, 2017
@jnohlgard jnohlgard force-pushed the pr/kinetis-one-cpu-dir branch from 8c03723 to 4895dcb Compare October 28, 2017 14:49
@jnohlgard jnohlgard force-pushed the pr/kinetis-one-cpu-dir branch from bb1e7a5 to ec61890 Compare October 31, 2017 12:34
@jnohlgard jnohlgard added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Oct 31, 2017
@jnohlgard
Copy link
Copy Markdown
Member Author

rebased, waiting for #7362

@jnohlgard jnohlgard force-pushed the pr/kinetis-one-cpu-dir branch 2 times, most recently from c1390d6 to c487373 Compare November 8, 2017 15:29
@jnohlgard jnohlgard added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed State: waiting for other PR State: The PR requires another PR to be merged first labels Nov 8, 2017
@jnohlgard
Copy link
Copy Markdown
Member Author

Deps have been merged. Ready for review

Copy link
Copy Markdown
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

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

Looks good to me, tested successfully with PhyNode (pba-d-01-kw2x).

Just one question, see comment - applies to all usages of $(CPU).

endif

-include $(RIOTCPU)/k22f/Makefile.dep
include $(RIOTCPU)/$(CPU)/Makefile.dep
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why use $(CPU) here instead of kinetis as in all other places, e.g., Makefile.features

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

@smlng
Copy link
Copy Markdown
Member

smlng commented Nov 8, 2017

please fix Murdock warnings and squash. Some more test reports with other boards would be great, too.

@jnohlgard jnohlgard force-pushed the pr/kinetis-one-cpu-dir branch from 5807575 to 9ed62ec Compare November 8, 2017 21:50
Copy link
Copy Markdown
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

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

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.

@jnohlgard jnohlgard force-pushed the pr/kinetis-one-cpu-dir branch from 9ed62ec to 6c22fd9 Compare November 9, 2017 07:02
@jnohlgard
Copy link
Copy Markdown
Member Author

@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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe make this a simple #else fallback error case above?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ok!

@@ -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')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

;)

Copy link
Copy Markdown
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

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

some minor stuff

#endif

#endif /* CPU_CONF_H */
#endif /* CPU_CONF_KINETIS_K_H */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

copy-paste: /CPU_CONF_KINETIS_K_H/CPU_CONF_KINETIS_L_H/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed

}
#endif

#endif /* CPU_CONF_KINETIS_K_H */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

dito, should be CPU_CONF_KINETIS_M_H

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed

}
#endif

#endif /* CPU_CONF_KINETIS_K_H */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and ... you know the drill 😉

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed

}
#endif

#endif /* CPU_CONF_KINETIS_K_H */
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

another one

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed

@@ -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')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 😄

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

btw, fixed the Temperature range debug print. It is supposed to be "V" for the mkw21d256vha5 (V is -40 -- +105 C)

{
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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good suggestion, will update

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

updated

@jnohlgard
Copy link
Copy Markdown
Member Author

While we are cleaning up the Kinetis directory, I removed the xxx_NUMOF guards in the periph drivers according to #7981

@smlng
Copy link
Copy Markdown
Member

smlng commented Nov 9, 2017

tested again with PhyNode, pba-d-01-kw2x -> still good.

@smlng
Copy link
Copy Markdown
Member

smlng commented Nov 9, 2017

please squash reasonably

@jnohlgard jnohlgard force-pushed the pr/kinetis-one-cpu-dir branch from b73eb67 to 33e751e Compare November 10, 2017 09:43
@jnohlgard
Copy link
Copy Markdown
Member Author

@smlng squashed

@jnohlgard jnohlgard added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 10, 2017
@smlng
Copy link
Copy Markdown
Member

smlng commented Nov 10, 2017

PhyNode still works, ACK & GO!

@smlng smlng merged commit 8f4b21b into RIOT-OS:master Nov 10, 2017
@jnohlgard
Copy link
Copy Markdown
Member Author

@smlng @kaspar030 @haukepetersen Thanks for a very good review effort 🎉

@jnohlgard jnohlgard deleted the pr/kinetis-one-cpu-dir branch November 10, 2017 14:53
@aabadie aabadie added this to the Release 2018.01 milestone Jan 18, 2018
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: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants