Robot-Will / Stino

A Sublime Text Plugin for Arduino
Other
1.58k stars 249 forks source link

'Upload by Using Programmer' greyed-out #190

Closed techydude closed 9 years ago

techydude commented 9 years ago

new-stino is a wonderful update to Stino, thank you Will! wondering how I can get the ability to use my Atmel AVR ISP mkII programmer option available?

Robot-Will commented 9 years ago

Hi, Thanks for your support. Would you please tell me more about your problem.

techydude commented 9 years ago

the 'Upload by Using Programmer' item in your Arduino menu is greyed-out:

screen shot 2014-11-18 at 2 58 07 pm

background: This is the first time I've tried using Stino 'for real', as the previous (still 'master') version didn't properly support additional cores defined in your 'Arduino'/hardware/ folder, but it does now, so I'm anxious to ditch the Arduino IDE :)

ubidefeo commented 9 years ago

hey @techydude to use a programmer you need to create an entry in the programmers.txt inside Arduino's folder [...]Java/Hardware/arduino/avr/programmers.txt

depending on the programmer you use (bare AVR converted to ISP or Dragon and the likes), you need to change the port (-p) or the protocol.

for Dragon go with -Pusb, but if it's a custom ISP you may have to go with -P{serial.port

avrispmkii.name=AVRISP mkII
avrispmkii.communication=usb
avrispmkii.protocol=stk500v2
avrispmkii.program.protocol=stk500v2
avrispmkii.program.tool=avrdude
avrispmkii.program.extra_params=-P{serial.port}

[ TEST pending ]: do not rely too much on this configuration [edited to fix avrispmkii.communication]

techydude commented 9 years ago

the first 3 lines were there (amongst entries for several other programmers), but the second 3 lines weren't. added them. restarted Sublime. still doesn't make the menu item appear.

ubidefeo commented 9 years ago

what programmer do you use?

techydude commented 9 years ago

OP: Atmel AVR ISP mkII

ubidefeo commented 9 years ago

sorry, my bad: for that one you may have to

avrispmkii.communication=serial

remember to first select the serial port :)

techydude commented 9 years ago

actually I didn't notice your 'avrispmkii.communication=serial' line actually said 'serial' instead of 'usb', because the Atmel AVRISM mkII does connect via USB, & my programmers.txt already had 'usb', & which works fine in the Arduino 1.0.6 IDE when I do + Upload... no?

ubidefeo commented 9 years ago

I updated the programmer description as I thought that would be the issue. sorry, did this a long ago, before getting a Dragon. let me look into it using my old hacked arduino NG

as far as I remember, Atmel's programmers communicate at a lower level, not through augmented TTL serial, so the -P has to state usb and so does the communication option.

will get back to you as soon as I get my old ISP setup. I accidentally deleted that old version of Arduino.app where I had configured the programmer correctly. will poke that thing around and let you know :)

ubidefeo commented 9 years ago

ok, I've connected my hacked NG

this is my configuration entry in the programmers.txt

avrispmkii.name=AVRISPmkII ubi
avrispmkii.communication=usb
avrispmkii.protocol=stk500v2
avrispmkii.program.protocol=stk500v2
avrispmkii.program.tool=avrdude
avrispmkii.program.extra_params=-P{serial.port}

I don't have boards with an ISP around right now, but I don't get failure upon trying, just the timeout for the missing microcontroller. as I get to my lab I'll have plenty of boards to test this with, but try yourself if you have time. I had missed the -P before {serial.port} too. I'm updating my entry above now.

techydude commented 9 years ago

but my problem is that the 'Upload by Using Programmer' menu option in Stino's 'Arduino' menu isn't even there!

ubidefeo commented 9 years ago

I just noticed you don't have a Programmer item in your menu. sorry, really underlooked there I'm not sure why it won't appear for you, it should be right above Burn Bootloader I can see you have several boards types showing up, which means you've properly selected the Arduino app. for me it shows up in both 1.0.5 and 1.5.8b(rc3). which version are you using?

techydude commented 9 years ago

clarification: the menu isn't isn't gone, just greyed out. per attached pic. 1.0.6. & Sublime Text 3 (3065), in a relatively un-customised state, other than a skin.

ubidefeo commented 9 years ago

I'm on ST2, check the extra menu item I have. it allows me to select any of the programmers listed in programmers.txt and sets them as variables to get avrdude params screen shot 2014-11-18 at 10 24 33

techydude commented 9 years ago

