Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support uno wifi rev2 #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
## stk500
Fully javascript stk500v1 programmer. Allows you to program Arduinos straight from node (or browser for that matter -- see [browserdude](github.com/jacobrosenthal/browserdude). No more avrdude system calls or using the arduino IDE.
Fully javascript stk500v1 programmer.

## NOTE
Version 2.1.0 is a patched version to support Arduino Uno WiFi Rev2, which
requires a differents start address when uploading a sketch.
Updated by [Christian Sarnataro](c.sarnataro@arduino.cc) in the context of [IOT-1813](https://arduino.atlassian.net/browse/IOT-1813).

A proper PR against the origin repo is on our roadmap.


### Intro
Allows you to program Arduinos straight from node (or browser for that matter -- see [browserdude](github.com/jacobrosenthal/browserdude). No more avrdude system calls or using the arduino IDE.

Huge thanks to Pinoccio for their stk500v2 browser implementation (for Arduino Megas, etc) from which I stole whole lines of code. We're working to unify our programmers with some sort of overarching module. For now see [js-stk500](https://github.com/Pinoccio/js-stk500) to program Arduino Mega and Pinoccio's

Expand Down
33 changes: 28 additions & 5 deletions index.js → index.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var async = require("async");
var Statics = require('./lib/statics');
var sendCommand = require('./lib/sendCommand');
var Statics = require('./lib/statics.cjs');
var sendCommand = require('./lib/sendCommand.cjs');

var stk500 = function (opts) {
this.opts = opts || {};
Expand Down Expand Up @@ -185,9 +185,28 @@ stk500.prototype.loadPage = function (stream, writeBytes, timeout, done) {
});
};

stk500.prototype.upload = function (stream, hex, pageSize, timeout, done) {
stk500.prototype.upload = function () {
this.log("program");

var stream, hex, pageSize, timeout, dontShiftPageAddr, done;
// to make it backward compatible, i.e. without the `dontShiftPageAddr` argument and
// with the callback `done` as last parameter, to be used in `async.sequence`
if (arguments.length === 6) {
stream = arguments[0];
hex = arguments[1];
pageSize = arguments[2];
timeout = arguments[3];
dontShiftPageAddr = arguments[4];
done = arguments[5];
} else {
stream = arguments[0];
hex = arguments[1];
pageSize = arguments[2];
timeout = arguments[3];
dontShiftPageAddr = undefined;
done = arguments[4];
}

var pageaddr = 0;
var writeBytes;
var useaddr;
Expand All @@ -201,7 +220,11 @@ stk500.prototype.upload = function (stream, hex, pageSize, timeout, done) {
self.log("program page");
async.series([
function(cbdone){
useaddr = pageaddr >> 1;
if (dontShiftPageAddr) {
useaddr = pageaddr;
} else {
useaddr = pageaddr >> 1;
}
cbdone();
},
function(cbdone){
Expand Down Expand Up @@ -339,7 +362,7 @@ stk500.prototype.bootload = function (stream, hex, opt, done) {
this.verifySignature.bind(this, stream, opt.signature, opt.timeout),
this.setOptions.bind(this, stream, parameters, opt.timeout),
this.enterProgrammingMode.bind(this, stream, opt.timeout),
this.upload.bind(this, stream, hex, opt.pageSize, opt.timeout),
this.upload.bind(this, stream, hex, opt.pageSize, opt.timeout, opt.dontShiftPageAddr),
this.verify.bind(this, stream, hex, opt.pageSize, opt.timeout),
this.exitProgrammingMode.bind(this, stream, opt.timeout)
], function(error){
Expand Down
2 changes: 1 addition & 1 deletion lib/receiveData.js → lib/receiveData.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Statics = require('./statics');
var Statics = require('./statics.cjs');

var startingBytes = [
Statics.Resp_STK_INSYNC
Expand Down
4 changes: 2 additions & 2 deletions lib/sendCommand.js → lib/sendCommand.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var receiveData = require('./receiveData');
var Statics = require('./statics');
var receiveData = require('./receiveData.cjs');
var Statics = require('./statics.cjs');

module.exports = function (stream, opt, callback) {
var timeout = opt.timeout || 0;
Expand Down
File renamed without changes.
Loading