Skip to content

[2.0.x] Autobuild update & add PlatformIO support for AT90USB boards#10779

Merged
thinkyhead merged 1 commit intoMarlinFirmware:bugfix-2.0.xfrom
Bob-the-Kuhn:autobuild-update-2.0.x
May 19, 2018
Merged

[2.0.x] Autobuild update & add PlatformIO support for AT90USB boards#10779
thinkyhead merged 1 commit intoMarlinFirmware:bugfix-2.0.xfrom
Bob-the-Kuhn:autobuild-update-2.0.x

Conversation

@Bob-the-Kuhn
Copy link
Contributor

@Bob-the-Kuhn Bob-the-Kuhn commented May 19, 2018

Added the following to the right click popup in autobuild:

  1. Repeat Build - re-runs PlatformIO. Useful when changing/correcting files. Does not take notice if the board is changed in Configuration.h
  2. Scroll Errors (CTL-shift-e) - highlights all the instances of the word ERROR and jumps to the first one. Repeated calls scroll through the errors.
  3. Open Selected as File Open File at Cursor - turns the selected text line where the insert cursor is at into a file name and tries to open it. This only works for files in the project directory. Will open it in a preferred editor if one is running. Otherwise opens it with the system default app. The preferred editors are:
    Notepad++
    Sublime
    Atom

Added support for the AT90USB boards in PlatformIO. This was done by:

  • Adding environments in PlatformIO for CDC bootloader boards and DFU bootloader boards. Also replaced monitor_baud with monitor_speed per PlatformIO message.
  • Add a JSON for a generic AT90USB1286 board. This JSON actually goes into a PlatformIO directory. Autobuild automatically copies this file into the correct location.
  • Added helper scripts so that the Teensyduino platform will use the correct AVRDUDE download protocol,
  • Modified the pins.h file to point to the new environments.

The affected boards are:
AT90USB1286 boards using CDC bootloader

  • BRAINWAVE
  • BRAINWAVE_PRO
  • SAV_MKI
  • TEENSYLU

AT90USB1286 boards using DFU bootloader

  • PrintrBoard
  • PrintrBoard Rev.F
  • ? 5DPRINT ?

Teensy++20 is not affected by this change,


The CDC bootloader system may not be working. This may be because I have the wrong bootloader on my Brainwave Pro. I have a TeensyLU on order but it'll be a month before I get it.

The problems I've seen are:

  • Downloads just fine, AVRDUDE reports that the bootloader didn't exit . Resetting the board results in nothing (won't bring up the USB port). USBtinyISP verified that everything was downloaded and that the image will run.
  • Download hangs and blows away the bootloader.

@Bob-the-Kuhn Bob-the-Kuhn added PR: Improvement PR: Configurations T: HAL & APIs Topic related to the HAL and internal APIs. labels May 19, 2018
@Bob-the-Kuhn Bob-the-Kuhn force-pushed the autobuild-update-2.0.x branch from 0933533 to 8187867 Compare May 19, 2018 19:08
almost missed some changes

improved open file

change to open file at cursor
@thinkyhead thinkyhead force-pushed the autobuild-update-2.0.x branch from 8187867 to 70c5941 Compare May 19, 2018 22:38
@thinkyhead thinkyhead merged commit 62e2987 into MarlinFirmware:bugfix-2.0.x May 19, 2018
@thinkyhead
Copy link
Member

Better all the time! I've updated platformio.ini for bugfix-1.1.x based on the latest 2.0.x version so we can have a similar build experience. Autobuild could also be migrated over since we still have some time left before all the needed fixes for bugfix-1.1.x will be merged.

@fiveangle
Copy link

fiveangle commented Jun 5, 2018

