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

Makefile.include: flash: do not peek into MAKECMDGOALS. #10548

Merged
merged 2 commits into from Dec 18, 2018

Conversation

jcarrano
Copy link
Contributor

@jcarrano jcarrano commented Dec 5, 2018

Contribution description

When flash-only was introduced (in #8373), the flash rule was made conditionally dependent on all by looking for flash-only in MAKECMDGOALS. This was done to avoid code duplication.

There's a cleaner way, by using canned recipes.

Testing procedure

Go to any example and type make flash-only and make flash. You don't even need to have the board connected.

In the first case it should not attempt to make all and in the second it should.

Issues/PRs references

Refactor of #8373.

@jcarrano jcarrano added Area: build system Area: Build system 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 labels Dec 5, 2018
@jcarrano jcarrano requested a review from smlng December 5, 2018 11:42
@cladmi cladmi added the CI: run tests If set, CI server will run tests on hardware for the labeled PR label Dec 5, 2018
@cladmi
Copy link
Contributor

cladmi commented Dec 5, 2018

I globally agree with the change. When introduced there were not many usages of define or usage of canned recipe so was not going in this direction as it would have asked to repeat the check and the FLASHER lines.

My only remark, is that I would prefer to use an active verb.

The check_cmd does check the command exists.
In the documentation they use run-yacc or frobnicate, where here flash-commands it is more a descriptive name or its content than of what it does.

@jcarrano
Copy link
Contributor Author

jcarrano commented Dec 5, 2018

What about "do-flash"?

@cladmi
Copy link
Contributor

cladmi commented Dec 5, 2018

Sent too early…

So maybe run-flash, or flash-firmware, or if you have any idea.

The build will also need to be re-triggered before merging as it was not done with CI: run tests but it can wait until updated.

@cladmi
Copy link
Contributor

cladmi commented Dec 5, 2018

Also, some infos I found about the define auie = that could fail with make 3.81 which is the version from osx if using automatic variables:

https://stackoverflow.com/questions/5032935/why-gnu-make-canned-recipe-doesnt-work
https://stackoverflow.com/questions/5033181/gnu-make-differences-in-multiline-variable-declarations

Here there should not be any issue for the moment as it is not using the name but maybe it is better to not put the = as it would be copied to other cases ?

@cladmi
Copy link
Contributor

cladmi commented Dec 5, 2018

Which also means, we need an OSX test of the current version at least.

@jcarrano
Copy link
Contributor Author

jcarrano commented Dec 5, 2018

That sucks! It means we cannot ?= a canned recipe. OSX sucks so bad it spreads its suckyness everywhere.

For reference, OSX's version of make is 12 years old.

@cladmi
Copy link
Contributor

cladmi commented Dec 5, 2018

It was also in debian wheezy, but its LTS support has been ended since May 2018 https://www.debian.org/releases/wheezy/

@cladmi
Copy link
Contributor

cladmi commented Dec 6, 2018

Shown irl, I found this line by checking something else:

flash: $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin

There might be others and they must be updated to FLASHDEPS then.

@cladmi
Copy link
Contributor

cladmi commented Dec 6, 2018

For upcoming steps, as you are also working on cleaning it.
This flash-recipe can also be used in mcuboot.mk and in riotboot PR also.

@cladmi
Copy link
Contributor

cladmi commented Dec 6, 2018

I tested that the wdog-disable.o wdog-disable.bin is indeed created when doing make flash and also when doing make all; make flash-only for BOARD=mulle.

For me you can squash. Please put the kinetis commit first as it is required to have a working history.

I would like a test on mac before merging this too @smlng

@miri64 miri64 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 Dec 6, 2018
With the canned recipe for flashing, flash dependencies should be
added to FLASHDEPS, instead of writing `flash: dependencies`. This
ensures that both flash and flash-only depend on the same prerequisites.
@miri64 miri64 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 Dec 6, 2018
@jcarrano
Copy link
Contributor Author

@smlng can you take look at this? or someone else with a fruit computer?

@smlng
Copy link
Member

smlng commented Dec 11, 2018

tested on macOS with pba-d-01-kw2x aka PhyNode, does work with flash and flash-only targets as expected.

@jcarrano
Copy link
Contributor Author

@smlng Thanks!

Copy link
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.

I give the ACK, but would prefer to have @cladmi have the final word and honour to hit the green button.

@cladmi
Copy link
Contributor

cladmi commented Dec 18, 2018

Just a last nitpick, can you please put in the commit description canned recipe definition that we do no use define name = or even define name ?= because of make 3.81 limitations. It would simplify understanding for future changes. You can directly amend the commit.

Note for future PRs, this can also be propagated later to mcuboot and riotboot but will need adaptation on their side so should come in followup PRs.

@cladmi
Copy link
Contributor

cladmi commented Dec 18, 2018

BTW github still shows the kinetis commit after the other one, but the order is correct when looked locally.

@jcarrano
Copy link
Contributor Author

I updated the commit message and added a comment too.

When flash-only was introduced (in RIOT-OS#8373), the `flash` rule was
made conditionally dependent on `all` by looking for `flash-only`
in MAKECMDGOALS. This was done to avoid code duplication.

There's a cleaner way, by using canned recipes. When we upgrade the
requirements to gnu make 4, the flash recipe can be defined as ?=.
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. Changes reviewed and also work with mac.
Commit messages and order has been reviewed.

I locally re-tested this branch merged with riot/master.

I used flash and flash-only for iotlab-m3.
And also checked the wdog-disable.bin file was created when doing flash and flash-only for mulle, pba-d-01-kw2x and with USE_OLD_OPENOCD=1 BOARD=frdm-k22f. I cleaned the file between each command to verify it was created for both flash and flash-only.

@cladmi cladmi merged commit 321dc52 into RIOT-OS:master Dec 18, 2018
@aabadie aabadie added this to the Release 2019.01 milestone Dec 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR CI: run tests If set, CI server will run tests on hardware 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.

None yet

5 participants