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

cpu+board frdm-k22f: Add NXP FRDM-K22F development board #6994

Merged
merged 6 commits into from
Jul 18, 2017

Conversation

jnohlgard
Copy link
Member

@jnohlgard jnohlgard commented May 2, 2017

This PR adds support for the NXP Kinetis K22F CPU and the FRDM-K22F development board.

Some common settings for FRDM development boards were moved to boards/frdm-common to reduce the maintenance effort. The existing FRDM-K64F board support has been updated to use the shared files.

Depends on #6916 #6993

@jnohlgard jnohlgard added Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: new feature The issue requests / The PR implemements a new feature for RIOT State: waiting for other PR State: The PR requires another PR to be merged first labels May 2, 2017
@jnohlgard jnohlgard added this to the Release 2017.07 milestone May 2, 2017
@jnohlgard jnohlgard force-pushed the pr/frdm-k22f branch 2 times, most recently from 98d195f to de76dac Compare June 1, 2017 05:16
@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 Jun 21, 2017
@aabadie aabadie added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Jun 22, 2017
Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

Codewise looks good. I only have a few nitpicks. Is there someone with the hardware that could test ?

This will be ok after usual rebase/squash and comments addressed.

Thanks for the hard work on supporting NXP @gebart :)

#endif

/**
* @brief ARM Cortex-M specific CPU configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

Could be @name ?

/**
* @name GPIO pin mux function numbers
*/
/** @{ */
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be moved in the same doxygen block above

/**
* @name GPIO interrupt flank settings
*/
/** @{ */
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

/**
* @name Timer hardware information
*/
/** @{ */
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

* @brief UART module configuration options
*/
typedef struct {
UART_Type *dev; /**< Pointer to module hardware registers */
void *dev; /**< Pointer to module hardware registers */
Copy link
Contributor

Choose a reason for hiding this comment

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

Any particular reason for replacing by void * ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is part of the commit to support both UART and LPUART in the same driver, and there are other CPUs which only have one or the other, so I used a void pointer as the least common denominator.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's interesting. I'm wondering if the same strategy could also be applied to STM32. Some macros make the driver implementation harder to read/understand btw.

Copy link
Member Author

Choose a reason for hiding this comment

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

The macros are used as a way to eliminate the dispatcher function if a board only supports one or the other type of hardware.

@jnohlgard
Copy link
Member Author

I will try to address all comments during this week

Copy link
Contributor

@haukepetersen haukepetersen left a comment

Choose a reason for hiding this comment

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

Nice one! My main issue is the added support for the lpuart which I think might be better PRed separately, but otherwise only minor things.

Did just try to flash the board with a newly pulled openOCD version (0.10.0+dev-00167-g29cfe9c (2017-07-13-18:35)), but without success -> using the jlink interface I get an Selected transport is not supported.... But then I did not try hard and did not try to update the firmware on the flash chip...

# watchdog automatically. However, current stable releases of Ubuntu and Debian
# have only version 0.9.0 and older OpenOCD packages (Ubuntu 17.04, Debian Jessie)
# Set this to 0 to avoid the extra manual step of disabling the watchdog.
export USE_OLD_OPENOCD ?= 1
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder: how about we make a recent version of OpenOCD mandatory if you want to use these boards? This would simplify the configuration quite a bit and I think it is completely ok to expect developers to have more or less recent tool versions... Maybe we can put something in place like OPENOCD_MIN_VER := 0.10.0 in the board's Makefile and add some code in dist/tools/openocd/openocd.sh to check that version and give some verbose error message telling the developter to update OpenOCD? This could also be useful for other boards...

Though this might as well be address in a follow-up PR...

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like the idea of requiring a newer version than what is available in the distributions. For the newer CPUs (e.g. kw41z) there's no choice, but the older CPUs should be possible to use the distribution provided openocd.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm fine with that, I just wanted to think that thought loud once :-)

# define the cpu used by the board
export CPU = k22f
export CPU_MODEL = mk22fn512vlh12
export CPU_FAMILY = kx
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer moving the CPU_FAMILY define into cpu/k22f/Makefile.include, as it is tied to that CPU...

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea

#define KINETIS_MCG_ERC_OSCILLATOR 1
#define KINETIS_MCG_ERC_FRDIV 3 /* ERC divider = 256 */
#define KINETIS_MCG_ERC_RANGE 1
#define KINETIS_MCG_ERC_FREQ 40000000u
Copy link
Contributor

Choose a reason for hiding this comment

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

parens around the value?

}, \
}
#define LPTMR_NUMOF (1U)
#define LPTMR_CONFIG { \
Copy link
Contributor

