Skip to content

Conversation

aabadie
Copy link
Contributor

@aabadie aabadie commented Jun 3, 2019

Contribution description

fixes #11616

In #11044 the phynode-kw41z was not updated to make use the common kw41z Makefile.include because it was not sharing the same debug adapter (dap instead of jlink) and not using the same board_init function (in board.c).

After #11616 was opened, I thought it would make more sense to explicitly move the USEMODULE += boards_common_kw41z in the boards that use it instead of using it by default in the common part. This simplify reuse of the common Makefile.include.

Now phynode-kw41z also uses the common Makefile.include and still doesn't depend on boards_common_kw41z since it provides its own board_init function.

Testing procedure

Normally, we should test that flashing still works on phynode-kw41z boards.
For the rest, a green Murdock should be ok.

Issues/PRs references

fixes #11616, follow-up of #11044

@aabadie aabadie added 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 Area: boards Area: Board ports labels Jun 3, 2019
@aabadie aabadie requested a review from cladmi June 3, 2019 11:13
@cladmi
Copy link
Contributor

cladmi commented Jun 3, 2019

Ohh, I see the pattern I do not like either :D (it is not specific to here but in general).

It is using the common but again not entirely again. And in practice I like having the USEMODULE += boards_common... in the common one too as it somehow defines that the board extends the common one. So let's not rush and see for the root cause first.

I think that somehow none of the common should define board_init but here only board_common_kw41z_init and be called from the main board_init. Here we still have code duplication as both define the led_init code.
Having these generic names somehow goes against the function namespacing rule too.
Do you think it makes sense ?

Would changing to a boards_common_kw41z_init be a valid change here for you ?
Starting a change like this may require a tracking issue to do it everywhere too.

And going like this, even maybe boards should define board_board_name_init. This would be required to allow reusing a board and extend it. (also needs to not define 'board' but 'board_board_name' module and all).

@aabadie
Copy link
Contributor Author

aabadie commented Jun 4, 2019

And in practice I like having the USEMODULE += boards_common... in the common one too as it somehow defines that the board extends the common one

The use of USEMODULE += boards_common_... is here to tell the build system that this board also uses the common board_init function. It's like having the common board_init in a shared module that is pulled in when a specific board can use it because it doesn't have specific initializations. So for me it makes more sense as it is now.

Do you think it makes sense ?

I see your point but I'm not sure this should be discussed here.

Would changing to a boards_common_kw41z_init be a valid change here for you ?

I'm not sure what would be the impact in term of code size, while I see the benefits in terms of flexibility. The problem is also that several boards are using the board_init function already, so it will end up in code duplication (several time the same main board_init function instead of only one implemented in one place).

@cladmi
Copy link
Contributor

cladmi commented Jun 11, 2019

The use of USEMODULE += boards_common_... is here to tell the build system that this board also uses the common board_init function. It's like having the common board_init in a shared module that is pulled in when a specific board can use it because it doesn't have specific initializations. So for me it makes more sense as it is now.

Currently it also says "use led_init" which is in common, and the content on board_init is duplicated.

But it is a different question/topic that touches the way to define boards and common boards in the C part.

Do you think it makes sense ?

I see your point but I'm not sure this should be discussed here.

Indeed it is not the place to discuss it, it was to ask some more background and see long term alternatives.

Would changing to a boards_common_kw41z_init be a valid change here for you ?

I'm not sure what would be the impact in term of code size, while I see the benefits in terms of flexibility. The problem is also that several boards are using the board_init function already, so it will end up in code duplication (several time the same main board_init function instead of only one implemented in one place).

It would still be implemented in one place but would be one more function call

board_init()
{
    board_common_auie_init();
    /* Allows having here my_board_specific_init(); */
} 

@cladmi
Copy link
Contributor

cladmi commented Jun 11, 2019

Right now, all the kw41z boards using common/kw41z/Makefile.features also use the common Makefile.dep and Makefile.include which is what I needed.

As phynode-kw41z does not use the common/kw41z module, it does not adds the directory in DIRS in its Makefile.

So it makes sense.

I will do a comparison of the reset/flash/debug output.

@cladmi
Copy link
Contributor

cladmi commented Jun 11, 2019

I get the same output for the variables with master and this PR

DEBUG_ADAPTER_ID=toto BOARD=phynode-kw41z make --no-print-directory -C examples/hello-world/ \
    info-debug-variable-FLASHER \
    info-debug-variable-FFLAGS \
    info-debug-variable-OPENOCD_ADAPTER_INIT \
    info-debug-variable-OPENOCD_PRE_FLASH_CMDS \
    info-debug-variable-INCLUDES \
    info-debug-variable-CPU \
    info-debug-variable-CPU_MODEL
/home/harter/work/git/RIOT/dist/tools/openocd/openocd.sh
flash /home/harter/work/git/RIOT/examples/hello-world/bin/phynode-kw41z/hello-world.elf
-c source [find interface/cmsis-dap.cfg] -c cmsis_dap_serial toto
-c kinetis fcf_source write
-isystem /opt/gcc-arm-none-eabi-7-2018-q2-update/arm-none-eabi/include/newlib-nano -I/home/harter/work/git/RIOT/core/include -I/home/harter/work/git/RIOT/drivers/include -I/home/harter/work/git/RIOT/sys/include -I/home/harter/work/git/RIOT/boards/phynode-kw41z/include -I/home/harter/work/git/RIOT/boards/common/kw41z/include -I/home/harter/work/git/RIOT/cpu/kinetis/include -I/home/harter/work/git/RIOT/cpu/cortexm_common/include -I/home/harter/work/git/RIOT/cpu/cortexm_common/include/vendor -I/home/harter/work/git/RIOT/sys/libc/include
kinetis
mkw41z512vht4

Copy link
Contributor

@cladmi cladmi left a comment

Choose a reason for hiding this comment

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

ACK. I get the same variables values with and without this pull request.

From a build system integration, I find it better that if a boards uses a common boards, it must include all the files .dep|.include|.features which otherwise leads to not understanding what means a common board.

@cladmi cladmi merged commit ec2278f into RIOT-OS:master Jun 11, 2019
@aabadie
Copy link
Contributor Author

aabadie commented Jun 11, 2019

Thanks :)

@aabadie aabadie deleted the pr/boards/kw41z-cleanup branch July 2, 2019 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: boards Area: Board ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR 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.

phynode-kw41z/Makefile.include does not use the common/kw41z/Makefile.include
2 participants