Use Arduino programmer modes to upload code on virtual COM port - com

This question is related to Upload Arduino code on virtual serial port through Arduino IDE. The main problem is being able to upload code onto virtual COM port instead of using Arduino so I could take the binary code output and use it in some other application. The problem with that is that the process of uploading is also related to the bootloader on the Arduino and that's why the upload process never reaches 100%. The suggested solution was either to implement a bootloader in my application or use something that is already out there.
My question now is can I make use of the different programmer modes in the Arduino IDE to sort of by-pass the bootloader so the upload process can reach 100% and the code would actually reach the virtual COM port?
Any help would be highly appreciated. Thanks

Sounds like your Virtual Serial Port driver is getting stuck on some timeouts or buffers. The IDE calls avrdude with a specific protocol to match with what is built into the Arduino's bootloader, loaded on the AVR. There are other bootloader (in fact many, too many to mention), some of which may have different timing and such, but to use them would basically no longer be Arduino. to see the possibilities .\avrdude.exe -c.
If you are just trying to get a dump of what is going over the Serial port. I have used Virtual Serial Ports Emulator . It is very versatile in that its modular, allowing you to build up what you want.
Also, as mentioned from the other threads about this, note the data over the serial port is formated ontop of the STK500 protocol. You also mention in other thread that you don't want to use another tool to get the data. Whereas in order to use another protocol you would need to change the source compiler.java and rebuild the project as to call avrdude with the new protocol. So you might as well just get it with another tool. see below this will tie back in.
you can get the raw binary, from what is being fed to avrdude. Where as it may not be initially obvious. As avrdude get ELF not BIN. The Arduino IDE contains all of avr-gcc and its tools. Where avr-objcopy located in .\Arduino\hardware\tools\avr\bin can convert the IDE's output that is funneled into avrdude, to the binary you likely desire. No need for scoping the serial port stream.
To do this by hand, You need to locate IDE's temp working directory, by enabling the IDE's verbose compile prints. And also likely put avr-objcopy in your path. then simply call it as in the below example, substituting your sketch's filename, in place of mine.
C:\Users\mflaga\AppData\Local\Temp\build6135656488044319492.tmp>avr-objcopy -I ihex FilePlayer.cpp.hex -O binary FilePlayer.cpp.bin
Where as you could replace avrdude.exe with a batchfile that calls both avrdude and avr-objcopy to automat

Related

Question about transferring files to ARM Linux in Gem5 full-system mode

I was running Linux in an ARM-based detailed CPU model in FS mode, and I was doing the checkpoint after the first time I launched the CPU. However, I needed to frequently transfer files to the ARM Linux, so I am wondering if there is any way to do so without re-launching the CPU model again (e.g., directly transfer files to linux through sftp, or mounting the host file system)? Great thanks!
Currently, I just added the files to the Linux disk image, and relaunched the CPU model from scratch (which takes more than 1.5 hours).
Here are the possibilities that I'm aware of:
use 9P. Semi outdated patch at: http://gem5.org/WA-gem5 but easy to get working again.
9P is designed explicitly to mount host directories on guest, and is therefore the nicest solution.
See also: https://github.com/cirosantilli2/gem5-issues/issues/24
QEMU example.
use a second disk image, normally squashfs which is easy to generate quickly and conveniently.
unmount, make changes to image, remount. So a bit annoying, but doable, and possibly the easiest to get working.
Not currently exposed on fs.py, patch mentioned at: How to attach multiple disk images in a simulation with gem5 fs.py?
m5 readfile + zip.
OK, this is likely going to be slow, just mentioning it ;-)
guest to host networking: as you mentioned, if that were possible, you could mount FTPs around
However I don't think it is supported, see: How to do port forwarding from guest to host and vice versa in gem5?
Also it would require messing with NFS setups on host / guest, which is always a bad thing.
With QEMU, as usual, it is possible.
The current situation is a mess. The main reason is that it is a bit hard to nicely integrate 9P / multidisk into fs.py. But I'm certain it is possible, we just need a brave soul.
Related thread about how to expand an existing disk image if space is your concern: https://www.mail-archive.com/gem5-users#gem5.org/msg16494.html
Mailing list thread: https://www.mail-archive.com/gem5-users#gem5.org/msg16477.html

Connecting to tty port through C++ fails unless you've connected through screen first

