rpremote 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,71 @@
1
+ diff --git a/mrbgems/picoruby-machine/include/machine.h b/mrbgems/picoruby-machine/include/machine.h
2
+ --- a/mrbgems/picoruby-machine/include/machine.h
3
+ +++ b/mrbgems/picoruby-machine/include/machine.h
4
+ @@ -68,1 +68,2 @@
5
+ void Machine_reboot(void);
6
+ +void Machine_bootsel(void);
7
+ diff --git a/mrbgems/picoruby-machine/mrblib/machine.rb b/mrbgems/picoruby-machine/mrblib/machine.rb
8
+ --- a/mrbgems/picoruby-machine/mrblib/machine.rb
9
+ +++ b/mrbgems/picoruby-machine/mrblib/machine.rb
10
+ @@ -22,0 +23,4 @@
11
+ + def self.bootsel
12
+ + self._bootsel
13
+ + end
14
+ +
15
+ diff --git a/mrbgems/picoruby-machine/ports/rp2040/machine.c b/mrbgems/picoruby-machine/ports/rp2040/machine.c
16
+ --- a/mrbgems/picoruby-machine/ports/rp2040/machine.c
17
+ +++ b/mrbgems/picoruby-machine/ports/rp2040/machine.c
18
+ @@ -10,0 +11,1 @@
19
+ +#include "pico/bootrom.h"
20
+ @@ -42,0 +44,6 @@
21
+ +void
22
+ +Machine_bootsel(void)
23
+ +{
24
+ + rom_reset_usb_boot(0, 0);
25
+ +}
26
+ +
27
+ diff --git a/mrbgems/picoruby-machine/src/mruby/machine.c b/mrbgems/picoruby-machine/src/mruby/machine.c
28
+ --- a/mrbgems/picoruby-machine/src/mruby/machine.c
29
+ +++ b/mrbgems/picoruby-machine/src/mruby/machine.c
30
+ @@ -496,0 +497,11 @@
31
+ +static mrb_value
32
+ +mrb_s__bootsel(mrb_state *mrb, mrb_value self)
33
+ +{
34
+ +#if !defined(PICORB_PLATFORM_POSIX)
35
+ + Machine_bootsel();
36
+ +#else
37
+ + mrb_raise(mrb, E_NOTIMP_ERROR, "Machine._bootsel is not available on this platform");
38
+ +#endif
39
+ + return mrb_nil_value();
40
+ +}
41
+ +
42
+ @@ -529,0 +541,1 @@
43
+ + mrb_define_class_method_id(mrb, module_Machine, MRB_SYM(_bootsel), mrb_s__bootsel, MRB_ARGS_NONE());
44
+ diff --git a/mrbgems/picoruby-machine/src/mrubyc/machine.c b/mrbgems/picoruby-machine/src/mrubyc/machine.c
45
+ --- a/mrbgems/picoruby-machine/src/mrubyc/machine.c
46
+ +++ b/mrbgems/picoruby-machine/src/mrubyc/machine.c
47
+ @@ -316,0 +317,11 @@
48
+ +static void
49
+ +c_Machine__bootsel(mrbc_vm *vm, mrbc_value *v, int argc)
50
+ +{
51
+ +#if !defined(PICORB_PLATFORM_POSIX)
52
+ + Machine_bootsel();
53
+ +#else
54
+ + mrbc_raise(vm, MRBC_CLASS(RuntimeError), "Machine.bootsel is not available on this platform.");
55
+ +#endif
56
+ + SET_NIL_RETURN();
57
+ +}
58
+ +
59
+ @@ -546,0 +558,1 @@
60
+ + mrbc_define_method(vm, module_Machine, "_bootsel", c_Machine__bootsel);
61
+ diff --git a/mrbgems/picoruby-shell/shell_executables/_path.txt b/mrbgems/picoruby-shell/shell_executables/_path.txt
62
+ --- a/mrbgems/picoruby-shell/shell_executables/_path.txt
63
+ +++ b/mrbgems/picoruby-shell/shell_executables/_path.txt
64
+ @@ -17,0 +18,1 @@
65
+ +/bin/bootsel
66
+ diff --git a/mrbgems/picoruby-shell/shell_executables/bootsel.rb b/mrbgems/picoruby-shell/shell_executables/bootsel.rb
67
+ new file mode 100644
68
+ --- /dev/null
69
+ +++ b/mrbgems/picoruby-shell/shell_executables/bootsel.rb
70
+ @@ -0,0 +1 @@
71
+ +Machine.bootsel
@@ -0,0 +1,59 @@
1
+ diff --git a/mrbgems/picoruby-shell/mrblib/job.rb b/mrbgems/picoruby-shell/mrblib/job.rb
2
+ index f650cce..225c944 100644
3
+ --- a/mrbgems/picoruby-shell/mrblib/job.rb
4
+ +++ b/mrbgems/picoruby-shell/mrblib/job.rb
5
+ @@ -1,5 +1,7 @@
6
+ class Shell
7
+ class Job
8
+ + RUBY_EXCEPTION_STATUS = "\x1eR2P2:RUBY_EXCEPTION\x1f"
9
+ +
10
+ def initialize(*params)
11
+ if params.empty?
12
+ raise ArgumentError, "Job requires at least one parameter"
13
+ @@ -24,12 +26,11 @@ class Shell
14
+ @sandbox.resume
15
+ @sandbox.wait(timeout: nil)
16
+ if error = @sandbox.error
17
+ - puts "#{error.message} (#{error.class})"
18
+ + return report_ruby_exception(error)
19
+ end
20
+ return true
21
+ rescue Exception => e
22
+ - puts "#{e.message} (#{e.class})"
23
+ - return false
24
+ + return report_ruby_exception(e)
25
+ end
26
+
27
+ def state
28
+ @@ -60,22 +61,28 @@ class Shell
29
+ end
30
+ if error = @sandbox.error
31
+ reap(before)
32
+ - puts "\n#{error.message} (#{error.class})"
33
+ + return report_ruby_exception(error, true)
34
+ end
35
+ return true
36
+ rescue Exception => e
37
+ - puts "#{e.message} (#{e.class})"
38
+ # backtrace uses a lot of memory
39
+ #if e.respond_to?(:backtrace)
40
+ # e.backtrace.each do |line|
41
+ # puts " #{line}"
42
+ # end
43
+ #end
44
+ - return false
45
+ + return report_ruby_exception(e)
46
+ end
47
+
48
+ private
49
+
50
+ + def report_ruby_exception(error, leading_newline = false)
51
+ + print "\n" if leading_newline
52
+ + puts "#{error.message} (#{error.class})"
53
+ + print RUBY_EXCEPTION_STATUS
54
+ + false
55
+ + end
56
+ +
57
+ # Terminate tasks the job started but left behind, and ONLY when the
58
+ # job died: a script killed by e.g. NoMemoryError never reaches the
59
+ # code that would stop its own tasks, and such an orphan keeps running
data/sig/rpremote.rbs CHANGED
@@ -166,11 +166,33 @@ module Rpremote
166
166
  def source_dir: () -> String
167
167
  end
168
168
 
169
+ class NukeFirmware
170
+ URL: String
171
+ FILENAME: String
172
+ MAX_REDIRECTS: Integer
173
+
174
+ def initialize: (?directory: String, ?fetcher: untyped) -> void
175
+ def setup: (?force: bool) -> String
176
+ end
177
+
178
+ class PicoRubySourcePatch
179
+ JOB_PATH: String
180
+ PATCH_ALIASES: Hash[String, String]
181
+
182
+ class Error < Rpremote::Error
183
+ end
184
+
185
+ attr_reader version: String
186
+
187
+ def initialize: (version: String) -> void
188
+ def apply: (String source) -> void
189
+ end
190
+
169
191
  class Builder
170
192
  class Error < Rpremote::Error
171
193
  end
172
194
 
173
- def initialize: (?root: String, ?runner: untyped, ?mrbgems_class: untyped) -> void
195
+ def initialize: (?root: String, ?runner: untyped, ?mrbgems_class: untyped, ?source_patcher: untyped) -> void
174
196
  def build: (
175
197
  ?language: String,
176
198
  ?language_version: String,
@@ -240,6 +262,7 @@ module Rpremote
240
262
  PROMPT_END: String
241
263
  CURSOR_POSITION_QUERY: String
242
264
  CURSOR_POSITION_RESPONSE: String
265
+ RUBY_EXCEPTION_STATUS: String
243
266
 
244
267
  class Error < Rpremote::Error
245
268
  end
@@ -260,7 +283,7 @@ module Rpremote
260
283
  def initialize: (untyped io, ?timeout: Float) -> void
261
284
  def synchronize!: () -> nil
262
285
  def send_command: (String command) -> nil
263
- def execute: (String command) -> String
286
+ def execute: (String command, ?output: IO?) -> String
264
287
  end
265
288
 
266
289
  class Terminal
@@ -293,7 +316,12 @@ module Rpremote
293
316
  ?shell_class: untyped,
294
317
  ?path_factory: untyped
295
318
  ) -> void
296
- def run: (String data) -> String
319
+ def run: (String data, ?output: IO?) -> String
320
+ end
321
+
322
+ class RecursiveCopy
323
+ def initialize: (output: IO, ?serial: untyped, ?device: untyped) -> void
324
+ def call: (String source, String destination, Hash[Symbol, untyped] options) -> void
297
325
  end
298
326
 
299
327
  class Resetter
@@ -323,7 +351,7 @@ module Rpremote
323
351
  class Result < Data
324
352
  attr_reader mount: String
325
353
  attr_reader destination: String
326
- attr_reader port: String
354
+ attr_reader port: String?
327
355
  end
328
356
 
329
357
  class Error < Rpremote::Error
@@ -348,8 +376,10 @@ module Rpremote
348
376
  ?port_probe: untyped,
349
377
  ?sleeper: untyped
350
378
  ) -> void
351
- def flash: (String uf2_path, ?mount: String?, ?port: String?) -> Result
379
+ def flash: (String uf2_path, ?mount: String?, ?port: String?, ?wait_for_port: bool) -> Result
352
380
  def find_mount: (?String? explicit_mount) -> String
381
+ def find_mounted: (?String? explicit_mount) -> String?
382
+ def wait_for_mount: (?mount: String?) -> String
353
383
  end
354
384
 
355
385
  class DfuCommand
@@ -401,4 +431,36 @@ module Rpremote
401
431
  ?flasher: untyped
402
432
  ) -> void
403
433
  end
434
+
435
+ class DeployCommand
436
+ def self.run: (
437
+ Array[String] args,
438
+ defaults: Hash[Symbol, untyped],
439
+ ?output: IO,
440
+ ?error: IO,
441
+ ?services: Hash[Symbol, untyped]
442
+ ) -> void
443
+ end
444
+
445
+ class BootselCommand
446
+ RESET_FLASH_FIRMWARE: String
447
+
448
+ class Error < Rpremote::Error
449
+ end
450
+
451
+ def self.run: (
452
+ Array[String] args,
453
+ defaults: Hash[Symbol, untyped],
454
+ ?output: IO,
455
+ ?services: Hash[Symbol, untyped]
456
+ ) -> void
457
+ def self.enter: (
458
+ mount: String?,
459
+ port: String?,
460
+ baud: Integer,
461
+ timeout: Numeric,
462
+ output: IO,
463
+ ?services: Hash[Symbol, untyped]
464
+ ) -> String
465
+ end
404
466
  end
@@ -32,9 +32,7 @@ output_dir = File.join(REPOSITORY_ROOT, "build", build_name)
32
32
  mruby_build_dir = File.join(picoruby_root, "build", config_name)
33
33
  cmake_source_dir = File.join(r2p2_gem_dir, "cmake")
34
34
 
35
- unless File.file?(File.join(picoruby_root, "Rakefile"))
36
- abort "PicoRuby source not found: #{picoruby_root}\nSet PICORUBY_DIR to a PicoRuby checkout."
37
- end
35
+ abort "PicoRuby source not found: #{picoruby_root}\nSet PICORUBY_DIR to a PicoRuby checkout." unless File.file?(File.join(picoruby_root, "Rakefile"))
38
36
  abort "Build config not found: #{base_config_path}" unless File.file?(base_config_path)
39
37
  abort "Generated build config not found: #{config_path}" unless File.file?(config_path)
40
38
  build_config = File.read(base_config_path)
@@ -60,11 +58,7 @@ build_env = {
60
58
  "PICO_EXTRAS_PATH" => pico_extras_path
61
59
  }
62
60
 
63
- # PicoRuby's build directory is keyed by the target name, not by MRUBY_CONFIG.
64
- # A generated overlay therefore shares the base target's objects. In particular,
65
- # mrblib.c includes picogem_init.c, but Make does not track that generated include
66
- # as a dependency. Reusing the directory can leave a removed or added local
67
- # mrbgem out of libmruby.a. Custom mrbgems must start from a fresh target build.
61
+ # PicoRuby keys build output by target, so an overlay can reuse stale objects; fresh builds keep changed local mrbgems in libmruby.a.
68
62
  if fingerprint && File.directory?(mruby_build_dir)
69
63
  puts "Removing stale PicoRuby build output: #{mruby_build_dir}"
70
64
  FileUtils.rm_rf(mruby_build_dir)
@@ -34,14 +34,10 @@ module Rpremote
34
34
  package = Gem::Package.new(gem_file)
35
35
  specification = package.spec
36
36
  missing_files = EXPECTED_FILES - package.contents
37
- changelog_entry = "## [#{Rpremote::VERSION}]"
37
+ changelog_entry = /^## #{Regexp.escape(Rpremote::VERSION)} - \d{4}-\d{2}-\d{2}$/
38
38
 
39
- unless specification.version.to_s == Rpremote::VERSION
40
- abort "built gem version does not match #{Rpremote::VERSION}"
41
- end
42
- unless File.read("CHANGELOG.md").include?(changelog_entry)
43
- abort "CHANGELOG.md has no entry for #{Rpremote::VERSION}"
44
- end
39
+ abort "built gem version does not match #{Rpremote::VERSION}" unless specification.version.to_s == Rpremote::VERSION
40
+ abort "CHANGELOG.md has no entry for #{Rpremote::VERSION}" unless File.read("CHANGELOG.md").match?(changelog_entry)
45
41
  abort "built gem is missing: #{missing_files.join(", ")}" unless missing_files.empty?
46
42
  abort "built gem does not require MFA" unless specification.metadata["rubygems_mfa_required"] == "true"
47
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rpremote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ogom
@@ -26,11 +26,14 @@ files:
26
26
  - THIRD_PARTY_NOTICES.md
27
27
  - exe/rpremote
28
28
  - lib/rpremote.rb
29
+ - lib/rpremote/bootsel_command.rb
29
30
  - lib/rpremote/build_command.rb
30
31
  - lib/rpremote/builder.rb
31
32
  - lib/rpremote/checksum.rb
32
33
  - lib/rpremote/cli.rb
33
34
  - lib/rpremote/config.rb
35
+ - lib/rpremote/config_show.rb
36
+ - lib/rpremote/deploy_command.rb
34
37
  - lib/rpremote/device.rb
35
38
  - lib/rpremote/dfu_command.rb
36
39
  - lib/rpremote/dfu_compiler.rb
@@ -41,7 +44,10 @@ files:
41
44
  - lib/rpremote/language_source.rb
42
45
  - lib/rpremote/mrbgems.rb
43
46
  - lib/rpremote/mrbgems_command.rb
47
+ - lib/rpremote/nuke_firmware.rb
44
48
  - lib/rpremote/picomodem.rb
49
+ - lib/rpremote/picoruby_source_patch.rb
50
+ - lib/rpremote/recursive_copy.rb
45
51
  - lib/rpremote/remote_path.rb
46
52
  - lib/rpremote/resetter.rb
47
53
  - lib/rpremote/runner.rb
@@ -51,6 +57,10 @@ files:
51
57
  - lib/rpremote/target.rb
52
58
  - lib/rpremote/terminal.rb
53
59
  - lib/rpremote/version.rb
60
+ - patches/picoruby-3.4.5-bootsel.patch
61
+ - patches/picoruby-3.4.5-ruby-exception-status.patch
62
+ - patches/picoruby-4.0.3-bootsel.patch
63
+ - patches/picoruby-4.0.3-ruby-exception-status.patch
54
64
  - sig/rpremote.rbs
55
65
  - tasks/firmware_build.rb
56
66
  - tasks/release.rake