msp430_bsl 0.1.2 → 0.3.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: 4348c30b38b554c1acc4ae87bf794d41b5b0e093187b0d943a549524bbdb524e
4
- data.tar.gz: ed9d5f99c55f4f773d30aada91db6e581a4b2a2659b68cf478da4c3c348f4aed
3
+ metadata.gz: 35aba075d912b2875eecabcebfc4325f54af1cd3085d23249e9e54949797fe89
4
+ data.tar.gz: 18e8e770e7259aac7c1585f38f94adaeba67689589363ba12f8a143b5fd1b66b
5
5
  SHA512:
6
- metadata.gz: c6d2884fb6079fb1a5211803dfcb9793316a69556287ffd3ddec8d6c9f0fab2f4972484b1eb7bcd97bf9ebf3ce89e46ad113f640ddc8c717ddd8ac7ad0de2724
7
- data.tar.gz: 642e82aa7eb54c4b60b81f02e311b40e3891820e1b67e0ec51c120f4d99e10af9ae2714375aea899eac64e9bd0c668d09161e9716f768ae86f7075bce31d26a9
6
+ metadata.gz: 95a9fd34842399eb965857bb83284d82d4f3a8b72f8912459c92f3dd57402c2d4599f9671b95c7bb91ad82595bc1326151f8bcdda0787aab069eb1bbaf58051f
7
+ data.tar.gz: c24a4ba28dffbda9f6404c7bcbdfc2155cfe3a17c6f2c49d39a33c1c8fcdeb5e625c18f254d376e74e425b23d3c092c09bc912ffaecb4ff5ed16316371c599db
data/bin/upload_hex CHANGED
@@ -1,7 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/setup'
4
- Bundler.require
5
3
  require 'slop'
6
4
  require_relative '../lib/msp430_bsl'
7
5
 
@@ -10,7 +8,6 @@ STDOUT.sync = true
10
8
 
11
9
  include Msp430Bsl::Utils
12
10
 
13
- HIGH_SPEED_UART_BAUD = 115200.freeze
14
11
  MAX_WRITE_ATTEMPTS = 3
15
12
 
16
13
  @opts = {}
@@ -19,9 +16,10 @@ begin
19
16
  o.string '-d', '--device', 'Mandatory: Path to serial programmer device', required: true
20
17
  o.string '-f', '--hexfile', 'Mandatory: Path to HEX file to load', required: true
21
18
  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
19
+ o.string '-l', '--loglevel', "Logger level. One of ['fatal', 'error', 'warn', 'info', 'debug']. Default: 'debug'", default: :debug
20
+ o.integer '-b', '--baud', 'BAUD rate with which communicate to BSL. Default: 115200', default: 115200
21
+ o.bool '-e', '--erase_info', 'Erase info memory. Default: false', default: false # TODO: implement
22
+ o.bool '-c', '--check', 'Verify flash content after each data block write. Default: true', default: true
25
23
  o.bool '-h', '--help', 'Print this help' do
26
24
  puts "#{o}\n"
27
25
  exit
@@ -37,6 +35,12 @@ end
37
35
 
38
36
  logger = build_logger_from @opts
39
37
 
38
+ unless Msp430Bsl::Configs::BAUD_RATES.include? @opts[:baud]
39
+ logger.error "BAUD rate #{@opts[:baud]} not supported. Available BAUD rates: #{ Msp430Bsl::Configs::BAUD_RATES.join ', ' }"
40
+ exit
41
+ end
42
+
43
+ # Build UART Connection
40
44
  @board = Msp430Bsl::Uart::Connection.new @opts[:device], logger: logger
41
45
 
42
46
  # Enter BSL
@@ -48,9 +52,9 @@ logger.info 'Mass erasing FLASH'
48
52
  logger.info "Unlocking BSL's password protected commands"
49
53
  @board.send_command :rx_password, data: Msp430Bsl::Configs::CMD_RX_PASSWORD
50
54
  # 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
55
+ logger.info "Changing UART BAUD to #{@opts[:baud]}"
56
+ @board.send_command :change_baud_rate, data: Msp430Bsl::Configs::BAUD_RATES[@opts[:baud]]
57
+ @board.set_uart_speed @opts[:baud]
54
58
 
55
59
  # If everything has gone well so far...
56
60
  hexfile = Msp430Bsl::HexFile.new @opts[:hexfile]
@@ -122,3 +126,4 @@ end
122
126
 
123
127
  logger.info 'Closing connection'
124
128
  @board.close_connection
129
+ logger.info 'Upload done!'
@@ -8,12 +8,12 @@ module Msp430Bsl
8
8
 
9
9
  UART_CONFIGS = { data_bits: 8, stop_bits: 1, parity: SerialPort::EVEN }.transform_keys(&:to_s).freeze
10
10
 
11
- WAIT_FOR_ACK_MAX = 100.millis
12
- WAIT_FOR_RESPONSE_MAX = 100.millis
11
+ WAIT_FOR_ACK_MAX = 1000.millis
12
+ WAIT_FOR_RESPONSE_MAX = 1000.millis
13
13
 
14
14
  MEM_START_MAIN_FLASH = 0x8000
15
15
 
16
- CORE_COMMANDS_BUFFER_SIZE = 260
16
+ CORE_COMMANDS_BUFFER_SIZE = 260
17
17
 
18
18
  attr_reader :serial_port, :device_path, :logger, :cmd_buff_size
19
19
 
@@ -23,6 +23,7 @@ module Msp430Bsl
23
23
  @cmd_buff_size = opts.fetch :cmd_buf_size, CORE_COMMANDS_BUFFER_SIZE
24
24
 
25
25
  @serial_port = SerialPort.new @device_path
26
+ @serial_port.flow_control = SerialPort::NONE
26
27
  end
27
28
 
28
29
  def close_connection
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Msp430Bsl
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.3.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.2
4
+ version: 0.3.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-08-17 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.3.7
115
+ rubygems_version: 3.4.20
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Texas Instrument MSP430 BSL Ruby library