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

makefiles/vars.inc.mk: introduce and use PROG_DEV #12460

Merged
merged 5 commits into from
Oct 25, 2019

Conversation

fjmolinas
Copy link
Contributor

@fjmolinas fjmolinas commented Oct 15, 2019

Contribution description

In some cases the PORT used to program a BOARD is not the same used to open a serial terminal. This is already the case for boards using PORT_BSL and AVRDUDE_PORT.

There are also use cases when boards that use a BSL botloader might want to use another PORT (threw a ftdi converter for examples). An examples of this are boards using BOSA (#12304) since the serial connection is lost if the the code halts or hardfaults, as well as during a reset command.

#12419 also needs this definition since it was shown that the PORT (device) used for programming is rarely the same device used for serial output, so both need to be passed to the container.

This PR introduces a new PROG_PORTPROG_DEV and merges the definitions of PORT_BSL and AVRDUDE_PORT to also use PROG_PORTPROG_DEV .

By default it is it set so that PROG_PORTPROG_DEV ?= PORT. A warning is added for boards using old PROGRAMMER PORT definitions

Testing procedure

  • Nothing has changed for BOARDS using AVRDUDE_PORT:
for board in arduino-leonardo mega-xplained waspmote-pro; do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT info-debug-variable-PROG_DEV; done > PORT_AVRDUDE-pr.txt 
for board in arduino-leonardo mega-xplained waspmote-pro; do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT info-debug-variable-AVRDUDE_PORT; done > PORT_AVRDUDE-master.txt
diff PORT_AVRDUDE-pr.txt PORT_AVRDUDE-master.txt
#no diff
  • Nothing has changed for BOARDS using PORT_BSL:
for board in openmote-b firefly remote-pa remote-revb remote-reva; do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT info-debug-variable-PROG_DEV done > PROG_DEV-pr.txt
for board in openmote-b firefly remote-pa remote-revb remote-reva; do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT info-debug-variable-PORT_BSL; done > PORT_BSL-master.txt
diff PORT_BSL-pr.txt PORT_BSL-master.txt
#no diff
  • PORT is still the same:
for board in $(make info-boards); do PORT=/dev/test-port BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT; done > PORT-[master/pr].txt
diff PORT-master.txt PORT-pr.txt
#no diff
  • FFLAGS and related are the same:
for board in $(make info-boards); do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-FFLAGS info-debug-variable-PREFFLAGS info-debug-variable-PROGRAMMER_FLAGS info-debug-variable-RESET_FLAGS; done > FFLAGS-[pr/master].txt
git diff FFLAGS-pr.txt FFLAGS-master.txt
#no diff
  • Do you agree with PROG_PORTPROG_DEV as a name?

Issues/PRs references

#12419

@fjmolinas fjmolinas added Area: tests Area: tests and testing framework Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation labels Oct 15, 2019
@keestux
Copy link
Contributor

keestux commented Oct 15, 2019

@fjmolinas Cool. From the description I can see that this what I need.
I'll take a closer look shortly.

@keestux
Copy link
Contributor

keestux commented Oct 15, 2019

For some reason I can't get it to work with compile_and_test_for_board.py. I'm assuming I don't need to modify my sodaq-autonomo Makefiles, right?

This is my command

PROG_PORT=/dev/ttyACM0 PORT=/dev/ttyUSB12 ./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py ~/src/RIOT sodaq-autonomo /tmp/RIOT-tests

@fjmolinas
Copy link
Contributor Author

PROG_PORT=/dev/ttyACM0 PORT=/dev/ttyUSB12 ./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py ~/src/RIOT sodaq-autonomo /tmp/RIOT-tests

I don't have the particular board to test but if I do:

PROG_PORT=/dev/ttyACM1 PORT=/dev/ttyUSB1 ./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py . sodaq-autonomo -j3 --applications tests/cpp11_thread/
INFO:sodaq-autonomo:Saving toolchain
INFO:sodaq-autonomo.tests/cpp11_thread/:Board supported: True
INFO:sodaq-autonomo.tests/cpp11_thread/:Board has enough memory: True
INFO:sodaq-autonomo.tests/cpp11_thread/:Application has test: True
INFO:sodaq-autonomo.tests/cpp11_thread/:Run compilation
INFO:sodaq-autonomo.tests/cpp11_thread/:Run test
INFO:sodaq-autonomo.tests/cpp11_thread/:Run test.flash
WARNING:sodaq-autonomo.tests/cpp11_thread/:make RIOT_CI_BUILD=1 CC_NOCOLOR=1 --no-print-directory -C ./tests/cpp11_thread/ flash-only
/home/francisco/Workspace/RIOT/dist/tools/bossa/bossac -p /dev/ttyACM1 -e -i -w -v -b -R /home/francisco/Workspace/RIOT/tests/cpp11_thread/bin/sodaq-autonomo/tests_cpp11_thread.bin
No device found on /dev/ttyACM1
/home/francisco/Workspace/RIOT/tests/cpp11_thread/../../Makefile.include:635: recipe for target 'flash-only' failed
make: *** [flash-only] Error 1

Return value: 2

ERROR:sodaq-autonomo.tests/cpp11_thread/:Error during test.flash, writing to results/sodaq-autonomo/tests/cpp11_thread/test.flash.failed
ERROR:sodaq-autonomo.tests/cpp11_thread/:Failed during: test.flash
ERROR:sodaq-autonomo:Tests failed: 1
Failures during test.flash:
- [tests/cpp11_thread/](tests/cpp11_thread/test.flash.failed)
PROG_PORT=/dev/ttyACM1 PORT=/dev/ttyUSB1 ./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py . sodaq-autonomo -j3 --applications tests/cpp11_thread/ --flash-targets=''
INFO:sodaq-autonomo:Saving toolchain
INFO:sodaq-autonomo.tests/cpp11_thread/:Board supported: True
INFO:sodaq-autonomo.tests/cpp11_thread/:Board has enough memory: True
INFO:sodaq-autonomo.tests/cpp11_thread/:Application has test: True
INFO:sodaq-autonomo.tests/cpp11_thread/:Run compilation
INFO:sodaq-autonomo.tests/cpp11_thread/:Run test
INFO:sodaq-autonomo.tests/cpp11_thread/:Run test.flash
WARNING:sodaq-autonomo.tests/cpp11_thread/:make RIOT_CI_BUILD=1 CC_NOCOLOR=1 --no-print-directory -C ./tests/cpp11_thread/ test
/home/francisco/Workspace/RIOT/dist/tools/pyterm/pyterm -p "/dev/ttyUSB1" -b "115200" --noprefix --no-repeat-command-on-empty-line
Twisted not available, please install it if you want to use pyterm's JSON capabilities
Connect to serial port /dev/ttyUSB1
Cannot connect to serial port /dev/ttyUSB1: could not open port /dev/ttyUSB1: [Errno 2] No such file or directory: '/dev/ttyUSB1'
/home/francisco/Workspace/RIOT/Makefile.include:650: recipe for target 'cleanterm' failed
make[1]: *** [cleanterm] Error 1
Unexpected end of file in expect script at "child.expect_exact("************ C++ thread test ***********")" (tests/cpp11_thread/tests/01-run.py:15)

Process already stopped
/home/francisco/Workspace/RIOT/tests/cpp11_thread/../../Makefile.include:689: recipe for target 'test' failed
make: *** [test] Error 1

Return value: 2

ERROR:sodaq-autonomo.tests/cpp11_thread/:Error during test, writing to results/sodaq-autonomo/tests/cpp11_thread/test.failed
ERROR:sodaq-autonomo.tests/cpp11_thread/:Failed during: test
ERROR:sodaq-autonomo:Tests failed: 1
Failures during test:
- [tests/cpp11_thread/](tests/cpp11_thread/test.failed)

I can see the right ports are being used.

@fjmolinas
Copy link
Contributor Author

For some reason I can't get it to work with compile_and_test_for_board.py. I'm assuming I don't need to modify my sodaq-autonomo Makefiles, right?

Could you post your exact output?

@aabadie
Copy link
Contributor

aabadie commented Oct 16, 2019

I can't get it to work with compile_and_test_for_board.py

This is because when the script tries to flash the running firmware is not the Arduino bootloader.
When the running firmware is the Arduino bootloader, the computer sees /dev/ttyACMx. When this is the RIOT firmware, it sees /dev/ttyUSBx (your USB to UART converter).

You need a way to automatically switch to bootloader mode before calling the flasher. This is what is done in #12304.

There's another manual solution: double tap the reset button while the script is building each application.

@aabadie
Copy link
Contributor

aabadie commented Oct 16, 2019

Otherwise I'm +1 for the name PROG_PORT. Maybe DEBUG_ADAPTER_ID could also be renamed in PROG_SERIAL later (e.g in a follow-up PR) to be consistent.

@MrKevinWeiss
Copy link
Contributor

I also really like this PR and it is on the list but it would take a while for me to test (both a while to find the time and the amount of time it would take for me to understand everything that needs to be tested).

@keestux
Copy link
Contributor

keestux commented Oct 16, 2019

OK, good that you showed me how to run one particular test. I was running all tests until I hit the error. You have to be patient for that :-)

