SAMD21 custom board and building/uploading custom bootloader

Hello,

I integrated https://github.com/mysensors/ArduinoBoards/blob/master/boards/mysensors-samd-1.0.7.tar.bz2 into a blink project. To do this I put a json under .platformio/boards, the variants folder into the project and extended the ini (board_build.variants_dir and board_build.variant) accordingly. This works so far.

grafik

Now I also want to add and customize the bootloader. I can already build it with make. What is a good way to integrate the bootloader build process into PlatformIO? And how to integrate the flashing process of the bootloader with openocd via blackmagic probe?

Are extra_scripts the way to go?