plot thickens. i completely uninstalled ST2 & ST3 & all related config files (Application Support, prefs, etc), downloaded new v2 & v3, reinstalled ST license, then followed the instructions to install Package Control, and then 'Arduino-like IDE', which gets you the 'old' Stino. That gave me the same Arduino menu, STILL with greyed-out 'Upload with Using Programmer' menu item, and no 'Programmer' menu item. In other words, back where I started.

At this stage (with just the 'old' Stino installed), the Stino plug-in is located in "%user%/Library/Application Support/Sublime Text 3/Packages/Arduino-like IDE".

So then I went back & re-read the repo's readme.md, & noticed it said to put the new 'new-stino' build into a different folder, "Stino" for me, "Stino-master" for the screenshots in Readme.md). Previously I'd completely deleted .../Arduino-like IDE/. & then copied in .../Stino. Thilly me. In another of my attempts I over-wrote .../Arduino-like IDE/. with the contents of 'new-stino; with equally unstable results ;). But it begs the question - how does old-Stino know where to look for the new-stino stuff? so confusing...

OK, so now I think I've got 'new-stino' installed in a way that appears to be being recognised by Stino, because now I have a 'double-whammy' Arduino menu, including 'Upload with Using Programmer' menu & 'Programmers' menu, in which I've ticked 'AVRISPmkII'. The 1st set of entries appear to be the old Stino, and the lower set of menu entries appear to be the new Stino menu items!

Now I can compile, but "Upload with Using Programmer" bombs out with an AVRDUDE error: "avrdude: invalid baud rate specified '{upload.speed}' ". Baud rate doesn't seem to make much sense in the context of a USB-connected 'AVRISP mkII' programmer.

So i searched on "{upload.speed}", & it's in platform_avr.txt located in new-stino. It appears to be a section of the file to do with Uploading to a target which has a boot-loader (i.e. your typical Arduino board): a few lines starting with "tools.avrdude.upload.".

My hunch is, when using a programmer like AVRISPmkII (& any others based on the STK500v2 protocol), Stino should be using/calling the set of lines starting with "tools.avrdude.program.", but it's not.

And again, this seems to relate to my earlier greyed-out 'Upload with Using Programmer' menu item...

Arduino Menu, & error screenshot attached: screen shot 2014-11-18 at 11 37 04 pm

screen shot 2014-11-18 at 11 22 09 pm

Robot-Will commented 9 years ago

Hi @techydude, your menu is not correct. I think you should install new stino correctly.

  1. Menu Preferences -> Package Control, click Package Control: Remove Package, remove all installed Stino (Arduino-like IDE) packages. Now, the Arduino menu disappears.
  2. Menu Preferences -> Browse Packages..., open the packages folder.
  3. Download the new-stino zip file and extract the folder in the zip file to the packages folder. And the Arduino menu appears. The Arduino menu should be like @ubidefeo's.

Then if there are still problems, leave messages here and I will help you. Thanks.

ubidefeo commented 9 years ago

@techydude that will definitely disable the menu from old-STino @Robot-Will , I have a doubt. my menu has the programmer submenu, but not the Select Build Folder, and @techydude seems to miss the programmer menu. maybe something in the menu build leaves something behind? an iterator losing some stuff? just guessing, haven't looked at the code screen shot 2014-11-18 at 16 40 36

Robot-Will commented 9 years ago

Hi @ubidefeo, you will find the Select Build Folder in Build Options.

In previous version, it was in Preferences and now it is in Build Options. Thanks.

techydude commented 9 years ago

ok, getting somewhere now. i see you updated the readme.md to clarify that 'old Stino' needs to be disabled/removed first :p I now have the correct menu for new-stino. However I'm still getting the AVRDUDE upload error: screen shot 2014-11-19 at 8 38 53 am

ubidefeo commented 9 years ago

@techydude , have you tested using simple command line? I never really use -b, often I've seen it set at 115200. can you try adding an extra flag for -b? it's 6am, as soon as I wake up properly I'm gonna give this a go :D do you finally get the programmer menu item?

techydude commented 9 years ago

yes, I have the Programmer menu item, & have ticked the 'AVRISP mkII'. no i've not tested avrdude @ cmd line (that's why I use Arduino ;), but it does work in Arduino 1.0.6 fine.

how do I "adding an extra flag for -b" ?

AFAIK, in platform_avr.txt: tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

...shouldn't be being called?

this line should be called instead: tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i" ...yes?

gonzoid commented 9 years ago

@ubidefeo Flashing chips early in the morning? You sure like to live dangerously! :p

