avburn 0.0.1

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.
data/lib/avburn.rb ADDED
@@ -0,0 +1,119 @@
1
+
2
+ Avrdude = "avrdude"
3
+ AvrdudeConf = File.open("/etc/avrdude.conf").read
4
+ Avb = ENV["HOME"] + "/.avb"
5
+ AvbHex = Avb + ".hex"
6
+ Conf = {}
7
+ Fuses = [:hfuse, :lfuse, :efuse]
8
+
9
+ Memory = %w{ eeprom flash fuse efuse hfuse lfuse lock signature fuseN application apptable boot prodsig usersig }
10
+ Format = {
11
+ :a => "Auto detect",
12
+ :i => "Intel Hex",
13
+ :s => "Motorola S-record",
14
+ :r => "Raw binary",
15
+ # :m => "Immediate",
16
+ :d => "Decimal",
17
+ :h => "Hexadecimal",
18
+ :o => "Octal",
19
+ :b => "Binary" } #todo hash
20
+
21
+ FuseLabel = YAML.load(File.read(File.dirname(__FILE__) + "/avburn/fuses.yml"))
22
+ # :attinyx5 => {
23
+ # :hfuse => %w{RSTDISBL DWEN SPIEN WDTON EESAVE BOOTSZ0 BOOTSZ1 BOOTRST},
24
+ # :lfuse => %w{CKDIB8 CKOUT SUT1 SUT0 CKSEL0 CKSEL1 CKSEL2 CKSEL3}
25
+ # },
26
+ # :atmega328p => {
27
+ # :hfuse => %w{RSTDISBL DWEN SPIEN WDTON EESAVE BOOTSZ0 BOOTSZ1 BOOTRST},
28
+ # :lfuse => %w{CKDIB8 CKOUT SUT1 SUT0 CKSEL0 CKSEL1 CKSEL2 CKSEL3}
29
+ # },
30
+ # :atmega32 => {
31
+ # :hfuse => %w{OCDEN JTAGEN SPIEN CKOPT EESAVE BOOTSZ1 BOOTSZ0 BOOTRST},
32
+ # :lfuse => %w{BODLEVEL BODEN SUT1 SUT0 CKSEL0 CKSEL1 CKSEL2 CKSEL3}
33
+ # }
34
+
35
+
36
+ # }
37
+
38
+
39
+ module Avburn
40
+ def avr_bool(bit)
41
+ bit.to_i.zero?
42
+ end
43
+
44
+ def run_comm(c)
45
+ @log.text = ""
46
+ comm = "#{Avrdude} -c #{Conf[:prog]} -p #{Conf[:platform]} "
47
+ comm << "-P #{Conf[:port]} " if @port
48
+ comm << "-U #{c}"
49
+ log "> Running #{comm}"
50
+ Kernel.system "#{comm} &> output"
51
+ log File.read("output")
52
+ end
53
+
54
+ class << self
55
+
56
+ def read_conf
57
+ `touch #{Avb}` unless File.exists?(Avb)
58
+ Conf.merge! YAML.load(File.read(Avb)) || {}
59
+ end
60
+
61
+ def write_conf
62
+ File.open(Avb, 'w') { |f| f << Conf.to_yaml }
63
+ end
64
+
65
+ end
66
+
67
+
68
+ end
69
+
70
+ class Part
71
+ def self.all
72
+ @parts ||= AvrdudeConf.scan(/part\s*\n\s*id\s*=\s*"(\w*)"\s*;/).flatten
73
+ end
74
+
75
+ def self.find(p)
76
+ puts "search! #{p}"
77
+ end
78
+ end
79
+
80
+ class Hex
81
+
82
+ def self.all
83
+ `mkdir ~/.avb.hex` unless File.exists?(AvbHex)
84
+ Dir[AvbHex + "/*.hex"].map { |fp| fp.split("/")[-1] }
85
+ end
86
+ end
87
+
88
+
89
+ class Prog
90
+ def self.all
91
+ @progs ||= AvrdudeConf.scan(/programmer\n\s*id\s*=\s*"(\w*)"\s*;/).flatten
92
+ end
93
+ end
94
+
95
+ class FuseStore < Hash
96
+ attr_reader :hfuse, :lfuse, :efuse
97
+
98
+ def hfuse
99
+ [:hfuse]
100
+ end
101
+
102
+ def set(fuse, hex)
103
+ hex = "0#{hex}" if hex.size == 1
104
+ hex = hex[0,2]
105
+ self[fuse.to_sym] = Integer("0x#{hex}").to_s(2).rjust(8, "0").split(//)
106
+ self["#{fuse}hex"] = hex
107
+ end
108
+
109
+ def set_bit(fuse, bit, bool)
110
+ self[fuse][bit] = (bool ? "0" : "1")
111
+ hexval = self[fuse].join.to_i(2).to_s(16).upcase
112
+ hexval = "0#{hexval}" if hexval.size == 1
113
+ self["#{fuse}hex"] = hexval
114
+ hexval
115
+ end
116
+ end
117
+
118
+
119
+ Avburn.read_conf
@@ -0,0 +1,107 @@
1
+ :attinyx5:
2
+ :hfuse:
3
+ - RSTDISBL
4
+ - DWEN
5
+ - SPIEN
6
+ - WDTON
7
+ - EESAVE
8
+ - BOOTSZ0
9
+ - BOOTSZ1
10
+ - BOOTRST
11
+ :lfuse:
12
+ - CKDIB8
13
+ - CKOUT
14
+ - SUT1
15
+ - SUT0
16
+ - CKSEL0
17
+ - CKSEL1
18
+ - CKSEL2
19
+ - CKSEL3
20
+
21
+ :atmega8:
22
+ :hfuse:
23
+ - RSTDISBL
24
+ - WDTON
25
+ - SPIEN
26
+ - CKOPT
27
+ - EESAVE
28
+ - BOOTSZ1
29
+ - BOOTSZ0
30
+ - BOOTRST
31
+ :lfuse:
32
+ - BODLEVEL
33
+ - BODEN
34
+ - SUT1
35
+ - SUT0
36
+ - CKSEL0
37
+ - CKSEL1
38
+ - CKSEL2
39
+ - CKSEL3
40
+
41
+ :atmega88:
42
+ :hfuse:
43
+ - RSTDISBL
44
+ - DWEN
45
+ - SPIEN
46
+ - WDTON
47
+ - EESAVE
48
+ - BODLEVEL0
49
+ - BODLEVEL1
50
+ - BODLEVEL2
51
+ :lfuse:
52
+ - CKDIV8
53
+ - CKOUT
54
+ - SUT1
55
+ - SUT0
56
+ - CKSEL0
57
+ - CKSEL1
58
+ - CKSEL2
59
+ - CKSEL3
60
+ :efuse:
61
+ - BOOTSZ1
62
+ - BOOTSZ0
63
+ - BOOTRST
64
+
65
+ :m328p:
66
+ :hfuse: &328hfuse
67
+ - RSTDISBL
68
+ - DWEN
69
+ - SPIEN
70
+ - WDTON
71
+ - EESAVE
72
+ - BOOTSZ0
73
+ - BOOTSZ1
74
+ - BOOTRST
75
+ :lfuse: &328lfuse
76
+ - CKDIV8
77
+ - CKOUT
78
+ - SUT1
79
+ - SUT0
80
+ - CKSEL3
81
+ - CKSEL2
82
+ - CKSEL1
83
+ - CKSEL0
84
+ :efuse:
85
+ - BODLEVEL0
86
+ - BODLEVEL1
87
+ - BODLEVEL2
88
+
89
+ :m32:
90
+ :hfuse:
91
+ - OCDEN
92
+ - JTAGEN
93
+ - SPIEN
94
+ - CKOPT
95
+ - EESAVE
96
+ - BOOTSZ1
97
+ - BOOTSZ0
98
+ - BOOTRST
99
+ :lfuse:
100
+ - BODLEVEL
101
+ - BODEN
102
+ - SUT1
103
+ - SUT0
104
+ - CKSEL3
105
+ - CKSEL2
106
+ - CKSEL1
107
+ - CKSEL0
@@ -0,0 +1,17 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Avburn" do
4
+ it "should find programmers" do
5
+ Prog.all.should_not be_empty
6
+ end
7
+
8
+
9
+ describe "FuseStore" do
10
+
11
+ it "should behave like hash" do
12
+ fs = FuseStore.new
13
+ fs[:foo] = 2
14
+ fs[:foo].should eql(2)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'avburn'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: avburn
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Marcos Piccinini
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-12-30 00:00:00 -02:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 2
29
+ - 3
30
+ - 0
31
+ version: 2.3.0
32
+ type: :development
33
+ prerelease: false
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: bundler
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ segments:
43
+ - 1
44
+ - 0
45
+ - 0
46
+ version: 1.0.0
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: jeweler
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ segments:
58
+ - 1
59
+ - 5
60
+ - 2
61
+ version: 1.5.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: *id003
65
+ - !ruby/object:Gem::Dependency
66
+ name: rcov
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: *id004
78
+ description: Shoes based GUI for AVRDUDE, burn fuses, bootloaders
79
+ email: x@nofxx.com
80
+ executables:
81
+ - avburn
82
+ - flash
83
+ extensions: []
84
+
85
+ extra_rdoc_files:
86
+ - LICENSE.txt
87
+ - README.rdoc
88
+ files:
89
+ - .document
90
+ - .rspec
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - LICENSE.txt
94
+ - README.rdoc
95
+ - Rakefile
96
+ - VERSION
97
+ - bin/avburn
98
+ - bin/flash
99
+ - lib/avburn.rb
100
+ - lib/avburn/fuses.yml
101
+ - spec/avburn_spec.rb
102
+ - spec/spec_helper.rb
103
+ has_rdoc: true
104
+ homepage: http://github.com/nofxx/avburn
105
+ licenses:
106
+ - MIT
107
+ post_install_message:
108
+ rdoc_options: []
109
+
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: -1524349970638977619
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ requirements: []
130
+
131
+ rubyforge_project:
132
+ rubygems_version: 1.3.7
133
+ signing_key:
134
+ specification_version: 3
135
+ summary: Shoes based GUI for AVRDUDE
136
+ test_files:
137
+ - spec/avburn_spec.rb
138
+ - spec/spec_helper.rb