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

Fix build failures caused by #12947. #15019

Merged
merged 2 commits into from Nov 2, 2021
Merged

Fix build failures caused by #12947. #15019

merged 2 commits into from Nov 2, 2021

Conversation

tzarc
Copy link
Member

@tzarc tzarc commented Nov 2, 2021

Description

#12947 caused a whole host of problems with other boards. This fixes their build errors, and likely causes issues for boards that picked up new functionality from the previous PR, most likely around partitioning.

Ping @stapelberg -- you'll need to confirm the fixes, otherwise I'll end up having to revert the original changes entirely.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

@tzarc tzarc requested a review from a team November 2, 2021 05:49
@purdeaandrei
Copy link
Contributor

Looks good to me, tested to fix build failure on my boards.

@stapelberg
Copy link
Contributor

Ping @stapelberg -- you'll need to confirm the fixes, otherwise I'll end up having to revert the original changes entirely.

Looking at this now

Copy link
Contributor

@stapelberg stapelberg left a comment

Choose a reason for hiding this comment

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

Why does moving the #if guards outside of the kinetis_hsrun_disable() function help with build error? I would have assumed that for non-MK66F18 boards, the functions compile to an empty function and the compiler removes them entirely as an optimization?

Anyway, the change looks correct except for one place where I added a comment.

// FlexRAM is configured as traditional RAM
// We need to reconfigure for EEPROM usage

# if defined(MK66F18)
kinetis_hsrun_disable();
FTFL->FCCOB0 = FTFE_FCCOB0_CCOBn_SET(0x80); // PGMPART = Program Partition Command
Copy link
Contributor

Choose a reason for hiding this comment

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

FCCOB0 needs to be set outside of MK66F18, too, so this #if directive is too broad.

I only changed FTFL->FCCOB0 = 0x80; to FTFL->FCCOB0 = FTFE_FCCOB0_CCOBn_SET(0x80); in PR #12947

Copy link
Member Author

Choose a reason for hiding this comment

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

Why does moving the #if guards outside of the kinetis_hsrun_disable() function help with build error?

Because those functions are unused on other platforms, and warnings occur as a result... which are treated as errors.

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 only changed FTFL->FCCOB0 = 0x80; to FTFL->FCCOB0 = FTFE_FCCOB0_CCOBn_SET(0x80); in PR #12947

FTFE_FCCOB0_CCOBn_SET does not exist on non-MK66F18 boards, and ends up failing the build.

Copy link
Member Author

@tzarc tzarc Nov 2, 2021

Choose a reason for hiding this comment

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

On develop CI:

Compiling: tmk_core/common/chibios/eeprom_teensy.c                                                 
tmk_core/common/chibios/eeprom_teensy.c:105:12: error: 'kinetis_hsrun_enable' defined but not used [-Werror=unused-function]
 static int kinetis_hsrun_enable(void) {
            ^~~~~~~~~~~~~~~~~~~~
tmk_core/common/chibios/eeprom_teensy.c:47:12: error: 'kinetis_hsrun_disable' defined but not used [-Werror=unused-function]
 static int kinetis_hsrun_disable(void) {
            ^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

...and:

Compiling: tmk_core/common/chibios/eeprom_teensy.c                                                 
tmk_core/common/chibios/eeprom_teensy.c: In function 'eeprom_initialize':
tmk_core/common/chibios/eeprom_teensy.c:237:24: error: implicit declaration of function 'FTFE_FCCOB0_CCOBn_SET' [-Werror=implicit-function-declaration]
         FTFL->FCCOB0 = FTFE_FCCOB0_CCOBn_SET(0x80);  // PGMPART = Program Partition Command
                        ^~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Copy link
Contributor

@stapelberg stapelberg Nov 2, 2021

Choose a reason for hiding this comment

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

I only changed FTFL->FCCOB0 = 0x80; to FTFL->FCCOB0 = FTFE_FCCOB0_CCOBn_SET(0x80); in PR #12947

FTFE_FCCOB0_CCOBn_SET does not exist on non-MK66F18 boards, and ends up failing the build.

Gotcha. We should just change it back to FTFL->FCCOB0 = 0x80 then. The macro does no changes, I only used it for descriptiveness.

Copy link
Member Author

Choose a reason for hiding this comment

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

FCCOB0 needs to be set outside of MK66F18, too, so this #if directive is too broad.

I only changed FTFL->FCCOB0 = 0x80; to FTFL->FCCOB0 = FTFE_FCCOB0_CCOBn_SET(0x80); in PR #12947

Are we missing a header or something, then?

Copy link
Contributor

Choose a reason for hiding this comment

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

The macro is defined in lib/chibios-contrib/os/common/ext/CMSIS/KINETIS/MK66F18.h, but not for other devices. Not sure why.

As i said, easiest to change it back to just 0x80.

Comment on lines 47 to 48
static int kinetis_hsrun_disable(void) {
#if defined(MK66F18)
static int kinetis_hsrun_disable(void) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe do this instead:

#if defined(MK66F18)
static int kinetis_hsrun_disable(void) {
   // ... the real implementation
}
#else
static inline int kinetis_hsrun_disable(void) { return 0; }
#endif

(static inline does not cause an error if the function ends up unused)

Copy link
Member Author

Choose a reason for hiding this comment

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

(static inline does not cause an error if the function ends up unused)

Fair point. Probably easier that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

Swapped the definitions to static inline, still broken with FTFE_FCCOB0_CCOBn_SET.

@tzarc
Copy link
Member Author

tzarc commented Nov 2, 2021

@stapelberg @sigprof should be good to go, now. Would be great for confirmation! Thanks!

@stapelberg
Copy link
Contributor

@stapelberg @sigprof should be good to go, now. Would be great for confirmation! Thanks!

Looks good, thanks for the fix!

@zvecr zvecr merged commit 0ecd492 into qmk:develop Nov 2, 2021
@tzarc tzarc deleted the fixup-12947 branch November 2, 2021 18:22
ptrxyz pushed a commit to ptrxyz/qmk_firmware that referenced this pull request Apr 9, 2022
* Fix build failures caused by qmk#12947. Unknown if this actually works.

* qmk format-c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants