From 2d618a86755362dd910d511ddc392330a1a35709 Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 2 Apr 2025 21:06:18 +0200 Subject: web: Fix dependencies in CMake This makes sure incremental builds work properly for the web page. --- cmake/hugo.cmake | 4 ++-- web/CMakeLists.txt | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/cmake/hugo.cmake b/cmake/hugo.cmake index e065f8b..0180958 100644 --- a/cmake/hugo.cmake +++ b/cmake/hugo.cmake @@ -2,7 +2,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at https://mozilla.org/MPL/2.0/. -function(hugo_site target source sink) +function(hugo_site target source sink dependencies) add_custom_target( "${target}" ALL @@ -16,6 +16,6 @@ function(hugo_site target source sink) COMMAND hugo --source ${source} --destination ${sink} DEPENDS - ${source} + ${dependencies} ) endfunction() diff --git a/web/CMakeLists.txt b/web/CMakeLists.txt index 0cdb498..92af0cb 100644 --- a/web/CMakeLists.txt +++ b/web/CMakeLists.txt @@ -2,8 +2,15 @@ cmake_minimum_required(VERSION 3.10) include(hugo) +set(dependencies + hugo.toml + layouts/baseof.html + layouts/home.html +) + hugo_site( "website" "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/public" + "${dependencies}" ) -- cgit v1.2.3-70-g09d2 From cfb844a53e6e008aaf3b7d1be3639559609d5540 Mon Sep 17 00:00:00 2001 From: xengineering Date: Wed, 2 Apr 2025 21:09:28 +0200 Subject: Add simple.css v2.3.5 This provides the CSS code for the deploy website as well as the web interface of the device. --- .gitmodules | 3 +++ simple.css | 1 + 2 files changed, 4 insertions(+) create mode 160000 simple.css diff --git a/.gitmodules b/.gitmodules index 755d4f6..8fcd4bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,3 +13,6 @@ [submodule "fw/zephyrproject/bootloader/mcuboot"] path = fw/rtos/modules/mcuboot url = https://github.com/zephyrproject-rtos/mcuboot.git +[submodule "simple.css"] + path = simple.css + url = https://github.com/kevquirk/simple.css.git diff --git a/simple.css b/simple.css new file mode 160000 index 0000000..9f62bf3 --- /dev/null +++ b/simple.css @@ -0,0 +1 @@ +Subproject commit 9f62bf3630812239712693886af032311c2dfa3c -- cgit v1.2.3-70-g09d2 From db02eb87ce5e955f1c970ea3ce88745e03f0bb74 Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 3 Apr 2025 18:13:16 +0200 Subject: web: Add meson build system CMake has some disadvantages when building subprojects like with `ExternalProject`. Furthermore the language is sometimes hard to read, hard to write and not so much appreciated. This is a little test if meson might perform better. If successful this project might switch to meson for all parts except the Zephyr builds. --- meson.build | 3 +++ web/meson.build | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 meson.build create mode 100644 web/meson.build diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..537d067 --- /dev/null +++ b/meson.build @@ -0,0 +1,3 @@ +project('iot-contact') + +subdir('web') diff --git a/web/meson.build b/web/meson.build new file mode 100644 index 0000000..3fcffed --- /dev/null +++ b/web/meson.build @@ -0,0 +1,16 @@ +custom_target('website', + output: ['public'], + command: [ + 'hugo', + '--source', + meson.current_source_dir(), + '--destination', + meson.current_build_dir() / 'public', + ], + depend_files: [ + 'hugo.toml', + 'layouts/baseof.html', + 'layouts/home.html', + ], + build_by_default: true, +) -- cgit v1.2.3-70-g09d2 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. --- meson.build | 2 ++ web/content/meson.build | 5 +++++ web/layouts/baseof.html | 1 + web/meson.build | 9 +++++---- 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 web/content/meson.build diff --git a/meson.build b/meson.build index 537d067..494da4e 100644 --- a/meson.build +++ b/meson.build @@ -1,3 +1,5 @@ project('iot-contact') +css = meson.current_source_dir() / 'simple.css' / 'simple.css' + subdir('web') diff --git a/web/content/meson.build b/web/content/meson.build new file mode 100644 index 0000000..75d3120 --- /dev/null +++ b/web/content/meson.build @@ -0,0 +1,5 @@ +configure_file( + input: css, + output: 'simple.css', + copy: true, +) 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 }} diff --git a/web/meson.build b/web/meson.build index 3fcffed..20a4520 100644 --- a/web/meson.build +++ b/web/meson.build @@ -1,11 +1,12 @@ +subdir('content') + custom_target('website', output: ['public'], command: [ 'hugo', - '--source', - meson.current_source_dir(), - '--destination', - meson.current_build_dir() / 'public', + '--source', meson.current_source_dir(), + '--destination', meson.current_build_dir() / 'public', + '--contentDir', meson.current_build_dir() / 'content', ], depend_files: [ 'hugo.toml', -- cgit v1.2.3-70-g09d2 From b7c46986ac3aa4a17b9fac2ad54afec9d6a3506f Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 3 Apr 2025 22:01:03 +0200 Subject: web: Remove CMake Trying meson worked so well that CMake is no longer needed. --- CMakeLists.txt | 1 - cmake/hugo.cmake | 21 --------------------- web/CMakeLists.txt | 16 ---------------- 3 files changed, 38 deletions(-) delete mode 100644 cmake/hugo.cmake delete mode 100644 web/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 90eac62..a21c5d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,4 +6,3 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) add_subdirectory(fw) add_subdirectory(pcb) -add_subdirectory(web) diff --git a/cmake/hugo.cmake b/cmake/hugo.cmake deleted file mode 100644 index 0180958..0000000 --- a/cmake/hugo.cmake +++ /dev/null @@ -1,21 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at https://mozilla.org/MPL/2.0/. - -function(hugo_site target source sink dependencies) - add_custom_target( - "${target}" - ALL - DEPENDS - ${sink} - ) - - add_custom_command( - OUTPUT - ${sink} - COMMAND - hugo --source ${source} --destination ${sink} - DEPENDS - ${dependencies} - ) -endfunction() diff --git a/web/CMakeLists.txt b/web/CMakeLists.txt deleted file mode 100644 index 92af0cb..0000000 --- a/web/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -include(hugo) - -set(dependencies - hugo.toml - layouts/baseof.html - layouts/home.html -) - -hugo_site( - "website" - "${CMAKE_CURRENT_SOURCE_DIR}" - "${CMAKE_CURRENT_BINARY_DIR}/public" - "${dependencies}" -) -- cgit v1.2.3-70-g09d2 From 6ff99393b4bbc1207375cbbc032814e233b03758 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 5 Apr 2025 09:52:41 +0200 Subject: pcb: Switch from CMake to Meson This allows to install the PCB-related files easier to the website which is built with Meson. --- CMakeLists.txt | 3 - cmake/LICENSE.txt | 373 ----------------------------------------------------- cmake/kicad.cmake | 50 ------- meson.build | 1 + pcb/CMakeLists.txt | 21 --- pcb/meson.build | 38 ++++++ 6 files changed, 39 insertions(+), 447 deletions(-) delete mode 100644 cmake/LICENSE.txt delete mode 100644 cmake/kicad.cmake delete mode 100644 pcb/CMakeLists.txt create mode 100644 pcb/meson.build diff --git a/CMakeLists.txt b/CMakeLists.txt index a21c5d0..7d5602c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,4 @@ cmake_minimum_required(VERSION 3.10) project(iot-contact LANGUAGES NONE) -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) - add_subdirectory(fw) -add_subdirectory(pcb) diff --git a/cmake/LICENSE.txt b/cmake/LICENSE.txt deleted file mode 100644 index d0a1fa1..0000000 --- a/cmake/LICENSE.txt +++ /dev/null @@ -1,373 +0,0 @@ -Mozilla Public License Version 2.0 -================================== - -1. Definitions --------------- - -1.1. "Contributor" - means each individual or legal entity that creates, contributes to - the creation of, or owns Covered Software. - -1.2. "Contributor Version" - means the combination of the Contributions of others (if any) used - by a Contributor and that particular Contributor's Contribution. - -1.3. "Contribution" - means Covered Software of a particular Contributor. - -1.4. "Covered Software" - means Source Code Form to which the initial Contributor has attached - the notice in Exhibit A, the Executable Form of such Source Code - Form, and Modifications of such Source Code Form, in each case - including portions thereof. - -1.5. "Incompatible With Secondary Licenses" - means - - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or - - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" - means any form of the work other than Source Code Form. - -1.7. "Larger Work" - means a work that combines Covered Software with other material, in - a separate file or files, that is not Covered Software. - -1.8. "License" - means this document. - -1.9. "Licensable" - means having the right to grant, to the maximum extent possible, - whether at the time of the initial grant or subsequently, any and - all of the rights conveyed by this License. - -1.10. "Modifications" - means any of the following: - - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or - - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor - means any patent claim(s), including without limitation, method, - process, and apparatus claims, in any patent Licensable by such - Contributor that would be infringed, but for the grant of the - License, by the making, using, selling, offering for sale, having - made, import, or transfer of either its Contributions or its - Contributor Version. - -1.12. "Secondary License" - means either the GNU General Public License, Version 2.0, the GNU - Lesser General Public License, Version 2.1, the GNU Affero General - Public License, Version 3.0, or any later versions of those - licenses. - -1.13. "Source Code Form" - means the form of the work preferred for making modifications. - -1.14. "You" (or "Your") - means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that - controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct - or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than - fifty percent (50%) of the outstanding shares or beneficial - ownership of such entity. - -2. License Grants and Conditions --------------------------------- - -2.1. Grants - -Each Contributor hereby grants You a world-wide, royalty-free, -non-exclusive license: - -(a) under intellectual property rights (other than patent or trademark) - Licensable by such Contributor to use, reproduce, make available, - modify, display, perform, distribute, and otherwise exploit its - Contributions, either on an unmodified basis, with Modifications, or - as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer - for sale, have made, import, and otherwise transfer either its - Contributions or its Contributor Version. - -2.2. Effective Date - -The licenses granted in Section 2.1 with respect to any Contribution -become effective for each Contribution on the date the Contributor first -distributes such Contribution. - -2.3. Limitations on Grant Scope - -The licenses granted in this Section 2 are the only rights granted under -this License. No additional rights or licenses will be implied from the -distribution or licensing of Covered Software under this License. -Notwithstanding Section 2.1(b) above, no patent license is granted by a -Contributor: - -(a) for any code that a Contributor has removed from Covered Software; - or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its - Contributions with other software (except as part of its Contributor - Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of - its Contributions. - -This License does not grant any rights in the trademarks, service marks, -or logos of any Contributor (except as may be necessary to comply with -the notice requirements in Section 3.4). - -2.4. Subsequent Licenses - -No Contributor makes additional grants as a result of Your choice to -distribute the Covered Software under a subsequent version of this -License (see Section 10.2) or under the terms of a Secondary License (if -permitted under the terms of Section 3.3). - -2.5. Representation - -Each Contributor represents that the Contributor believes its -Contributions are its original creation(s) or it has sufficient rights -to grant the rights to its Contributions conveyed by this License. - -2.6. Fair Use - -This License is not intended to limit any rights You have under -applicable copyright doctrines of fair use, fair dealing, or other -equivalents. - -2.7. Conditions - -Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted -in Section 2.1. - -3. Responsibilities -------------------- - -3.1. Distribution of Source Form - -All distribution of Covered Software in Source Code Form, including any -Modifications that You create or to which You contribute, must be under -the terms of this License. You must inform recipients that the Source -Code Form of the Covered Software is governed by the terms of this -License, and how they can obtain a copy of this License. You may not -attempt to alter or restrict the recipients' rights in the Source Code -Form. - -3.2. Distribution of Executable Form - -If You distribute Covered Software in Executable Form then: - -(a) such Covered Software must also be made available in Source Code - Form, as described in Section 3.1, and You must inform recipients of - the Executable Form how they can obtain a copy of such Source Code - Form by reasonable means in a timely manner, at a charge no more - than the cost of distribution to the recipient; and - -(b) You may distribute such Executable Form under the terms of this - License, or sublicense it under different terms, provided that the - license for the Executable Form does not attempt to limit or alter - the recipients' rights in the Source Code Form under this License. - -3.3. Distribution of a Larger Work - -You may create and distribute a Larger Work under terms of Your choice, -provided that You also comply with the requirements of this License for -the Covered Software. If the Larger Work is a combination of Covered -Software with a work governed by one or more Secondary Licenses, and the -Covered Software is not Incompatible With Secondary Licenses, this -License permits You to additionally distribute such Covered Software -under the terms of such Secondary License(s), so that the recipient of -the Larger Work may, at their option, further distribute the Covered -Software under the terms of either this License or such Secondary -License(s). - -3.4. Notices - -You may not remove or alter the substance of any license notices -(including copyright notices, patent notices, disclaimers of warranty, -or limitations of liability) contained within the Source Code Form of -the Covered Software, except that You may alter any license notices to -the extent required to remedy known factual inaccuracies. - -3.5. Application of Additional Terms - -You may choose to offer, and to charge a fee for, warranty, support, -indemnity or liability obligations to one or more recipients of Covered -Software. However, You may do so only on Your own behalf, and not on -behalf of any Contributor. You must make it absolutely clear that any -such warranty, support, indemnity, or liability obligation is offered by -You alone, and You hereby agree to indemnify every Contributor for any -liability incurred by such Contributor as a result of warranty, support, -indemnity or liability terms You offer. You may include additional -disclaimers of warranty and limitations of liability specific to any -jurisdiction. - -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- - -If it is impossible for You to comply with any of the terms of this -License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) -describe the limitations and the code they affect. Such description must -be placed in a text file included with all distributions of the Covered -Software under this License. Except to the extent prohibited by statute -or regulation, such description must be sufficiently detailed for a -recipient of ordinary skill to be able to understand it. - -5. Termination --------------- - -5.1. The rights granted under this License will terminate automatically -if You fail to comply with any of its terms. However, if You become -compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an -ongoing basis, if such Contributor fails to notify You of the -non-compliance by some reasonable means prior to 60 days after You have -come back into compliance. Moreover, Your grants from a particular -Contributor are reinstated on an ongoing basis if such Contributor -notifies You of the non-compliance by some reasonable means, this is the -first time You have received notice of non-compliance with this License -from such Contributor, and You become compliant prior to 30 days after -Your receipt of the notice. - -5.2. If You initiate litigation against any entity by asserting a patent -infringement claim (excluding declaratory judgment actions, -counter-claims, and cross-claims) alleging that a Contributor Version -directly or indirectly infringes any patent, then the rights granted to -You by any and all Contributors for the Covered Software under Section -2.1 of this License shall terminate. - -5.3. In the event of termination under Sections 5.1 or 5.2 above, all -end user license agreements (excluding distributors and resellers) which -have been validly granted by You or Your distributors under this License -prior to termination shall survive termination. - -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ - -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ - -8. Litigation -------------- - -Any litigation relating to this License may be brought only in the -courts of a jurisdiction where the defendant maintains its principal -place of business and such litigation shall be governed by laws of that -jurisdiction, without reference to its conflict-of-law provisions. -Nothing in this Section shall prevent a party's ability to bring -cross-claims or counter-claims. - -9. Miscellaneous ----------------- - -This License represents the complete agreement concerning the subject -matter hereof. If any provision of this License is held to be -unenforceable, such provision shall be reformed only to the extent -necessary to make it enforceable. Any law or regulation which provides -that the language of a contract shall be construed against the drafter -shall not be used to construe this License against a Contributor. - -10. Versions of the License ---------------------------- - -10.1. New Versions - -Mozilla Foundation is the license steward. Except as provided in Section -10.3, no one other than the license steward has the right to modify or -publish new versions of this License. Each version will be given a -distinguishing version number. - -10.2. Effect of New Versions - -You may distribute the Covered Software under the terms of the version -of the License under which You originally received the Covered Software, -or under the terms of any subsequent version published by the license -steward. - -10.3. Modified Versions - -If you create software not governed by this License, and you want to -create a new license for such software, you may create and use a -modified version of this License if you rename the license and remove -any references to the name of the license steward (except to note that -such modified license differs from this License). - -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses - -If You choose to distribute Source Code Form that is Incompatible With -Secondary Licenses under the terms of this version of the License, the -notice described in Exhibit B of this License must be attached. - -Exhibit A - Source Code Form License Notice -------------------------------------------- - - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at https://mozilla.org/MPL/2.0/. - -If it is not possible or desirable to put the notice in a particular -file, then You may include the notice in a location (such as a LICENSE -file in a relevant directory) where a recipient would be likely to look -for such a notice. - -You may add additional accurate notices of copyright ownership. - -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- - - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/cmake/kicad.cmake b/cmake/kicad.cmake deleted file mode 100644 index 0feac80..0000000 --- a/cmake/kicad.cmake +++ /dev/null @@ -1,50 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at https://mozilla.org/MPL/2.0/. - -function(kicad_schematic_pdf target sink source) - add_custom_target( - "${target}" - ALL - DEPENDS - ${sink} - ) - - add_custom_command( - OUTPUT - ${sink} - COMMAND - kicad-cli sch export pdf --output ${sink} ${source} - COMMAND - echo "Exported schematic: ${sink}" - DEPENDS - ${source} - JOB_POOL - kicad - ) -endfunction() - -function(kicad_bom_csv target sink source) - add_custom_target( - "${target}" - ALL - DEPENDS - ${sink} - ) - - add_custom_command( - OUTPUT - ${sink} - COMMAND - kicad-cli sch export bom - --fields 'Reference,Description,Value,Footprint,Manufacturer,MPN,Datasheet' - --output ${sink} - ${source} - COMMAND - echo "Exported BOM: ${sink}" - DEPENDS - ${source} - JOB_POOL - kicad - ) -endfunction() diff --git a/meson.build b/meson.build index 494da4e..a0e6468 100644 --- a/meson.build +++ b/meson.build @@ -2,4 +2,5 @@ project('iot-contact') css = meson.current_source_dir() / 'simple.css' / 'simple.css' +subdir('pcb') subdir('web') diff --git a/pcb/CMakeLists.txt b/pcb/CMakeLists.txt deleted file mode 100644 index 8d2c49a..0000000 --- a/pcb/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -project(iot-contact-pcb LANGUAGES NONE) - -include(kicad) - -set_property(GLOBAL PROPERTY JOB_POOLS kicad=1) - -set(schematic "${CMAKE_CURRENT_SOURCE_DIR}/iot-contact.kicad_sch") - -kicad_schematic_pdf( - "schematic" - "${CMAKE_CURRENT_BINARY_DIR}/schematic.pdf" - "${schematic}" -) - -kicad_bom_csv( - "bom" - "${CMAKE_CURRENT_BINARY_DIR}/bom.csv" - "${schematic}" -) diff --git a/pcb/meson.build b/pcb/meson.build new file mode 100644 index 0000000..cd45a48 --- /dev/null +++ b/pcb/meson.build @@ -0,0 +1,38 @@ +schematic_files = [ + 'iot-contact.kicad_sch', + 'contacts.kicad_sch', + 'ethernet.kicad_sch', + 'io.kicad_sch', + 'power.kicad_sch', + 'processor.kicad_sch', +] + +schematic = custom_target('schematic', + output: ['schematic.pdf'], + command: [ + 'kicad-cli', + 'sch', + 'export', + 'pdf', + '--output', meson.current_build_dir() / 'schematic.pdf', + meson.current_source_dir() / 'iot-contact.kicad_sch', + ], + depend_files: schematic_files, + build_by_default: true, +) + +bom = custom_target('bom', + output: ['bill-of-materials.csv'], + command: [ + 'kicad-cli', + 'sch', + 'export', + 'bom', + '--fields', + 'Reference,Description,Value,Footprint,Manufacturer,MPN,Datasheet', + '--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, +) -- cgit v1.2.3-70-g09d2 From ec8958e5ded76bd148e2cb4efbd22603555b93f5 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 5 Apr 2025 10:21:36 +0200 Subject: web: Depend on schematic and bom targets This triggers a website rebuild when schematic files are updated. --- web/meson.build | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/web/meson.build b/web/meson.build index 20a4520..1e8989c 100644 --- a/web/meson.build +++ b/web/meson.build @@ -1,6 +1,6 @@ subdir('content') -custom_target('website', +website = custom_target('website', output: ['public'], command: [ 'hugo', @@ -13,5 +13,9 @@ custom_target('website', 'layouts/baseof.html', 'layouts/home.html', ], + depends: [ + schematic, + bom, + ], build_by_default: true, ) -- 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 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 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 82fa02bcac5e278586cb2e3c9cc597699f6f640d Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 5 Apr 2025 11:10:12 +0200 Subject: fw: btl: Configure bootloader build with Meson CMake ExternalProject creates a pretty confusing build tree. Since the rest of the project anyway starts moving to Meson the bootloader is configured via Meson as a first step. --- fw/btl/configure.sh | 14 ++++++++++++++ fw/btl/meson.build | 16 ++++++++++++++++ fw/meson.build | 7 +++++++ fw/rtos/meson.build | 3 +++ fw/rtos/modules/meson.build | 8 ++++++++ meson.build | 1 + 6 files changed, 49 insertions(+) create mode 100755 fw/btl/configure.sh create mode 100644 fw/btl/meson.build create mode 100644 fw/meson.build create mode 100644 fw/rtos/meson.build create mode 100644 fw/rtos/modules/meson.build diff --git a/fw/btl/configure.sh b/fw/btl/configure.sh new file mode 100755 index 0000000..87df3d2 --- /dev/null +++ b/fw/btl/configure.sh @@ -0,0 +1,14 @@ +#!/bin/sh + + +set -eufx + + +cmake \ + "-S$1" \ + "-B$2" \ + "-DBOARD=$3" \ + "-DZEPHYR_BASE=$4" \ + "-DZEPHYR_MODULES=${5}" \ + "-DEXTRA_CONF_FILE=${6}" \ + "-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\"${7}\"" diff --git a/fw/btl/meson.build b/fw/btl/meson.build new file mode 100644 index 0000000..fd6562e --- /dev/null +++ b/fw/btl/meson.build @@ -0,0 +1,16 @@ +bootloader_config = meson.current_source_dir() / 'bootloader.conf' + +external_project = import('unstable-external_project') +bootloader_bin = meson.current_build_dir() / 'zephyr' / 'zephyr.bin' +bootloader_project = external_project.add_project('configure.sh', + configure_options: [ + bootloader_firmware, + meson.current_build_dir(), + board, + zephyr, + ';'.join(zephyr_modules), + bootloader_config, + signing_key, + ], + verbose: true, +) diff --git a/fw/meson.build b/fw/meson.build new file mode 100644 index 0000000..7f9bead --- /dev/null +++ b/fw/meson.build @@ -0,0 +1,7 @@ +board = 'nucleo_f767zi' + +fs = import('fs') +signing_key = fs.expanduser('~') / 'mcuboot' / 'key.pem' + +subdir('rtos') +subdir('btl') diff --git a/fw/rtos/meson.build b/fw/rtos/meson.build new file mode 100644 index 0000000..800153d --- /dev/null +++ b/fw/rtos/meson.build @@ -0,0 +1,3 @@ +subdir('modules') + +zephyr = meson.current_source_dir() / 'zephyr' diff --git a/fw/rtos/modules/meson.build b/fw/rtos/modules/meson.build new file mode 100644 index 0000000..52f50c2 --- /dev/null +++ b/fw/rtos/modules/meson.build @@ -0,0 +1,8 @@ +zephyr_modules = [ + meson.current_source_dir() / 'cmsis', + meson.current_source_dir() / 'hal_stm32', + meson.current_source_dir() / 'mbedtls', + meson.current_source_dir() / 'mcuboot', +] + +bootloader_firmware = meson.current_source_dir() / 'mcuboot' / 'boot' / 'zephyr' diff --git a/meson.build b/meson.build index 73206f4..9205388 100644 --- a/meson.build +++ b/meson.build @@ -8,5 +8,6 @@ css = fs.copyfile( install_dir: 'website/static', ) +subdir('fw') subdir('pcb') subdir('web') -- cgit v1.2.3-70-g09d2 From 28576b0bdb6b6e08b186c2919bbed4393b38bb7f Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 13:28:53 +0200 Subject: fw: btl: Fix build with Meson --- fw/btl/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fw/btl/meson.build b/fw/btl/meson.build index fd6562e..08399a9 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -5,7 +5,7 @@ bootloader_bin = meson.current_build_dir() / 'zephyr' / 'zephyr.bin' bootloader_project = external_project.add_project('configure.sh', configure_options: [ bootloader_firmware, - meson.current_build_dir(), + meson.current_build_dir() / 'build', board, zephyr, ';'.join(zephyr_modules), -- cgit v1.2.3-70-g09d2 From 9f75ad79c0df9035bcdfd11011ba475cc80ad50a Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 13:38:24 +0200 Subject: fw: btl: Configure with Python script To use a more readable scripting language and keep portability the POSIX shell script for Zephyr configuration is replaced by Python. --- fw/btl/configure.py | 30 ++++++++++++++++++++++++++++++ fw/btl/configure.sh | 14 -------------- fw/btl/meson.build | 2 +- 3 files changed, 31 insertions(+), 15 deletions(-) create mode 100755 fw/btl/configure.py delete mode 100755 fw/btl/configure.sh diff --git a/fw/btl/configure.py b/fw/btl/configure.py new file mode 100755 index 0000000..a1f6e38 --- /dev/null +++ b/fw/btl/configure.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + + +import subprocess +import sys + + +source_tree = sys.argv[1] +build_tree = sys.argv[2] +board = sys.argv[3] +zephyr_base = sys.argv[4] +zephyr_modules = sys.argv[5] +extra_conf_file = sys.argv[6] +signing_key_file = sys.argv[7] + + +subprocess.run( + [ + "cmake", + f"-S{source_tree}", + f"-B{build_tree}", + f"-DBOARD={board}", + f"-DZEPHYR_BASE={zephyr_base}", + f"-DZEPHYR_MODULES={zephyr_modules}", + f"-DEXTRA_CONF_FILE={extra_conf_file}", + f"-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\"{signing_key_file}\"" + ], + shell=False, + check=True, +) diff --git a/fw/btl/configure.sh b/fw/btl/configure.sh deleted file mode 100755 index 87df3d2..0000000 --- a/fw/btl/configure.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - - -set -eufx - - -cmake \ - "-S$1" \ - "-B$2" \ - "-DBOARD=$3" \ - "-DZEPHYR_BASE=$4" \ - "-DZEPHYR_MODULES=${5}" \ - "-DEXTRA_CONF_FILE=${6}" \ - "-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\"${7}\"" diff --git a/fw/btl/meson.build b/fw/btl/meson.build index 08399a9..0b48c11 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -2,7 +2,7 @@ bootloader_config = meson.current_source_dir() / 'bootloader.conf' external_project = import('unstable-external_project') bootloader_bin = meson.current_build_dir() / 'zephyr' / 'zephyr.bin' -bootloader_project = external_project.add_project('configure.sh', +bootloader_project = external_project.add_project('configure.py', configure_options: [ bootloader_firmware, meson.current_build_dir() / 'build', -- cgit v1.2.3-70-g09d2 From e28796985d5f605fbdb1f5043618b1f570e747af Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 13:41:42 +0200 Subject: fw: btl: Clean up meson.build --- fw/btl/meson.build | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fw/btl/meson.build b/fw/btl/meson.build index 0b48c11..b783191 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -1,7 +1,5 @@ -bootloader_config = meson.current_source_dir() / 'bootloader.conf' - external_project = import('unstable-external_project') -bootloader_bin = meson.current_build_dir() / 'zephyr' / 'zephyr.bin' + bootloader_project = external_project.add_project('configure.py', configure_options: [ bootloader_firmware, @@ -9,7 +7,7 @@ bootloader_project = external_project.add_project('configure.py', board, zephyr, ';'.join(zephyr_modules), - bootloader_config, + meson.current_source_dir() / 'bootloader.conf', signing_key, ], verbose: true, -- 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 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 04e504c94db921d45b63c7ea75389d692de6738e Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 17:07:53 +0200 Subject: Remove symlink compile_commands.json With multiple CMake Zephyr builds a single link does not make sense anymore. The user should set a custom symlink. `.gitignore` is altered to avoid committing such a link. --- .gitignore | 1 + compile_commands.json | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 120000 compile_commands.json diff --git a/.gitignore b/.gitignore index 60fd437..14f1e78 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .cache build log.txt +compile_commands.json diff --git a/compile_commands.json b/compile_commands.json deleted file mode 120000 index 25eb4b2..0000000 --- a/compile_commands.json +++ /dev/null @@ -1 +0,0 @@ -build/compile_commands.json \ No newline at end of file -- cgit v1.2.3-70-g09d2 From e78341079228b135bee65deb8e0d4e2b4385cf94 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 17:27:49 +0200 Subject: tools: Add directory and move scripts here This allows to re-use these scripts. Since they are currently used to build Zephyr builds and three are intended (application, bootloader and application as native_sim build) this makes sense. --- fw/btl/build.py | 29 ---- fw/btl/configure.py | 30 ---- fw/btl/meson.build | 5 +- meson.build | 4 + tools/LICENSE.txt | 373 ++++++++++++++++++++++++++++++++++++++++++++++ tools/build_zephyr.py | 34 +++++ tools/configure_zephyr.py | 35 +++++ 7 files changed, 449 insertions(+), 61 deletions(-) delete mode 100755 fw/btl/build.py delete mode 100755 fw/btl/configure.py create mode 100644 tools/LICENSE.txt create mode 100755 tools/build_zephyr.py create mode 100755 tools/configure_zephyr.py diff --git a/fw/btl/build.py b/fw/btl/build.py deleted file mode 100755 index 6478701..0000000 --- a/fw/btl/build.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/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/configure.py b/fw/btl/configure.py deleted file mode 100755 index a1f6e38..0000000 --- a/fw/btl/configure.py +++ /dev/null @@ -1,30 +0,0 @@ -#!/usr/bin/env python3 - - -import subprocess -import sys - - -source_tree = sys.argv[1] -build_tree = sys.argv[2] -board = sys.argv[3] -zephyr_base = sys.argv[4] -zephyr_modules = sys.argv[5] -extra_conf_file = sys.argv[6] -signing_key_file = sys.argv[7] - - -subprocess.run( - [ - "cmake", - f"-S{source_tree}", - f"-B{build_tree}", - f"-DBOARD={board}", - f"-DZEPHYR_BASE={zephyr_base}", - f"-DZEPHYR_MODULES={zephyr_modules}", - f"-DEXTRA_CONF_FILE={extra_conf_file}", - f"-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\"{signing_key_file}\"" - ], - shell=False, - check=True, -) diff --git a/fw/btl/meson.build b/fw/btl/meson.build index 37c8c25..ed40cd3 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -1,6 +1,7 @@ external_project = import('unstable-external_project') -bootloader_project = external_project.add_project('configure.py', +bootloader_project = external_project.add_project( + configure_zephyr, configure_options: [ bootloader_firmware, meson.current_build_dir() / 'build', @@ -16,7 +17,7 @@ bootloader_project = external_project.add_project('configure.py', bootloader = custom_target('bootloader', output: ['bootloader.bin'], command: [ - meson.current_source_dir() / 'build.py', + build_zephyr, meson.current_build_dir() / 'build', ], build_by_default: true, diff --git a/meson.build b/meson.build index 9205388..446fb29 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,9 @@ project('iot-contact') +tools = meson.current_source_dir() / 'tools' +configure_zephyr = tools / 'configure_zephyr.py' +build_zephyr = tools / 'build_zephyr.py' + fs = import('fs') css = fs.copyfile( meson.current_source_dir() / 'simple.css' / 'simple.css', diff --git a/tools/LICENSE.txt b/tools/LICENSE.txt new file mode 100644 index 0000000..d0a1fa1 --- /dev/null +++ b/tools/LICENSE.txt @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at https://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/tools/build_zephyr.py b/tools/build_zephyr.py new file mode 100755 index 0000000..c99727e --- /dev/null +++ b/tools/build_zephyr.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 + + +# This Source Code Form is subject to the terms of the Mozilla Public License, +# v. 2.0. If a copy of the MPL was not distributed with this file, You can +# obtain one at https://mozilla.org/MPL/2.0/. + + +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/tools/configure_zephyr.py b/tools/configure_zephyr.py new file mode 100755 index 0000000..fa1fc5d --- /dev/null +++ b/tools/configure_zephyr.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + + +# This Source Code Form is subject to the terms of the Mozilla Public License, +# v. 2.0. If a copy of the MPL was not distributed with this file, You can +# obtain one at https://mozilla.org/MPL/2.0/. + + +import subprocess +import sys + + +source_tree = sys.argv[1] +build_tree = sys.argv[2] +board = sys.argv[3] +zephyr_base = sys.argv[4] +zephyr_modules = sys.argv[5] +extra_conf_file = sys.argv[6] +signing_key_file = sys.argv[7] + + +subprocess.run( + [ + "cmake", + f"-S{source_tree}", + f"-B{build_tree}", + f"-DBOARD={board}", + f"-DZEPHYR_BASE={zephyr_base}", + f"-DZEPHYR_MODULES={zephyr_modules}", + f"-DEXTRA_CONF_FILE={extra_conf_file}", + f"-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\"{signing_key_file}\"" + ], + shell=False, + check=True, +) -- cgit v1.2.3-70-g09d2 From 84ab791be78c4f2014a78b09305c5c332b5383e3 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 17:33:13 +0200 Subject: fw: btl: Clean meson.build --- fw/btl/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fw/btl/meson.build b/fw/btl/meson.build index ed40cd3..cedd11d 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -1,6 +1,6 @@ external_project = import('unstable-external_project') -bootloader_project = external_project.add_project( +external_project.add_project( configure_zephyr, configure_options: [ bootloader_firmware, -- cgit v1.2.3-70-g09d2 From 867755129e5c50f4e35bc34d5818c2397f3f09db Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 17:59:06 +0200 Subject: tools: Use argparse for build scripts This makes them re-usable for the application and native_sim firmwares. --- fw/btl/meson.build | 17 +++++++------- tools/build_zephyr.py | 47 +++++++++++++++++++++++-------------- tools/configure_zephyr.py | 59 ++++++++++++++++++++++++++++++----------------- 3 files changed, 77 insertions(+), 46 deletions(-) diff --git a/fw/btl/meson.build b/fw/btl/meson.build index cedd11d..b64fd40 100644 --- a/fw/btl/meson.build +++ b/fw/btl/meson.build @@ -3,13 +3,13 @@ external_project = import('unstable-external_project') external_project.add_project( configure_zephyr, configure_options: [ - bootloader_firmware, - meson.current_build_dir() / 'build', - board, - zephyr, - ';'.join(zephyr_modules), - meson.current_source_dir() / 'bootloader.conf', - signing_key, + '--source-tree', bootloader_firmware, + '--build-tree', meson.current_build_dir() / 'build', + '--board', board, + '--zephyr-base', zephyr, + '--zephyr-modules', ';'.join(zephyr_modules), + '--extra-config', meson.current_source_dir() / 'bootloader.conf', + '--signing-key', signing_key, ], verbose: true, ) @@ -18,7 +18,8 @@ bootloader = custom_target('bootloader', output: ['bootloader.bin'], command: [ build_zephyr, - meson.current_build_dir() / 'build', + '--build-tree', meson.current_build_dir() / 'build', + '--target-name', 'bootloader.bin', ], build_by_default: true, install: true, diff --git a/tools/build_zephyr.py b/tools/build_zephyr.py index c99727e..e201bac 100755 --- a/tools/build_zephyr.py +++ b/tools/build_zephyr.py @@ -6,29 +6,42 @@ # obtain one at https://mozilla.org/MPL/2.0/. +import argparse import multiprocessing import shutil import subprocess -import sys import pathlib -build_tree = pathlib.Path(sys.argv[1]) -output_dir = build_tree.parent +def main() -> None: + parser = argparse.ArgumentParser( + description="Build a Zephyr GNU Make build", + ) + parser.add_argument("-B", "--build-tree", required=True) + parser.add_argument("-n", "--target-name", required=True) -subprocess.run( - [ - "make", - f"-j{multiprocessing.cpu_count()}", - "-C", - f"{str(build_tree)}", - ], - shell=False, - check=True, -) + args = parser.parse_args() -shutil.copy( - build_tree / "zephyr" / "zephyr.bin", - output_dir / "bootloader.bin" -) + build_tree = pathlib.Path(args.build_tree) + 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 / args.target_name + ) + + +if __name__ == "__main__": + main() diff --git a/tools/configure_zephyr.py b/tools/configure_zephyr.py index fa1fc5d..e709063 100755 --- a/tools/configure_zephyr.py +++ b/tools/configure_zephyr.py @@ -6,30 +6,47 @@ # obtain one at https://mozilla.org/MPL/2.0/. +import argparse import subprocess -import sys -source_tree = sys.argv[1] -build_tree = sys.argv[2] -board = sys.argv[3] -zephyr_base = sys.argv[4] -zephyr_modules = sys.argv[5] -extra_conf_file = sys.argv[6] -signing_key_file = sys.argv[7] +def main() -> None: + parser = argparse.ArgumentParser( + description="Configure a Zephyr CMake build", + ) + parser.add_argument("-S", "--source-tree", required=True) + parser.add_argument("-B", "--build-tree", required=True) + parser.add_argument("-b", "--board", required=True) + parser.add_argument("-z", "--zephyr-base", required=True) + parser.add_argument("-m", "--zephyr-modules", required=False) + parser.add_argument("-c", "--extra-config", required=False) + parser.add_argument("-k", "--signing-key", required=False) + parser.add_argument("--prefix", required=False) + parser.add_argument("--libdir", required=False) + parser.add_argument("--bindir", required=False) -subprocess.run( - [ + args = parser.parse_args() + + command = [ "cmake", - f"-S{source_tree}", - f"-B{build_tree}", - f"-DBOARD={board}", - f"-DZEPHYR_BASE={zephyr_base}", - f"-DZEPHYR_MODULES={zephyr_modules}", - f"-DEXTRA_CONF_FILE={extra_conf_file}", - f"-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\"{signing_key_file}\"" - ], - shell=False, - check=True, -) + f"-S{args.source_tree}", + f"-B{args.build_tree}", + f"-DBOARD={args.board}", + f"-DZEPHYR_BASE={args.zephyr_base}", + ] + + if args.zephyr_modules is not None: + command.append(f"-DZEPHYR_MODULES={args.zephyr_modules}") + + if args.extra_config is not None: + command.append(f"-DEXTRA_CONF_FILE={args.extra_config}") + + if args.signing_key is not None: + command.append(f"-DCONFIG_BOOT_SIGNATURE_KEY_FILE=\"{args.signing_key}\"") + + subprocess.run(command, shell=False, check=True) + + +if __name__ == "__main__": + main() -- 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 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 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(-) 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 51531e94ad3d909b6a136b6506f79fdb463f7432 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 19:12:17 +0200 Subject: fw: Remove nucleo.sh Because of the Meson build system the application firmware is signed automatically. Furthermore all artifacts required to flash the Nucleo board are deployed to the website. Thus this script is not necessary anymore. --- fw/nucleo.sh | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100755 fw/nucleo.sh diff --git a/fw/nucleo.sh b/fw/nucleo.sh deleted file mode 100755 index ad0467b..0000000 --- a/fw/nucleo.sh +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh - - -# This Source Code Form is subject to the terms of the Mozilla Public License, -# v. 2.0. If a copy of the MPL was not distributed with this file, You can -# obtain one at https://mozilla.org/MPL/2.0/. - - -set -euf - - -SCRIPT="$(realpath "$0")" -FW="$(dirname "$SCRIPT")" -ROOT="$(dirname "$FW")" -BUILD="${ROOT}/build" -BOOTLOADER_FIRMWARE="${BUILD}/fw/btl/zephyr/zephyr.bin" -APPLICATION_FIRMWARE="${BUILD}/fw/app/zephyr/zephyr.bin" -APPLICATION_FIRMWARE_SIGNED="${BUILD}/fw/app/zephyr/zephyr.signed.bin" -BOOTLOADER_FLASH_ADDRESS='0x8000000' -APPLICATION_FLASH_ADDRESS='0x8040000' -IMGTOOL="${ROOT}/imgtool.py" -KEY="${HOME}/mcuboot/key.pem" -BOARD='nucleo_f767zi' - - -set -x - -python "$IMGTOOL" sign \ - --version 0.0.0 \ - --header-size 0x200 \ - --slot-size 0xc0000 \ - --key "$KEY" \ - "$APPLICATION_FIRMWARE" \ - "$APPLICATION_FIRMWARE_SIGNED" -st-flash --connect-under-reset write "$BOOTLOADER_FIRMWARE" \ - "$BOOTLOADER_FLASH_ADDRESS" -st-flash --connect-under-reset write "$APPLICATION_FIRMWARE_SIGNED" \ - "$APPLICATION_FLASH_ADDRESS" -- cgit v1.2.3-70-g09d2 From 71f6c1991f0451df4c5c92fd8cd8302146fcbf6f Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 19:14:01 +0200 Subject: fw: Remove README.md --- fw/README.md | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 fw/README.md diff --git a/fw/README.md b/fw/README.md deleted file mode 100644 index 9883b2d..0000000 --- a/fw/README.md +++ /dev/null @@ -1,6 +0,0 @@ -# iot-contact Firmware - -This is the firmware for iot-contact. It is based on the Zephyr real time -operating system [1]. - -[1]: https://zephyrproject.org -- cgit v1.2.3-70-g09d2 From 8cc751f284b15ff3dbc5b1ba27e3733671cb964c Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 19:16:48 +0200 Subject: Remove top-level CMake build system Meson now handles this. CMake is only used as Meson external project to build Zephyr firmwares. --- CMakeLists.txt | 5 ----- fw/CMakeLists.txt | 37 ------------------------------------- fw/rtos/CMakeLists.txt | 16 ---------------- 3 files changed, 58 deletions(-) delete mode 100644 CMakeLists.txt delete mode 100644 fw/CMakeLists.txt delete mode 100644 fw/rtos/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index 7d5602c..0000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -cmake_minimum_required(VERSION 3.10) - -project(iot-contact LANGUAGES NONE) - -add_subdirectory(fw) diff --git a/fw/CMakeLists.txt b/fw/CMakeLists.txt deleted file mode 100644 index 2affe92..0000000 --- a/fw/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public License, -# v. 2.0. If a copy of the MPL was not distributed with this file, You can -# obtain one at https://mozilla.org/MPL/2.0/. - -cmake_minimum_required(VERSION 3.20.0) - -include(ExternalProject) - -set(KEY_DEFAULT "$ENV{HOME}/mcuboot/key.pem") -set(KEY ${KEY_DEFAULT} CACHE STRING "Firmware signing key path") -message(STATUS "Firmware signing key path: ${KEY}") - -set(BOARD_DEFAULT "native_sim/native/64") -set(BOARD ${BOARD_DEFAULT} CACHE STRING "Zephyr board identifier") -message(STATUS "Selected board: ${BOARD}") - -add_subdirectory(rtos) -string(REPLACE ";" "," ZEPHYR_MODULES_COMMA "${ZEPHYR_MODULES}") - -if(BOARD STREQUAL "nucleo_f767zi") - ExternalProject_Add( - btl - PREFIX btl - SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rtos/modules/mcuboot/boot/zephyr" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/btl" - INSTALL_COMMAND "" - LIST_SEPARATOR "," - CMAKE_ARGS - "-DBOARD=${BOARD}" - "-DZEPHYR_BASE=${ZEPHYR_BASE}" - "-DZEPHYR_MODULES=${ZEPHYR_MODULES_COMMA}" - "-DEXTRA_CONF_FILE=${CMAKE_CURRENT_SOURCE_DIR}/btl/bootloader.conf" - -DCONFIG_BOOT_SIGNATURE_KEY_FILE="${KEY}" - ) -endif() - -add_subdirectory(app) diff --git a/fw/rtos/CMakeLists.txt b/fw/rtos/CMakeLists.txt deleted file mode 100644 index d9f116c..0000000 --- a/fw/rtos/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public License, -# v. 2.0. If a copy of the MPL was not distributed with this file, You can -# obtain one at https://mozilla.org/MPL/2.0/. - -set(ZEPHYR_MODULES - "${CMAKE_CURRENT_SOURCE_DIR}/modules/cmsis" - "${CMAKE_CURRENT_SOURCE_DIR}/modules/hal_stm32" - "${CMAKE_CURRENT_SOURCE_DIR}/modules/mbedtls" - "${CMAKE_CURRENT_SOURCE_DIR}/modules/mcuboot" - PARENT_SCOPE -) - -set(ZEPHYR_BASE - "${CMAKE_CURRENT_SOURCE_DIR}/zephyr" - PARENT_SCOPE -) -- cgit v1.2.3-70-g09d2 From d0215a2f9f01df704446cbc0ce289a75a623413d Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 19:30:52 +0200 Subject: tools: Add meson.build --- meson.build | 4 +--- tools/meson.build | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 tools/meson.build diff --git a/meson.build b/meson.build index 446fb29..85faf87 100644 --- a/meson.build +++ b/meson.build @@ -1,8 +1,6 @@ project('iot-contact') -tools = meson.current_source_dir() / 'tools' -configure_zephyr = tools / 'configure_zephyr.py' -build_zephyr = tools / 'build_zephyr.py' +subdir('tools') fs = import('fs') css = fs.copyfile( diff --git a/tools/meson.build b/tools/meson.build new file mode 100644 index 0000000..85ddbb3 --- /dev/null +++ b/tools/meson.build @@ -0,0 +1,2 @@ +configure_zephyr = meson.current_source_dir() / 'configure_zephyr.py' +build_zephyr = meson.current_source_dir() / 'build_zephyr.py' -- cgit v1.2.3-70-g09d2 From e95aa78acb1a7ee3802cf01823f148bcdc4f809a Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 6 Apr 2025 19:44:29 +0200 Subject: Update README.md --- README.md | 53 ++++++++++++++++------------------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index 8b39597..7e794bf 100644 --- a/README.md +++ b/README.md @@ -3,61 +3,40 @@ iot-contact is an IoT device to check if doors and windows are closed or open. Furthermore roller shutter motors should be controlled. -Currently two boards are supported: - -- `native_sim/native/64` without bootloader -- `nucleo_f767zi` with bootloader - ## Usage -To build the device repository a firmware signing key is required. It is -generated with the `imgtool.py`. - -``` -mkdir ~/mcuboot -./imgtool.py keygen --key ~/mcuboot/key.pem --type ed25519 -``` - -The content of this repository can be build with CMake and Ninja. The -application firmware will be built for the simulation board to easily use it -without special hardware. - -The bootloader is built for `nucleo_f767zi` since the simulation board is -currently not supported. +The source code can be retrieved with `git`. ``` -cmake -Bbuild -GNinja -ninja -C build +git clone https://cgit.xengineering.eu/iot-contact +cd iot-contact +git submodule update --init ``` -A custom key location can be set by providing `-DKEY=/path/to/key` to the CMake -call. - -To run the simulated firmware a virtual network interface `zeth` and a router -advertisement daemon have to be provided with an embedded script. Root rights -are required for that (prefix e.g. with `sudo`). +To sign the application firmware and thus to build the project a cryptographic +signing key is required. It can be generated with `imgtool.py`. ``` -./fw/simulate-network.sh +mkdir ~/mcuboot +./imgtool.py keygen --key ~/mcuboot/key.pem --type ed25519 ``` -With the firmware built and the network being prepared the simulated firmware -can be run. +The project is built with the Meson build system. ``` -./build/fw/app/zephyr/zephyr.exe +meson setup build +meson compile -C build +meson install -C build --destdir artifacts ``` -To build the firmware in a clean `nucleo` build folder, flash it and open a -serial interface another script can be used for convenience. +The resulting artifacts can be listed with `tree`. ``` -./fw/nucleo.sh +tree build/artifacts ``` -Next to the firmware artifacts the exported files related to the printed -circuit board (PCB) can be found in the build folder. +These artifacts are organized as static website. It can be opened with Firefox. ``` -tree build/pcb +find build/artifacts -name 'index.html' -exec firefox {} \; ``` -- 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(-) 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 }}