0
Offline
Newbie
Karma: 0
Posts: 3
Arduino rocks
|
 |
« on: December 22, 2009, 09:11:50 am » |
http://blog.makezine.com/archive/2009/12/simavr_a_simulator_for_avr_chips.htmlhttp://gitorious.org/simavrI just saw this project outlined on MAKE's website (via adafruit), and one of the comments suggested possibly building this into Arduino IDE. This would be awesome for conceptual development on the go, where lugging your gear with you isn't feasible. I'm not sure how well it translates to multi-platform, but it does use avr-gcc. What do you think?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #1 on: December 23, 2009, 10:01:32 am » |
Actualy, I now got duino's bootloader running in simavr.
My problem is to redirect the duino's IDE serial port to something I can use. On OSX I have no choice, it only shows "serial ports" and I can't specify a PTY.
Any suggestion ? If I could talk to the bootloader, I could use simavr as a "target board" exactly like a real board, bootloader and all!
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #2 on: December 23, 2009, 06:04:54 pm » |
Pushed a few patches to simavr. I added a "board" called "simduino" that loads a 'duino bootloader into a 328 core and runs it, eventualy timeouts, and "reset" into nothingness.
I also made a virtual UART<->UDP bridge, so soon I will get avrdude talking to the bootloader (via socat) and when I can "program" a firmware uding that bootloader.
I will then need someone at DuinoLand HQ to figure out how to make the IDE talk to me..
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #3 on: December 24, 2009, 07:28:28 am » |
Getting there :> % ./simduino Starting atmega328 - flashend 7fff ramend 08ff e2end 03ff atmega328 init read_ihex_file: ./ATmegaBOOT_168_atmega328.ihex, unsupported check type 03 Booloader 7800: 1950 UART-0 configured to 0010 = 58823 baud uart_udp_xon_hook % socat -d -d PTY UDP:localhost:4321 2009/12/24 11:48:13 socat[14797] N PTY is /dev/pts/10 2009/12/24 11:48:13 socat[14797] N opening connection to AF=2 127.0.0.1:4321 2009/12/24 11:48:13 socat[14797] N successfully connected from local address AF=2 127.0.0.1:39595 % avrdude -p m328p -c arduino -P /dev/pts/10
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e950f
avrdude: safemode: Fuses OK
avrdude done. Thank you.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #4 on: December 24, 2009, 11:39:28 am » |
All working now. I can program a .hex file I made (that just 'exits' the simulator) using avrdude, talking to the Arduino bootloader without /any/ changes. Once programmed, the bootloader verifies, and then jump to the 'app'. So, any if the arduino developers interested ? or is this the wrong board/forum to reach them ? % avrdude -p m328p -c arduino -P /dev/pts/10 -U flash:w:atmega328p_dummy_blinky.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e950f avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed To disable this feature, specify the -D option. avrdude: erasing chip avrdude: reading input file "atmega328p_dummy_blinky.hex" avrdude: input file atmega328p_dummy_blinky.hex auto detected as Intel Hex avrdude: writing flash (394 bytes):
Writing | ################################################## | 100% 0.15s
avrdude: 394 bytes of flash written avrdude: verifying flash memory against atmega328p_dummy_blinky.hex: avrdude: load data flash data from input file atmega328p_dummy_blinky.hex: avrdude: input file atmega328p_dummy_blinky.hex auto detected as Intel Hex avrdude: input file atmega328p_dummy_blinky.hex contains 394 bytes avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.13s
avrdude: verifying ... avrdude: 394 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you. % ./simduino Starting atmega328 - flashend 7fff ramend 08ff e2end 03ff atmega328 init avr_flash_init init SPM 0057 read_ihex_file: ./ATmegaBOOT_168_atmega328.ihex, unsupported check type 03 Booloader 7800: 1950 uart_udp_init bridge on port 4321 UART-0 configured to 0010 = 58823 baud Erasing page 0000 (128) Writing page 0000 (128) Erasing page 0001 (128) Writing page 0001 (128) Erasing page 0002 (128) Writing page 0002 (128) Erasing page 0003 (128) Writing page 0003 (128) simavr: sleeping with interrupts off, quitting gracefully
|
|
|
|
|
Logged
|
|
|
|
|
Sofia, Bulgaria
Offline
Full Member
Karma: 0
Posts: 237
Arduino rocks
|
 |
« Reply #5 on: December 24, 2009, 01:38:43 pm » |
Definitely meaningful effort! And I personally thank you in advance. The idea of the Arduino is to have a hands on experience with hardware and produce physical interactive objects, but more often than not freshmen have troubles starting or worry if they fried something and they don't have another Arduino at hand. So this is one possible scenario for using such an emulator. I think that incorporating one such emulator in the "official" Arduino distribution is more a matter of somebody helping them (the Arduino guys) doing that. And providing support for that later to the community. Once again - thanks for the meaningful effort!!! It's a wonderful gift for the community!
|
|
|
|
« Last Edit: December 24, 2009, 01:39:23 pm by mircho »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #6 on: December 25, 2009, 07:01:26 am » |
Well without the Arduino people getting along it's not going to get anywhere tho.
I probed on IRC, here and on avrfreaks and there's nobody home. So right now I have to shelve this.
Maybe too many people depend on selling arduino boards to welcome a free software simulator ?
|
|
|
|
|
Logged
|
|
|
|
|
Forum Administrator
Cambridge, MA
Offline
Faraday Member
Karma: 7
Posts: 3532
|
 |
« Reply #7 on: December 25, 2009, 11:36:30 am » |
I think you're a bit too suspicious. Maybe we're just busy?
I can't tell what this simulator looks like, or how much it actually does. What is the UI like? What can you do with it? How easy is it to use?
|
|
|
|
|
Logged
|
|
|
|
|
Sofia, Bulgaria
Offline
Full Member
Karma: 0
Posts: 237
Arduino rocks
|
 |
« Reply #8 on: December 25, 2009, 01:53:43 pm » |
As far as my observations go the Arduino is embraced by artsy people (they want to bring life to a previously static object), schools, and professionals that want to sketch quickly an idea, hobbyists that want to make a cat feeder or something similar. In all those cases the real Arduino board is needed. Probably you can simulate the relatively frequent projects where some lights blink - there is a timer(s), ISRs, PWM, pin toggling. But whenever an analog signal is read something more is needed - probably a nice GUI for that simulator and sensor simulation too. Whatever the case if you want to push the use of the simulator you have to "sell" the benefits of it. The guys behind the Arduino project already have hard time finding a way to address somehow in the software, the wiki and forums the most frequent question out there - "Led doesn't blink!!! WTF!!!"
|
|
|
|
|
Logged
|
|
|
|
|
New Zealand
Offline
God Member
Karma: 0
Posts: 999
Arduino pebbles
|
 |
« Reply #9 on: December 25, 2009, 11:11:42 pm » |
I think that incorporating one such emulator in the "official" Arduino distribution is more a matter of somebody helping them (the Arduino guys) doing that. FWIW, as I recall, in that past the Arduino devs have said they don't intend to support an emulator in the IDE as actual hardware is considered an integral part of project. --Philip;
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 76
Arduino rocks
|
 |
« Reply #10 on: December 28, 2009, 04:07:09 pm » |
@busError : Could you write a small tutorial to have this working. I use OS X. I'm very interested.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 5
Arduino rocks
|
 |
« Reply #11 on: January 08, 2010, 10:01:26 am » |
"FWIW, as I recall, in that past the Arduino devs have said they don't intend to support an emulator in the IDE as actual hardware is considered an integral part of project."
That is an extreamly stupid statement for them to make if it is true. Anyone who has programmed micro's knows after the honeymoon you are searching for a way to develop faster without needlessly burning off write cycles. As the arduino provides for much larger programs, the cycle of "make a change, write it, test it, repeat" gets counter productive. (And a good reason people will switch from a stamp, i might add)
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Online
Brattain Member
Karma: 277
Posts: 25544
Solder is electric glue
|
 |
« Reply #12 on: January 08, 2010, 10:16:11 am » |
That is an extreamly stupid statement for them to make if it is true Pot and kettle spring to mind. Anyone who has programmed micro's knows ..... you are searching for a way to develop faster without needlessly burning off write cycles. That way is called thinking about what you are doing. Us old timers learnt to program when you could only physically get one run a day. It made you think before you committed something to code. Therefore the proportion of "right first time" is quite high. As the arduino provides for much larger programs, the cycle of "make a change, write it, test it, repeat" gets counter productive. Ye it does if you don't know what you are doing, the easer it gets the less productive you are. (And a good reason people will switch from a stamp, i might add) By by
|
|
|
|
|
Logged
|
|
|
|
|
United States
Offline
Newbie
Karma: 0
Posts: 1
Sanguino rocks
|
 |
