msp430_bsl 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04be185fd24cfefaaf6f4d2ca3c0aa5fc919b912aebd0db25e0ac71a4308d10e
4
- data.tar.gz: 228d4f5fe568b5d22e1072d169f8e5292803639b994a407872ed05ef93ad8ee5
3
+ metadata.gz: 6f8dd8c87262211f1ebb94d9399262f04b57d713d02e78c5b0409ef21d01fe55
4
+ data.tar.gz: 58a14360aa3a75747cb57a1c74f73ce9ac2509169e1ccb661328632a720316be
5
5
  SHA512:
6
- metadata.gz: f3597deabec5b77da55ae9d5d89f577c09d351fe4bf376178927c3b8d90f957d3e64e6b8d8a0430a6249c1fb0cc27d9ff0c62d1d3620ee34c4c09aa57d3f8060
7
- data.tar.gz: 88c10187a3049aa22a9a3083341399b683d5ad0475e4bbb6d292430f2fdf7ead9b5e723f359442e4706f31d828912a4ae8d5d1f105c19d09e5b5ee38cfb034cf
6
+ metadata.gz: 634b16289e8c5ba1d14c207e0f57f4a51e057a87081d3a699e18e145c09d23432a09c55317e7e19d5eb26d97dcb51eb3f87d156aa6834e1d0b322e58ab244a75
7
+ data.tar.gz: 42ee1e8a9b67ea7a316f429a4ba70784f58b1513548fb1e29ba0da476c3dd67d271701480da31e9177af6920ac72b291230665a01243ffe3a413d934fbb264ae
data/bin/upload_hex CHANGED
@@ -10,7 +10,6 @@ STDOUT.sync = true
10
10
 
11
11
  include Msp430Bsl::Utils
12
12
 
13
- HIGH_SPEED_UART_BAUD = 115200.freeze
14
13
  MAX_WRITE_ATTEMPTS = 3
15
14
 
16
15
  @opts = {}
@@ -19,9 +18,10 @@ begin
19
18
  o.string '-d', '--device', 'Mandatory: Path to serial programmer device', required: true
20
19
  o.string '-f', '--hexfile', 'Mandatory: Path to HEX file to load', required: true
21
20
  o.string '-g', '--logfile', 'Path to logfile'
22
- o.string '-l', '--loglevel', "Logger level. One of ['fatal', 'error', 'warn', 'info', 'debug']. Defaults to 'debug'", default: :debug
23
- o.bool '-e', '--erase_info', 'Erase info memory', default: false # TODO: implement
24
- o.bool '-c', '--check', 'Verify flash content after each data block write', default: true
21
+ o.string '-l', '--loglevel', "Logger level. One of ['fatal', 'error', 'warn', 'info', 'debug']. Default: 'debug'", default: :debug
22
+ o.integer '-b', '--baud', 'BAUD rate with which communicate to BSL. Default: 115200', default: 115200
23
+ o.bool '-e', '--erase_info', 'Erase info memory. Default: false', default: false # TODO: implement
24
+ o.bool '-c', '--check', 'Verify flash content after each data block write. Default: true', default: true
25
25
  o.bool '-h', '--help', 'Print this help' do
26
26
  puts "#{o}\n"
27
27
  exit
@@ -37,6 +37,7 @@ end
37
37
 
38
38
  logger = build_logger_from @opts
39
39
 
40
+ # Build UART Connection
40
41
  @board = Msp430Bsl::Uart::Connection.new @opts[:device], logger: logger
41
42
 
42
43
  # Enter BSL
@@ -48,9 +49,9 @@ logger.info 'Mass erasing FLASH'
48
49
  logger.info "Unlocking BSL's password protected commands"
49
50
  @board.send_command :rx_password, data: Msp430Bsl::Configs::CMD_RX_PASSWORD
50
51
  # Switch UART to max speed
51
- logger.info 'Changing UART BAUD to 115200'
52
- @board.send_command :change_baud_rate, data: Msp430Bsl::Configs::BAUD_RATES[HIGH_SPEED_UART_BAUD]
53
- @board.set_uart_speed HIGH_SPEED_UART_BAUD
52
+ logger.info "Changing UART BAUD to #{@opts[:baud]}"
53
+ @board.send_command :change_baud_rate, data: Msp430Bsl::Configs::BAUD_RATES[@opts[:baud]]
54
+ @board.set_uart_speed @opts[:baud]
54
55
 
55
56
  # If everything has gone well so far...
56
57
  hexfile = Msp430Bsl::HexFile.new @opts[:hexfile]
@@ -98,7 +99,7 @@ line_groups.each do |group|
98
99
  if curr_data_packet.empty?
99
100
  # Use current line's addr as packet addr
100
101
  curr_data_packet << line
101
- curr_data_size += 2 + line.data_length # 2 is the addr size (2 bytes)
102
+ curr_data_size += line.data_length + Msp430Bsl::Uart::PeripheralInterface::TOTAL_SIZE
102
103
  elsif (curr_data_size + line.data_length) <= Msp430Bsl::Uart::Connection::CORE_COMMANDS_BUFFER_SIZE
103
104
  # If there's still room, append the line data
104
105
  curr_data_packet << line
@@ -122,3 +123,4 @@ end
122
123
 
123
124
  logger.info 'Closing connection'
124
125
  @board.close_connection
126
+ logger.info 'Upload done!'
@@ -13,7 +13,11 @@ module Msp430Bsl
13
13
  end
14
14
  class MessageNotSupported < StandardError
15
15
  def initialize(value)
16
- message = "message with value 0x#{value.to_hex_str} not supported"
16
+ message = if value
17
+ "message with value 0x#{value.to_hex_str} not supported"
18
+ else
19
+ "message without a value"
20
+ end
17
21
  super(message)
18
22
  end
19
23
  end
@@ -11,6 +11,7 @@ module Msp430Bsl
11
11
  HEADER_SIZE = 1.freeze
12
12
  DATA_LEN_SIZE = 2.freeze
13
13
  CRC_SIZE = 2.freeze
14
+ TOTAL_SIZE = (HEADER_SIZE + DATA_LEN_SIZE + CRC_SIZE).freeze
14
15
 
15
16
  class << self
16
17
  include Utils
@@ -1,3 +1,3 @@
1
1
  module Msp430Bsl
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msp430_bsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Verlato
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-30 00:00:00.000000000 Z
11
+ date: 2023-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
- rubygems_version: 3.4.6
115
+ rubygems_version: 3.4.20
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Texas Instrument MSP430 BSL Ruby library