New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload & Monitor Task selects wrong environment #2623
Comments
Hi @TD-er ! The MMU configuration is handled by this code.
It's a pretty straightforward configuration, so TBH I'm not sure why it might be unreliable. Are there any changes between two consecutive compilations? |
I got the idea the building process on its self might be flaky. Just some observations:
N.B. I don't build other PIO envs inbetween and don't touch the PIO ini files. What does happen every now and then -now that I think of it- is that my PIO project tasks tree gets folded with an infinite waiting state (like what you have when unfolding it for the first time, showing "Loading...") unless you close the item and open it again. This does seem to happen more often when you toggle between tasks like "build", "clean" and "Upload and Monitor". |
Highly unlikely. That task tree simply runs the In any case, your freshly edited files will trigger linker to reassemble the final elf image and there might something wrong with autogenerated linker scripts. Anyway, could you please prepare a minimal example so I can reproduce it on my machine? |
Well a "minimal" example is quite hard as I don't have a clue here what triggers it. By the way, the IDE just suddenly "folded" the project tasks as I described, which happens every now and then. Edit2: |
I do have the feeling (I know, lots of 'feeling', not yet hard facts) that it may somehow be related to this issue: The reason I got the feeling it may be related is that I'm having a number of issues when running the current staging code of esp8266/Arduino, regardless if it is using SDK3 or SDK222 and also with or without experimenting with the 2nd heap. What I'm seeing (so leave out the idea of the MMU defines) is that the ESP may crash on seemingly unrelated code. So this does seem like there is something fishy in the way how code is being linked. The order in which it is linked may lead to working or crashing build. I hope this is enough defense to give my 'gut feeling' some credits ;) Edit: |
I have another idea of what may be happening here... In VS code, you have on the right the various PIO tasks once done so you can switch between them. What I now noticed was that I was building a build before that did not have the 2nd heap stuff defined for the PIO env. But since a previous task with "Upload and Monitor" from another env was still present in this list in the lower right corner of VS code, it built that one instead. So it looks like the re-use of tasks is picking the wrong environment. |
So it seems the issue has nothing to do with the |
Yep, I guess so. |
I'm hitting a similar issue, though I've managed to get some more details - in my case, the environment passed when running the "Upload" or "Upload and Monitor" task is not updated if a monitor started by "Upload and Monitor" is still running. Say I have two environments set up in my Stopping the monitor allows things to function correctly. |
Further investigation has revealed this is due to the "autoCloseSerialMonitor" feature. When the monitor is resumed, this is done by restoring the task that opened the monitor. If that task was itself an "Upload and Monitor" task, then restoring it will clobber the task you just tried to run - you can actually see this in list of task terminals (if you tried to do an "Upload" it will have failed, and the old Upload and Monitor will have restarted - whether it's the right environment or not). Worse, here the new "Upload and Monitor" task is completely ignored in favour of restoring the old one - even if args like the environment are different. Fundamentally, I'm not sure it's ever really okay to be trying to restore an "Upload and Monitor" task - as it'll try and re-upload via that, rather than the "Upload" or "Upload and Monitor" task you've just selected... For now, the main workaround is to just close any active monitor before uploading if you are using multiple environments. The risk here is that people will get stung expecting to have uploaded one environment, when it's actually re-uploaded the old one. As far as fixing this, I'm also not really sure what the desired behavior here would actually be. Unless there is a way of breaking out the "monitor" task such that it is always independent of which combination task called it? Then it would be able to be restored without the side effects of re-running the entire task that first needed the monitor (like Upload and Monitor). |
That I can confirm from experience as it happens to me all the time. |
This is happening to me all the time as well. But it happens almost each time I switch from one task to another. |
@ivankravets Is there a possibility to use added targets from a platform like platform-espressif32 in a custom toolbar with the current active env? So in this example |
@ivankravets Hi!
2-3 are problematic, as I want to monitor several targets on different boards. Native platform: Edit: Actually, my Multi-platform-Multi-board demo project could be used to test this, even if there are no boards attached, one should be able to see what PlatformIO tries to do: |
@Jason2866, yes, just use the name of the task which you see in the VSCode Menu: Terminal > Run Task > PlatformIO "text": "$(check)",
"tooltip": "PlatformIO: Upload Filesystem Image (tasmota32-lvgl)",
"commands": [
{
"id": "workbench.action.tasks.runTask",
"args": "PlatformIO: Upload Filesystem Image (tasmota32-lvgl)"
}
]
|
@ivankravets Thx for the answer, is there a variable holding the current env which can be used instead of a hard coded value here? |
@Jason2866, good idea. That we can remove "custom commands", such as Could I ask yo to file a feature request? We will implement it in
|
Could you re-test with PlatformIO IDE 3.0.1-beta.3 for VSCode? |
@ivankravets Nice! The only kink is that "Native" still starts a connection to one of my boards (the first one in platformio.ini), and that will later likely block the upload of "Upload and monitor" as it hogs that port. In its current state,perhaps the Native platforms' "Upload and monitor" should have a "Run"-task instead to separate it properly? Unless there is some upload support for Native to for example som RaspberryPy or something? |
Thanks for fixing this. I tried 3.0.1-beta.3 in my project with two devices/environments and the build targets now use the correct environment and open or reuse the right terminal windows. I've just started using PlatformIO this week, so was great to see this fixed. It makes it really simple to deploy and monitor on two different devices now - kudos! |
@nicklasb, could you share here the |
You should be able to run at least Native out of the box, the project is sort of a start-of-point so it should work: |
…ve" development platform is used // Issue #2623
The PlatformIO IDE 3.0.1 (pre-release version of 3.1.0) is published to the registry. @nicklasb, it contains the fix for the "native" platform. Please re-test:
Does it work now? |
@ivankravets |
@nicklasb In VSC extensions switch to Pre-Release Version |
@ivankravets Interestingly, I don't see that button. Is that because I run the .vsx? |
@nicklasb "update" to 3.0.0 and after this you can change to prerelease |
Ok, now I have managed to switch, but the problem persists, regrettably. Note the log below, after I don't want to carry on, but could you not reproduce using this project? It should try to connect to some (hopefully) non-existing usb-port on your host.
|
@nicklasb Have you tried to add the monitor speed to the port?
Or maybe i do not understand your issue at all? |
@Jason2866 |
Imho it is a platformio user config error to use |
Sorry, I don't understand the problem at all :( See this commit what we did da93a68 It means, when there is an open serial port monitor and you try to use a "native" dev-platform, we will not close the active monitors. It seems we should remove that part of the code because the use case is very rare. |
@ivankravets @Jason2866
But as you rather asked about "Upload and monitor", I answered and tested. And here we are now. :-) |
@ivankravets @Jason2866 |
This fix appears to have created undesireable behavior. As of 3.1 (I've rolled back to 3.0 and verified this is new to this version), clicking on "Upload and Monitor" subsequent times causes a "The task ... is already active. [Terminate Task] [Restart Task]" dialog. This appears to be a regression of this bug: #2266 |
Same here, just noticed that I am getting this (had so many that correctly was like this that I didn't see those who shouldn't be...) |
@birnam , could I ask you to open a new issue at https://github.com/platformio/platformio-vscode-ide/issues? |
@ivankravets @nicklasb New issue created here: #3656 |
Steps to reproduce:
The text was updated successfully, but these errors were encountered: