Collection of SVD files with meson recipe to handle them
Python3 is required for this meson project with the following packages:
- Jinja2
- svd2json (Ledger package, see https://git.orange.ledgerlabs.net/outpost/python-svd2json)
svd
: string, svd filename to use (without.svd
extension) The given file must be present under the<project root>/svd
directory. The meson.build recipe will walk through thesvds
list.
e.g.:
meson setup -Dstm32u5xx <builddir>
This project defines a custom target that convert the manufacturer provided svd to a custom json format to ease header generation with Jinja2
, that target is named <svd_basename>.json
cd <builddir>
ninja stm32u5xx.json
While use as a meson subproject, this project provides useful variables.
svd_json
: targets that generates json file.jinja_cli
: program (found byfind_program
) to use withcustom_target
orgenerator
.irq_defs_in
: template to generate soc irqs definition header.layout_in
: template to generate soc peripherals layout (IP base address) header.peripheral_defs_in
: template to generate a peripheral (or peripheral group) registers and fields description.
irq_def_h = custom_target('gen_irq_defs',
input: irq_defs_in,
output: '@BASENAME@',
depends: [ svd_json ],
command: [ jinja_cli, '-d', svd_json, '-o', '@OUTPUT@', '@INPUT@' ],
)
layout_h = custom_target('gen_layout',
input: layout_in,
output: '@BASENAME@',
depends: [ svd_json ],
command: [ jinja_cli, '-d', svd_json, '-o', '@OUTPUT@', '@INPUT@' ],
)
jinja_gen = generator(jinja_cli,
output: '@BASENAME@',
arguments: ['-d', '@0@'.format(svd_json),
'-o', '@OUTPUT@',
'@EXTRA_ARGS@',
'@INPUT@'],
depends: [ svd_json ])
irq_def_h = jinja_gen.process(irq_defs_in)
layout_h = jinja_gen.process(layout_in)
gpio_h = jinja_gen.process(peripheral_defs_in, extra_args: ['--define', 'NAME', 'GPIO'])
NOTE:
NAME
value must be either a peripheralname
or peripheralsgroupName
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.