« Reply #13 on: January 02, 2011, 12:20:06 am » |
My problem is to redirect the duino's IDE serial port to something I can use. On OSX I have no choice, it only shows "serial ports" and I can't specify a PTY.
Any suggestion ? If I could talk to the bootloader, I could use simavr as a "target board" exactly like a real board, bootloader and all!
Yes. If everything were working properly on OS X, you would specify valid serial ports in a file named "gnu.io.rxtx.properties". Sadly, this fails on OS X. Happily, there's a fix. If everything were working, the file would live in any of the following locations: - /Users/<Your username here>/Library/Java/Extensions/gnu.io.rxtx.properties
- /Library/Java/Extensions/gnu.io.rxtx.properties
- /System/Library/Java/Extensions/gnu.io.rxtx.properties
- ... and so on.
The file would read something like this: gnu.io.rxtx.SerialPorts=/dev/ttys005:/dev/ttys006:/dev/ttys007
[/list] Mine reads like so: gnu.io.rxtx.SerialPorts=/dev/ttys001:/dev/ttys002:/dev/ttys003:/dev/ttys004:/dev/ttys005:/dev/ttys006:/dev/ttys007:/dev/ttys008:/dev/ttys009:/dev/ttys010:/dev/ttys011 [/tt] On OS X this fails because of bugs in RXTX, a library included with Arduino for OS X. RXTX is an open-source serial-port communication library. Its website is http://rxtx.qbang.org. In Arduino version 0021 for OS X, the part of RXTX that needs to be fixed is the following file. It lives inside of the Arduino application bundle: Arduino.app/Contents/Resources/Java/RXTXcomm.jar
Fixing this file is kind of a pain. The short version: - Download the source code for RXTX version 2.1-7r2. See http://rxtx.qbang.org/wiki/index.php/Download to find the file.
- Patch the file src/RXTXCommDriver.java using the following diff:
--- src/RXTXCommDriver.java.orig 2011-01-01 23:12:47.000000000 -0500 +++ src/RXTXCommDriver.java 2011-01-01 23:36:54.000000000 -0500 @@ -306,13 +306,11 @@ file. If that doesn't exist, then scan for ports. */ for (int PortType=CommPortIdentifier.PORT_SERIAL;PortType<=CommPortIdentifier.PORT_PARALLEL;PortType++) { - if (!registerSpecifiedPorts(PortType)) { - if (!registerKnownPorts(PortType)) { + registerSpecifiedPorts(PortType); + registerKnownPorts(PortType); registerScannedPorts(PortType); } } - } - } private void addSpecifiedPorts(String names, int PortType) { @@ -351,25 +349,36 @@ private boolean registerSpecifiedPorts(int PortType) { String val = null; - - try - { - - String ext_dir=System.getProperty("java.ext.dirs")+System.getProperty("file.separator"); - FileInputStream rxtx_prop=new FileInputStream(ext_dir+"gnu.io.rxtx.properties"); + String ext_dirs = System.getProperty("java.ext.dirs"); + String[] ext_dir_list = ext_dirs.split(":"); + String sep = System.getProperty("file.separator"); + + for (int i = 0; i < ext_dir_list.length; i++){ + String ext_dir = ext_dir_list[i]; + String rxtx_prop_fnam = ext_dir + sep + "gnu.io.rxtx.properties"; + try { + FileInputStream rxtx_prop=new FileInputStream(rxtx_prop_fnam); Properties p=new Properties(); p.load(rxtx_prop); - System.setProperties(p); for (Iterator it = p.keySet().iterator(); it.hasNext();) { String key = (String) it.next(); System.setProperty(key, p.getProperty(key)); - } - }catch(Exception e){ if (debug){ - System.out.println("The file: gnu.io.rxtx.properties doesn't exists."); + System.out.println("Set property " + key + " to " + p.getProperty(key) + " ..."); + }//end if + } + break; + } + catch(Exception e) { + if (debug) { + System.out.println("The file: " + rxtx_prop_fnam + " doesn't exist."); System.out.println(e.toString()); }//end if }//end catch + } + if (debug){ + System.out.println("Loaded properties seems to have worked ..."); + }//end if if (debug) System.out.println("checking for system-known ports of type "+PortType);
- Follow the instructions included with the source code in order to build a new version of RXTXcomm.jar, using the patched version of src/RXTXCommDriver.java. This will probably not work without some hacking, because RXTX is hard to build on OS X. However, if you're able to get RXTXcomm.jar built, don't worry about the rest. RXTXcomm.jar is the only file you'll need.
- Make a backup of Arduino.app/Contents/Resources/Java/RXTXcomm.jar so you can restore it in case Bad Things Happen (don't worry, they will). I back-up by renaming Arduino.app/Contents/Resources/Java/RXTXcomm.jar to Arduino.app/Contents/Resources/Java/RXTXcomm.jar.old.
- Copy the patched version of RXTXcomm.jar into Arduino.app/Contents/Resources/Java/.
- Create the file /Users/<Your username here>/Library/Java/Extensions/gnu.io.rxtx.properties described above.
When you next launch Arduino, your new, custom serial ports should be available. Good luck ...
|
|
|
|
|
Logged
|
|
|
|
|
|