@Bob-the-Kuhn — What is the expectation here for Printrboard Rev F users ? Selecting at90USB1286_DFU environment results in compile failure (presumably due to your new custom JSON not available for at90USB1286 board:

[06/05/18 15:52:49] Processing at90USB1286_DFU (extra_scripts: pre:buildroot/share/atom/create_custom_upload_command_DFU.py; build_flags: -fmax-errors=5, -g, -ggdb; lib_deps: https://github.com/MarlinFirmware/U8glib-HAL/archive/dev.zip, LiquidCrystal_I2C@1.1.2, TMC2130Stepper, https://github.com/teemuatlut/TMC2208Stepper/archive/v0.1.1.zip, Adafruit NeoPixel@1.1.3, https://github.com/lincomatic/LiquidTWI2/archive/30aa480.zip, https://github.com/ameyer/Arduino-L6470/archive/master.zip, https://github.com/trinamic/TMC26XStepper/archive/c1921b4.zip; platform: teensy; board: at90USB1286; framework: arduino; lib_ldf_mode: deep+; src_filter: +<src/*> -<src/config>)

Library Storage: C:\dev\git\Marlin\.piolibdeps
LibraryManager: Installing dev
U8glib-HAL @ 0.4 is already installed
LibraryManager: Installing id=576 @ 1.1.2
LiquidCrystal_I2C @ 1.1.2 is already installed
Looking for TMC2130Stepper library in registry
Found: https://platformio.org/lib/show/1493/TMC2130Stepper
LibraryManager: Installing id=1493
TMC2130Stepper @ 2.0.1 is already installed
LibraryManager: Installing v0.1.1
TMC2208Stepper @ 0.1.1 is already installed
LibraryManager: Installing id=28 @ 1.1.3
Adafruit NeoPixel @ 1.1.3 is already installed
LibraryManager: Installing 30aa480
30aa480 @ 0.0.0 is already installed
LibraryManager: Installing master
Arduino-L6470 @ 0.6.1 is already installed
LibraryManager: Installing c1921b4
c1921b4 @ 0.0.0 is already installed
Error: Unknown board ID 'at90USB1286'

How would a Printrboard owner know not to use this entry and instead use Teensy2pp ?:

#
# AT90USB1286 boards using DFU bootloader
# - PrintrBoard
# - PrintrBoard Rev.F
# - ? 5DPRINT ?
#
[env:at90USB1286_DFU]
platform      = teensy
framework     = arduino
board         = at90USB1286
build_flags   = ${common.build_flags}
lib_deps      = ${common.lib_deps}
lib_ldf_mode  = deep+
src_filter    = ${common.default_src_filter}
extra_scripts = pre:buildroot/share/atom/create_custom_upload_command_DFU.py

Am I missing something fundamental here ? :)

-=dave

@Bob-the-Kuhn
Copy link
Contributor Author

I'm out of state & my responses are going to be spotty for another 2 weeks at least.

That error is because the new board definition JSON didn't get copied to the correct platformio directory.

The auto build script will automatically do the copy.

My desire/hope is for the AT90USB users to use only the auto build script. It'll find all the needed info, copy the file(s) as needed and then do the build/upload.

The correct enviromnent for a given board is in the comments in the pins.h file. That's how the script connects the board to the correct environment.

@fiveangle
Copy link

The auto build script will automatically do the copy.

Okay.

My desire/hope is for the AT90USB users to use only the auto build script.

So you're saying that moving forward users will need to run some script to build Marlin and can't use PIOcore in other IDEs ? Seems a bit of a step the a ditch, no ? If true, the "Environment" should probably be changed to something like "autobuild-only-AT90USB_DFU" or something that indicates it is not for generic use for that board.

Where do we find info on this fancy new auto build script ?

-=dave

@Bob-the-Kuhn
Copy link
Contributor Author

Bob-the-Kuhn commented Jun 16, 2018

Auto Build is not a replacement/requirement for anything. It's a method of automating the PlatformIO build & upload process.

I did add some hooks for the USB boards so they'd also be part of the automated process. Your current method is still available and is unchanged.

Easy access to the Auto Build script has been implemented in Atom, Sublime & VS code.

It can be manually kicked off using a terminal.

  1. Open a terminal
  2. Set the CWD to the Marlin top directory
  3. Issue one of the commands
  • python buildroot/share/atom/auto_build.py build
  • python buildroot/share/atom/auto_build.py clean
  • python buildroot/share/atom/auto_build.py upload

I need to spend some serious time documenting Auto Build.

@fiveangle
Copy link

fiveangle commented Jun 20, 2018

Selecting at90USB1286_DFU environment results in compile failure...
Error: Unknown board ID 'at90USB1286'

@Bob-the-Kuhn: That error is because the new board definition JSON didn't get copied to the correct platformio directory.

The auto build script will automatically do the copy.

@Bob-the-Kuhn: Auto Build is not a replacement/requirement for anything. It's a method of automating the PlatformIO build & upload process.

I'm trying to reconcile these two statements above.

How can we fix it to support those that do not use the auto build scripts then ?

https://www.screencast.com/users/davejohnson3000/folders/Jing/media/19316ae8-7e26-4f37-ae0b-fe9c36ab3833

@Bob-the-Kuhn
Copy link
Contributor Author

Here's an excerpt from my proposed doc update. It's talking about AT90USB boards when using the PlatformIO CLI.


One additional step is needed to use this method with the other AT90USB based boards that have CDC or DFU bootloaders.

PlatformIO does not currently have a useable board definition for these board so Marlin has created a new board JSON. This JSON needs to be copied to a PlatformIO directory. Without it PlatformIO will issue an error message saying the board was not found.

The file at90USB1286.json needs to end up in the directory .platformio/boards.

The boards subdir may not exist under .platformio so the easiest method is to copy the boards subdir from the Marlin directory buildroot/share/PlatformIO to the .platformio directory


Another method would be to run Auto Build from the command line:

capture

@Bob-the-Kuhn
Copy link
Contributor Author

python buildroot/share/atom/auto_build.py build
python buildroot/share/atom/auto_build.py clean
python buildroot/share/atom/auto_build.py upload
python buildroot/share/atom/auto_build.py traceback
python buildroot/share/atom/auto_build.py program
python buildroot/share/atom/auto_build.py test
python buildroot/share/atom/auto_build.py remote
python buildroot/share/atom/auto_build.py debug

@thinkyhead
Copy link
Member

thinkyhead commented Jun 20, 2018

Now that auto_build.py is for both Atom and VSCode, it can move to buildroot/share/PlatformIO/ or buildroot/share/PlatformIO/auto-build/.

@fiveangle
Copy link

The fully scriptable and extendable power of PIO is to not require this antiquated manual copying of files here and there. The Environment entry should be fixed to require neither a manual, nor manual file manipulation, so it supports all methods of using PIO, not just 2 specific pet IDEs.

@Bob-the-Kuhn
Copy link
Contributor Author

We have three "pets". I hope to document Sublime in the next few days if things calm down here.

The Auto Build stuff started out as me getting tired of going through all the steps and scrolling needed to switch boards. Then I thought that this would be an easier method for people to get started with Marlin 2.0. It's been growing ever since.

I definitely want to hear your ideas. I have a problem with RTFM so I know there are options/methods that I'm not aware of.

The Environment entry should be fixed ...

Please explain further. I'm not following what you are saying.

@thinkyhead
Copy link
Member

thinkyhead commented Jun 21, 2018

The Environment entry should be fixed ...

Please explain further. I'm not following what you are saying.

My guess is he's saying that "new board definition JSON didn't get copied to the correct platformio directory" is something that the extra_scripts specified in platformio.ini should handle.

@fiveangle
Copy link

fiveangle commented Jun 21, 2018

Yes, that's what I mean. I haven't tried it in order to determine precedence ordering, but it would be pretty silly of PIO to make it so the board definition file must exist prior to doing any extra_scripts processing (in at least some fashion).

New requirement for me to commute into the office daily has prevented me from having any time anymore, but will try to look at it at some point. (Bay Area traffic is a mind-numbing motivation killer btw 😭)

Regarding "Sublime" usage, I'm sure your autobuild integration will be useful, but it's still just a (great) editor. The DevIoT plugin for Sublime is what allows easy PIO build automation without any customization. It does it in a way that mimics how Arduino IDE does (for better or worse) but I find it pretty excellent (after the initial stumbling blocks Scott and I had with due to bugs that the dev later fixed).

UPDATE: okay, did a quick google and none of this copying hoopla should even be necessary since boards_dir is for just this purpose:

http://docs.platformio.org/en/latest/projectconf/section_platformio.html#projectconf-pio-boards-dir

I gave it a quick shot by adding an entry into the at90USB1286_DFU Environment entry but didn't seem to pick it up, getting the same error as in my first post:

#
# AT90USB1286 boards using DFU bootloader
# - PrintrBoard
# - PrintrBoard Rev.F
# - ? 5DPRINT ?
#
[env:at90USB1286_DFU]
platform      = teensy
framework     = arduino
board         = at90USB1286
boards_dir    = buildroot/share/PlatformIO/boards
build_flags   = ${common.build_flags}
lib_deps      = ${common.lib_deps}
lib_ldf_mode  = deep+
src_filter    = ${common.default_src_filter}
extra_scripts = pre:buildroot/share/atom/create_custom_upload_command_DFU.py

I'm guessing it may have a different base folder or can only be used in a specific section of the PIO INI. I'll try to play around with it later to figure it out. BTW- Self-driving cars cannot come soon enough ! 😉

@fiveangle
Copy link

For your consideration: #11079

Bob- Can you give this a try in all your auto-build environments to ensure it still works as expected ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Configurations PR: Improvement T: HAL & APIs Topic related to the HAL and internal APIs.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants