Pages: [1]   Go Down
Author Topic: How to upload ready HEX file using processing or java?  (Read 920 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd like to upload ready HEX file to Arduino board. How can i do that in java code?
Should i implement stk500 protocol in java? Are there any working solutions or examples in java? Thank a lot!

PS. I've found stk500 implementation in Erlang (https://github.com/msantos/stk500) but i don't know it.
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You can call avrdude from java. Why do you need to circumvent avrdude? You need native code anyways (for accessing the serial interface), so why don't you wanna use avrdude?
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The idea was to upload Arduino sketch right from Android device via USB, Ethernet or Bluetooth.
I can use native code using NDK but it should be not console app and it's not good to use arch-dependent code in java app in general.

I tend to write stk500 implementation as it seems to be pretty simple protocol.
But i agree that it's better to use smth ready and bugs-free instead of reinventing the wheel.

So what do you think about it?

PS. Serial interface is available in java code too
« Last Edit: January 30, 2013, 12:10:15 pm by 4ntoine » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
PS. Serial interface is available in java code too

Interfaces: yes, but you don't have support for it in the JVM, you need an external native library (like RXTXcomm or javax.com, but javax.com is available only on Unix platforms). To be a little picky: Dalvik (the vm for running code on Android) is not Java.

I guess, to emulate avrdude on Android and update Arduinos over Ethernet or Bluetooth, stk500 is not your biggest challenge.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay, let's say i already know how to pass bytes array to bootloader (via Serial, Bluetooth, Ethernet, etc, etc). Serial at least for sure.
Uploading via Bluetooth example:


The problem is how to interact with it in optimal way..
« Last Edit: January 31, 2013, 08:37:34 am by 4ntoine » Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So you're uploading via Bluetooth and hit the reset button when your upload is ready? Why do you need it to be wireless then?
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, it's just a proof of concerns that compiled sketch can be uploaded via Bluetooth too. Let's leave the question about transport: usb, serial, bluetooth, ethernet - anyway.
The goal is to "talk with bootloader". So the question is "is there smth useful that can be used in java (Android to be exact) to help to do it".

One idea suggested was to use avrdude and it has few drawbacks like arch-dependency. And it's pretty difficult to integrate it into java app as Process.exec() is not supported in Android.
So it will be necessary to change avrdude code to use streams instead of file input and serial output. Does anyone want to do it?

Another idea is to implement stk500 in pure java code by myself.

Any suggestions, anyone?
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 96
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Keep in mind that Arduino is using something similar to stk500 but it's not identical. If you implement it yourself take a look at the C implementation in avrdude.
Also keep in mind that not all Arduinos are using that protocol. For example the Leonardo or the Mega2560 are using another protocol for the upload. If you stay with UNOs and compatible you're fine with a slightly adapted stk500.
Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've found smth useful here (protocols for boards):
http://arduino.cc/en/uploads/Main/boards.txt

Stk500 protocol description can be found at:
http://www.atmel.com/Images/doc2525.pdf

I will use avrdude code and erlang impl too.
Thank you, pylon!
« Last Edit: February 01, 2013, 06:36:54 am by 4ntoine » Logged

Offline Offline
Full Member
***
Karma: 1
Posts: 158
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Checkout this: http://arduinocommander.blogspot.com/2013/03/upload-sketch.html
Logged

Pages: [1]   Go Up
Jump to: