From 8350421e659e9273a94debdd6f29cd80979a63f1 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 18:04:25 +0200 Subject: fw: app: Build with Meson --- fw/app/meson.build | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 fw/app/meson.build (limited to 'fw/app') diff --git a/fw/app/meson.build b/fw/app/meson.build new file mode 100644 index 0000000..7f35ebb --- /dev/null +++ b/fw/app/meson.build @@ -0,0 +1,25 @@ +external_project = import('unstable-external_project') + +external_project.add_project( + configure_zephyr, + configure_options: [ + '--source-tree', meson.current_source_dir(), + '--build-tree', meson.current_build_dir() / 'build', + '--board', board, + '--zephyr-base', zephyr, + '--zephyr-modules', ';'.join(zephyr_modules), + ], + verbose: true, +) + +application = custom_target('application', + output: ['application.bin'], + command: [ + build_zephyr, + '--build-tree', meson.current_build_dir() / 'build', + '--target-name', 'application.bin', + ], + build_by_default: true, + install: true, + install_dir: 'website/static', +) -- cgit v1.2.3-70-g09d2 From 7fc6bc84609022992e1827a07b95c427208e7289 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 18:43:28 +0200 Subject: fw: sim: Integrate into Meson build This adds a build for the native_sim board of the application firmware to the default Meson build. The resulting Linux binary is also added to the webpage. --- fw/app/meson.build | 5 ++++- fw/btl/meson.build | 1 + fw/meson.build | 1 + fw/sim/meson.build | 27 +++++++++++++++++++++++++++ tools/build_zephyr.py | 3 ++- web/layouts/home.html | 1 + 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 fw/sim/meson.build (limited to 'fw/app') diff --git a/fw/app/meson.build b/fw/app/meson.build index 7f35ebb..d477331 100644 --- a/fw/app/meson.build +++ b/fw/app/meson.build @@ -1,9 +1,11 @@ external_project = import('unstable-external_project') +application_source = meson.current_source_dir() + external_project.add_project( configure_zephyr, configure_options: [ - '--source-tree', meson.current_source_dir(), + '--source-tree', application_source, '--build-tree', meson.current_build_dir() / 'build', '--board', board, '--zephyr-base', zephyr, @@ -17,6 +19,7 @@ application = custom_target('application', command: [ build_zephyr, '--build-tree', meson.current_build_dir() / 'build', + '--binary-name', 'zephyr.bin', '--target-name', 'application.bin', ], build_by_default: true, diff --git a/fw/btl/meson.build b/fw/btl/meson.build index b64fd40..4d80a58 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -19,6 +19,7 @@ bootloader = custom_target('bootloader', command: [ build_zephyr, '--build-tree', meson.current_build_dir() / 'build', + '--binary-name', 'zephyr.bin', '--target-name', 'bootloader.bin', ], build_by_default: true, diff --git a/fw/meson.build b/fw/meson.build index 492465e..8194827 100644 --- a/fw/meson.build +++ b/fw/meson.build @@ -6,3 +6,4 @@ signing_key = fs.expanduser('~') / 'mcuboot' / 'key.pem' subdir('rtos') subdir('app') subdir('btl') +subdir('sim') diff --git a/fw/sim/meson.build b/fw/sim/meson.build new file mode 100644 index 0000000..a4dcb8a --- /dev/null +++ b/fw/sim/meson.build @@ -0,0 +1,27 @@ +external_project = import('unstable-external_project') + +external_project.add_project( + configure_zephyr, + configure_options: [ + '--source-tree', application_source, + '--build-tree', meson.current_build_dir() / 'build', + '--board', 'native_sim/native/64', + '--zephyr-base', zephyr, + '--zephyr-modules', ';'.join(zephyr_modules), + ], + verbose: true, +) + +simulation = custom_target( + 'simulation', + output: ['simulation-linux-amd64.exe'], + command: [ + build_zephyr, + '--build-tree', meson.current_build_dir() / 'build', + '--binary-name', 'zephyr.exe', + '--target-name', 'simulation-linux-amd64.exe', + ], + build_by_default: true, + install: true, + install_dir: 'website/static', +) diff --git a/tools/build_zephyr.py b/tools/build_zephyr.py index e201bac..1d9e783 100755 --- a/tools/build_zephyr.py +++ b/tools/build_zephyr.py @@ -19,6 +19,7 @@ def main() -> None: ) parser.add_argument("-B", "--build-tree", required=True) + parser.add_argument("-b", "--binary-name", required=True) parser.add_argument("-n", "--target-name", required=True) args = parser.parse_args() @@ -38,7 +39,7 @@ def main() -> None: ) shutil.copy( - build_tree / "zephyr" / "zephyr.bin", + build_tree / "zephyr" / args.binary_name, output_dir / args.target_name ) diff --git a/web/layouts/home.html b/web/layouts/home.html index fe40af2..f4c4e80 100644 --- a/web/layouts/home.html +++ b/web/layouts/home.html @@ -5,5 +5,6 @@
  • schematic.pdf
  • application.bin
  • bootloader.bin
  • +
  • simulation-linux-amd64.exe
  • {{- end -}} -- cgit v1.2.3-70-g09d2 From f6f6d285c318d28bddfb99cf04104a5306a97c78 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 19:05:20 +0200 Subject: fw: app: Add image signing to Meson build This automates signing the application firmware image for the MCUboot bootloader. --- fw/app/meson.build | 19 ++++++++++++++++++- fw/rtos/modules/meson.build | 4 +++- web/layouts/home.html | 2 +- 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'fw/app') diff --git a/fw/app/meson.build b/fw/app/meson.build index d477331..97c17f1 100644 --- a/fw/app/meson.build +++ b/fw/app/meson.build @@ -14,7 +14,8 @@ external_project.add_project( verbose: true, ) -application = custom_target('application', +application = custom_target( + 'application', output: ['application.bin'], command: [ build_zephyr, @@ -22,7 +23,23 @@ application = custom_target('application', '--binary-name', 'zephyr.bin', '--target-name', 'application.bin', ], +) + +application_signed = custom_target( + 'application_signed', + output: ['application.signed.bin'], + command: [ + imgtool, + 'sign', + '--version', '0.0.0', + '--header-size', '0x200', + '--slot-size', '0xc0000', + '--key', signing_key, + meson.current_build_dir() / 'application.bin', + meson.current_build_dir() / 'application.signed.bin', + ], build_by_default: true, + depends: application, install: true, install_dir: 'website/static', ) diff --git a/fw/rtos/modules/meson.build b/fw/rtos/modules/meson.build index 52f50c2..14b14f5 100644 --- a/fw/rtos/modules/meson.build +++ b/fw/rtos/modules/meson.build @@ -5,4 +5,6 @@ zephyr_modules = [ meson.current_source_dir() / 'mcuboot', ] -bootloader_firmware = meson.current_source_dir() / 'mcuboot' / 'boot' / 'zephyr' +mcuboot = meson.current_source_dir() / 'mcuboot' +bootloader_firmware = mcuboot / 'boot' / 'zephyr' +imgtool = mcuboot / 'scripts' / 'imgtool.py' diff --git a/web/layouts/home.html b/web/layouts/home.html index f4c4e80..6bc457c 100644 --- a/web/layouts/home.html +++ b/web/layouts/home.html @@ -3,7 +3,7 @@ -- cgit v1.2.3-70-g09d2