Created
October 23, 2020 16:13
-
-
Save jepler/5fa7f40554a380a139d3fe27a638c077 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
twai_self_test failure with CONFIG_COMPILER_OPTIMIZATION_SIZE=y | |
Software version used: esp-idf v4.3-dev-1561-g357a27760 | |
(problem also affects v4.2-dev-2968-g8bc19ba89 (circuitpython 6.0.0-rc.0)) | |
Hardware used: ESP32-S2-Kaluga-1 | |
Teseting procedure: | |
1. Prepare hardware: Install jumper wire between pins 17 and 18. | |
2. Build working configuration: | |
cd examples/peripherals/twai/twai_self_test/ | |
git clean -dxf | |
idf.py set-target esp32-s2 | |
idf.py menuconfig | |
In "Example Configuration" set | |
TX GPIO number to 17 | |
RX GPIO number to 18 | |
save and exit | |
idf.py flash | |
Open terminal, press reset button. | |
Result: Test succeeds, printing many "Msg received" log lines and finally "Driver uninstalled" | |
3. Build non-working configuration: | |
idf.py menuconfig | |
In "Compiler options" set | |
Optimization Level to "Optimize for size (-Os)" | |
save and exit | |
idf.py flash | |
Open terminal, press reset button. | |
Result: Test fails, hanging after printing "TWAI Self Test: Driver started" | |
Note: With additional instrumentation added, it appears that when the | |
compiler optimization is "-Os", writes to acceptance_filter.acr and .amr | |
do not succeed, and incorrect values are read back. | |
Patch to add instrumentation: https://gist.github.com/1c90b383888ca40f3dbafd0b4d68ce9d | |
Typical instrumentation output when working properly: | |
I (325) TWAI Self Test: Driver installed | |
I (325) TWAI Self Test: f_config.acceptance_code = 0x00000000 | |
I (335) TWAI Self Test: f_config.acceptance_mask = 0xffffffff | |
I (345) TWAI Self Test: f_config.single_filter = 0x00000001 | |
I (345) TWAI Self Test: mode_reg = 0x0000000b | |
I (355) TWAI Self Test: command_reg = 0x00000000 | |
I (355) TWAI Self Test: status_reg = 0x0000003c | |
I (365) TWAI Self Test: clock_divider_reg = 0x00000300 | |
I (375) TWAI Self Test: acceptance_filter.acr[] = | |
I (375) TWAI Self Test: 00 | |
I (375) TWAI Self Test: 00 | |
I (385) TWAI Self Test: 00 | |
I (385) TWAI Self Test: 00 | |
I (395) TWAI Self Test: | |
I (395) TWAI Self Test: acceptance_filter.amr[] = | |
I (395) TWAI Self Test: ff | |
I (405) TWAI Self Test: ff | |
I (405) TWAI Self Test: ff | |
I (405) TWAI Self Test: ff | |
I (415) TWAI Self Test: | |
Typical instrumentation output when working improperly ("Optimize for size") - note incorrect values read back for acceptance_filter: | |
I (328) TWAI Self Test: Driver installed | |
I (328) TWAI Self Test: f_config.acceptance_code = 0x00000000 | |
I (338) TWAI Self Test: f_config.acceptance_mask = 0xffffffff | |
I (348) TWAI Self Test: f_config.single_filter = 0x00000001 | |
I (348) TWAI Self Test: mode_reg = 0x0000000b | |
I (358) TWAI Self Test: command_reg = 0x00000000 | |
I (358) TWAI Self Test: status_reg = 0x0000003c | |
I (368) TWAI Self Test: clock_divider_reg = 0x00000300 | |
I (378) TWAI Self Test: acceptance_filter.acr[] = | |
I (378) TWAI Self Test: db | |
I (378) TWAI Self Test: ff | |
I (388) TWAI Self Test: 0d | |
I (388) TWAI Self Test: 7f | |
I (398) TWAI Self Test: | |
I (398) TWAI Self Test: acceptance_filter.amr[] = | |
I (398) TWAI Self Test: 7e | |
I (408) TWAI Self Test: 77 | |
I (408) TWAI Self Test: fe | |
I (408) TWAI Self Test: da | |
I (418) TWAI Self Test: | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment