summaryrefslogtreecommitdiffstats
path: root/upgrade
diff options
context:
space:
mode:
authorBluebie <a@creativepony.com>2013-12-16 13:22:57 +1100
committerBluebie <a@creativepony.com>2013-12-16 13:22:57 +1100
commitbe17f02352ca73af8325828b6e0e242b5d764fdc (patch)
tree22c4a1c79b314c1376a009a20ae78a3cb531c80a /upgrade
parent22506b5f1b1582e99c3b9c50cdb4493e0e20d1dd (diff)
downloadmicronucleus-be17f02352ca73af8325828b6e0e242b5d764fdc.tar.gz
micronucleus-be17f02352ca73af8325828b6e0e242b5d764fdc.tar.bz2
micronucleus-be17f02352ca73af8325828b6e0e242b5d764fdc.zip
upgrade: hacked to work with new preinitialized firmwares
Diffstat (limited to 'upgrade')
-rw-r--r--upgrade/generate-data.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/upgrade/generate-data.rb b/upgrade/generate-data.rb
index c54f679..875870c 100644
--- a/upgrade/generate-data.rb
+++ b/upgrade/generate-data.rb
@@ -7,9 +7,12 @@ puts data.instance_variable_get(:@bytes).inspect
data = data.bytes
# find start address
-start_address = 0
+start_address = 16 # skip past baked in trampoline - upgrade firmware generates one anyway!
+# TODO: Verify jump table? or store it in the upgrade firmware for verbatim installation?
start_address += 1 while data[start_address] == 0xFF
+raise "Seems to be junk data quite early in the bootloader" unless start_address > 100
+
# trim blank padding data from start of data
start_address.times { data.shift }
@@ -20,11 +23,13 @@ puts "Length: #{data.length}"
puts "Start address: #{start_address}"
File.open "bootloader_data.c", "w" do |file|
- file.puts "// This file contains the bootloader data itself and the address to install the bootloader at"
- file.puts "// Use generate-data.rb with ruby 1.9 to generate these values from a hex file"
- file.puts "// Generated from #{ARGV.first} at #{Time.now}"
+ file.puts "// This file contains the bootloader data itself and the address to"
+ file.puts "// install the bootloader"
+ file.puts "// Use generate-data.rb with ruby 1.9 or 2.0 to generate these"
+ file.puts "// values from a hex file"
+ file.puts "// Generated from #{ARGV.first} at #{Time.now} by #{ENV['USER']}"
file.puts ""
- file.puts "uint16_t bootloader_data[#{data.length / 2}] PROGMEM = {"
+ file.puts "const uint16_t bootloader_data[#{data.length / 2}] PROGMEM = {"
file.puts data.each_slice(2).map { |big_end, little_end|
"0x#{ ((little_end * 256) + big_end).to_s(16).rjust(4, '0') }"
}.join(', ')