From 08973157cca0fbf7d2e834fa8d87503987867c7e Mon Sep 17 00:00:00 2001 From: Barabas Raffai Date: Sat, 3 Aug 2024 18:23:59 +0100 Subject: [PATCH] Implement nvs save tool It does not work because esp provisioning and flutter_libserialport depend on Flutter. We should be able to replace both with pure dart versions. --- .../lib/src/shrapnel_test_lib_base.dart | 22 ++ .../bin/shrapnel_test_tool.dart | 2 +- .../lib/shrapnel_test_tool.dart | 13 +- dart/shrapnel_test_tool/pubspec.lock | 212 ++++++++++++++++-- dart/shrapnel_test_tool/pubspec.yaml | 8 +- .../test/shrapnel_test_tool_test.dart | 5 +- 6 files changed, 231 insertions(+), 31 deletions(-) diff --git a/dart/shrapnel_test_lib/lib/src/shrapnel_test_lib_base.dart b/dart/shrapnel_test_lib/lib/src/shrapnel_test_lib_base.dart index 2f107753..c13876f9 100644 --- a/dart/shrapnel_test_lib/lib/src/shrapnel_test_lib_base.dart +++ b/dart/shrapnel_test_lib/lib/src/shrapnel_test_lib_base.dart @@ -266,6 +266,28 @@ Future nvsLoad(String binaryPath, {required String port}) async { _log.info(result.stdout); } +Future nvsSave(String binaryPath, {required String port}) async { + _log.info('Saving NVS partition'); + + // pip can be used to install esptool into the global environment: + // https://docs.espressif.com/projects/esptool/en/latest/esp32/#quick-start + const command = 'esptool.py'; + final args = '-p $port ' + '-b 2000000 ' + '--before default_reset --after hard_reset ' + '--chip esp32 ' + 'read_flash --flash_mode dio --flash_size 4MB --flash_freq 80m ' + '0x9000 0x6000 $binaryPath' + .split(' '); + + final result = await Process.run(command, args); + + _log.info(result.exitCode); + _log.info(result.pid); + _log.info(result.stderr); + _log.info(result.stdout); +} + /// UART driver class ShrapnelUart { ShrapnelUart._(this.port, this.reader) { diff --git a/dart/shrapnel_test_tool/bin/shrapnel_test_tool.dart b/dart/shrapnel_test_tool/bin/shrapnel_test_tool.dart index c5a43c5d..b1228ac0 100644 --- a/dart/shrapnel_test_tool/bin/shrapnel_test_tool.dart +++ b/dart/shrapnel_test_tool/bin/shrapnel_test_tool.dart @@ -1,5 +1,5 @@ import 'package:shrapnel_test_tool/shrapnel_test_tool.dart' as shrapnel_test_tool; void main(List arguments) { - print('Hello world: ${shrapnel_test_tool.calculate()}!'); + shrapnel_test_tool.main(arguments); } diff --git a/dart/shrapnel_test_tool/lib/shrapnel_test_tool.dart b/dart/shrapnel_test_tool/lib/shrapnel_test_tool.dart index f64ad726..4855abca 100644 --- a/dart/shrapnel_test_tool/lib/shrapnel_test_tool.dart +++ b/dart/shrapnel_test_tool/lib/shrapnel_test_tool.dart @@ -1,3 +1,12 @@ -int calculate() { - return 6 * 7; +import 'package:logging/logging.dart'; +import 'package:shrapnel_test_lib/shrapnel_test_lib.dart'; + +final _log = Logger('shrapnel.test_tool'); + +void main(List arguments) { + hierarchicalLoggingEnabled = true; + Logger.root.onRecord.listen(print); + + _log.info('hello $arguments'); + nvsSave('nvs_${DateTime.now().toIso8601String()}.bin', port: '/dev/ttyUSB0'); } diff --git a/dart/shrapnel_test_tool/pubspec.lock b/dart/shrapnel_test_tool/pubspec.lock index d82c6c75..40973551 100644 --- a/dart/shrapnel_test_tool/pubspec.lock +++ b/dart/shrapnel_test_tool/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + sha256: eb376e9acf6938204f90eb3b1f00b578640d3188b4c8a8ec054f9f479af8d051 url: "https://pub.dev" source: hosted - version: "67.0.0" + version: "64.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + sha256: "69f54f967773f6c26c7dcb13e93d7ccee8b17a641689da39e878d5cf13b06893" url: "https://pub.dev" source: hosted - version: "6.4.1" + version: "6.2.0" args: dependency: transitive description: @@ -41,6 +41,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" + characters: + dependency: transitive + description: + name: characters + sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605" + url: "https://pub.dev" + source: hosted + version: "1.3.0" collection: dependency: transitive description: @@ -73,6 +81,39 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + cryptography: + dependency: transitive + description: + name: cryptography + sha256: d146b76d33d94548cf035233fbc2f4338c1242fa119013bead807d033fc4ae05 + url: "https://pub.dev" + source: hosted + version: "2.7.0" + dylib: + dependency: transitive + description: + name: dylib + sha256: bf609b3eb6492a3309b3d1dbe8f83a4031de5535dd7686be33487051cc760bb0 + url: "https://pub.dev" + source: hosted + version: "0.3.3" + esp_softap_provisioning: + dependency: transitive + description: + path: "." + ref: shrapnel + resolved-ref: f4d5fc671568f50753fc90c3e9b99bc2165c6a39 + url: "https://github.com/ShrapnelDSP/esp_softap_provisioning.git" + source: git + version: "1.0.1" + ffi: + dependency: transitive + description: + name: ffi + sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878" + url: "https://pub.dev" + source: hosted + version: "2.1.0" file: dependency: transitive description: @@ -81,6 +122,35 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" + flutter: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" + flutter_libserialport: + dependency: transitive + description: + name: flutter_libserialport + sha256: "20c320dcde8592a16f9badc0cacad61b1fb283dbec647b6ebfc1020f8274c67b" + url: "https://pub.dev" + source: hosted + version: "0.4.0" + freezed_annotation: + dependency: transitive + description: + name: freezed_annotation + sha256: c2e2d632dd9b8a2b7751117abcfc2b4888ecfe181bd9fca7170d9ef02e595fe2 + url: "https://pub.dev" + source: hosted + version: "2.4.4" frontend_server_client: dependency: transitive description: @@ -97,6 +167,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.2" + http: + dependency: transitive + description: + name: http + sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba + url: "https://pub.dev" + source: hosted + version: "1.2.0" http_multi_server: dependency: transitive description: @@ -125,10 +203,26 @@ packages: dependency: transitive description: name: js - sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf + sha256: f2c445dce49627136094980615a031419f7f3eb393237e4ecd97ac15dea343f3 + url: "https://pub.dev" + source: hosted + version: "0.6.7" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: "1ce844379ca14835a50d2f019a3099f419082cfdd231cd86a142af94dd5c6bb1" + url: "https://pub.dev" + source: hosted + version: "4.9.0" + libserialport: + dependency: transitive + description: + name: libserialport + sha256: "392e1592def65282429832ec66fa25e9e163d3b37716b97691482e2406720727" url: "https://pub.dev" source: hosted - version: "0.7.1" + version: "0.3.0+1" lints: dependency: "direct dev" description: @@ -137,8 +231,16 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.1" - logging: + logger: dependency: transitive + description: + name: logger + sha256: "697d067c60c20999686a0add96cf6aba723b3aa1f83ecf806a8097231529ec32" + url: "https://pub.dev" + source: hosted + version: "2.4.0" + logging: + dependency: "direct main" description: name: logging sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340" @@ -153,14 +255,22 @@ packages: url: "https://pub.dev" source: hosted version: "0.12.16+1" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + url: "https://pub.dev" + source: hosted + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7 + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.15.0" + version: "1.10.0" mime: dependency: transitive description: @@ -193,6 +303,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.9.0" + platform: + dependency: transitive + description: + name: platform + sha256: "9b71283fc13df574056616011fb138fd3b793ea47cc509c189a6c3fa5f8a1a65" + url: "https://pub.dev" + source: hosted + version: "3.1.5" pool: dependency: transitive description: @@ -201,6 +319,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + protobuf: + dependency: transitive + description: + name: protobuf + sha256: "68645b24e0716782e58948f8467fd42a880f255096a821f9e7d0ec625b00c84d" + url: "https://pub.dev" + source: hosted + version: "3.1.0" pub_semver: dependency: transitive description: @@ -237,10 +363,29 @@ packages: dependency: transitive description: name: shelf_web_socket - sha256: "073c147238594ecd0d193f3456a5fe91c4b0abbcc68bf5cd95b36c4e194ac611" + sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1" url: "https://pub.dev" source: hosted - version: "2.0.0" + version: "1.0.4" + shrapnel_common: + dependency: transitive + description: + path: "../shrapnel_common" + relative: true + source: path + version: "1.0.0" + shrapnel_test_lib: + dependency: "direct main" + description: + path: "../shrapnel_test_lib" + relative: true + source: path + version: "1.0.0" + sky_engine: + dependency: transitive + description: flutter + source: sdk + version: "0.0.99" source_map_stack_trace: dependency: transitive description: @@ -289,6 +434,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + string_validator: + dependency: transitive + description: + name: string_validator + sha256: a278d038104aa2df15d0e09c47cb39a49f907260732067d0034dc2f2e4e2ac94 + url: "https://pub.dev" + source: hosted + version: "1.1.0" term_glyph: dependency: transitive description: @@ -301,26 +454,26 @@ packages: dependency: "direct dev" description: name: test - sha256: "7ee44229615f8f642b68120165ae4c2a75fe77ae2065b1e55ae4711f6cf0899e" + sha256: "7ee446762c2c50b3bd4ea96fe13ffac69919352bd3b4b17bac3f3465edc58073" url: "https://pub.dev" source: hosted - version: "1.25.7" + version: "1.25.2" test_api: dependency: transitive description: name: test_api - sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb" + sha256: "9955ae474176f7ac8ee4e989dadfb411a58c30415bcfb648fa04b2b8a03afa7f" url: "https://pub.dev" source: hosted - version: "0.7.2" + version: "0.7.0" test_core: dependency: transitive description: name: test_core - sha256: "55ea5a652e38a1dfb32943a7973f3681a60f872f8c3a05a14664ad54ef9c6696" + sha256: "2bc4b4ecddd75309300d8096f781c0e3280ca1ef85beda558d33fcbedc2eead4" url: "https://pub.dev" source: hosted - version: "0.6.4" + version: "0.6.0" typed_data: dependency: transitive description: @@ -329,6 +482,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.2" + universal_io: + dependency: transitive + description: + name: universal_io + sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad" + url: "https://pub.dev" + source: hosted + version: "2.2.2" + vector_math: + dependency: transitive + description: + name: vector_math + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" + url: "https://pub.dev" + source: hosted + version: "2.1.4" vm_service: dependency: transitive description: @@ -349,18 +518,18 @@ packages: dependency: transitive description: name: web - sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05" + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 url: "https://pub.dev" source: hosted - version: "0.4.2" + version: "0.3.0" web_socket_channel: dependency: transitive description: name: web_socket_channel - sha256: "939ab60734a4f8fa95feacb55804fa278de28bdeef38e616dc08e44a84adea23" + sha256: d88238e5eac9a42bb43ca4e721edba3c08c6354d4a53063afaa568516217621b url: "https://pub.dev" source: hosted - version: "2.4.3" + version: "2.4.0" webkit_inspection_protocol: dependency: transitive description: @@ -379,3 +548,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.2.6 <4.0.0" + flutter: ">=3.0.0" diff --git a/dart/shrapnel_test_tool/pubspec.yaml b/dart/shrapnel_test_tool/pubspec.yaml index db3c5b1f..86c532a3 100644 --- a/dart/shrapnel_test_tool/pubspec.yaml +++ b/dart/shrapnel_test_tool/pubspec.yaml @@ -1,14 +1,16 @@ name: shrapnel_test_tool description: A sample command-line application. version: 1.0.0 -# repository: https://github.com/my_org/my_repo + +publish_to: 'none' environment: sdk: ^3.2.6 -# Add regular dependencies here. dependencies: - # path: ^1.8.0 + logging: ^1.2.0 + shrapnel_test_lib: + path: ../shrapnel_test_lib dev_dependencies: lints: ^2.1.0 diff --git a/dart/shrapnel_test_tool/test/shrapnel_test_tool_test.dart b/dart/shrapnel_test_tool/test/shrapnel_test_tool_test.dart index 77f56eff..13880f99 100644 --- a/dart/shrapnel_test_tool/test/shrapnel_test_tool_test.dart +++ b/dart/shrapnel_test_tool/test/shrapnel_test_tool_test.dart @@ -1,8 +1,5 @@ -import 'package:shrapnel_test_tool/shrapnel_test_tool.dart'; import 'package:test/test.dart'; void main() { - test('calculate', () { - expect(calculate(), 42); - }); + test('dummy', () {}); }