I now see what I was doing wrong. I have several RIOT checkouts and I was executing the tests from my "main" checkout, not from the clone of your repo.

Yes, it's working! Well, sort of. I'll try a few more tests and see why it didn't see all of the test output.

$ PROG_PORT=/dev/ttyACM0 PORT=/dev/ttySLOT12 ./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py --applications tests/cpp11_thread . sodaq-autonomo /tmp/RIOT-tests
INFO:sodaq-autonomo:Saving toolchain
INFO:sodaq-autonomo.tests/cpp11_thread:Board supported: True
INFO:sodaq-autonomo.tests/cpp11_thread:Board has enough memory: True
INFO:sodaq-autonomo.tests/cpp11_thread:Application has test: True
INFO:sodaq-autonomo.tests/cpp11_thread:Run compilation
INFO:sodaq-autonomo.tests/cpp11_thread:Run test
INFO:sodaq-autonomo.tests/cpp11_thread:Run test.flash
WARNING:sodaq-autonomo.tests/cpp11_thread:make RIOT_CI_BUILD=1 CC_NOCOLOR=1 --no-print-directory -C ./tests/cpp11_thread test
/home/kees/src/RIOT-fjmolinas/dist/tools/pyterm/pyterm -p "/dev/ttySLOT12" -b "115200" --noprefix --no-repeat-command-on-empty-line
Connect to serial port /dev/ttySLOT12
Welcome to pyterm!
Type '/exit' to exit.
Done

