Sketch Upload

All distros
PaulRB
Posts: 21
Joined: Tue Apr 28, 2015 1:15 pm
Location: West Yorkshire, UK

Sketch Upload

Post by PaulRB » Mon Jun 15, 2015 9:55 pm

Hi all,

I have Arduino 1.6.5 running OK on Ubuntu 14.04 and uploading to Maple Mini.

As I have not been working much on the Maple recently, I would like to ask a couple of questions:

1. Is there any way to have auto-reset work for the Maple like it does for other Ardunino boards, so that its not neccessary to set the Maple to Perpetual Bootloader Mode before sketch upload, and then perform manual reset after sketch upload to start the sketch running?

2. How long are other Linux users finding that the upload process takes with DFU? Even a simple sketch takes ~10 seconds for me. Is that normal? (output below)

Code: Select all

Sketch uses 12,556 bytes (11%) of program storage space. Maximum is 110,592 bytes.
Global variables use 3,104 bytes of dynamic memory.
dfu-util 0.8
dfu-util: Invalid DFU suffix signature

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Opening DFU capable USB device...
ID 1eaf:0003
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #1 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
Copying data from PC to DFU device

Download	[                         ]   0%            0 bytes
Download	[=                        ]   7%         1024 bytes
Download	[===                      ]  15%         2048 bytes
Download	[=====                    ]  22%         3072 bytes
Download	[=======                  ]  30%         4096 bytes
Download	[=========                ]  37%         5120 bytes
Download	[===========              ]  45%         6144 bytes
Download	[=============            ]  52%         7168 bytes
Download	[===============          ]  60%         8192 bytes
Download	[================         ]  67%         9216 bytes
Download	[==================       ]  75%        10240 bytes
Download	[====================     ]  82%        11264 bytes
Download	[======================   ]  90%        12288 bytes
Download	[======================== ]  97%        12556 bytes
Download	[=========================] 100%        12556 bytes
Download done.
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
3. Direct port manipulation on Maple - can someone point me to a good guide?

Thanks everyone.

Paul

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Sketch Upload

Post by RogerClark » Mon Jun 15, 2015 10:11 pm

Paul

Have you tried using the new bootloader. AKIK, upload speeds are now faster.

Re: auto reset

I'm sure I posted about this issue for OSX but its basically the same.

The upload script just resets the USB device but this is not enough to cause the USB code on the board to reset into the bootloader (the code that does this is part of the sketch).

Basically, the USB serial code looks for DTR being toggled and a special sequence of chars being sent. ( something like "LEAFLABS")

On windows this is done in a jar file to which we don't have the source :-(

But I should be fairly trivial to write a small executable for both Linux and OSX that sets DTR and sends that sequence.

I don't generally use OSX or Linux, so I am not an expert in writing code to control a serial device, but I know there are other people like Rick and Andy who are Linux whiz kids who could probably point us in the right direction . The problem is that neither rick not andy use the Maple mini.

peppeve
Posts: 20
Joined: Sat Jul 25, 2015 9:01 am

Re: Sketch Upload

Post by peppeve » Fri Aug 14, 2015 6:12 am

Same problem on my Ubuntu, perpetual mode for sketch upload and reset after upload. Very boring.

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Sketch Upload

Post by RogerClark » Fri Aug 14, 2015 6:27 am

This is supposed to be fixed now.

there is a utility called upload_reset which gets passed the com port of the board, and it sends the magic reset sequence,

I'm sure I've posted the instructions in another thread, but...

open a terminal window
Go to /tools/linux

Code: Select all

run ./upload_reset YOUR_COM_DEVICE 750
This should reset the device.

If not you should get an error message.

I presume you have run the install script in /tools/linux which sets the udev rules etc

Anyway, let me know if you an manually run upload_reset or whether it doesnt work or you get an error

PS. the 750 at the end is a delay for USB - re-enumeration

If the board resets but you can't upload, I have had reports about some machines taking too long to re-enumerate the USB bus becuase the Maple is connected via a USB hub, Can you confirm its directly connected to your machine?

enif
Posts: 32
Joined: Wed Jul 29, 2015 4:49 pm
Location: Switzerland
Contact:

Re: Sketch Upload

Post by enif » Sat Aug 15, 2015 12:07 pm

