Upload Arduino code on virtual serial port through Arduino IDE - serial-port

I downloaded several software that provide virtual COM ports. These COM ports do appear in the Device Manager and can be selected for upload from the Arduino IDE, menu Tools -> Serial Port -> COM3. It starts uploading and reaches 90% and then it either times out or just does nothing.
I want to upload onto the virtual COM port so I could then read the compilation output files in another program. I don't want to use my Arduino at all, and I don't want to manually get the verbose output files when uploading. This problem doesn't happen when I upload on the real Arduino.
The application should work on all platforms. This task seems easy on Linux, and I am facing the stated problem on Windows and any help with Mac would also be useful.
The application will be an educational tool for hardware simulation and visualization trying to give a more hands-on experience for users than other simulators out there. So may be this will give you an idea of why I want to do so.
How can I get started?

I think you might be assuming that uploading code to Arduino is one-way communications: this would be like putting strawberries in a blender, and a Daquiri comes out. If that was true, you could just take whatever the IDE dumps to the serial port, save it to a file, and you have an Arduino binary. (Skip to TL;DR if not interested in details. Upshot: this assumption is not correct).
The 1-way communication assumption is not entirely correct: there is a program on the Arduino (called "a bootloader") which is responsible for communicating with the programmer ("programmer": a program that programs the Arduino, assume it is the Arduino IDE for now). In their most "natural" state, the Arduino CPUs cannot be programmed across serial lines. Rather these chips are programmed either via the in system programming (ISP) or via the JTAG protocol. The bootloader is a program that runs on an Arduino CPU and loading of sketches/programs over the serial port. This program runs at startup and looks for programming commands over the serial port.
If it discovers that a programmer is trying to communicate programming information, it will read the compiled Arduino binary coming over the serial link, store it in flash memory, send it back to over the serial link for verification, and if everything is successful, exit and launch the stored sketch. If no programming information appears on the serial port, that is, no programmer is trying to write a new sketch, then the bootloader simply quits and launches the program already stored in flash.
TL;DR: In order to implement a pseudo-Arduino on your serial port you must write a program some code that simulates an Arduino (bootloader) on the other end of your virtual serial port. So when a programmer/IDE says to Arduino "are you there?" your program will respond "yes!", just like an Arduino would.
The default Arduino bootloader is STK-500 compatible: that means that it implements STK-500 commands - the reference for which can be found here. If you decide to do this, then the easiest thing might be to start with an existing bootloader, such as Arduino's or AdaFruit's (there are others too), and modify it. Such a bootloader would have all the commands already implemented, and since it is written in C (I wouldn't choose an assembly bootloader to modify :), it should be easy enough to modify.
Alternatively, you might decide that STK-500 is too difficult to implement. If this is the case, you can use any programmer protocol that Avrdude supports: Avrdude is a program for programming AVR chips, and Arduino IDE uses Avrdude internally to send the sketch to the Arduino. If you do this, then you'd have to change the settings in Arduino IDE for which programmer you are using.
Personally, I think STK-500 compatible is the best option for this, but YMMV.

Related

Arduino mega entry point address

I am working on a fresh arduino mega rev3 device.
I want to understand how it works and i need to disassemble flash memory dump.
I have seen that bootloader starts at address 0x3E000
What i want to know now is where does the main program starts in memory.
Thanks
Where the bootloader starts (if it's used) depends on fuse settings. If you have compact bootloader, you can use smaller BOOTSZ. If you're using ICSP header for uploading user program, you don't even need bootloader at all.
Anyway, program starts at 0x0000 on this chip.

arduino as isp and to burn atmega16 using avrdude compiler

I am trying to burn my atmega16 with arduino as ISP. So far the codes have been uploaded to my arduino flawlessly. I have uploaded arduino as ISP codes to my arduino, I have burnt bootloader of atmega16 using arduino IDE. As I sent the core working code from arduino IDE this went flawlessly. But the atmega is not showing the response, i.e. hardware is not working. And that is my (case I) issue. Case II: Furthermore, when I tried sending hex file (core working code) with avrdude compiler, it says ser_open() ... can't find lpt1. Is this the problem of avrdude's compiler? In case II there it didn't even uploaded the code, let alone the working of hardware. Please help.
The fact that it's trying to send it to the LPT1 parallel port suggests you haven't specified "Arduino as ISP" as your programmer. Also make sure you do a Control-Shift-U (upload via programmer) instead of Control-U (upload via the bootloader). Finally keep in mind that uploading code via an external programmer will overwrite the bootloader so you won't be able to upload via USB after that unless you reflash the bootloader or do it via the command line.

Cant upload a boot loader to arduino

Using arduino UNO(mac) i am trying to upload boot loader to the atmega328 where the chip is on a bread board, and connected to the UNO board tx-tx, rx-rx, vcc,gnd ,reset .
So i am trying to upload a boot loader by adding to the boards.txt file the atmega on a breadboard 8mhz , and choose it from boards menu.
than when i try to burn boot loader he says after 0 seconds :
did not find any USB device "usb"
than i change the programmer from - AVR ISP mkii to- AVR ISP
it starts then, and after 6-7 seconds of try he fails saying:
programmer is not responding
I dont know what am i doing wrong, i have also tried with a oscillator,or without it, nothing works.
maybe the fact that its a mac has todo with it ?
To access that portion of memory you need to use the arduino as an ISP (in-system programmer).
The use of USB to program an arduino chip is enabled by the bootloader you are trying to put on.
The usual way is to program a chip directly is using an ISP.
Have a look at the setup here:
http://arduino.cc/en/Tutorial/ArduinoISP
Another good resource for an advanced build is this:
How to Build an AVR Development Board: http://youtu.be/ncobWc61wL4
He explains what he is doing as he goes so it is really easy to follow and he talks about the programming process.

Serial Output to Arduino LED Display

I recently completed this project with my Arduino (a fairly new hobby for me):
http://www.instructables.com/id/Make-a-24X6-LED-matrix/?ALLSTEPS
I can change the code to make whatever messages I want scroll accross the matrix but I thought it might be cool to have live information, like stock quotes, scroll accross. I think I could figure out how to do that except I would like to use it at work where there are lots of firewalls in place and I doubt Arduino software is on the approved list of programs. Is it possible to send messages to the Arduino through a USB without installing any drivers?
No it is impossible because data in Arduino is sent via serial command, the USB is only for convenience, but arduino work with FTD driver that emulate a serial connection. You should choose another type of connection bluetooth or wifi.
Hope this help you.

How to send/receive serial communication

How can I send a string via serial communications from Java or Python? I have a very little arduino program that will recieve a CSV string of ints that each control different relays (I adapted it from their example).
I just got an Arduino, and I am trying to use it to open and close a relay remotely. I have it opening and closing the relay, no problem. But I really have no idea where to start as far as using serial communication.
I have a bluetooth dongle that I can connect to, but once I do that I'm lost.
Also, this is my first time using serial communications AND my first time using an Arduino. So I'm sorry if I am completely off on some of the things I am asking. All I know is what I've learned from Google.
Thank you very much
You can use any Java or Python serial port classes and methods. There is however one thing you need to be aware of.
The newer arduino's have a feature known as AutoReset. This works by connecting the DTR signal from the serial port to the Reset line on the chip using a capacitor or such. The IDE uses this to reset the board to activate the bootloader and initiate uploading code to the arduino. The serial monitor in the IDE is aware of this and does not toggle the DTR line when comunicating with the device (except when it initially connects).
There is are several ways to defeat this feature and you can read about them here.
As for actually comunicating with the device, there are several tutorials about serial communication in both Java and Python.
Pyserial includes the option to not use the DTR lines when opening a port.
Here is a website explaining how to use RXTX (a Java library) to comunicate with an Arduino
Best of luck.

Resources