Testing sleep_until ...
Done

Swapping two threads ...
Done

Move constructor ...
Done

Bye, bye.
******************************************
Timeout in expect script at "child.expect_exact("************ C++ thread test ***********")" (tests/cpp11_thread/tests/01-run.py:15)

/home/kees/src/RIOT-fjmolinas/tests/cpp11_thread/../../Makefile.include:689: recipe for target 'test' failed
make: *** [test] Error 1

Return value: 2

ERROR:sodaq-autonomo.tests/cpp11_thread:Error during test, writing to /tmp/RIOT-tests/sodaq-autonomo/tests/cpp11_thread/test.failed
ERROR:sodaq-autonomo.tests/cpp11_thread:Failed during: test
ERROR:sodaq-autonomo:Tests failed: 1
Failures during test:
- [tests/cpp11_thread](tests/cpp11_thread/test.failed)

@keestux
Copy link
Contributor

keestux commented Oct 16, 2019

Running it a second time and it succeed. Hmm.

$ PROG_PORT=/dev/ttyACM0 PORT=/dev/ttySLOT12 ./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py --applications tests/cpp11_thread . sodaq-autonomo /tmp/RIOT-tests
INFO:sodaq-autonomo:Saving toolchain
INFO:sodaq-autonomo.tests/cpp11_thread:Board supported: True
INFO:sodaq-autonomo.tests/cpp11_thread:Board has enough memory: True
INFO:sodaq-autonomo.tests/cpp11_thread:Application has test: True
INFO:sodaq-autonomo.tests/cpp11_thread:Run compilation
INFO:sodaq-autonomo.tests/cpp11_thread:Run test
INFO:sodaq-autonomo.tests/cpp11_thread:Run test.flash
INFO:sodaq-autonomo.tests/cpp11_thread:Success
INFO:sodaq-autonomo:Tests successful

@keestux
Copy link
Contributor

keestux commented Oct 16, 2019

@aabadie can you comment briefly on the fact that tests are "not supported" anymore when combining #12304 with this PR?

$ PROG_PORT=/dev/ttyACM0 PORT=/dev/ttySLOT12 ./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py --applications tests/bench_msg_pingpong/ . sodaq-autonomo /tmp/RIOT-tests
INFO:sodaq-autonomo:Saving toolchain
INFO:sodaq-autonomo.tests/bench_msg_pingpong/:Board supported: False
INFO:sodaq-autonomo:Tests successful

@aabadie
Copy link
Contributor

aabadie commented Oct 17, 2019

can you comment briefly on the fact that tests are "not supported" anymore when combining #12304 with this PR?

