From 34c0c109551c3a67bb89dcfbcd437a5ed812809f Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 3 Apr 2025 21:45:55 +0200 Subject: web: Add simple.css to website This uses meson to copy the simple.css file to the build dir and references the CSS file in the HTML code. --- web/layouts/baseof.html | 1 + 1 file changed, 1 insertion(+) (limited to 'web/layouts') diff --git a/web/layouts/baseof.html b/web/layouts/baseof.html index 983e6e1..b52d039 100644 --- a/web/layouts/baseof.html +++ b/web/layouts/baseof.html @@ -3,6 +3,7 @@ + {{ .Site.Title }} -- cgit v1.2.3-70-g09d2 From 061a67ea6e4a7fb9658fd3efc1c670eae5ff3eb6 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 5 Apr 2025 10:36:38 +0200 Subject: Deploy schematic and BOM to website These important design files should be deployed with the website. --- pcb/meson.build | 8 ++++++-- web/content/copy.py | 9 +++++++++ web/content/meson.build | 24 ++++++++++++++++++++++++ web/layouts/home.html | 4 ++++ web/meson.build | 4 ++-- 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100755 web/content/copy.py (limited to 'web/layouts') diff --git a/pcb/meson.build b/pcb/meson.build index cd45a48..d74f8c3 100644 --- a/pcb/meson.build +++ b/pcb/meson.build @@ -7,6 +7,7 @@ schematic_files = [ 'processor.kicad_sch', ] +schematic_pdf = meson.current_build_dir() / 'schematic.pdf' schematic = custom_target('schematic', output: ['schematic.pdf'], command: [ @@ -14,13 +15,14 @@ schematic = custom_target('schematic', 'sch', 'export', 'pdf', - '--output', meson.current_build_dir() / 'schematic.pdf', + '--output', schematic_pdf, meson.current_source_dir() / 'iot-contact.kicad_sch', ], depend_files: schematic_files, build_by_default: true, ) +bom_csv = meson.current_build_dir() / 'bill-of-materials.csv' bom = custom_target('bom', output: ['bill-of-materials.csv'], command: [ @@ -30,9 +32,11 @@ bom = custom_target('bom', 'bom', '--fields', 'Reference,Description,Value,Footprint,Manufacturer,MPN,Datasheet', - '--output', meson.current_build_dir() / 'bill-of-materials.csv', + '--output', bom_csv, meson.current_source_dir() / 'iot-contact.kicad_sch', ], depend_files: schematic_files, build_by_default: true, ) + +pcb = meson.current_build_dir() diff --git a/web/content/copy.py b/web/content/copy.py new file mode 100755 index 0000000..0b06e6d --- /dev/null +++ b/web/content/copy.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 + + +import shutil +import sys + + +print(f"Copying {sys.argv[1]} to {sys.argv[2]}") +shutil.copyfile(sys.argv[1], sys.argv[2]) diff --git a/web/content/meson.build b/web/content/meson.build index 75d3120..5046982 100644 --- a/web/content/meson.build +++ b/web/content/meson.build @@ -3,3 +3,27 @@ configure_file( output: 'simple.css', copy: true, ) + +schematic_web = custom_target('schematic_web', + output: ['schematic.pdf'], + command: [ + 'copy.py', + schematic_pdf, + meson.current_build_dir() / 'schematic.pdf' + ], + depends: [ + schematic, + ], +) + +bom_web = custom_target('bom_web', + output: ['bill-of-materials.csv'], + command: [ + 'copy.py', + bom_csv, + meson.current_build_dir() / 'bill-of-materials.csv' + ], + depends: [ + bom, + ], +) diff --git a/web/layouts/home.html b/web/layouts/home.html index 5425ac9..dcd4a66 100644 --- a/web/layouts/home.html +++ b/web/layouts/home.html @@ -1,3 +1,7 @@ {{- define "main" -}}

{{ .Site.Title }}

+ {{- end -}} diff --git a/web/meson.build b/web/meson.build index 1e8989c..1c64394 100644 --- a/web/meson.build +++ b/web/meson.build @@ -14,8 +14,8 @@ website = custom_target('website', 'layouts/home.html', ], depends: [ - schematic, - bom, + schematic_web, + bom_web, ], build_by_default: true, ) -- cgit v1.2.3-70-g09d2 From 00189e737517f4470336d819d52327a037509493 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 5 Apr 2025 15:28:04 +0200 Subject: web: Replace file copying by Meson installation This makes the build system code way less hacky and more modular. --- meson.build | 8 +++++++- pcb/meson.build | 12 ++++++------ web/content/copy.py | 9 --------- web/content/meson.build | 29 ----------------------------- web/layouts/baseof.html | 2 +- web/layouts/home.html | 4 ++-- web/meson.build | 13 ++++++------- 7 files changed, 22 insertions(+), 55 deletions(-) delete mode 100755 web/content/copy.py delete mode 100644 web/content/meson.build (limited to 'web/layouts') diff --git a/meson.build b/meson.build index a0e6468..73206f4 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,12 @@ project('iot-contact') -css = meson.current_source_dir() / 'simple.css' / 'simple.css' +fs = import('fs') +css = fs.copyfile( + meson.current_source_dir() / 'simple.css' / 'simple.css', + 'simple.css', + install: true, + install_dir: 'website/static', +) subdir('pcb') subdir('web') diff --git a/pcb/meson.build b/pcb/meson.build index d74f8c3..7f8b85f 100644 --- a/pcb/meson.build +++ b/pcb/meson.build @@ -7,7 +7,6 @@ schematic_files = [ 'processor.kicad_sch', ] -schematic_pdf = meson.current_build_dir() / 'schematic.pdf' schematic = custom_target('schematic', output: ['schematic.pdf'], command: [ @@ -15,14 +14,15 @@ schematic = custom_target('schematic', 'sch', 'export', 'pdf', - '--output', schematic_pdf, + '--output', meson.current_build_dir() / 'schematic.pdf', meson.current_source_dir() / 'iot-contact.kicad_sch', ], depend_files: schematic_files, build_by_default: true, + install: true, + install_dir: 'website/static', ) -bom_csv = meson.current_build_dir() / 'bill-of-materials.csv' bom = custom_target('bom', output: ['bill-of-materials.csv'], command: [ @@ -32,11 +32,11 @@ bom = custom_target('bom', 'bom', '--fields', 'Reference,Description,Value,Footprint,Manufacturer,MPN,Datasheet', - '--output', bom_csv, + '--output', meson.current_build_dir() / 'bill-of-materials.csv', meson.current_source_dir() / 'iot-contact.kicad_sch', ], depend_files: schematic_files, build_by_default: true, + install: true, + install_dir: 'website/static', ) - -pcb = meson.current_build_dir() diff --git a/web/content/copy.py b/web/content/copy.py deleted file mode 100755 index 0b06e6d..0000000 --- a/web/content/copy.py +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env python3 - - -import shutil -import sys - - -print(f"Copying {sys.argv[1]} to {sys.argv[2]}") -shutil.copyfile(sys.argv[1], sys.argv[2]) diff --git a/web/content/meson.build b/web/content/meson.build deleted file mode 100644 index 5046982..0000000 --- a/web/content/meson.build +++ /dev/null @@ -1,29 +0,0 @@ -configure_file( - input: css, - output: 'simple.css', - copy: true, -) - -schematic_web = custom_target('schematic_web', - output: ['schematic.pdf'], - command: [ - 'copy.py', - schematic_pdf, - meson.current_build_dir() / 'schematic.pdf' - ], - depends: [ - schematic, - ], -) - -bom_web = custom_target('bom_web', - output: ['bill-of-materials.csv'], - command: [ - 'copy.py', - bom_csv, - meson.current_build_dir() / 'bill-of-materials.csv' - ], - depends: [ - bom, - ], -) diff --git a/web/layouts/baseof.html b/web/layouts/baseof.html index b52d039..96d8e07 100644 --- a/web/layouts/baseof.html +++ b/web/layouts/baseof.html @@ -3,7 +3,7 @@ - + {{ .Site.Title }} diff --git a/web/layouts/home.html b/web/layouts/home.html index dcd4a66..bf534cf 100644 --- a/web/layouts/home.html +++ b/web/layouts/home.html @@ -1,7 +1,7 @@ {{- define "main" -}}

{{ .Site.Title }}

{{- end -}} diff --git a/web/meson.build b/web/meson.build index 1c64394..1526621 100644 --- a/web/meson.build +++ b/web/meson.build @@ -1,12 +1,9 @@ -subdir('content') - website = custom_target('website', - output: ['public'], + output: ['index.html'], command: [ 'hugo', '--source', meson.current_source_dir(), - '--destination', meson.current_build_dir() / 'public', - '--contentDir', meson.current_build_dir() / 'content', + '--destination', meson.current_build_dir(), ], depend_files: [ 'hugo.toml', @@ -14,8 +11,10 @@ website = custom_target('website', 'layouts/home.html', ], depends: [ - schematic_web, - bom_web, + schematic, + bom, ], build_by_default: true, + install: true, + install_dir: 'website', ) -- cgit v1.2.3-70-g09d2 From 5376b67a9df63d2b30cac415cb827e6b4c1674e9 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 14:24:06 +0200 Subject: Build bootloader and add to website Meson makes this relatively easy. The current approach is nevertheless a bit hacky. For the first attempt it is still way better than CMake ExternalProject. --- fw/btl/build.py | 29 +++++++++++++++++++++++++++++ fw/btl/meson.build | 11 +++++++++++ web/layouts/home.html | 1 + web/meson.build | 1 + 4 files changed, 42 insertions(+) create mode 100755 fw/btl/build.py (limited to 'web/layouts') diff --git a/fw/btl/build.py b/fw/btl/build.py new file mode 100755 index 0000000..6478701 --- /dev/null +++ b/fw/btl/build.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 + + +import multiprocessing +import shutil +import subprocess +import sys +import pathlib + + +build_tree = pathlib.Path(sys.argv[1]) +output_dir = build_tree.parent + + +subprocess.run( + [ + "make", + f"-j{multiprocessing.cpu_count()}", + "-C", + f"{str(build_tree)}", + ], + shell=False, + check=True, +) + +shutil.copy( + build_tree / "zephyr" / "zephyr.bin", + output_dir / "bootloader.bin" +) diff --git a/fw/btl/meson.build b/fw/btl/meson.build index b783191..37c8c25 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -12,3 +12,14 @@ bootloader_project = external_project.add_project('configure.py', ], verbose: true, ) + +bootloader = custom_target('bootloader', + output: ['bootloader.bin'], + command: [ + meson.current_source_dir() / 'build.py', + meson.current_build_dir() / 'build', + ], + build_by_default: true, + install: true, + install_dir: 'website/static', +) diff --git a/web/layouts/home.html b/web/layouts/home.html index bf534cf..4f1f7fc 100644 --- a/web/layouts/home.html +++ b/web/layouts/home.html @@ -3,5 +3,6 @@ {{- end -}} diff --git a/web/meson.build b/web/meson.build index 1526621..270b7c3 100644 --- a/web/meson.build +++ b/web/meson.build @@ -13,6 +13,7 @@ website = custom_target('website', depends: [ schematic, bom, + bootloader, ], build_by_default: true, install: true, -- cgit v1.2.3-70-g09d2 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 +++++++++++++++++++++++++ fw/meson.build | 1 + web/layouts/home.html | 1 + web/meson.build | 1 + 4 files changed, 28 insertions(+) create mode 100644 fw/app/meson.build (limited to 'web/layouts') 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', +) diff --git a/fw/meson.build b/fw/meson.build index 7f9bead..492465e 100644 --- a/fw/meson.build +++ b/fw/meson.build @@ -4,4 +4,5 @@ fs = import('fs') signing_key = fs.expanduser('~') / 'mcuboot' / 'key.pem' subdir('rtos') +subdir('app') subdir('btl') diff --git a/web/layouts/home.html b/web/layouts/home.html index 4f1f7fc..fe40af2 100644 --- a/web/layouts/home.html +++ b/web/layouts/home.html @@ -3,6 +3,7 @@ {{- end -}} diff --git a/web/meson.build b/web/meson.build index 270b7c3..da45440 100644 --- a/web/meson.build +++ b/web/meson.build @@ -13,6 +13,7 @@ website = custom_target('website', depends: [ schematic, bom, + application, bootloader, ], build_by_default: true, -- 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 'web/layouts') 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 'web/layouts') 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 From da27d61588202d6b460e36d29a8789d206495bd6 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 19:48:20 +0200 Subject: web: Structure index page --- web/layouts/home.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'web/layouts') diff --git a/web/layouts/home.html b/web/layouts/home.html index 6bc457c..3bf37d9 100644 --- a/web/layouts/home.html +++ b/web/layouts/home.html @@ -1,8 +1,11 @@ {{- define "main" -}}

    {{ .Site.Title }}