From b1838d1c5b6bd27757d50d784543ea0ae16c1769 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 24 May 2025 11:17:46 +0200 Subject: Remove `st-flash`-based build targets This was used since flashing was complex. Thus the build system should help making it easier. The new approach is more to provide artifacts by the build system which are easy to flash / remote-update. A `factory-image.bin` and `update-image.bin` should be provided. --- fw/app/meson.build | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'fw/app') diff --git a/fw/app/meson.build b/fw/app/meson.build index ddd5aa6..8d84209 100644 --- a/fw/app/meson.build +++ b/fw/app/meson.build @@ -43,17 +43,3 @@ application_signed = custom_target( install: true, install_dir: '/', ) - -flash_application = custom_target( - build_always_stale: true, - build_by_default: false, - command: [ - 'st-flash', - '--connect-under-reset', - 'write', - meson.current_build_dir() / 'application.signed.bin', - '0x8040000', - ], - depends: application_signed, - output: ['flash'], -) -- cgit v1.2.3-70-g09d2 From caf416218623d6778b3d0c2fe12ee08135c2d126 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 24 May 2025 11:18:38 +0200 Subject: Remove installation step Using the installation step to copy selected artifacts into one folder was anyway a hack. This commit shows that the complexity can be reduced by adding copy targets. The `build/artifacts` folder contains the selected artifacts, they are always up to date, the user does not have to call the install step separately and the target definitions do not require install-related keyword arguments. --- README.md | 8 +++----- artifacts/meson.build | 22 ++++++++++++++++++++++ fw/app/meson.build | 4 ---- fw/btl/meson.build | 4 +--- fw/sim/meson.build | 3 --- meson.build | 19 ++++++------------- pcb/meson.build | 8 ++------ web/meson.build | 7 +------ 8 files changed, 35 insertions(+), 40 deletions(-) create mode 100644 artifacts/meson.build (limited to 'fw/app') diff --git a/README.md b/README.md index 3d81e83..a6dfe0a 100644 --- a/README.md +++ b/README.md @@ -25,19 +25,17 @@ The project is built with the Meson build system. ``` meson setup build -cd build -ninja -meson install --destdir artifacts +ninja -C build ``` The resulting artifacts can be listed with `tree`. ``` -tree artifacts +tree build/artifacts ``` These artifacts are organized as static website. It can be opened with Firefox. ``` -firefox artifacts/index.html +firefox build/artifacts/index.html ``` diff --git a/artifacts/meson.build b/artifacts/meson.build new file mode 100644 index 0000000..ea6fc39 --- /dev/null +++ b/artifacts/meson.build @@ -0,0 +1,22 @@ +artifacts = [ + index_html, + css, + schematic, + bom, + simulation, + bootloader, + application_signed, +] + +foreach artifact : artifacts + custom_target( + output: [fs.name(artifact.full_path())], + command: [ + cp, + artifact.full_path(), + meson.current_build_dir(), + ], + depends: artifact, + build_by_default: true, + ) +endforeach diff --git a/fw/app/meson.build b/fw/app/meson.build index 8d84209..84e4c21 100644 --- a/fw/app/meson.build +++ b/fw/app/meson.build @@ -15,7 +15,6 @@ external_project.add_project( ) application = custom_target( - 'application', output: ['application.bin'], command: [ build_zephyr, @@ -26,7 +25,6 @@ application = custom_target( ) application_signed = custom_target( - 'application_signed', output: ['application.signed.bin'], command: [ imgtool, @@ -40,6 +38,4 @@ application_signed = custom_target( ], build_by_default: true, depends: application, - install: true, - install_dir: '/', ) diff --git a/fw/btl/meson.build b/fw/btl/meson.build index c22ba3c..2ba1cf4 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -14,7 +14,7 @@ external_project.add_project( verbose: true, ) -bootloader = custom_target('bootloader', +bootloader = custom_target( output: ['bootloader.bin'], command: [ build_zephyr, @@ -23,6 +23,4 @@ bootloader = custom_target('bootloader', '--target-name', 'bootloader.bin', ], build_by_default: true, - install: true, - install_dir: '/', ) diff --git a/fw/sim/meson.build b/fw/sim/meson.build index 7667f9b..5edcad9 100644 --- a/fw/sim/meson.build +++ b/fw/sim/meson.build @@ -13,7 +13,6 @@ external_project.add_project( ) simulation = custom_target( - 'simulation', output: ['simulation-linux-amd64.exe'], command: [ build_zephyr, @@ -22,6 +21,4 @@ simulation = custom_target( '--target-name', 'simulation-linux-amd64.exe', ], build_by_default: true, - install: true, - install_dir: '/', ) diff --git a/meson.build b/meson.build index eb7f9ad..9b7d7c1 100644 --- a/meson.build +++ b/meson.build @@ -1,20 +1,13 @@ -project( - 'iot-contact', - default_options: { - 'prefix': '/', - }, -) +project('iot-contact') -subdir('tools') +cp = find_program('cp', required : true) fs = import('fs') -css = fs.copyfile( - meson.current_source_dir() / 'simple.css' / 'simple.css', - 'simple.css', - install: true, - install_dir: '/', -) +css = fs.copyfile(meson.current_source_dir() / 'simple.css' / 'simple.css') + +subdir('tools') subdir('fw') subdir('pcb') subdir('web') +subdir('artifacts') diff --git a/pcb/meson.build b/pcb/meson.build index f320aae..293b2a1 100644 --- a/pcb/meson.build +++ b/pcb/meson.build @@ -7,7 +7,7 @@ schematic_files = [ 'processor.kicad_sch', ] -schematic = custom_target('schematic', +schematic = custom_target( output: ['schematic.pdf'], command: [ 'kicad-cli', @@ -19,11 +19,9 @@ schematic = custom_target('schematic', ], depend_files: schematic_files, build_by_default: true, - install: true, - install_dir: '/', ) -bom = custom_target('bom', +bom = custom_target( output: ['bill-of-materials.csv'], command: [ 'kicad-cli', @@ -37,6 +35,4 @@ bom = custom_target('bom', ], depend_files: schematic_files, build_by_default: true, - install: true, - install_dir: '/', ) diff --git a/web/meson.build b/web/meson.build index f8c2024..19551a5 100644 --- a/web/meson.build +++ b/web/meson.build @@ -1,6 +1 @@ -website = fs.copyfile( - meson.current_source_dir() / 'index.html', - 'index.html', - install: true, - install_dir: '/', -) +index_html = fs.copyfile(meson.current_source_dir() / 'index.html') -- cgit v1.2.3-70-g09d2 From ca28bf9b784fd2c57133c1f8b5a6d99de7d10c6b Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 24 May 2025 11:19:06 +0200 Subject: fw: app: Provide confirmed image in build tree This prepares the upcoming `factory-image.bin` which can be flashed to the default boot address of the microcontroller. --- fw/app/meson.build | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'fw/app') diff --git a/fw/app/meson.build b/fw/app/meson.build index 84e4c21..1a16862 100644 --- a/fw/app/meson.build +++ b/fw/app/meson.build @@ -24,18 +24,37 @@ application = custom_target( ], ) +version = '0.0.0' +header_size = '0x200' +slot_size = '0xc0000' + application_signed = custom_target( output: ['application.signed.bin'], command: [ imgtool, 'sign', - '--version', '0.0.0', - '--header-size', '0x200', - '--slot-size', '0xc0000', + '--version', version, + '--header-size', header_size, + '--slot-size', slot_size, + '--key', signing_key, + meson.current_build_dir() / 'application.bin', + '@OUTPUT@', + ], + depends: application, +) + +application_signed_confirmed = custom_target( + output: ['application.signed.confirmed.bin'], + command: [ + imgtool, + 'sign', + '--version', version, + '--header-size', header_size, + '--slot-size', slot_size, '--key', signing_key, + '--confirm', meson.current_build_dir() / 'application.bin', - meson.current_build_dir() / 'application.signed.bin', + '@OUTPUT@', ], - build_by_default: true, depends: application, ) -- cgit v1.2.3-70-g09d2 From 4af0ed8242ab24b2b222a9ebbf417e12f608b756 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 24 May 2025 11:20:22 +0200 Subject: Remove redundant file name in Meson code --- fw/app/meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fw/app') diff --git a/fw/app/meson.build b/fw/app/meson.build index 1a16862..27b4a41 100644 --- a/fw/app/meson.build +++ b/fw/app/meson.build @@ -37,7 +37,7 @@ application_signed = custom_target( '--header-size', header_size, '--slot-size', slot_size, '--key', signing_key, - meson.current_build_dir() / 'application.bin', + application, '@OUTPUT@', ], depends: application, @@ -53,7 +53,7 @@ application_signed_confirmed = custom_target( '--slot-size', slot_size, '--key', signing_key, '--confirm', - meson.current_build_dir() / 'application.bin', + application, '@OUTPUT@', ], depends: application, -- cgit v1.2.3-70-g09d2 From bf8d20fe4d8d3369dd7f63e95f53613dbbfa3603 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 24 May 2025 11:20:28 +0200 Subject: artifacts: Provide `{factory,update}-image.bin` This presents only the `factory-image.bin` and `update-image.bin` for MCU firmware. A separate bootloader image is not available. The reason is that the `factory-image.bin` is used during production once (flashing at default boot address) to set up the device. Later only the `update-image.bin` of future versions would be required to remotely update devices. --- artifacts/meson.build | 3 +-- fw/app/meson.build | 4 ++-- web/index.html | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'fw/app') diff --git a/artifacts/meson.build b/artifacts/meson.build index 9e14232..278c695 100644 --- a/artifacts/meson.build +++ b/artifacts/meson.build @@ -4,8 +4,7 @@ artifacts = [ schematic, bom, simulation, - bootloader, - application_signed, + update_image, factory_image, ] diff --git a/fw/app/meson.build b/fw/app/meson.build index 27b4a41..6665fe4 100644 --- a/fw/app/meson.build +++ b/fw/app/meson.build @@ -28,8 +28,8 @@ version = '0.0.0' header_size = '0x200' slot_size = '0xc0000' -application_signed = custom_target( - output: ['application.signed.bin'], +update_image = custom_target( + output: ['update-image.bin'], command: [ imgtool, 'sign', diff --git a/web/index.html b/web/index.html index 1f23096..e5bf005 100644 --- a/web/index.html +++ b/web/index.html @@ -18,8 +18,8 @@

Firmware

-- cgit v1.2.3-70-g09d2