| Author |
Message |
|
|
Posted: Mar 23, 2012 - 02:00 PM |
|


Joined: Aug 27, 2010
Posts: 14
|
|
hello everybody,
I'm a java programmer and I have a atmega32 microcontroller. till now I have programmed with bascom in basic but I want to switch to java. It's possible and if yes, what do I need to run a java program on my atmega32? thanks in advance. |
|
|
| |
|
|
|
|
|
Posted: Mar 23, 2012 - 03:16 PM |
|


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
Google "nanoVM"
(I'll move this thread it clearly has nothing to do with ASF!) |
_________________
|
| |
|
|
|
|
|
Posted: Mar 23, 2012 - 08:55 PM |
|

Joined: Jan 14, 2010
Posts: 15
|
|
beware: nanoVM is not real java (the math is wonky: 31 or 15 bit, not 32 bit) which breaks most existing code, and it has no support for many important language features.
There *is* a full featured java VM for AVRs, but it barely fits into the atmega32 (no floats, doubles, longs). In an atmega64 it fits with support for floats and longs, and in atmega128 you can even have support for "double" |
|
|
| |
|
|
|
|
|
Posted: Mar 26, 2012 - 08:50 AM |
|


Joined: Aug 27, 2010
Posts: 14
|
|
|
dmitrygr wrote:
beware:
thank you for the advice. I agree with you that knowing the limitations of nanoVM is very important. furtunatly java is that flexible that there is almost a workaround. |
|
|
| |
|
|
|
|
|
Posted: Mar 26, 2012 - 11:31 AM |
|


Joined: Jan 14, 2007
Posts: 1836
Location: Nantes, France
|
|
|
|
|
|
|
Posted: Mar 27, 2012 - 04:16 AM |
|

Joined: Dec 18, 2001
Posts: 4708
|
|
| Java and 8 bit small RAM micros is like me trying to fit into my Army uniform now. |
|
|
| |
|
|
|
|
|
Posted: Mar 27, 2012 - 06:59 AM |
|

Joined: Dec 30, 2004
Posts: 8764
Location: Melbourne,Australia
|
|
| There's also TinyVM or LeJos, but that wont fit onto a mega32, again, targetted for a 32bit micro. Ram being the critical resource. |
|
|
| |
|
|
|
|
|
Posted: Apr 06, 2012 - 05:44 PM |
|

Joined: Jul 24, 2010
Posts: 1
|
|
Check out Bajos.
This might be what you're looking for. |
|
|
| |
|
|
|
|
|
Posted: Apr 06, 2012 - 06:13 PM |
|


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
Java and 8 bit small RAM micros is like me trying to fit into my Army uniform now.
If one is just taking the challenge like climbing Everest - "because it's there" - then I'd go for it. It seems to fall into the same "cool stuff" category as the emulators that run CP/M or ARM simulated Linux on an AVR. Completely pointless but real fun.
I doubt many people will be writing serious industrial microcontroller apps in Java though!
(maybe for those "bigger micros" that include a JVM in the silicon though?) |
_________________
|
| |
|
|
|
|
|
Posted: Apr 06, 2012 - 10:26 PM |
|

Joined: Jan 14, 2010
Posts: 15
|
|
Curious, since my jvm is fast enough to have allowed me to make a breakout clone on a graphical LCD  |
|
|
| |
|
|
|
|
|
Posted: Apr 07, 2012 - 02:47 PM |
|


Joined: Feb 19, 2001
Posts: 25904
Location: Wisconsin USA
|
|
|
Quote:
If one is just taking the challenge like climbing Everest - "because it's there" - then I'd go for it. It seems to fall into the same "cool stuff" category as the emulators that run CP/M or ARM simulated Linux on an AVR. Completely pointless but real fun.
I doubt many people will be writing serious industrial microcontroller apps in Java though!
This has been visited before. For many years, off and on. Search for "javacard". http://www.avrfreaks.net/index.php?name ... 3105#73105 for one of my takes. I wouldn't call smart cards a "pointless" app. It doesn't seem to have taken off on AVR8, though. Perhaps because ARM timelines are parallel?
Once the VM is written it might indeed be an interesting platform for e.g. little sensors. |
|
|
| |
|
|
|
|
|
Posted: Apr 07, 2012 - 03:57 PM |
|


Joined: Sep 04, 2002
Posts: 21257
Location: Orlando Florida
|
|
| The Department Of Defense decided to eliminate the Ada mandate in favor of "Best Commercial Practice" because some analyst analyzed that they could't find enough Ada programmers to write the space station and missle defense shield software. Evidently, the schools are turning out beaucoup java programmers. Thus soon old c programmers will be retiring. I tried to learn some java to write some android apps, but didn't quite embrace the whole concept enough to light the lightbulb. I just think procedural evidently. |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Apr 07, 2012 - 07:23 PM |
|

Joined: Dec 18, 2001
Posts: 4708
|
|
|
bobgardner wrote:
I tried to learn some java to write some android apps, but didn't quite embrace the whole concept enough to light the lightbulb. I just think procedural evidently.
I'm a, er, veteran, with history of:
FORTRAN II, PDP11 ASM, 6809 ASM, 8080 ASM, Nova800 ASM, PASCAL, C, VB6, JavaScript, VBscript, C++.
The path of C to C++ was hard. But if I avoid things like C++ Templates, it's not so difficult for embedded, where class instances need to be static.
Java/VM is very similar to C++.
these are all procedural; somthing like the Prolog language isn't. It's a fascinating language to me.
C# is, IMO, to be avoided as it's a box of crutches for coders rather than software engineers.
operating systems including Microsoft's, are, for the most part, still in C/C++ as C# is a VM target. Embedded systems are a first cousin of this; too inefficient to have a bytecode interpreter/VM in most low cost embedded systems. |
|
|
| |
|
|
|
|
|
Posted: Apr 08, 2012 - 03:50 PM |
|


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
|
Quote:
; too inefficient to have a bytecode interpreter/VM in most low cost embedded systems.
Unless it's in the silicon. Almost all ARM based mobile devices (phones, MP3s, etc) have a processor with a JVM in the silicon which is why Java games on mobiles work so well. |
_________________
|
| |
|
|
|
|
|
Posted: Apr 08, 2012 - 03:59 PM |
|


Joined: Feb 19, 2001
Posts: 25904
Location: Wisconsin USA
|
|
|
Quote:
Quote:
; too inefficient to have a bytecode interpreter/VM in most low cost embedded systems.
Unless it's in the silicon.
So what about these Javacard thingies? They all have a Java hard engine? Or perhaps there really are few Javacard-compatibles around? |
|
|
| |
|
|
|
|
|
Posted: Apr 08, 2012 - 04:22 PM |
|


Joined: Sep 04, 2002
Posts: 21257
Location: Orlando Florida
|
|
| I thought the Dalvic Virtual Machine in the Android was software, not hardware? (Dalvic is the place it was written) |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Apr 08, 2012 - 04:25 PM |
|


Joined: Jul 18, 2005
Posts: 62281
Location: (using avr-gcc in) Finchingfield, Essex, England
|
|
| I'd be hugely surprised if the JVM in most Android wasn't in the silicon but there bay some kind of software "shim" adapting the execution mechanism to the h/w implementation I guess. |
_________________
|
| |
|
|
|
|
|
Posted: Apr 08, 2012 - 05:58 PM |
|


Joined: Sep 04, 2002
Posts: 21257
Location: Orlando Florida
|
|
|
|
|
|
|
Posted: Jan 22, 2013 - 09:09 PM |
|

Joined: Jan 22, 2013
Posts: 3
|
|
HaikuVM is a full featured (= support for all JAVA byte codes) JAVA VM for AVRs and fits even into an Atmega8. In addition it has a full featured runtime which is borrowed from the leJOS project.
The feature list of HaikuVM is long. I mention 3 of them which make HaikuVM extra usefull for micros and Atmegas:
1) Configurable 64, 32 or 16 bit data type modes. To list two configurations:
- 32/64 for full JAVA compliance (long/double are 64Bit)
- 16/32 practical compromise for micros (long/double are 32Bit)
2) Configurable 16 or 8 bit type for char arrays.
- 16Bit for full JAVA compliance.
- 8Bit practical compromise for micros.
3) Direct access to memory like in the following JAVA line:
ADCSRA |= (1 << ADSC);
to every predefined AVR variable is standard. Armed with this, programming an AVR in JAVA is pretty close to programming in C.
And in general:
4) Threading |
|
|
| |
|
|
|
|
|
Posted: Jan 22, 2013 - 09:40 PM |
|


Joined: Sep 04, 2002
Posts: 21257
Location: Orlando Florida
|
|
| And speaking of ram expanders, dont forget the Rugged Circuits megaram with 512K that plugs into a mega2560 arduino. |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Feb 03, 2013 - 10:40 PM |
|

Joined: Jan 22, 2013
Posts: 3
|
|
Please, don't be fooled by this C-veteran and buy this 512K thing! Wait until your C or JAVA program realy needs it. Instead, if you run this JAVA/HaikuVM program on an Atmega8:
Code:
package avr.tutorial;
import static haiku.avr.AVRConstants.*;
public class BlinkSimple {
private static final int LED = 1 << 5;
private static void delay(int nounit) {
while(nounit>0) {
nounit--;
}
}
public static void main(String[] args) {
DDRB = LED; // Data direction of I/O-Port.
while (true) {
PORTB |= LED; // on
delay(3000);
PORTB &= ~LED; // off
delay(30000);
}
}
}
You have plenty of RAM left to sell them bobgardner  |
|
|
| |
|
|
|
|
|
Posted: Feb 03, 2013 - 11:44 PM |
|


Joined: Sep 04, 2002
Posts: 21257
Location: Orlando Florida
|
|
| Hi Genom. You think I'm selling the rugged circuits 512K ram card? Let me see if I get your advice: I can run a Haiku Java program on a mega8 with 1K of ram. I assume there is an interpreter that reads the bytecodes. It is an interpreter. I suggested running on a mega2560 with 256K of flash and 512K of ram. My inference was that one can run a much larger program. Like 512 times as big. I get the idea you think this is untrue. Back to you for your analysis. |
_________________ Imagecraft compiler user
|
| |
|
|
|
|
|
Posted: Feb 04, 2013 - 09:12 PM |
|

Joined: Jan 22, 2013
Posts: 3
|
|
Hi Bobgardner. No, I've never thought that you sell this thing. Instead I thought you made a kind of sophisticated joke. This because your suggestion is too perfect. Which I understood as: If you choose an Atmega which is 512 times bigger, then you are able to write programs which are 512 times as big.
I totally agree with this. Sorry for any misunderstanding. |
|
|
| |
|
|
|
|
|
Posted: Feb 04, 2013 - 10:36 PM |
|


Joined: Nov 22, 2002
Posts: 12044
Location: Tangent, OR, USA
|
|
A. Hello, I would like to speak to Jim. But, I prefer to speak in German
Jim. Jim does not come with a German language module. He only speaks English, more or less.
A. But, I prefer German
Jim. Jim does not come with a German language module.
A. But, I prefer German
Jim. See above.
Jim |
_________________ Jim Wagner
Oregon Research Electronics, Consulting Div.
Tangent, OR, USA
"The only thing standing between us and victory is defeat" P.G.Wodhouse in Wooster & Jeeves series
|
| |
|
|
|
|
|