I picked up an AUPS-A10-R11 DC UPS, and am working with their API to build some monitoring software for my xen host. Their API runs over the USB connection on the device, which presents itself as /dev/ttyUSB# on the host.
I've got things working fine except for one thing that's puzzling me. When I first power on or reboot the host it's connected to, I can't communicate with the device. However, if I open up a screen connection to it:
screen /dev/ttyUSB0 9600
and then close it (ctrl+a, k) then it will work perfectly fine until the next time that you reboot the host.
Does anyone have any idea as to why I would have to connect to the device over screen first? I've pasted my code here: http://susepaste.org/0b8bb37f . When connecting on a fresh reboot, it stops at the "Read Nothing" section of the if...else clause. After connecting to the device with screen, it works fine.
Any thoughts??
Does anyone have any idea as to why I would have to connect to the device over screen first?
Such behavior is almost always related to incomplete termios initialization by your program.
The ideal program would configure a serial terminal for its purposes, and on exit restore the termios configuration back to the way it found it.
But most programs, including terminal emulation programs such as minicom and apparently screen, simply leave their termios configuration instead of restoring it.
Fortunately for you, this leftover termios configuration fills in the missing pieces that allows your program to access the serial terminal as expected.
Review of "your" code suggests that it was copied from the accepted answer of this question. Based on the number of up-votes, this code apparently works for a lot of people. However the author admits it was written before POSIX standards, and therefore the code should not be considered portable. In other words, your mileage may vary.
Apparently you overlooked the alternative answer which is POSIX compliant. A tested termios configuration for blocking non-canonical mode is in that program.
If you prefer to simplify with the use of the cfmakeraw() macro, then here's another code example.

Getting the contents of Arduino's flash memory back

I have a code burned on Arduino uno and I want to get the hex file of this code back?!
How can I make that ?!
On this forum it says you can extract the code from the Arduino to your computer but it will be in executable code which you cannot edit (it would probably be faster to rewrite the program)
http://forum.arduino.cc/index.php/topic,48218.0.html
You can read-out flash from an AVR via the ISP (if it has not been disabled) if you have suitable hardware/software. You can build the hardware using another Arduino, use "avrisp" as the ISP interface device ID in avrdude.
Do not disable the power to the AVR's SPI port - this will also disable the ISP interface (same pins), and lock you out permanently if you don't have a working bootloader to load code to re-enable again!

GPRS and GPS on embedded Linux

I've got an embedded linux and a Telit gprs/gps module ("GM862-GPS" on USB-Port). My current project requires it to be connected via gprs for sending data, while continuously asking the module for the gps position. I'm connected to gprs with a ppp-daemon and chatsripts, but when the connection is established, the module seems to be locked (no reaction on AT-commands through minicom).
I read, that 'AT+CMUX' could be one solution, which is provided by this device, but I don't know how to use it, since the 'CMUX User Guide' by Telit isn't really helpfull (and a program for automatic setup is only provided for windows).
Does anyone know, how to deal with this command, or even knows a better choice to handle this problem ?
My answer might be too late.
You need to use CMUX to create another COM port to talk to it. I played with CMUX once and I understand your frustrations. In my case, it worked for a while and then failed and I couldn't find out why. You might want to post your question at Roundsolutions.
I programmed the module by writing Python scripts and upload to the module. Their Python API provides two channels to send AT commands to the module: MDM and MDM2. I use MDM as the AT command and use MDM2 to create sockets. Initially, you use MDM2 to send AT commands to create a socket connection. Once connected, whatever data sent to it will be interpreted as data stream instead of AT commands. They allow you to send '+++' to switch back to AT command mode.

What's the best way to spy on IOCTLs?

I have a U9 Telit modem which, at first, appears as a disk drive on USB bus. Then, the native software after autorun and install, sends a couple of IOCTLs to tell the device to reappear as other things. I can see them in procmon.
I want to better spy on these, to know exactly what they send and how, in order to do the same in proper way.
Try something like Systemtap. Attach a probe that dumps all ioctls and arguments from the kernel, grep through them.
You could use something like strace under linux. The windows equivalent is discussed here Systrace for Windows.
This might show you the ioctl commands sent.
Some companies offer the linux kernels of their devices as direct download from their official webpage. There you might find more information on how it works. For some devices, it's easy to build and deploy your own kernel. This helps as you can add custom debug output.