This was a problem in #12304. I've just pushed a fixup commit.

@aabadie
Copy link
Contributor

aabadie commented Oct 18, 2019

This one needs a rebase.

@fjmolinas
Copy link
Contributor Author

Rebased.

@fjmolinas fjmolinas changed the title makefiles/vars.inc.mk: introduce and use PROG_PORT makefiles/vars.inc.mk: introduce and use DEV_PROG Oct 22, 2019
@keestux
Copy link
Contributor

keestux commented Oct 22, 2019

@fjmolinas What happened to the agreed PROG_DEV ?

@fjmolinas
Copy link
Contributor Author

fjmolinas commented Oct 22, 2019

@fjmolinas What happened to the agreed PROG_DEV ?

Damn, I'm so sorry... I changed to the wrong name (somehow got confused when making the change). Sorry for the confusion, I'll fix tomorrow morning.

@fjmolinas fjmolinas changed the title makefiles/vars.inc.mk: introduce and use DEV_PROG makefiles/vars.inc.mk: introduce and use PROG_DEV Oct 22, 2019
@fjmolinas
Copy link
Contributor Author

@keestux I went ahead and fixed it right away, sorry for the inconvenience.

PORT_LINUX ?= /dev/ttyUSB0
AVRDUDE_PORT ?= /dev/ttyACM0
PROG_DEV ?= /dev/ttyACM0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fix alignment here when squashing.

Copy link
Contributor

@keestux keestux left a comment

Choose a reason for hiding this comment

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

Testing done on sodaq-autonomo. Doing manually board resets.
I ran a few tests, not all.
It looks good to me.

@MrKevinWeiss MrKevinWeiss added 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 labels Oct 23, 2019
@MrKevinWeiss
Copy link
Contributor

All failures are due to flashing or connection issues.

### arduino-mega2560/failuresummary.md
Failures during test.flash:
- [tests/bloom_bytes](tests/bloom_bytes/test.flash.failed)
- [tests/xtimer_usleep](tests/xtimer_usleep/test.flash.failed)
#### cc2650-launchpad/failuresummary.md
#### ek-lm4f120xl/failuresummary.md
#### esp32-wroom-32/failuresummary.md
Failures during test:
- [tests/bloom_bytes](tests/bloom_bytes/test.failed)
- [tests/xtimer_usleep](tests/xtimer_usleep/test.failed)
#### frdm-k64f/failuresummary.md
#### frdm-kw41z/failuresummary.md
Failures during test:
- [tests/xtimer_usleep](tests/xtimer_usleep/test.failed)
#### msba2/failuresummary.md
#### mulle/failuresummary.md
Failures during test:
- [tests/bloom_bytes](tests/bloom_bytes/test.failed)
- [tests/xtimer_usleep](tests/xtimer_usleep/test.failed)
#### nrf52dk/failuresummary.md
#### nucleo-f103rb/failuresummary.md
#### pba-d-01-kw2x/failuresummary.md
#### sltb001a/failuresummary.md
#### stm32f3discovery/failuresummary.md

@fjmolinas fjmolinas force-pushed the pr_port_migration branch 2 times, most recently from 1f95e5b to 4b46c27 Compare October 24, 2019 09:59
@fjmolinas
Copy link
Contributor Author

I re-ran my test procedure after squash, no diff excpet in some esp32 errors because the line of info-debug-variable-%: changed to 148.

``` git checkout pr_port_migration for board in arduino-leonardo mega-xplained waspmote-pro; do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT info-debug-variable-PROG_DEV; done > PORT_AVRDUDE-pr.txt git checkout upstream/master for board in arduino-leonardo mega-xplained waspmote-pro; do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT info-debug-variable-AVRDUDE_PORT; done > PORT_AVRDUDE-master.txt git checkout pr_port_migration diff PORT_AVRDUDE-pr.txt PORT_AVRDUDE-master.txt for board in openmote-b firefly remote-pa remote-revb remote-reva; do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT info-debug-variable-PROG_DEV; done > PORT_BSL-pr.txt git checkout upstream/master for board in openmote-b firefly remote-pa remote-revb remote-reva; do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT info-debug-variable-PORT_BSL; done > PORT_BSL-master.txt git checkout pr_port_migration diff PORT_BSL-pr.txt PORT_BSL-master.txt for board in $(make info-boards); do PORT=/dev/test-port BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT; done > PORT-pr.txt git checkout upstream/master for board in $(make info-boards); do PORT=/dev/test-port BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-PORT; done > PORT-master.txt git checkout pr_port_migration diff PORT-master.txt PORT-pr.txt for board in $(make info-boards); do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-FFLAGS info-debug-variable-PREFFLAGS info-debug-variable-PROGRAMMER_FLAGS info-debug-variable-RESET_FLAGS; done > FFLAGS-pr.txt git checkout upstream/master for board in $(make info-boards); do BOARD=${board} make --no-print-directory -C examples/hello-world/ info-debug-variable-BOARD info-debug-variable-FFLAGS info-debug-variable-PREFFLAGS info-debug-variable-PROGRAMMER_FLAGS info-debug-variable-RESET_FLAGS; done > FFLAGS-master.txt git checkout pr_port_migration diff FFLAGS-pr.txt FFLAGS-master.txt ``` ``` 137c137 < /home/francisco/workspace/RIOT/makefiles/info.inc.mk:147: recipe for target 'info-debug-variable-PREFFLAGS' failed --- > /home/francisco/workspace/RIOT/makefiles/info.inc.mk:148: recipe for target 'info-debug-variable-PREFFLAGS' failed 143c143 < /home/francisco/workspace/RIOT/makefiles/info.inc.mk:147: recipe for target 'info-debug-variable-PREFFLAGS' failed --- > /home/francisco/workspace/RIOT/makefiles/info.inc.mk:148: recipe for target 'info-debug-variable-PREFFLAGS' failed 149c149 < /home/francisco/workspace/RIOT/makefiles/info.inc.mk:147: recipe for target 'info-debug-variable-PREFFLAGS' failed --- > /home/francisco/workspace/RIOT/makefiles/info.inc.mk:148: recipe for target 'info-debug-variable-PREFFLAGS' failed 155c155 < /home/francisco/workspace/RIOT/makefiles/info.inc.mk:147: recipe for target 'info-debug-variable-PREFFLAGS' failed --- > /home/francisco/workspace/RIOT/makefiles/info.inc.mk:148: recipe for target 'info-debug-variable-PREFFLAGS' failed 161c161 < /home/francisco/workspace/RIOT/makefiles/info.inc.mk:147: recipe for target 'info-debug-variable-PREFFLAGS' failed --- > /home/francisco/workspace/RIOT/makefiles/info.inc.mk:148: recipe for target 'info-debug-variable-PREFFLAGS' failed 168c168 < /home/francisco/workspace/RIOT/makefiles/info.inc.mk:147: recipe for target 'info-debug-variable-FFLAGS' failed --- > /home/francisco/workspace/RIOT/makefiles/info.inc.mk:148: recipe for target 'info-debug-variable-FFLAGS' failed 175c175 < /home/francisco/workspace/RIOT/makefiles/info.inc.mk:147: recipe for target 'info-debug-variable-FFLAGS' failed --- > /home/francisco/workspace/RIOT/makefiles/info.inc.mk:148: recipe for target 'info-debug-variable-FFLAGS' failed 182c182 < /home/francisco/workspace/RIOT/makefiles/info.inc.mk:147: recipe for target 'info-debug-variable-FFLAGS' failed --- > /home/francisco/workspace/RIOT/makefiles/info.inc.mk:148: recipe for target 'info-debug-variable-FFLAGS' failed ```

@aabadie can you re-check the commits messages? I changed them after squash.

- Introduce new PROG_DEV variable to specify device PORT used by the
  PROGRAMMER or DEBUGGER.
- Move serial.inc.mk in mega-xplained/Makefile.include after
  PROG_DEV so PROG_DEV can still default to PORT
- Add deprecation warning for arduino-leonardo and mega-xplained
- Move serial.inc.mk in remote and openmote-b Makefile.include before
  PROG_DEV to avoid repeating OS logic check
- Add deprecation warning for PORT_BSL
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.

ACK

@aabadie aabadie merged commit b0dfda2 into RIOT-OS:master Oct 25, 2019
@fjmolinas
Copy link
Contributor Author

@aabadie @keestux Thanks for the review! @MrKevinWeiss thanks for testing!

@fjmolinas fjmolinas deleted the pr_port_migration branch October 25, 2019 07:47
@MrKevinWeiss
Copy link
Contributor

Nice job everyone! 🎉

@fjmolinas fjmolinas added this to the Release 2020.01 milestone Dec 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: tests Area: tests and testing framework 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.

4 participants