Choose a reason for hiding this comment

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

allignment of \ chars is somewhat inconsistent (sorry for being picky :-) )

{ ADC0, GPIO_PIN(PORT_B, 0), 8 },
{ ADC0, GPIO_PIN(PORT_B, 1), 9 },
{ ADC0, GPIO_PIN(PORT_C, 1), 15 },
{ ADC0, GPIO_PIN(PORT_C, 2), 4 },
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to name the parameters : { .dev = ADC0, .pin = ... },

@@ -1,31 +1,7 @@
# define the cpu used by the FRDM-K64F board
export CPU = k64f
export CPU_MODEL = mk64fn1m0vll12
export CPU_FAMILY = kx
Copy link
Contributor

Choose a reason for hiding this comment

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

same here: move to CPUs Makefile.include

@@ -322,6 +330,7 @@ typedef struct {
volatile uint32_t *scgc_addr; /**< Clock enable register, in SIM module */
uint8_t scgc_bit; /**< Clock enable bit, within the register */
uint8_t mode; /**< UART mode: data bits, parity, stop bits */
uint8_t type; /**< Hardware module type (KINETIS_UART or KINETIS_LPUART)*/
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would prefer to PR the 'UART extension' in a separate PR...

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there any benefit in doing this in two steps, other than bureaucratic? This CPU supports both UART and LPUART, the KW41Z (other PR) supports only LPUART. The already supported kinetis CPUs support AFAIK, only UART. The LPUART should probably be the default when possible because it is working in STOP and VLPS modes (async operation), to allow lower power consumption.

@@ -105,6 +105,7 @@ WEAK_DEFAULT void isr_i2s0_rx(void);
WEAK_DEFAULT void isr_i2s0_tx(void);
WEAK_DEFAULT void isr_llwu(void);
WEAK_DEFAULT void isr_lptmr0(void);
WEAK_DEFAULT void isr_lpuart0(void);
Copy link
Contributor

Choose a reason for hiding this comment

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

this is added to the common vectors file, but never used in this file, right?!

Copy link
Member Author

Choose a reason for hiding this comment

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

Should be used in the periph UART driver, I'll look it up.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the weak default for the function used in vectors.c (https://github.com/gebart/RIOT/blob/pr/frdm-k22f/cpu/k22f/vectors.c#L76) for when the LPUART module is not used by the UART driver.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, never mind then.

@@ -23,13 +23,27 @@
* @}
Copy link
Contributor

Choose a reason for hiding this comment

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

as stated above, I think the support for the LPUART should be PRed separately...

@jnohlgard
Copy link
Member Author

@haukepetersen did you try flashing with the default setting for FRDM_IFACE? My frdm-k22f board came flashed with a DAP interface firmware. The frdm-kw41z, on the other hand, came with a jlink firmware. The default settings in the board Makefile.include reflect what my boards have had from the factory.

@jnohlgard
Copy link
Member Author

addressed comments

@jnohlgard
Copy link
Member Author

Split the LPUART change into a separate PR #7362
I think all comments have now been addressed.

@haukepetersen @aabadie OK to squash?

Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

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

Untested-ACK (to not block this PR)

@haukepetersen
Copy link
Contributor

Ok, turned out that I was not able to flash because I don't have a frdm-k22f, but I tried to flash a frdm-kw41z...

Copy link
Contributor

@haukepetersen haukepetersen left a comment

Choose a reason for hiding this comment

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

untested ACK. But confirmed the frdm-k64f to be still working with this PR.

@haukepetersen
Copy link
Contributor

please squash and merge at will one Murdock is happy.

@jnohlgard jnohlgard removed the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Jul 18, 2017
@jnohlgard
Copy link
Member Author

squashed, rebased

@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: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jul 18, 2017
@jnohlgard jnohlgard merged commit 0f494bb into RIOT-OS:master Jul 18, 2017
@jnohlgard
Copy link
Member Author

Murdock is happy -> go

@jnohlgard jnohlgard deleted the pr/frdm-k22f branch July 18, 2017 06:54
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: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants