svi 0.2.9 → 0.3.10
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.
- checksums.yaml +8 -8
- data/bin/svi +85 -0
- data/lib/svi/cmd/app.rb +57 -0
- data/lib/svi/cmd/dfu.rb +54 -0
- data/lib/svi/cmd/leds.rb +10 -0
- data/lib/svi/cmd/list.rb +14 -0
- data/lib/svi/cmd/lun.rb +20 -0
- data/lib/svi/cmd/random.rb +9 -0
- data/lib/svi/cmd/sys.rb +12 -0
- data/lib/svi/cmd/usb.rb +12 -0
- data/lib/svi/sbiif.rb +57 -0
- data/lib/svi/sviif.rb +57 -0
- data/lib/svi/version.rb +1 -0
- data/lib/svi/vidpid.rb +60 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDRlYzA0ZTM0NTE1ZmU2OTZjODIzMzkwZTVmM2RiNGU3MWUxMzg1Ng==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWJiNDJiY2QwNDkwNDVmNDg1N2ExOTVhZmQ5MzEyNmI1MzQ5M2JkZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjY0YmU3OGM0NTM2ZGJhMzNkMWZiMDg5NDAxZDI2ZWJiNzkyMGQ4MjRiYWVl
|
10
|
+
MTE4YTZhZGY0ODdiMzFjN2QyODYxNTk1NzIwMzA2OGVkOTA0NGFjYWNiNGI3
|
11
|
+
OTFjMGQxNzY2ODVlMWY2Y2I0MzdhNzVlMDdkNTVmNWM0YTU4N2U=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2NiMDkzOTA3NzE0NDdmNzgxODc1ZmNjMzYyOTkyMGQ5MjRhOTllZmMyYzY2
|
14
|
+
OTE4MTRmMWE3ODcwOGViYzJmMTZkNWM4ZmQ1N2E5NjgyODMwNGM5ODM4YTll
|
15
|
+
ZmZlZDY3ZDBjNzdlMDA2ZDQ5YmJhMDdlZDE0YjdjODZmM2NkMWE=
|
data/bin/svi
CHANGED
@@ -1,4 +1,89 @@
|
|
1
1
|
#!/usr/bin/ruby19
|
2
2
|
|
3
|
+
require 'gli'
|
4
|
+
require 'colorize'
|
5
|
+
require 'svi/version'
|
6
|
+
require 'svi/vidpid'
|
7
|
+
require 'svi/sviif'
|
8
|
+
require 'svi/sbiif'
|
9
|
+
require 'svi/svi'
|
10
|
+
|
11
|
+
include GLI::App
|
12
|
+
|
13
|
+
program_desc 'SVI interface tool set'
|
14
|
+
|
15
|
+
accept(VidPid) do |str|
|
16
|
+
VidPid.new(str)
|
17
|
+
end
|
18
|
+
|
19
|
+
accept(SVIIf) do |str|
|
20
|
+
SVIIf.new(str)
|
21
|
+
end
|
22
|
+
|
23
|
+
accept(SBIIf) do |str|
|
24
|
+
SBIIf.new(str)
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Use appropriate VID/PID'
|
28
|
+
arg_name 'vid:pid'
|
29
|
+
default_value VidPid.new '3241:9372'
|
30
|
+
flag [:D, 'device'], :type => VidPid
|
31
|
+
|
32
|
+
desc 'Use device number N (see device list by --list option)'
|
33
|
+
arg_name 'N'
|
34
|
+
default_value 0
|
35
|
+
flag [:N,'device-number'], :type => Integer
|
36
|
+
|
37
|
+
desc 'Timeout for transfers on both interfaces'
|
38
|
+
arg_name 'milliseconds'
|
39
|
+
default_value 3000
|
40
|
+
flag [:T,'timeout'], :type => Integer
|
41
|
+
|
42
|
+
desc 'Define interface for SVI'
|
43
|
+
arg_name 'ifnum:epout:epin'
|
44
|
+
default_value SVIIf.new '2:4:4'
|
45
|
+
flag ['svi-if'], :type => SVIIf
|
46
|
+
|
47
|
+
desc 'Define interface for SBI'
|
48
|
+
arg_name 'ifnum:epout:epin'
|
49
|
+
default_value SBIIf.new '3:3:3'
|
50
|
+
flag ['sbi-if'], :type => SBIIf
|
51
|
+
|
52
|
+
desc 'Show devices list only'
|
53
|
+
switch ['l', 'list'], :negatable => false
|
54
|
+
|
55
|
+
desc 'Show version'
|
56
|
+
switch ['verbose'], :negatable => false
|
57
|
+
|
58
|
+
desc 'Rescue mode of device'
|
59
|
+
default_value false
|
60
|
+
switch ['r', 'rescue'], :negatable => false
|
61
|
+
|
62
|
+
pre do |global_opts, cmd, opts, args|
|
63
|
+
$dev = USB.new(global_opts[:device].vid, global_opts[:device].pid).svi_devices[global_opts[:N]]
|
64
|
+
|
65
|
+
if $dev
|
66
|
+
$dev.svi_if = global_opts['svi-if'].ifnum
|
67
|
+
$dev.svi_if_ep_in = global_opts['svi-if'].epin
|
68
|
+
$dev.svi_if_ep_out = global_opts['svi-if'].epout
|
69
|
+
$dev.svi_timeout = global_opts[:timeout]
|
70
|
+
end
|
71
|
+
|
72
|
+
exit_now! 'No devices detected' unless $dev
|
73
|
+
|
74
|
+
true
|
75
|
+
end
|
76
|
+
|
77
|
+
require 'svi/cmd/list'
|
78
|
+
require 'svi/cmd/leds'
|
79
|
+
require 'svi/cmd/app'
|
80
|
+
require 'svi/cmd/lun'
|
81
|
+
require 'svi/cmd/random'
|
82
|
+
require 'svi/cmd/usb'
|
83
|
+
require 'svi/cmd/sys'
|
84
|
+
require 'svi/cmd/dfu'
|
85
|
+
|
86
|
+
exit run(ARGV)
|
87
|
+
|
3
88
|
# vim: sw=2 sts=2 ts=8:
|
4
89
|
|
data/lib/svi/cmd/app.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
desc 'app control'
|
2
|
+
command :app do |c|
|
3
|
+
c.desc 'Start app task'
|
4
|
+
c.command :start do |start|
|
5
|
+
start.action do
|
6
|
+
$dev.app_start
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
c.desc 'Stop app task'
|
11
|
+
c.command :stop do |stop|
|
12
|
+
stop.action do
|
13
|
+
$dev.app_stop
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
c.desc 'Test is app task exist in device'
|
18
|
+
c.command :exist do |exist|
|
19
|
+
exist.action do
|
20
|
+
puts $dev.app_exist[0] == 1 ? 'Application exist' : 'Application is not exist'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
c.desc 'Get app size'
|
25
|
+
c.command [:size, :length] do |size|
|
26
|
+
size.action do
|
27
|
+
puts "App size = #{$dev.app_length[0]}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
c.desc 'Get app state'
|
32
|
+
c.command :state do |state|
|
33
|
+
state.action do
|
34
|
+
state = [
|
35
|
+
'UNINIT',
|
36
|
+
'LOADED',
|
37
|
+
'RUN',
|
38
|
+
'SLEEP',
|
39
|
+
'INT_RUN',
|
40
|
+
'INT_SLEEP',
|
41
|
+
'HALTED'
|
42
|
+
]
|
43
|
+
|
44
|
+
puts "App state = #{state[$dev.app_state[0]]}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
c.desc 'Get app checksum'
|
49
|
+
c.command :crc do |crc|
|
50
|
+
crc.action do
|
51
|
+
puts "App checksum = #{$dev.app_checksum[0].to_s(16)}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# vim: sw=2 sts=2 ts=8:
|
57
|
+
|
data/lib/svi/cmd/dfu.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
desc 'Device firmwares update'
|
2
|
+
command :dfu do |c|
|
3
|
+
c.desc 'Update kernel'
|
4
|
+
arg_name 'firmware.bin'
|
5
|
+
c.command :kernel do |kernel|
|
6
|
+
kernel.action do |global_opts, opts, args|
|
7
|
+
exit_now! 'Invalid arguments' if args.count != 1
|
8
|
+
|
9
|
+
filepath = args[0]
|
10
|
+
|
11
|
+
res = $dev.nvm_load_file 1, 0, filepath
|
12
|
+
|
13
|
+
exit_now! "Can't load firmware into buffer" if res != [0]
|
14
|
+
|
15
|
+
res = $dev.nvm_verify_file 1, 0, filepath
|
16
|
+
|
17
|
+
exit_now! "Can't verify firmware into buffer" if res != [0]
|
18
|
+
|
19
|
+
addr = 0x10000
|
20
|
+
#addr = 0x20000 if options.target == :app
|
21
|
+
|
22
|
+
res = $dev.firmware_program addr, Pathname.new(filepath).size()/512+1, !global_opts[:rescue]
|
23
|
+
|
24
|
+
puts res[0] == 0 ? 'OK'.light_green : 'Fail'.light_red
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
c.desc 'Update app'
|
29
|
+
arg_name 'firmware.bin'
|
30
|
+
c.command :app do |app|
|
31
|
+
app.action do |global_opts, opts, args|
|
32
|
+
exit_now! 'Invalid arguments' if args.count != 1
|
33
|
+
|
34
|
+
filepath = args[0]
|
35
|
+
|
36
|
+
res = $dev.nvm_load_file 1, 0, filepath
|
37
|
+
|
38
|
+
exit_now! "Can't load firmware into buffer" if res != [0]
|
39
|
+
|
40
|
+
res = $dev.nvm_verify_file 1, 0, filepath
|
41
|
+
|
42
|
+
exit_now! "Can't verify firmware into buffer" if res != [0]
|
43
|
+
|
44
|
+
addr = 0x20000
|
45
|
+
|
46
|
+
res = $dev.firmware_program addr, Pathname.new(filepath).size()/512+1, !global_opts[:rescue]
|
47
|
+
|
48
|
+
puts res[0] == 0 ? 'OK'.light_green : 'Fail'.light_red
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# vim: sw=2 sts=2 ts=8:
|
54
|
+
|
data/lib/svi/cmd/leds.rb
ADDED
data/lib/svi/cmd/list.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
desc 'list detected devices'
|
2
|
+
command :list do |c|
|
3
|
+
c.action do |opts|
|
4
|
+
devs = USB.new(opts[:device].vid, opts[:device].pid).svi_devices
|
5
|
+
|
6
|
+
if devs.empty?
|
7
|
+
puts 'No devices detected'
|
8
|
+
else
|
9
|
+
devs.each_with_index { |dev, i|
|
10
|
+
puts "##{i} #{dev.manufacturer} #{dev.product}"
|
11
|
+
}
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/svi/cmd/lun.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
desc 'LUN control'
|
2
|
+
command :lun do |c|
|
3
|
+
c.desc 'Get eMMC capacity (in 512 blocks)'
|
4
|
+
c.command :seccount do |seccount|
|
5
|
+
seccount.action do
|
6
|
+
capacity = $dev.lun_get_seccount[0]
|
7
|
+
puts "eMMC capacity = #{capacity} blocks (#{capacity/2/1024/1024.0} GiB)"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
c.desc 'Get count of active luns'
|
12
|
+
c.command :count do |count|
|
13
|
+
count.action do
|
14
|
+
puts "Count of active LUNs = #{$dev.lun_get_count[0]}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# vim: sw=2 sts=2 ts=8:
|
20
|
+
|
data/lib/svi/cmd/sys.rb
ADDED
data/lib/svi/cmd/usb.rb
ADDED
data/lib/svi/sbiif.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
class SBIIf
|
2
|
+
@ifnum
|
3
|
+
@epin
|
4
|
+
@epout
|
5
|
+
|
6
|
+
def initialize *args
|
7
|
+
raise ArgumentError, 'function shall accept 0, 1 or 3 arguments' unless [0, 1, 3].include? args.count
|
8
|
+
|
9
|
+
@ifnum, @epin, @epout = 0, 0, 0
|
10
|
+
|
11
|
+
if args.count == 1
|
12
|
+
_args = args[0].to_s.split ':'
|
13
|
+
|
14
|
+
raise ArgumentError, "Invalid string format of vid:pid - #{args[0].to_s}" if _args.count != 3
|
15
|
+
|
16
|
+
args = _args
|
17
|
+
end
|
18
|
+
|
19
|
+
if args.count == 3
|
20
|
+
self.ifnum = args[0]
|
21
|
+
self.epin = args[1]
|
22
|
+
self.epout = args[2]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def ifnum
|
27
|
+
@ifnum
|
28
|
+
end
|
29
|
+
|
30
|
+
def epin
|
31
|
+
@epin
|
32
|
+
end
|
33
|
+
|
34
|
+
def epout
|
35
|
+
@epout
|
36
|
+
end
|
37
|
+
|
38
|
+
def ifnum= (n)
|
39
|
+
@ifnum = n.to_i
|
40
|
+
end
|
41
|
+
|
42
|
+
def epin= (n)
|
43
|
+
raise ArgumentError, 'Invalid endpoint number' if n.to_i > 0xFF || n.to_i&0x7F > 16
|
44
|
+
|
45
|
+
@epin = n.to_i&0x7F
|
46
|
+
end
|
47
|
+
|
48
|
+
def epout= (n)
|
49
|
+
raise ArgumentError, 'Invalid endpoint number' if n.to_i > 0xFF || n.to_i&0x7F > 16
|
50
|
+
|
51
|
+
@epout = n.to_i&0x7F
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
"#{@ifnum.to_s}:#{@epin.to_s}:#{@epout.to_s}"
|
56
|
+
end
|
57
|
+
end
|
data/lib/svi/sviif.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
class SVIIf
|
2
|
+
@ifnum
|
3
|
+
@epin
|
4
|
+
@epout
|
5
|
+
|
6
|
+
def initialize *args
|
7
|
+
raise ArgumentError, 'function shall accept 0, 1 or 3 arguments' unless [0, 1, 3].include? args.count
|
8
|
+
|
9
|
+
@ifnum, @epin, @epout = 0, 0, 0
|
10
|
+
|
11
|
+
if args.count == 1
|
12
|
+
_args = args[0].to_s.split ':'
|
13
|
+
|
14
|
+
raise ArgumentError, "Invalid string format of vid:pid - #{args[0].to_s}" if _args.count != 3
|
15
|
+
|
16
|
+
args = _args
|
17
|
+
end
|
18
|
+
|
19
|
+
if args.count == 3
|
20
|
+
self.ifnum = args[0]
|
21
|
+
self.epin = args[1]
|
22
|
+
self.epout = args[2]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def ifnum
|
27
|
+
@ifnum
|
28
|
+
end
|
29
|
+
|
30
|
+
def epin
|
31
|
+
@epin
|
32
|
+
end
|
33
|
+
|
34
|
+
def epout
|
35
|
+
@epout
|
36
|
+
end
|
37
|
+
|
38
|
+
def ifnum= (n)
|
39
|
+
@ifnum = n.to_i
|
40
|
+
end
|
41
|
+
|
42
|
+
def epin= (n)
|
43
|
+
raise ArgumentError, 'Invalid endpoint number' if n.to_i > 0xFF || n.to_i&0x7F > 16
|
44
|
+
|
45
|
+
@epin = n.to_i&0x7F
|
46
|
+
end
|
47
|
+
|
48
|
+
def epout= (n)
|
49
|
+
raise ArgumentError, 'Invalid endpoint number' if n.to_i > 0xFF || n.to_i&0x7F > 16
|
50
|
+
|
51
|
+
@epout = n.to_i&0x7F
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_s
|
55
|
+
"#{@ifnum.to_s}:#{@epin.to_s}:#{@epout.to_s}"
|
56
|
+
end
|
57
|
+
end
|
data/lib/svi/version.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
VERSION='0.3.10'
|
data/lib/svi/vidpid.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
class VidPid
|
2
|
+
@vid
|
3
|
+
@pid
|
4
|
+
|
5
|
+
def initialize *args
|
6
|
+
raise ArgumentError, 'function shall accept 2 arguments max' if args.count > 2
|
7
|
+
|
8
|
+
@vid, @pid = 0, 0
|
9
|
+
|
10
|
+
if args.count == 1
|
11
|
+
_args = args[0].to_s.split ':'
|
12
|
+
|
13
|
+
raise ArgumentError, "Invalid string format of vid:pid - #{args[0].to_s}" if _args.count != 2
|
14
|
+
|
15
|
+
args = _args
|
16
|
+
end
|
17
|
+
|
18
|
+
if args.count == 2
|
19
|
+
self.vid = args[0]
|
20
|
+
self.pid = args[1]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def vid
|
25
|
+
@vid
|
26
|
+
end
|
27
|
+
|
28
|
+
def pid
|
29
|
+
@pid
|
30
|
+
end
|
31
|
+
|
32
|
+
def vid= (vendor)
|
33
|
+
if String === vendor
|
34
|
+
i = vendor.to_i 16
|
35
|
+
else
|
36
|
+
i = vendor.to_i
|
37
|
+
end
|
38
|
+
|
39
|
+
raise ArgumentError, "Invalid vendor #{vendor}" if i < 0 || i > 65535
|
40
|
+
|
41
|
+
@vid = i
|
42
|
+
end
|
43
|
+
|
44
|
+
def pid= (product)
|
45
|
+
if String === product
|
46
|
+
i = product.to_i 16
|
47
|
+
else
|
48
|
+
i = product.to_i
|
49
|
+
end
|
50
|
+
|
51
|
+
raise ArgumentError, "Invalid product #{product}" if i < 0 || i > 65535
|
52
|
+
|
53
|
+
@pid = i
|
54
|
+
end
|
55
|
+
|
56
|
+
def to_s
|
57
|
+
"#{@vid.to_s(16)}:#{@pid.to_s(16)}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: svi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Levenkov Artem
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: libusb
|
@@ -70,7 +70,19 @@ files:
|
|
70
70
|
- bin/usb_reconnect
|
71
71
|
- lib/svi/api.generated.rb
|
72
72
|
- lib/svi/api.rb
|
73
|
+
- lib/svi/cmd/app.rb
|
74
|
+
- lib/svi/cmd/dfu.rb
|
75
|
+
- lib/svi/cmd/leds.rb
|
76
|
+
- lib/svi/cmd/list.rb
|
77
|
+
- lib/svi/cmd/lun.rb
|
78
|
+
- lib/svi/cmd/random.rb
|
79
|
+
- lib/svi/cmd/sys.rb
|
80
|
+
- lib/svi/cmd/usb.rb
|
81
|
+
- lib/svi/sbiif.rb
|
73
82
|
- lib/svi/svi.rb
|
83
|
+
- lib/svi/sviif.rb
|
84
|
+
- lib/svi/version.rb
|
85
|
+
- lib/svi/vidpid.rb
|
74
86
|
homepage: http://www.mcs51.ru/svi-utils
|
75
87
|
licenses:
|
76
88
|
- MIT
|