I also had always to go to perpetual mode before uploading, but the actual upload was then very quick (<1sec for small sketches).

Today, I finally discovered that it was still using an old version of Arduino_STM32 which was still lying in ~/sketchbook/hardware, while my new version was in the arduino-1.6.5/hardware directory :(

After removing the old version, the upload-reset would now work well when setting port to /dev/ttyACM0. But I also noted that the upload was much slower (13sec for the same sketch). As it turns out, the old (fast) version called Ubuntu's own dfu-util, while the new (slow) version would use the dfu-util in Arduino_STM32/tools/linux/dfu-util. So after changing maple_upload in the new version to call /usr/bin/dfu-util it got fast again.

The only problem which remained, was that I still had to push reset manually after each upload. That was solved when adding the option -R to the dfu-util call at the end of the maple_upload script. The Maple Mini now automatically resets after the upload has finished.

fredbox
Posts: 95
Joined: Tue Jul 07, 2015 4:44 pm

Re: Sketch Upload

Post by fredbox » Sat Aug 15, 2015 8:04 pm

The only problem which remained, was that I still had to push reset manually after each upload. That was solved when adding the option -R to the dfu-util call at the end of the maple_upload script. The Maple Mini now automatically resets after the upload has finished.
I was having the same problem needing to manually reset the board after each upload. Adding -R to line 40 of maple_upload fixed it.

Code: Select all

${DFU_UTIL} -d ${usbID} -a ${altID} -D ${binfile} ${dfuse_addr} -R

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Sketch Upload

Post by RogerClark » Sat Aug 15, 2015 9:27 pm

Guys

I wasnt aware that the reset was missing from the end of the dfu util command line

I will update the repo.

Its interesting that Ubuntus version of dfu util is faster, AFIK the version that we have was built from the latest sources.

Also, if you have not already done this, I'd recommend you update to the new bootloader, it is faster than the old one.
There is an updater sketch, for the Maple mini in the stm32duino-bootloader repo ( use at your own risk, but it seems really stable and no one has reported having any problems with it before)

User avatar
RogerClark
Posts: 7482
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Sketch Upload

Post by RogerClark » Sun Aug 16, 2015 10:46 pm

OK

Those changes should no be in the repo

wyzarddoc
Posts: 5
Joined: Sun Nov 29, 2015 8:52 pm

Re: Sketch Upload

Post by wyzarddoc » Sun Jan 31, 2016 6:30 pm

Hi All;
Updated to linux mint 17.3 64bit and now I am having a strange problem

java.io.IOException: Cannot run program "/home/doc/Arduino/hardware/Arduino_STM32/tools/linux/maple_upload": error=13, Permission denied
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
at java.lang.Runtime.exec(Runtime.java:620)
at java.lang.Runtime.exec(Runtime.java:485)
at processing.app.helpers.ProcessUtils.exec(ProcessUtils.java:11)
at cc.arduino.packages.Uploader.executeUploadCommand(Uploader.java:115)
at cc.arduino.packages.uploaders.SerialUploader.uploadUsingPreferences(SerialUploader.java:159)
at processing.app.debug.Compiler.upload(Compiler.java:166)
at processing.app.Sketch.upload(Sketch.java:1167)
at processing.app.Sketch.exportApplet(Sketch.java:1141)
at processing.app.Sketch.exportApplet(Sketch.java:1113)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2380)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: error=13, Permission denied
at java.lang.UNIXProcess.forkAndExec(Native Method)
at java.lang.UNIXProcess.<init>(UNIXProcess.java:248)
at java.lang.ProcessImpl.start(ProcessImpl.java:134)
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029)
... 11 more
I have reset permissions on each file I think it maybe the arduino user/group assignments? IDE works great on mega2650 etc but not stm.
blink compiles ok but it's the upload that causes the problem.
any help would be appreciated
thanks
Doc

User avatar
Rintin
Posts: 16
Joined: Sat Jan 23, 2016 11:20 am

Re: Sketch Upload

Post by Rintin » Sun Jan 31, 2016 6:41 pm

Does the file (maple_upload) exist at that location?
Is it marked as executable?

Please open a terminal and type:
ls -la /home/doc/Arduino/hardware/Arduino_STM32/tools/linux/
and post the output here.
#legalizeawoo

Post Reply