usb: Initialize USB Code Update
Compile the USB Code Update function after enabling `usb-code-update`,
and expect to pass in the name of the USB mount folder when calling
the process.
Also, the dependency of CLI11 has been added.
Tested: enabled `usb-code-update` and built `phosphor-bmc-code-mgmt`
successfully and check that there is a `phosphor-usb-code-update`
process in image-bmc.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Iedfb63c3866cc8542afef9b54bfeaaf5f7b40c6b
diff --git a/meson.build b/meson.build
index e182f46..1367a72 100644
--- a/meson.build
+++ b/meson.build
@@ -326,3 +326,7 @@
)
)
endif
+
+if get_option('usb-code-update').enabled()
+ subdir('usb')
+endif
diff --git a/meson_options.txt b/meson_options.txt
index de3540c..7dd411c 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -25,6 +25,11 @@
option('verify-full-signature', type: 'feature', value: 'enabled',
description: 'Enable image full signature validation.')
+option(
+ 'usb-code-update', type: 'feature', value: 'enabled',
+ description: 'Firmware update via USB.',
+)
+
# Variables
option(
'active-bmc-max-allowed', type: 'integer',
diff --git a/subprojects/CLI11.wrap b/subprojects/CLI11.wrap
new file mode 100644
index 0000000..e695a9d
--- /dev/null
+++ b/subprojects/CLI11.wrap
@@ -0,0 +1,3 @@
+[wrap-git]
+url = https://github.com/CLIUtils/CLI11.git
+revision = HEAD
diff --git a/usb/meson.build b/usb/meson.build
new file mode 100644
index 0000000..f0ac2d0
--- /dev/null
+++ b/usb/meson.build
@@ -0,0 +1,22 @@
+if cpp.has_header('CLI/CLI.hpp')
+ CLI11_dep = declare_dependency()
+else
+ CLI11_dep = dependency(
+ 'CLI11',
+ fallback: [ 'CLI11', 'CLI11_dep' ],
+ )
+endif
+
+source = [
+ 'usb_manager_main.cpp',
+ ]
+
+executable(
+ 'phosphor-usb-code-update',
+ source,
+ dependencies: [
+ CLI11_dep,
+ ],
+ install: true,
+ install_dir: get_option('bindir')
+)
diff --git a/usb/usb_manager_main.cpp b/usb/usb_manager_main.cpp
new file mode 100644
index 0000000..b5a538d
--- /dev/null
+++ b/usb/usb_manager_main.cpp
@@ -0,0 +1,14 @@
+#include <CLI/CLI.hpp>
+
+int main(int argc, char** argv)
+{
+ std::string fileName{};
+
+ CLI::App app{"Update the firmware of OpenBMC via USB app"};
+ app.add_option("-f,--fileName", fileName,
+ "Get the name of the USB mount folder");
+
+ CLI11_PARSE(app, argc, argv);
+
+ return 0;
+}