949dcd3ee5
19851: boards/stm32f769i-disco: enable FMC with SDRAM support r=aabadie a=gschorcht
### Contribution description
This PR enables the FMC support on the `stm32f769i-disco` board and the on-board SDRAM MT48LC4M32B2B5-6A with 16 MByte.
The PR also includes a very small documentation fix for the `stm32f746g-disco` board (commit
f761e2d616c861e4857563bae26152bc1f1699d7) and removes double empy line in the test app `tests/periph/fmc`.
### Testing procedure
1. `tests/periph/fmc` should succeed, just compile and flash the app with
```
BOARD=stm32f769i-disco make -C tests/periph/fmc flash term
```
2. `tests/sys/malloc` should also use the SDRAM. Use
```
USEMODULE=periph_fmc_sdram CFLAGS='-DCHUNK_SIZE=131072' \
BOARD=stm32f769i-disco make -C tests/sys/malloc flash term
```
and check that the heap also uses the memory in the range from `0xc0000000` to `0xc0fffffff`.
**UPDATE:** Tested with a `stm32f769i-disco` board.
<details>
<summary>Output from <b>tests/periph/fmc</b></summary>
```
Help: Press s to start test, r to print it is ready
START
main(): This is RIOT! (Version: 2023.10-devel-88-gdcecc-boards/stm32f769i_disco_fmc)
FMC HCLK freq 216 MHz
8-bit data `@0xc0000000,` 16-bit data `@0xc0000100,` 32-bit data `@0xc0ffff00`
------------------------------------------------------------------------
C0000000 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
C0000010 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
C0000020 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F
C0000030 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F
C0000040 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F
C0000050 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F
C0000060 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F
C0000070 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F
C0000080 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F
C0000090 90 91 92 93 94 95 96 97 98 99 9A 9B 9C 9D 9E 9F
C00000A0 A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 AA AB AC AD AE AF
C00000B0 B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB BC BD BE BF
C00000C0 C0 C1 C2 C3 C4 C5 C6 C7 C8 C9 CA CB CC CD CE CF
C00000D0 D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 DA DB DC DD DE DF
C00000E0 E0 E1 E2 E3 E4 E5 E6 E7 E8 E9 EA EB EC ED EE EF
C00000F0 F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 FA FB FC FD FE FF
------------------------------------------------------------------------
C0000100 00 80 01 81 02 82 03 83 04 84 05 85 06 86 07 87
C0000110 08 88 09 89 0A 8A 0B 8B 0C 8C 0D 8D 0E 8E 0F 8F
C0000120 10 90 11 91 12 92 13 93 14 94 15 95 16 96 17 97
C0000130 18 98 19 99 1A 9A 1B 9B 1C 9C 1D 9D 1E 9E 1F 9F
C0000140 20 A0 21 A1 22 A2 23 A3 24 A4 25 A5 26 A6 27 A7
C0000150 28 A8 29 A9 2A AA 2B AB 2C AC 2D AD 2E AE 2F AF
C0000160 30 B0 31 B1 32 B2 33 B3 34 B4 35 B5 36 B6 37 B7
C0000170 38 B8 39 B9 3A BA 3B BB 3C BC 3D BD 3E BE 3F BF
C0000180 40 C0 41 C1 42 C2 43 C3 44 C4 45 C5 46 C6 47 C7
C0000190 48 C8 49 C9 4A CA 4B CB 4C CC 4D CD 4E CE 4F CF
C00001A0 50 D0 51 D1 52 D2 53 D3 54 D4 55 D5 56 D6 57 D7
C00001B0 58 D8 59 D9 5A DA 5B DB 5C DC 5D DD 5E DE 5F DF
C00001C0 60 E0 61 E1 62 E2 63 E3 64 E4 65 E5 66 E6 67 E7
C00001D0 68 E8 69 E9 6A EA 6B EB 6C EC 6D ED 6E EE 6F EF
C00001E0 70 F0 71 F1 72 F2 73 F3 74 F4 75 F5 76 F6 77 F7
C00001F0 78 F8 79 F9 7A FA 7B FB 7C FC 7D FD 7E FE 7F FF
------------------------------------------------------------------------
C0FFFF00 00 40 80 C0 01 41 81 C1 02 42 82 C2 03 43 83 C3
C0FFFF10 04 44 84 C4 05 45 85 C5 06 46 86 C6 07 47 87 C7
C0FFFF20 08 48 88 C8 09 49 89 C9 0A 4A 8A CA 0B 4B 8B CB
C0FFFF30 0C 4C 8C CC 0D 4D 8D CD 0E 4E 8E CE 0F 4F 8F CF
C0FFFF40 10 50 90 D0 11 51 91 D1 12 52 92 D2 13 53 93 D3
C0FFFF50 14 54 94 D4 15 55 95 D5 16 56 96 D6 17 57 97 D7
C0FFFF60 18 58 98 D8 19 59 99 D9 1A 5A 9A DA 1B 5B 9B DB
C0FFFF70 1C 5C 9C DC 1D 5D 9D DD 1E 5E 9E DE 1F 5F 9F DF
C0FFFF80 20 60 A0 E0 21 61 A1 E1 22 62 A2 E2 23 63 A3 E3
C0FFFF90 24 64 A4 E4 25 65 A5 E5 26 66 A6 E6 27 67 A7 E7
C0FFFFA0 28 68 A8 E8 29 69 A9 E9 2A 6A AA EA 2B 6B AB EB
C0FFFFB0 2C 6C AC EC 2D 6D AD ED 2E 6E AE EE 2F 6F AF EF
C0FFFFC0 30 70 B0 F0 31 71 B1 F1 32 72 B2 F2 33 73 B3 F3
C0FFFFD0 34 74 B4 F4 35 75 B5 F5 36 76 B6 F6 37 77 B7 F7
C0FFFFE0 38 78 B8 F8 39 79 B9 F9 3A 7A BA FA 3B 7B BB FB
C0FFFFF0 3C 7C BC FC 3D 7D BD FD 3E 7E BE FE 3F 7F BF FF
------------------------------------------------------------------------
fill complete memory of 16384 kByte, a . represents a 16 kByte block
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
ready
check memory content, a + represents one 16 kByte block of matching data
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
ready
------------------------------------------------------------------------
Doing some benchmarks
write 8 bit: 233018us --- 0.013us per call --- 71999656 calls per sec
write 16 bit: 116510us --- 0.013us per call --- 71999038 calls per sec
write 32 bit: 563125us --- 0.134us per call --- 7448264 calls per sec
read 8 bit: 900066us --- 0.053us per call --- 18639984 calls per sec
read 16 bit: 1165181us --- 0.138us per call --- 7199403 calls per sec
read 32 bit: 225729us --- 0.053us per call --- 18581148 calls per sec
ready
------------------------------------------------------------------------
print first and last memory block after benchmark, should be 0xaa
C0000000 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000010 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000020 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000030 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000040 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000050 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000060 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000070 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000080 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0000090 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C00000A0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C00000B0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C00000C0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C00000D0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C00000E0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C00000F0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF00 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF10 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF20 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF30 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF40 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF50 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF60 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF70 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF80 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFF90 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFFA0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFFB0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFFC0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFFD0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFFE0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
C0FFFFF0 AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA AA
------------------------------------------------------------------------
[SUCCESS]
{ "threads": [{ "name": "main", "stack_size": 1536, "stack_used": 412}]}
```
</details>
<details>
<summary>Output from <b>tests/sys/malloc</b></summary>
```
Help: Press s to start test, r to print it is ready
START
main(): This is RIOT! (Version: 2023.10-devel-88-gdcecc-boards/stm32f769i_disco_fmc)
calloc(zu, zu) = 0x10000000
CHUNK_SIZE: 131072
NUMBER_OF_TESTS: 3
Allocated 131072 Bytes at 0x200013a8, total 131072
Allocated 131072 Bytes at 0x200213c0, total 262152
Allocated 131072 Bytes at 0x200413d8, total 393232
Allocated 131072 Bytes at 0xc0000008, total 524312
Allocated 131072 Bytes at 0xc0020010, total 655392
Allocated 131072 Bytes at 0xc0040018, total 786472
Allocated 131072 Bytes at 0xc0060020, total 917552
Allocated 131072 Bytes at 0xc0080028, total 1048632
Allocated 131072 Bytes at 0xc00a0030, total 1179712
Allocated 131072 Bytes at 0xc00c0038, total 1310792
Allocated 131072 Bytes at 0xc00e0040, total 1441872
Allocated 131072 Bytes at 0xc0100048, total 1572952
Allocated 131072 Bytes at 0xc0120050, total 1704032
Allocated 131072 Bytes at 0xc0140058, total 1835112
Allocated 131072 Bytes at 0xc0160060, total 1966192
Allocated 131072 Bytes at 0xc0180068, total 2097272
Allocated 131072 Bytes at 0xc01a0070, total 2228352
Allocated 131072 Bytes at 0xc01c0078, total 2359432
Allocated 131072 Bytes at 0xc01e0080, total 2490512
Allocated 131072 Bytes at 0xc0200088, total
|
||
---|---|---|
.. | ||
bench | ||
board_microbit | ||
build_system | ||
buttons | ||
core | ||
cpu | ||
drivers | ||
fault_handler | ||
leds | ||
mcuboot | ||
minimal | ||
net | ||
periph | ||
pkg | ||
riotboot | ||
riotboot_flashwrite | ||
riotboot_hdr | ||
rust_libs | ||
rust_minimal | ||
sys | ||
turo | ||
turo_txt | ||
unittests | ||
.gitignore | ||
Makefile.boards.netif | ||
Makefile.tests_common | ||
README.md | ||
riot_logo.h | ||
test_print_stack_usage.config | ||
test_utils.config |
Running and creating tests
There are a number of tests included in RIOT. They are located in the tests directory. These tests allow basic functionality to be verified as well as provide an example of usage.
Directory Structure
The tests directory in RIOT is further divided into a number of subdirectories.
- bench: Benchmark tests, these provide numbers on how RIOT performs on the used hardware.
- build_system: Tests the RIOT build system functionality, such as blob, external board/module/package dirs, and kconfig.
- core: Tests the RIOT core functionality such as threading and IPC.
- cpu: Tests RIOT cpu specific features such as efm32, stm32, native and AVR.
- drivers: Tests individual drivers. The tests for sensors print the measured values to the console, others demonstrate the functionality of the driver and attached hardware.
- net: Tests the networking features provided in RIOT, such as CoAP, emcute, GNRC, IEEE 802.15.4 and sntp.
- periph: Tests the low level peripherals in RIOT, such as interacting with SPI and I2C peripherals.
- pkg: Tests the external packages available in RIOT, such as lvgl, lwip, nanocbor, and tinyusb.
- sys: Collection of tests for the utilities in sys directory of RIOT.
- unittests: Collection of very simple test applications that test simple modules and do not rely on extra hardware. Can be flashed and run as single application to test all unit tests at once.
Running automated tests
Some tests can be performed automatically. The test automation scripts are
defined in the <test_application>/tests/
folder. They are written in python
and interact through the serial (typically UART) with the test application code running on a
board to do the validation. It is recommended to flash the board with the
test just before running it because some platforms cannot be reset while
testing.
Running single test
From the test application directory run:
BOARD=<board_of_your_choice> make flash test
An automated way of knowing if a test is available is to execute the 'test/available' target from the test application directory. It executes without error if tests run by 'make test' are present.
make test/available
Running all test for particular board
If you would like execute all tests for given board, you could use dedicated
script compile_and_test_for_board.py
Go to main RIOT directory and execute command:
./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py . <board_of_your_choice> --with-test-only --jobs=4
More details concerning other available parameters provided by this tool can be found in README.md file and directly in compile_and_test_for_board.py script.
Running tests that require a preliminary manual configuration
Some tests need active monitoring or manual setup steps but still have some
automated scripts. The test automation scripts are defined in the
<test_application>/tests-with-config/
folder.
For running them, follow the setup or analysis documentation and use the
test-with-config
target.
Running tests that require root privileges
Some tests require root privileges to launch their automated script. In this
case, the test automation scripts are defined in the
<test_application>/tests-as-root/
folder.
For running them, follow the setup or analysis documentation and use the
test-as-root
target.
Cleaning intermediate files
After test execution intermediate files are not automatically deleted. Execution of multiple tests, especially all for particular board could generate many files. For example, after execution of all test for stm32f469i-disco board (more than 230 tests) around 7.5 GB of intermediate files are created.
There are few methods for cleaning intermediate files.
If you would like to clean intermediate file only for particular board you should go to main RIOT directory and execute one from these commands:
./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py . <board_of_your_choice> --compile-targets clean
or
make BOARD=<board_of_your_choice> clean
If you would like to clean intermediate files for all boards go to main RIOT directory and use this command.
@warning This command cleans all local files, for example, pkg downloads and locally generared docs.
make distclean
Implementing automated tests
The goal is to be able to run all tests in a sequential way for as many targets as possible.
As some board can't be reset without a manual trigger tests should be implemented
with some kind of synchronization
. This can be done in two ways:
- use
test_utils_interactive_sync
when uart input/output does not need to be disabled for the test. This is enabled by default. - set up the test in a loop so the test script will be able so sync with some kind of start condition in the test.
The module for the first option is test_utils_interactive_sync
and is set as a
default module in Makefile.tests_common
. It can be disabled by setting in the
application makefile DISABLE_MODULE += test_utils_interactive_sync
. The python
test script will adapt to it automatically.
When using the shell
module, test_utils_interactive_sync
will use the shell
itself to synchronize, and will not use test_utils_interactive_sync();
function
to synchronize. Some times you will want to synchronize before the start of the
script and use test_utils_interactive_sync();
function (e.g.:
tests/ps_schedstatistics). For these cases
you can disable test_utils_interactive_sync_shell
module in the application
Makefile
: DISABLE_MODULE += test_utils_interactive_sync_shell
.
Automated Tests Guidelines
When using pexpect
$
is useless for matching the end of a line, instead use
\r\n
(pexpect end-of-line).
Beware of +
and *
at the end of patterns. These patterns will always get
a minimal match (non-greedy).(pexpect end-of-patterns)
This can be an issue when matching groups and using the matched groups to verify
some kind of behavior since *
could return an empty match and +
only a subset.
This is especially prevalent since printf()
is buffered so the output might not
arrive in a single read to pexpect
.
To avoid this make sure to match a non-ambiguous character at the end of the
pattern like \r\n
, \s
, \)
, etc..
don't:
child.expect(r'some string: (\d+)')
do:
child.expect(r'some string: (\d+)\r\n')
child.expect(r'some string: (\d+)\s')
child.expect(r'some string: (\d+) ,')
Use expect() instead of assert()
In order to make a test application functional in all cases, use expect()
instead of assert()
. The former works like the latter, but will still be
compiled in if NDEBUG
is defined. This is useful to keep a test application
working even when compiling with -DNDEBUG, allowing for the code-under-test to
be compiled with that flag. Otherwise, the application would force compiling
all tested code with assertions enabled.
expect()
is defined in the header test_utils/expect.h
.
Interaction through the uart
Tests implemented with testrunner
use the cleanterm
target that
provides an interaction without adding extra text output or input handling.
It can currently be expected to have unmodified line based interaction with the
board.
The expected behavior is verified with the test in tests/test_tools
.
Tests cannot rely on having on all boards and terminal programs:
- unbuffered input
- allowing sending special characters like
ctrl+c/ctrl+d