Repository navigation
Add support for multiple configuration to deduplicate examples - #1118
Conversation
d2d6b2f to
f533689
Compare
|
Ok, so in order to deduplicate more examples we need |
|
I've prototyped this for some NUCLEO-32 boards, I think it's a good idea to deduplicate all the I2C/SPI examples too. |
2afca50 to
87a6802
Compare
87a6802 to
6221a7b
Compare
3125e63 to
7e9a13f
Compare
|
ok, so I think the deduplication is a good thing, but I don't like the idea of putting everything into the
|
|
What about a more flat structure? I would prefer no subdirectories over non-obvious subdirectories. |
|
it's flat like that, the second indentation is already the example folder. I just didn't list all the i2c drivers. |
|
ah, you mean completely flat? I think it's just too much, particularly because not everything can actually be deduplicated. I currently have 285 examples in this PR (down from 374 on develop), The analog examples can be fairly device specific, so they would be multiple ones like |
|
I think tags instead of categories are more useful for users (including me) to find an example. But that is not possible to implement using filesystem structures anyway, but we could generate a table of all examples inside |
|
I'm also a bit skeptical about the impact of deduplication, use of scripting and undocumented magic XML comment syntax for new modm users. The examples are most users' first exposure to modm, and I find it unfavorable to add unnecessary complexity. What do we think about generating the examples completely in a separate repo (e.g. https://github.com/modm-io/modm-examples) for all boards, including the modm repo as submodules and a |
|
To get users started with their own projects, I created the I hope users are not even gonna notice that there's magic XML syntax in the |
|
(deleted) |
2935385 to
a17f93b
Compare
b6e6323 to
45bf5de
Compare
Replaces: - examples/stm32f3_discovery/accelerometer
Replaces: - examples/rp_pico/rtc_mcp7941x
Replaces: - examples/stm32f072_discovery/tmp102 - examples/stm32f746g_discovery/tmp102
Replaces: - examples/nucleo_f103rb/rtos - examples/nucleo_f303k8/rtos - examples/nucleo_f303re/rtos - examples/nucleo_f411re/rtos - examples/nucleo_f767zi/freertos_blink - examples/nucleo_g071rb/rtos - examples/nucleo_l552ze-q/freertos_blink
Replaces: - examples/nucleo_l452re/lvgl
Replaces: - examples/weact_u585ci/usb
Replaces: - examples/nucleo_f429zi/usbfatfs
Replaces: - examples/feather_m4/usbserial - examples/nucleo_f446ze/usbserial - examples/samd21_xplained_pro/usbserial - examples/same54_xplained_pro/usbserial - examples/samg55_xplained_pro/usbserial
Replaces: - examples/arduino_uno/basic/blink - examples/avr/mega_pro - examples/black_pill_f103/blink - examples/black_pill_f401/blink - examples/black_pill_f411/blink - examples/blue_pill_f103/blink - examples/feather_m4/blink - examples/feather_rp2040/blink - examples/nrf51422-dk/blink - examples/nrf52840-dk/blink - examples/nrf5340-dk/blink - examples/nucleo_c031c6/blink - examples/nucleo_f031k6/blink - examples/nucleo_f042k6/blink - examples/nucleo_f072rb/blink - examples/nucleo_f091rc/blink - examples/nucleo_f103rb/blink - examples/nucleo_f207zg/blink - examples/nucleo_f303k8/blink - examples/nucleo_f303re/blink - examples/nucleo_f334r8/blink - examples/nucleo_f401re/blink - examples/nucleo_f411re/blink - examples/nucleo_f429zi/blink - examples/nucleo_f439zi/blink - examples/nucleo_f446re/blink - examples/nucleo_f446ze/blink - examples/nucleo_f722ze/blink - examples/nucleo_f746zg/blink - examples/nucleo_f767zi/blink - examples/nucleo_g070rb/blink - examples/nucleo_g071rb/blink - examples/nucleo_g431kb/blink - examples/nucleo_g431rb/blink - examples/nucleo_g474re/blink - examples/nucleo_h503rb/blink - examples/nucleo_h533re/blink - examples/nucleo_h563zi/blink - examples/nucleo_h723zg/blink - examples/nucleo_h743zi/blink - examples/nucleo_l031k6/blink - examples/nucleo_l053r8/blink - examples/nucleo_l152re/blink - examples/nucleo_l432kc/blink - examples/nucleo_l452re/blink - examples/nucleo_l476rg/blink - examples/nucleo_l496zg-p/blink - examples/nucleo_l552ze-q/blink - examples/nucleo_u083rc/blink - examples/nucleo_u385rg-q/blink - examples/nucleo_u575zi-q/blink - examples/olimexino_stm32/blink - examples/rp_pico/blink - examples/samd/blink - examples/samd21_xplained_pro/blink - examples/same54_xplained_pro/blink - examples/same70_xplained/blink - examples/samg55_xplained_pro/blink - examples/samv71_xplained_ultra/blink - examples/srxe/blink - examples/stm32f030f4p6_demo_board/blink - examples/stm32f072_discovery/blink - examples/stm32f0_discovery/blink - examples/stm32f1_discovery/blink - examples/stm32f3_discovery/blink - examples/stm32f401_discovery/blink - examples/stm32f407vet6_devebox/blink - examples/stm32f429_discovery/blink - examples/stm32f469_discovery/blink - examples/stm32f746g_discovery/blink - examples/stm32f769i_discovery/blink - examples/stm32h750vbt6_devebox/blink - examples/stm32l1_discovery/blink - examples/stm32l476_discovery/blink - examples/thingplus_rp2040/blink - examples/weact_g0b1cb/blink - examples/weact_h503cb/blink - examples/weact_h523ce/blink - examples/weact_h562rg/blink - examples/weact_u585ci/blink
Replaces: - examples/avr/logger - examples/nrf51422-dk/uart_logging - examples/nrf52840-dk/uart_logging - examples/nrf5340-dk/uart_logging_net - examples/rp_pico/logger
Replaces: - examples/arduino_nano/printf - examples/linux/printf
Replaces: - examples/stm32f072_discovery/uart - examples/stm32f401_discovery/uart
Replaces: - examples/samv71_xplained_ultra/pwm
Replaces: - examples/nucleo_g474re/servo_pwm
Replaces: - examples/same70_xplained/timer
Replaces the table of every single example, which is not useful anymore with examples that run on many boards.
c1994ac to
27c16b8
Compare
|
@chris-durand Good point, that's how it's sorted now: device drivers are in This PR is now complete: I reviewed it myself and it was tested extensively on hardware, way more than ever before (22 boards, see the description). So I'm going to merge it now. |
Depends on #1387, #1389 and #1393all merged.This flips the example matrix from "board -> use case" to "use case -> board": an example now lists all the boards it runs on in its
project.xmland the CI compiles it for every one of them. Turns out we had a lot of copy-pasted examples, whoops.The syntax is based on XML comments, so that the example remains usable manually and is hopefully self-explanatory:
<extends>, commented or not, is one configuration.<option>,<collect>and<module>lines directly below it to these configurations. Everything else applies to all of them.examples_compile.pycopies the example into the build folder once per configuration, flips the comments and compiles it. Relative includes still resolve to the original folder.modm:hostedboard with the versionslinux-x86_64,linux-arm64,darwin-x86_64,darwin-arm64andwindows, defaulting to your computer. Its configurations moved fromtools/devices/hostedtosrc/modm/board/hosted, and it has a logger and no-op LEDs and buttons, so the generic examples (blinky,logger,printf,fiber, ...) run on hosted without any#ifdef. So no special casing ofhosted-*in the scripts.Since the board is now just a configuration, sorting the examples by board makes no sense anymore, so they are sorted by what they show:
coregpioanalogtimerloggingcandrivermodm:driver: sensors, displays, radios, LEDs and more.uicommunicationextThis is the layout from #1118 (comment). Almost half of all examples show an external device, so the
driverfolder has the same categories assrc/modm/driver:driver/inertial/bmi270,driver/display/ssd1306,driver/radio/nrf24and so on. If you know where the driver lives, you know where its example is, and the bus it uses does not matter. A suffix likeanalog/dac_dma_g4names the family that an example is specific to.A bunch of "examples" were really tests or benchmarks that nobody would use as a starting point. These moved to
test/integrationand all end with aINTEGRATION TEST PASSEDorFAILEDline on the logger (and the exit code on hosted), so that we can eventually run them automatically on real hardware.Some numbers:
So half the projects, but more builds, since a lot of examples now also compile for boards that never had them. That found a few boards that were missing clocks, connections or aliases, which is fixed here too.
The commits are sorted so that moves and changes are separate and you can review them one by one:
Only the last commit is guaranteed to compile, since the scripts and CI expect the final layout from the start.
The CI now uses all 20 concurrent jobs and splits the configurations in a stable pseudo-random order (sorted by hash) instead of contiguous chunks, so that every part gets a similar mix of examples and targets. The Cortex-M examples and the HAL compile are matrix jobs now and the STM32 unit tests have their own job, so the check names changed.
examples_compile.pywith--target REGEXfilter and--split/--partover configurations.test/integrationwith a pass result.examples_check.pychecks for unknown configurations, boards without any example, and targets that no CI job compiles. No more silent failures.examples/README.md.can/app_can2usbdidn't even use CAN, lol), merged the remaining near-duplicates (L3GD20, LSM303, DOGM128, servo PWM, LVGL, encoder, TCS3472, nRF logging) and cleaned up test benches and dead code in the rest, e.g.driver/pressure/bme280read four sensors on two buses.examples/README.md.test/integration/flashandspi_flashgenerate the CompilationDB again, so that it keeps getting compiled on Windows.__has_includeguessing: if a board has no logger, the example does not list it. Same forBoard::i2c,Board::spiand theBoard::D*aliases instead of hardcoded pins.build/folder, also for the integration tests, so cleaning up is a singlerm -rf build.driver/inertial/lis3mdlnow compiles for all 39 boards withBoard::i2c,driver/pwm/sk6812only for the 6 boards whose SPI can do exactly 3 MHz.Do we need negative filters?noDo we want config globbing support?no,--targettakes a regex instead.I ran all examples and integration tests that need no external hardware on every bare dev board I had in my box, 22 boards in total: NUCLEO-C031C6, -F103RB, -F207ZG, -F401RE, -F429ZI, -F722ZE, -G071RB, -H563ZI, -H723ZG, -L152RE, -L432KC, -L476RG, -U083RC, -U385RG-Q, -U575ZI-Q, DISCO-F072RB, -F303VC, -F407VG, -F469NI, -F746NG, rp-pico and a Mega 2560 Pro. That's all STM32 families except G4 and all cores from M0 to M7 and M33.
fdcan_samv71andspi_loopback(no SAM boards)Every test passes on every board it fits on, but only after fixing a bunch of real bugs, whoops. The ones in modm itself went into #1393 (F4 dual-bank flash sectors, H5 and L4 delay tuning, L4 boot frequency, ARMv8-M stack overflow detection, recursive static init without fibers, newlib
mallocasserting instead of returningnullptr, the monochrome display buffers), the ones in the tests and examples are fixed here (e.g. the flash test divided by zero when the H7 verified 512kB in less than 1ms, lol).Also missing:
examples/analogis still a mess with one example per family and macros in the merged ones. The ADC drivers have ten different APIs with nineinitialize()signatures between them, so this needs fixing in the drivers first and not in the examples. I'm leaving the folder as is, its shape alone is a good reminder to fix this later, lol.cc @rleh @chris-durand