I don't have an ARDUINO Leonardo. And this board seams to be somewhat different. But I want to support the Leonardo too. For this I need your help:
1) What is going wrong with HaikuVM and Leonardo?
2) Does it work if you write a sketch with the ARDUINO IDE (without HaikuVM beeing involved)?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The compiled program doesn't seem to run on the board.
Yes, it works with a sketch from the Arduino IDE.
I am using Netbeans with my own scripts and the bootstrap seems to be ok. I verified this with a sketch from the Aduino IDE, that bootstrapped with my Netbeans scripts (I filled in the name of the Aduino IDE generated hex file). This sketch runs as expected (blinking led).
When I bootstrap the HaikuVM program, loading seems to be ok, but the program won't start (it is the very simple Blink program). Even when I do not create a new instance of the Blink class, and put everything in the static main method, nothing happens.
I did some disassembly on the elf code but these look very different from each other. I found that the stack pointer is initialised differently, but don't think that is a problem (Leonardo with its MEGA32U4 has more memory than other boards). Then I stopped searching for differences, as there were far too many...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm not an expert for the Arduino IDE. But as far as I know, behind the scence there is an avr-gcc and avrdude doing the heavy work. (Like with HaikuVM.)
1) For the avr-gcc, to adapt to the target hardware, an important option is "-mmcu=[Target]". What does the Arduino IDE inserts for [Target]?
2) For avrdude, to adapt to the target hardware and bootloader, important options are "-p [Partno]" and "-c [Programmer-id]". What does the Arduino IDE inserts for [Partno] and/or [Programmer-id]?
Can you find out this for Leonardo (and me)?
3) Make a clone of the 'arduino' section in file 'HaikuVM.properties' and give it a new name(prefix) e.g.: 'leonardo'. For this, take a look into file 'HaikuVM.properties' to see example avrdude configurations for other AVRs. Or, alternativly, take a look into this discussion http://sourceforge.net/p/haiku-vm/discussion/general/thread/c3298729/. Here Alan configured a Gertboard in 'HaikuVM.properties' for his needs.
Finally, in file 'HaikuVM.properties', adapt the values for [Target], [Partno] and/or [Programmer-id] in the new section 'leonardo' to your findings (see questions 1 and 2).
4) From this time on, with the HaikuVM commands, use '--Config leonardo' (instead of '--Config arduino') for your Arduino Leonardo hardware.
Let me know about your results!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thank you for your response. In the attachment ArduinoIDEBlink you can find the compiler/download output from the Arduino IDE.
The -mmcu was wrong indeed. But now I have another problem, because in the chaotic setup I created, the compiler won't create the file wiring.o.
I will have to sort out the directory structure of haikuVM and cleanup my setup to match this structure. Just for fun I also uploaded the output of the Netbeans build output.
Thank you for your attachments. And yes, you are right, this is chaos :-D. Here are my findings:
1) Arduino IDE found "Leonardo upload port: COM5"
2) For HaikuVM you configured COM6. Why?
3) Nevertheless, Netbeans tries COM5 (I wonder) but telling that:
"avrdude.exe: ser_open(): can't open device "\.\COM5": Het systeem kan het opgegeven bestand niet vinden."
Which is a contradiction compared to 1). I still wonder.
4) Registers UCSR0B, UBRR0H and UBRR0L seams to be undeclared for atmega32u4. So, to have a first success with Leonardo, I suggest to change to "--Config simple010" and "BlinkSimple.java" with a "MicroKernel = haiku.avr.lib.simple010.HaikuMicroKernel" like I suggested in this discussion http://sourceforge.net/p/haiku-vm/discussion/general/thread/c3298729/
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Don't mind about the com: ports, they change dynamically.
I am going to take small steps from now on. First the cpu in the leonardo.
Trying to change the cpu to atmega32u4 seems to cause the unknown registers (UCSR0B UBRR0H and UBRR0L). Because I really want to use this cpu type (it works with the ArduinoIDE), I spent a lot of time trying to understand why this error occurs, but that is too difficult for me. I hope that you can reproduce and correct the error. This is what I put into HaikuVM.properties:
I tried but I'm not able to reproduce this. This is what I did:
I followed your givings and cut&past your leonardo configuration into my 'HaikuVM.properties' then I followed my advice which I gave to you and called
and I get no "unresolved errors" from the compiler. Simply because "BlinkSimple.java" is not using serial IO (and therefor not refering to registers UCSR0B, UBRR0H and UBRR0L).
Later when it comes to upload avrdude told me
avrdude:Can'tfindprogrammerid"gpio"
If you encounter the same problem change your configuration to something like:
Ok, I am going to try to follow you. If I know it works in the default settings, that would be a nice starting point.
First I got an error that I solved by starting in another directory. The error was "Error: Don't use HAIKUVM_HOME as your project home. Please select an other directory." (from HaikuVM.java:217). I do not understand why this could be a problem.
See the attachment for the error I encountered:
link > haiku/avr/AVRDefines from d:\downloads\HaikuVM-1.0.2\haikuVM\lib\haikuvm\bootstrap.jar
const class_t haiku_avr_AVRDefinesclass PROGMEM = {
& java_lang_Objectclass,
sizeof(haiku_avr_AVRDefines),
0,
};
into D:.\haikuJava\haiku\avr\AVRDefines.c
link > avr/tutorial/BlinkSimple from D:\downloads\HaikuVM-1.0.2\haikuVM\examples\src\main\java\/avr/tutorial/BlinkSimple.class
const class_t avr_tutorial_BlinkSimpleclass PROGMEM = {
& java_lang_Objectclass,
sizeof(avr_tutorial_BlinkSimple),
0,
};
into D:.\haikuJava\avr\tutorial\BlinkSimple.c
at haikuvm.pc.tools.BuildMakes.collectDirs(BuildMakes.java:199)
at haikuvm.pc.tools.BuildMakes.collectDirs(BuildMakes.java:200)
at haikuvm.pc.tools.BuildMakes.collectDirs(BuildMakes.java:200)
at haikuvm.pc.tools.BuildMakes.build(BuildMakes.java:49)
at haikuvm.pc.tools.HaikuVM.haikulink(HaikuVM.java:423)
at haikuvm.pc.tools.HaikuVM.main(HaikuVM.java:93)
1)
You are right, starting in HAIKUVM_HOME is forbidden. If so HaikuVM will give you the error message you mentioned. So, in your case 'd:\downloads\HaikuVM-1.0.2\haikuVM\' is forbidden.
2)
But it's possible to start in any (initial) empty directory e.g. ${HAIKUVM_HOME}\myCProject\ which I do recommend here 'http://haiku-vm.sourceforge.net/#Arduino'
In your case it would be 'd:\downloads\HaikuVM-1.0.2\haikuVM\myCProject\'.
Any empty directory will do like explained here 'http://haiku-vm.sourceforge.net/#Architecture' and elsewhere on my side.
3)
In your appended file 'haiku_output.txt' I found that you use 'D:\.' for your project directory. You should avoid this, because this is NOT an empty directory as stated.
4)
In one of your former post you wrote you have this MicroKernel configuration:
Compilation works! But the program doesn't run in the Leonardo.
I think there are a few (minor but time consuming) errors that should be fixed, or improvements that should be implemented, in haiku:
- the error message about the current directory should state that one should start in an empty directory (or previously used directory?)
- it should be possible to give the .java file as a relative path. At least in Windows, that does not work and leads to an error (the error I mentioned earlier): if I specify "..\examples(..)\yyyy.java" the (new) error message complains about not finding "//\examples(..)\yyyy.class".
- DO NOT SPEND TIME ON THIS ONE, SEE NEXT POST: a fresh implementation on Ubuntu in a VirtualBox leads to the following error in generating c files: Exception in thread "main"java.Lang.NullPointerException, at haikuvm.pc.tools.HaikuVM.java:292),
at haikuvm.pc.tools.HaikuVM.main(HaikuVM..java:93)
and then a java.lang.Exception error with errorcode=1
at haikuvm.pc.tools.HaikuVM.executeBlocking(HaikuVM.java:499)
I suggest that the make should abort on an error.
There are some changes in HaikuVM.properties, see attached file (options to avrdude and PORT)
Because not everybody has the Leonardo hardware, I decided to give simulavr a chance. On Windows (not my favorite os), it ended very soon in a not-found gcc dll and I gave up.
Then I tried ubuntu in a vbox. But then c compiling went wrong, see attached file.
I'm very happy to read that BlinkSimple.java finaly compiles and uploads.
The program BlinkSimple.java "Assumes that LED is connected at Port B and Bit 5." as stated in the JavaDocs (see line 6 of this tiny program).
I don't own a leonardo so I googled a bit and found that leonardo has the LED (pin 13) connected with Port C and Bit 7. Can you confirm this? If so, did you change BlinkSimple.java to reflect this? If not, try this first and tell me about the results.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Yes! It works!
But only with a tweaked JVM.c: I had to comment out the sei(). When I enable sei(), the program won't run in the Leonardo.
Can you give me a hint how to find the cause of the (presumably unwanted) interrupt? I do have a keyboard/display shield to use as output device (never tried with Java). I think I can find it myself, but if you have done this before I would gladly use your knowledge.
In svn I saw you changed the check on the property with value null. I think this is not what you want: you don't want to check whether the property has the String value "null", you want to check whether the property is null (as I wrote on the 1st of may). It is very well possible that I earlier posted the (wrong) solution (the one you have put into svn), and that I changed it later in my post.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) And I wonder why calling sei() has this bad effect.
1a) This, because I'm not aware of any interrupt cause if useing haiku.avr.lib.simple010.HaikuMicroKernel. So I took a look into wiring.c to find out how they do it. To my surprise, the first thing happens in init() is a call of sei()! And they use TIMER0_OVF_vect too! Now I have no clue!
1b) I found a special case for ATmega32U4 in WInterrupts.c. May be it helps if you insert this modified snippet somewhere into JVM.c:
#if defined(__AVR_ATmega32U4__)
SIGNAL(INT0_vect) {
// do nothing just catch the interrupt
}
SIGNAL(INT1_vect) {
// do nothing just catch the interrupt
}
SIGNAL(INT2_vect) {
// do nothing just catch the interrupt
}
SIGNAL(INT3_vect) {
// do nothing just catch the interrupt
}
#endif
2) "null" vs. null
The leonardo configuration extends the avr configuration (and so on). It's not possible to start your JAVA program completly without MicroKernel support by deleting the entry leonardo.MicroKernel. Because in this case the leonardo configuration inherits the MicroKernel from avr (and so on). The only way to overwrite the inherited MicroKernel (and run without MicroKernel) is by writing:
leonardo.MicroKernel = null
So I have to test for the String "null".
My code change you mentioned followed your advice partly. The current solution is failsave against null pointers, I hope ;-).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried to put the code into JVM.c, first in the function startJVM, but that resulted in an error message about static and non-static calls.
Then I put the code somewhere at the top of the file. No result. Then I put some more code (up to INTA_vect), no result. Then I put cli() into these routines. No result. And now I have to eat. I know for the best results I should put all the interrupt routines (up to F?). Maybe later.
Other question: I have translated new bootstrap file and example file for the liquidCrystal display, see the attached files. But I am very clumsy with Eclipse (normally I use Netbeans), so I cannot compile the example. Don't know how to build the bootstrap jar from Eclipse. Do you have a recipe for it? Or can you put build the system and put the files into svn?
This helps (disable interrupts from usb controller):
SIGNAL(USB_GEN_vect) {
USBCON &= 127; // CLEAR BIT 7
}
SIGNAL(USB_COM_vect) {
USBCON &= 127; // CLEAR BIT 7
}
After discovering this, I made the next improvement to JVM.C. I deleted the SIGNAL calls and I inserted the next code, in function startJVM, just before the call to sei() and it provides a neat and generally applicable solution (IMHO):
#if defined(__AVR_ATmega32U4__)
USBCON &= 127; // CLEAR BIT 7
USBCON &= 127; // CLEAR BIT 7
#endif
sei();
Last edit: Carl van Denzen 2013-05-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
2)
Thank you! Trying to be more general, I will implement your solution like this (if you don't mind):
#if defined(USBCON)
USBCON &= 127; // CLEAR BIT 7 -> disable USB interrupt
#endif
sei();
3)
Meanwhile I really wonder, because I thought that no interrupt is enabled after uploading any program to an arduino (in this case leonardo). Do you have an idea why this interrupt is enabled from the beginning?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1) it is funny (you mean two times USBCON) because I made a mistake. It was meant to be USBCON and USBGEN (or something like that), but copy/paste went wrong somewhere. I found it because I saw in the Arduino Leonardo specs the differences between Leonardo and the others and the biggest change was the usb system. So I gave that a try.
2) ok!
3) It has probably a relation with the boot procedure. A Leonardo U4 cpu has built-in usb support. Maybe the author of the boot loader forgot to disable the usb port? Or maybe it does have a function. There is something special about the usb port and the emulated com port(s).
If you set the baud rate of com6 to 1200 baud, a boot procedure is initiated, and then com5 functions as the boot port. The exact port numbers (6 and 5, or 5 and 4) depend on the sequence that I connect my peripherals (mouse, handy (that's German for cell phone?), etc.).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Can you give me some hints about Eclipse and Haiku? I should RTFM, but the help text is not very to the point.
I imported the projects from svn (import with "find child projects") into Eclipse.
I have some concrete questions:
- where can I find the logging of the build process? The Progress view is empty.
- is it a good idea to compile LiquidCrystal.java into bootstrap.jar (package haiku.avr.lib.arduino)?
- is it a good idea to put LiquidCrystalHelloWorld.java in examples (package arduino.tutorial)
- how would I build the bootstrap.jar?
- should I copy the bootstrap.jar from the Eclipse workspace into my Haiku directory and build from there?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Has there been any reported success with HaikuVM on an Arduino Leonardo?
Last edit: genom2 2013-04-07
I don't have an ARDUINO Leonardo. And this board seams to be somewhat different. But I want to support the Leonardo too. For this I need your help:
1) What is going wrong with HaikuVM and Leonardo?
2) Does it work if you write a sketch with the ARDUINO IDE (without HaikuVM beeing involved)?
I am using Netbeans with my own scripts and the bootstrap seems to be ok. I verified this with a sketch from the Aduino IDE, that bootstrapped with my Netbeans scripts (I filled in the name of the Aduino IDE generated hex file). This sketch runs as expected (blinking led).
When I bootstrap the HaikuVM program, loading seems to be ok, but the program won't start (it is the very simple Blink program). Even when I do not create a new instance of the Blink class, and put everything in the static main method, nothing happens.
I did some disassembly on the elf code but these look very different from each other. I found that the stack pointer is initialised differently, but don't think that is a problem (Leonardo with its MEGA32U4 has more memory than other boards). Then I stopped searching for differences, as there were far too many...
I'm not an expert for the Arduino IDE. But as far as I know, behind the scence there is an avr-gcc and avrdude doing the heavy work. (Like with HaikuVM.)
1) For the avr-gcc, to adapt to the target hardware, an important option is "-mmcu=[Target]". What does the Arduino IDE inserts for [Target]?
2) For avrdude, to adapt to the target hardware and bootloader, important options are "-p [Partno]" and "-c [Programmer-id]". What does the Arduino IDE inserts for [Partno] and/or [Programmer-id]?
Can you find out this for Leonardo (and me)?
3) Make a clone of the 'arduino' section in file 'HaikuVM.properties' and give it a new name(prefix) e.g.: 'leonardo'. For this, take a look into file 'HaikuVM.properties' to see example avrdude configurations for other AVRs. Or, alternativly, take a look into this discussion http://sourceforge.net/p/haiku-vm/discussion/general/thread/c3298729/. Here Alan configured a Gertboard in 'HaikuVM.properties' for his needs.
Finally, in file 'HaikuVM.properties', adapt the values for [Target], [Partno] and/or [Programmer-id] in the new section 'leonardo' to your findings (see questions 1 and 2).
4) From this time on, with the HaikuVM commands, use '--Config leonardo' (instead of '--Config arduino') for your Arduino Leonardo hardware.
Let me know about your results!
Thank you for your response. In the attachment ArduinoIDEBlink you can find the compiler/download output from the Arduino IDE.
The -mmcu was wrong indeed. But now I have another problem, because in the chaotic setup I created, the compiler won't create the file wiring.o.
I will have to sort out the directory structure of haikuVM and cleanup my setup to match this structure. Just for fun I also uploaded the output of the Netbeans build output.
Last edit: Carl van Denzen 2013-04-09
Thank you for your attachments. And yes, you are right, this is chaos :-D. Here are my findings:
1) Arduino IDE found "Leonardo upload port: COM5"
2) For HaikuVM you configured COM6. Why?
3) Nevertheless, Netbeans tries COM5 (I wonder) but telling that:
"avrdude.exe: ser_open(): can't open device "\.\COM5": Het systeem kan het opgegeven bestand niet vinden."
Which is a contradiction compared to 1). I still wonder.
4) Registers UCSR0B, UBRR0H and UBRR0L seams to be undeclared for atmega32u4. So, to have a first success with Leonardo, I suggest to change to "--Config simple010" and "BlinkSimple.java" with a "MicroKernel = haiku.avr.lib.simple010.HaikuMicroKernel" like I suggested in this discussion http://sourceforge.net/p/haiku-vm/discussion/general/thread/c3298729/
Don't mind about the com: ports, they change dynamically.
I am going to take small steps from now on. First the cpu in the leonardo.
Trying to change the cpu to atmega32u4 seems to cause the unknown registers (UCSR0B UBRR0H and UBRR0L). Because I really want to use this cpu type (it works with the ArduinoIDE), I spent a lot of time trying to understand why this error occurs, but that is too difficult for me. I hope that you can reproduce and correct the error. This is what I put into HaikuVM.properties:
leonardo.Extends = avr
leonardo.Target = atmega32u4
leonardo.MemorySize = 1540
leonardo.Clock = 16000000
leonardo.MicroKernel = haiku.avr.lib.simple010.HaikuMicroKernel
leonardo.Port = gpio
leonardo.Upload = avrdude -p atmega32u4 -c $(HAIKU_PORT) -v -U flash:w:$(HAIKU_OUTPUT)
I tried but I'm not able to reproduce this. This is what I did:
I followed your givings and cut&past your leonardo configuration into my 'HaikuVM.properties' then I followed my advice which I gave to you and called
and I get no "unresolved errors" from the compiler. Simply because "BlinkSimple.java" is not using serial IO (and therefor not refering to registers UCSR0B, UBRR0H and UBRR0L).
Later when it comes to upload avrdude told me
If you encounter the same problem change your configuration to something like:
Let me know about your progress!
Ok, I am going to try to follow you. If I know it works in the default settings, that would be a nice starting point.
First I got an error that I solved by starting in another directory. The error was "Error: Don't use HAIKUVM_HOME as your project home. Please select an other directory." (from HaikuVM.java:217). I do not understand why this could be a problem.
See the attachment for the error I encountered:
link > haiku/avr/AVRDefines from d:\downloads\HaikuVM-1.0.2\haikuVM\lib\haikuvm\bootstrap.jar
const class_t haiku_avr_AVRDefinesclass PROGMEM = {
& java_lang_Objectclass,
sizeof(haiku_avr_AVRDefines),
0,
};
into D:.\haikuJava\haiku\avr\AVRDefines.c
link > avr/tutorial/BlinkSimple from D:\downloads\HaikuVM-1.0.2\haikuVM\examples\src\main\java\/avr/tutorial/BlinkSimple.class
const class_t avr_tutorial_BlinkSimpleclass PROGMEM = {
& java_lang_Objectclass,
sizeof(avr_tutorial_BlinkSimple),
0,
};
into D:.\haikuJava\avr\tutorial\BlinkSimple.c
totalMethods= 43
totalBClength= 908
totalConstLength= 249
totalClassesLength=204
Exception in thread "main" java.lang.NullPointerException
1)
You are right, starting in HAIKUVM_HOME is forbidden. If so HaikuVM will give you the error message you mentioned. So, in your case 'd:\downloads\HaikuVM-1.0.2\haikuVM\' is forbidden.
2)
But it's possible to start in any (initial) empty directory e.g. ${HAIKUVM_HOME}\myCProject\ which I do recommend here 'http://haiku-vm.sourceforge.net/#Arduino'
In your case it would be 'd:\downloads\HaikuVM-1.0.2\haikuVM\myCProject\'.
Any empty directory will do like explained here 'http://haiku-vm.sourceforge.net/#Architecture' and elsewhere on my side.
3)
In your appended file 'haiku_output.txt' I found that you use 'D:\.' for your project directory. You should avoid this, because this is NOT an empty directory as stated.
4)
In one of your former post you wrote you have this MicroKernel configuration:
Using simple010 is good. But in your appended file 'haiku_output.txt' I found this in the effective configuration list:
Which is a contradiction. You have to clean up this first.
Compilation works! But the program doesn't run in the Leonardo.
I think there are a few (minor but time consuming) errors that should be fixed, or improvements that should be implemented, in haiku:
- the error message about the current directory should state that one should start in an empty directory (or previously used directory?)
- it should be possible to give the .java file as a relative path. At least in Windows, that does not work and leads to an error (the error I mentioned earlier): if I specify "..\examples(..)\yyyy.java" the (new) error message complains about not finding "//\examples(..)\yyyy.class".
- DO NOT SPEND TIME ON THIS ONE, SEE NEXT POST: a fresh implementation on Ubuntu in a VirtualBox leads to the following error in generating c files: Exception in thread "main"java.Lang.NullPointerException, at haikuvm.pc.tools.HaikuVM.java:292),
at haikuvm.pc.tools.HaikuVM.main(HaikuVM..java:93)
and then a java.lang.Exception error with errorcode=1
at haikuvm.pc.tools.HaikuVM.executeBlocking(HaikuVM.java:499)
Last edit: Carl van Denzen 2013-05-01
Line HaikuVM.java:292 should be:
if (HaikuDefs.getProperty("MicroKernel")==null ) {
(and not .....equals("null"))
The trigger for this error was missing leonardo entries in haikuvm.properties.
Last edit: Carl van Denzen 2013-05-01
Because not everybody has the Leonardo hardware, I decided to give simulavr a chance. On Windows (not my favorite os), it ended very soon in a not-found gcc dll and I gave up.
Then I tried ubuntu in a vbox. But then c compiling went wrong, see attached file.
I'm very happy to read that BlinkSimple.java finaly compiles and uploads.
The program BlinkSimple.java "Assumes that LED is connected at Port B and Bit 5." as stated in the JavaDocs (see line 6 of this tiny program).
I don't own a leonardo so I googled a bit and found that leonardo has the LED (pin 13) connected with Port C and Bit 7. Can you confirm this? If so, did you change BlinkSimple.java to reflect this? If not, try this first and tell me about the results.
Yes! It works!
But only with a tweaked JVM.c: I had to comment out the sei(). When I enable sei(), the program won't run in the Leonardo.
Can you give me a hint how to find the cause of the (presumably unwanted) interrupt? I do have a keyboard/display shield to use as output device (never tried with Java). I think I can find it myself, but if you have done this before I would gladly use your knowledge.
In svn I saw you changed the check on the property with value null. I think this is not what you want: you don't want to check whether the property has the String value "null", you want to check whether the property is null (as I wrote on the 1st of may). It is very well possible that I earlier posted the (wrong) solution (the one you have put into svn), and that I changed it later in my post.
I'm glad to read that things are working now!!
1) And I wonder why calling sei() has this bad effect.
1a) This, because I'm not aware of any interrupt cause if useing haiku.avr.lib.simple010.HaikuMicroKernel. So I took a look into wiring.c to find out how they do it. To my surprise, the first thing happens in init() is a call of sei()! And they use TIMER0_OVF_vect too! Now I have no clue!
1b) I found a special case for ATmega32U4 in WInterrupts.c. May be it helps if you insert this modified snippet somewhere into JVM.c:
2) "null" vs. null
The leonardo configuration extends the avr configuration (and so on). It's not possible to start your JAVA program completly without MicroKernel support by deleting the entry leonardo.MicroKernel. Because in this case the leonardo configuration inherits the MicroKernel from avr (and so on). The only way to overwrite the inherited MicroKernel (and run without MicroKernel) is by writing:
leonardo.MicroKernel = null
So I have to test for the String "null".
My code change you mentioned followed your advice partly. The current solution is failsave against null pointers, I hope ;-).
I tried to put the code into JVM.c, first in the function startJVM, but that resulted in an error message about static and non-static calls.
Then I put the code somewhere at the top of the file. No result. Then I put some more code (up to INTA_vect), no result. Then I put cli() into these routines. No result. And now I have to eat. I know for the best results I should put all the interrupt routines (up to F?). Maybe later.
Other question: I have translated new bootstrap file and example file for the liquidCrystal display, see the attached files. But I am very clumsy with Eclipse (normally I use Netbeans), so I cannot compile the example. Don't know how to build the bootstrap jar from Eclipse. Do you have a recipe for it? Or can you put build the system and put the files into svn?
Last edit: Carl van Denzen 2013-05-11
This helps (disable interrupts from usb controller):
SIGNAL(USB_GEN_vect) {
USBCON &= 127; // CLEAR BIT 7
}
SIGNAL(USB_COM_vect) {
USBCON &= 127; // CLEAR BIT 7
}
After discovering this, I made the next improvement to JVM.C. I deleted the SIGNAL calls and I inserted the next code, in function startJVM, just before the call to sei() and it provides a neat and generally applicable solution (IMHO):
Last edit: Carl van Denzen 2013-05-13
1)
This solution is funny! How did you find this?
2)
Thank you! Trying to be more general, I will implement your solution like this (if you don't mind):
3)
Meanwhile I really wonder, because I thought that no interrupt is enabled after uploading any program to an arduino (in this case leonardo). Do you have an idea why this interrupt is enabled from the beginning?
1) it is funny (you mean two times USBCON) because I made a mistake. It was meant to be USBCON and USBGEN (or something like that), but copy/paste went wrong somewhere. I found it because I saw in the Arduino Leonardo specs the differences between Leonardo and the others and the biggest change was the usb system. So I gave that a try.
2) ok!
3) It has probably a relation with the boot procedure. A Leonardo U4 cpu has built-in usb support. Maybe the author of the boot loader forgot to disable the usb port? Or maybe it does have a function. There is something special about the usb port and the emulated com port(s).
If you set the baud rate of com6 to 1200 baud, a boot procedure is initiated, and then com5 functions as the boot port. The exact port numbers (6 and 5, or 5 and 4) depend on the sequence that I connect my peripherals (mouse, handy (that's German for cell phone?), etc.).
Can you give me some hints about Eclipse and Haiku? I should RTFM, but the help text is not very to the point.
I imported the projects from svn (import with "find child projects") into Eclipse.
I have some concrete questions:
- where can I find the logging of the build process? The Progress view is empty.
- is it a good idea to compile LiquidCrystal.java into bootstrap.jar (package haiku.avr.lib.arduino)?
- is it a good idea to put LiquidCrystalHelloWorld.java in examples (package arduino.tutorial)
- how would I build the bootstrap.jar?
- should I copy the bootstrap.jar from the Eclipse workspace into my Haiku directory and build from there?
I think we can close this leonardo topic.
For your last questions I started a new topic here:
https://sourceforge.net/p/haiku-vm/discussion/general/thread/df6181c2/