@techydude You can add an extra flag in the menu Build Options > Extra Flags but I think it's only used for compilation.

I wondered what was the difference between Upload and Upload by Using Programmer and as it happens, it is exactly related to what you pointed out in your post. This is explained in the Arduino wiki. For reference, here is a thread of the Arduino forum about the same matter.

ubidefeo commented 9 years ago

@gonzoid I think aging is making it worse :D hope this weekend with my gf on holiday I can manage to re-read this whole thread and make some sense out of it.

ubidefeo commented 9 years ago

hey @gonzoid I've finally retrieved my ISP and bare AVR chip to test in a clean way. I have no issues uploading (I don't have a BootLoader on my chip, now), I just needed to properly configure the entry for the programmer and it worked like a charm.

avrispmkii.name=AVRISPmkII ubi
avrispmkii.communication=usb
avrispmkii.protocol=stk500v2
avrispmkii.program.protocol=stk500v2
avrispmkii.program.tool=avrdude
avrispmkii.program.extra_params=-P{serial.port}
Robot-Will commented 9 years ago

Hi @techydude, upload by programmer should be this pattern: tools.avrdude.program.pattern="{cmd.path}" "-C{config.path}" {program.verbose} -p{build.mcu} -c{protocol} {program.extra_params} "-Uflash:w:{build.path}/{build.project_name}.hex:i"

and your message showed this pattern: tools.avrdude.upload.pattern="{cmd.path}" "-C{config.path}" {upload.verbose} -p{build.mcu} -c{upload.protocol} -P{serial.port} -b{upload.speed} -D "-Uflash:w:{build.path}/{build.project_name}.hex:i"

I do not know why. I got the right command: "G:\creative\arduino-1.0.6/hardware/tools/avr/bin/avrdude" "-CG:\creative\arduino-1.0.6/hardware/tools/avr/etc/avrdude.conf" -v -v -v -v -patmega328p -cstk500v2 -Pusb "-Uflash:w:D:\test\Blink/Blink.hex:i"

techydude commented 9 years ago

confusion:

the "tools.avrdude.upload.pattern=" line is what IS being called, which means it's instructing AVRDUDE to upload via a bootlaoder.

but i'm NOT using a bootloader, I'm programming directly via an AVRISP mkII device programmer (like @ubidefeo described above), & in ST3:Stino's Arduino menu when I click "Upload by Using Programmer", the AVRDUDE cmd line error suggests Stino is calling the tools.avrdude.upload.pattern=" line instead of "tools.avrdude.program.pattern="

re: link to Arduino wiki about 'platform.txt', that's in relation to Arduino 1.5.x. I'm using 1.0.6. re: link to Arduino forum, that person just doesn't understand what 'Upload using Programmer' is supposed to do :)

ubidefeo commented 9 years ago

@techydude , do you still have a bootloader on your Arduino even if you don't use it? if so then you have to deal with BOOTSZ and BOOTRST you can find some info on google or here

AVRFuses also comes in handy if you don't want to deal with command-line avrdude (which will always be my preferred way to do things, by the way) and do the Binary > HEX conversion yourself, especially because 1 = clear and 0 = set, some bits are reserved and many more things (I've read big chunks of the ATMega*8 datasheet... the 448 pages one). it can mess with your sense of human logic :D

you may already know this, but I don't know how advanced your knowledge of AVR is. I've been playing with them since 2007/8 or so. I'm not an expert in any way, but I like these little chips enough to wanting to know them better. besides, they're the best thing to understand low level code and have been helping me craft some interesting teaching methods :)

techydude commented 9 years ago

This is my own PCB with an ATtiny (which were assembled completely unprogrammed), NO bootloader needed (not the least of which is because there is no USB i/f for uploading anyway!), and this works fine under plain Arduino 1.0.5, 1.0.6 using 'Shift + Upload', it's just in Stino that it's trying to upload via a bootloader instead of program using the AVRISMmkII programmer.

Yeah I used another website for the fuses (http://www.engbedded.com/fusecalc/) which makes getting the entries in boards.txt right & much easier!

ubidefeo commented 9 years ago

@techydude refreshing :) I'm gonna give a shot at ST3 (ST2 has the warm feeling of not being in Beta).

I may have asked this already, but this thread is getting longer and longer: have you tried command line programming just to be sure you can get anything on that chip?

ubidefeo commented 9 years ago

I installed ST3 and the first question I have is: will this work with ST3? haven't been able to get it installed

