Skip to content

Commit

Permalink
Implement nvs save tool
Browse files Browse the repository at this point in the history
It does not work because esp provisioning and flutter_libserialport
depend on Flutter. We should be able to replace both with pure dart
versions.
  • Loading branch information
Barabas5532 committed Aug 3, 2024
1 parent da927a2 commit 0897315
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 31 deletions.
22 changes: 22 additions & 0 deletions dart/shrapnel_test_lib/lib/src/shrapnel_test_lib_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,28 @@ Future<void> nvsLoad(String binaryPath, {required String port}) async {
_log.info(result.stdout);
}

Future<void> 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) {
Expand Down
2 changes: 1 addition & 1 deletion dart/shrapnel_test_tool/bin/shrapnel_test_tool.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:shrapnel_test_tool/shrapnel_test_tool.dart' as shrapnel_test_tool;

void main(List<String> arguments) {
print('Hello world: ${shrapnel_test_tool.calculate()}!');
shrapnel_test_tool.main(arguments);
}
13 changes: 11 additions & 2 deletions dart/shrapnel_test_tool/lib/shrapnel_test_tool.dart
Original file line number Diff line number Diff line change
@@ -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<String> arguments) {
hierarchicalLoggingEnabled = true;
Logger.root.onRecord.listen(print);

_log.info('hello $arguments');
nvsSave('nvs_${DateTime.now().toIso8601String()}.bin', port: '/dev/ttyUSB0');
}
Loading

0 comments on commit 0897315

Please sign in to comment.