techydude commented 9 years ago

[major revelation below, but answering questions in order:] No I haven't done the cmd-line call of avrdude myself, because the Arduino IDE does it for me ;), and it works :). When Stino does it, it appears to be calling upload-via-bootloader, instead of program-via-programmer method.

But it seems the issue is something at my end, if it's working fine for both you & RobotWill :-(

So this pushes me to consider something that might be 'unique' to my situation (but not all that unique really): When you 'Upload by Using Programmer', whether it's in the Arduino IDE or in ST:Stino, are you programming standard Arduino boards, or something custom of your own?

Because I'm programming PCBs of my own, using 3rd-party hardware/core add-ons that support the ATtiny range of chips, & the AT90USB(646/647/1286/1287) range. The ATtiny core is located in my %user%/Arduino/hardware folder (just like user-added Arduino libraries are stored in user/Arduino/libraries), however the AT90USBxxxx cores are actually stored in the Arduino 1.0.6 app itself (because Teensy (pjrc.com) adds support for them 'built in' when you install Teensyduino).

Both of these compile & upload fine with Arduino IDE 1.0.x, via USB for the Teensy stuff, & via the Atmel AVRISP mkII programer for my ATtiny & AT90USBxxxx -based PCBs.

But until now, I've only been compiling & trying to program (via AVRISPmkII) to the ATtiny-based PCB. So I just tried programming the AT90USBxxxx-based PCB with ST:Stino, but it wouldn't even compile, with weird compile errors.

So then I grabbed a Teensy 2.0 PCB and connected it via USB & tried to upload a sketch to it, and it got the same compile error as for my own custom AT90USBxxxx.

So then I grabbed a bog-standard Arduino Uno & uploaded the example blink sketch - all OK. Then I programmed it via AVRISPmkII, all OK, then re-programmed the bootloader onto it, & then uploaded a new sketch via USB. All OK.

Basically, Stino only seems to be working with 'bog-standard' Arduino PCBs? Are "custom" Arduino boards a 'corner case' not (yet) supported by Stino? What do you think, @Robot-Will ?

ubidefeo commented 9 years ago

@techydude one more question out of what you just wrote: did you create a custom board entry for your setup?

techydude commented 9 years ago

yes, added my own entries to boards.txt. and these work under 1.0.5 & 1.0.6. 2 different boards.txt actually, one for the AT90USBxxxx-based stuff that Teensy sets up, and one for the ATtiny hardware/core library.

& original/old Stino is said to work for both ST2 & ST3, so I'm assuming new-Stino is as well?

ubidefeo commented 9 years ago

your issue is driving me insane :D what can the issue be???

techydude commented 9 years ago

oh I lost all sanity many years ago, it's a much more realistic response to the real world ;)

so what are you uploading/programming - standard Arduino boards only, or something of your own?

given that Stino appears not to be working for any 'non-Arduino-standard'board, not even ones like the Teensy that ostensibly should work as they're well proven in Arduinoland (i.e. it's not like there's something odd I've got set up that truly is unique to me), I'm guessing Stino just doesn't yet support anything other than standard Arduino boards?

techydude commented 9 years ago

...and there is this related issue: https://github.com/Robot-Will/Stino/issues/142 ...with the work-around being adding a symlink "from the cores folder provided by the Arduino application to a cores folder in your hardware sub folder". But Teensy is already installed in the Arduino app's /hardware folder, and that's not working either. Nor are my hardware/core setups that are already located inside the Arduino app. So I think the problem goes deeper...

Robot-Will commented 9 years ago

Hi @techydude , I found something wrong and fixed some problems. I think this problem is due to the judgement error in arduino_uploader.py line 107.

Just calm down. I am just a chemist and not an EE engineer or a software developer, and I try my best to make this plugin better. Without official documents and without boards, I tried to make this plugin supports more boards, but it is not easy. It needs a lot of time and finally no test (I have no such boards). The 3rd-party non-Arduino-standard board developer provides a software for Arduino IDE and it works fine in Arduino IDE, but I do not know how it works. Nobody tells me.

The two files in preset folder (platform_teensy.txt amd platform_teensy3.txt) are for compiling Teensy boards, but the two files are not finished. You can revise the files to make them work. Thanks.

ubidefeo commented 9 years ago

@Robot-Will you're doing an amazing job. it's the main reason why we enjoy finding solutions to bugs, or helping track them down :)

keep the great work. we're so happy we don't have to deal with the Arduino IDE :D

techydude commented 9 years ago

hey @Robot-Will, oh please don't think what I've said or the way I've said it has been frustrated or angry AT YOU, or anything like that, I apologise if I sounded that way. I'm very aware you're not an EE or software dev, and the only reason I've stuck with this issue, and with this latest new-Stino, is that Stino is an awesome tool, and I'd like to help make it better & help solve these issues.

and about that lack of documentation in Arduino & the other 3rd-party add-ons for it, I know exactly what you mean. i've lost count of how many DAYS I've put into getting Arduino IDE to work with non-Arduino-standard boards/chips over the past year, dealing with half-baked code - and that's with the help of 3rd-party add-ons that do most of the work! but in context, what I've done is a small amount compared to the efforts of people like you, and the people who have made this 'half baked' code (i.e. it works for the hardware they're using, and it works for the way they use it, but not necessarily for everyone), so I remain humble. my software skills are not anywhere near as good as my hardware skills :)

ok, i'll get the latest new-stino, & poke around in the platform_teensy files, and see if I can work out what's happening. might be several days from now though.

ubidefeo commented 9 years ago

hey guys. I just remembered something else, which may not be completely related, but I guess I'll throw it in. not long ago, I was working with a beta version of the IDE (I'm not allowed to disclose how and why), and found out that some folders are not named the same as earlier versions. the new ZERO comes with a Cortex M0 and rather than containing a folder gcc-arm-none, the folder name contains extra stuff. I had to go and do some changes, but my brain hasn't retained what I did :D maybe it's related, maybe not.

@techydude can you recap exactly your configuration? Arduino version, ST version, µC and so on?

screen shot 2014-11-25 at 07 46 22

techydude commented 9 years ago

@ubidefeo , interesting, but if this version of Arduino IDE is supporting the Zero with an ARM CPU, then it's presumably a beta of the 1.5.x stream? (the 1.0.x stream is, AFAIK, AVRs only). In 1.5.x "Things Are Different Here" :), including the way both libraries & hardware/core definitions are treated. But, given you're not-wanting-to-talk-about a beta version of 'something' when publicly available beta versions of 1.5.x are all that's ever existed thus far, then perhaps you're refering to... something else :) But you're right, if core folders aren't named as expected by Stino, that could cause problems...

me: Mac. Arduino 1.0.6. ST3 (3065). all working fine, including "Upload using (AVRISPmkII) Programmer". Additional cores 'installed':

But as I discovered last night, even 'bog-standard' Teensy boards aren't compiling via ST3:Stino (I hadn't tried before until last night), let along uploading.

Do you have any Teensys? Or any other non-Arduino-standard cores installed in 1.0.x ?

screen shot 2014-11-25 at 9 52 29 pm

screen shot 2014-11-25 at 9 53 32 pm

ubidefeo commented 9 years ago

@techydude I'm gonna make another clean install of Arduino 1.06, install Teensy's tools and test with a Teensy 3.1. I have one, but I never got to use it. only test I did with an ARM is with an M0 from within Arduino IDE, but I'm willing to test with new STino. I found an Arduino Micro which has a 32u4, that should do, right? as far as I remember these are just USB controllers on steroids, but I may be wrong.

I don't have any 90xx lying around, though. maybe we can catch up outside of this thread and figure this out so we don't crowd the space with too much trial/error, and if there's a solution we can report it here :)

let me know how you feel about it.

gonzoid commented 9 years ago

Hi there! I think it's a good idea to export our thoughts on another platform to keep this ticket readable (doh! too late :)

I've opened an Etherpad here: https://etherpad.fr/p/stino-debug I'm not the owner of this host and we can choose another in this list if you want: https://github.com/ether/etherpad-lite/wiki/Sites-that-run-Etherpad-Lite

ubidefeo commented 9 years ago

hi @gonzoid thanks, I don't use etherpad. I think this issue is quite specific to some custom configurations. if @techydude and I manage to find where the issue lies then we can offer a contribution.

@techydude I'm using my custom ISP (Arduino NG modified) with an Arduino Micro (m32u4). I've managed to upload.

techydude commented 9 years ago

sorry guys, snowed under with work at the moment. can we come back to this next week? happy to take it to an alternative medium, just say where (if not that etherpad).

ubidefeo commented 9 years ago

@techydude , know exactly what you mean. I'm in a relatively relaxed period now, but it's the exception.

for me a HangOut or anything more real-time would be great, but we can use anything you fancy, I'm not too fussy about it :)

ping me when you're out of the quarry u