p3p / pio-framework-arduino-lpc176x

10 stars 20 forks source link

Fix no response on Serial* with high BAUDRATE #47

Closed mh-dm closed 3 years ago

mh-dm commented 3 years ago

Fix no response on Serial for LPC1768 (SKR v1.3) with BAUDRATE > 250000 Fix no response on Serial for LPC1769 (SKR v1.4 Turbo) with BAUDRATE >= 1000000

Fix derived from https://github.com/MarlinFirmware/Marlin/pull/22284 that was tested on Marlin with SERIAL_PORT 0 on SKR v1.3 and with SERIAL_PORT 0, 1, 3 on SKR v1.4 Turbo . With that fix verified 57600, 115200, 250000, 460800, 500000, 921600, 1000000 BAUDRATEs work.

mh-dm commented 3 years ago

@p3p Note this patch is untested as I don't know the magic platformio incantation for platform and platform_packages to redirect it my local git repo or https://github.com/mihai-dumitresq/pio-framework-arduino-lpc176x/tree/patch-1 Currently I have: platform = https://github.com/p3p/pio-nxplpc-arduino-lpc176x/archive/0.1.3.zip platform_packages = framework-arduino-lpc176x@^0.2.6

p3p commented 3 years ago

Hey thanks for finding this, I think you can use this syntax: platform_packages = framework-arduino-lpc176x @ https://* to redirect to a specific package. I tend to just checkout my repository into platformios packages folder (~/.platformio/packages on linux) directly though.

mh-dm commented 3 years ago

First try, framework-arduino-lpc176x @ https://github.com/mihai-dumitresq/pio-framework-arduino-lpc176x/tree/patch-1:

Error: VCS: Could not process command ['git', 'clone', '--recursive', '--depth', '1', 'https://github.com/mihai-dumitresq/pio-framework-arduino-lpc176x/tree/patch-1', '/home/mihai/.platformio/.cache/tmp/pkg-installing-zq21abgl']`

At least the error is self explanatory.

Second try, switch default branch and framework-arduino-lpc176x @ https://github.com/mihai-dumitresq/pio-framework-arduino-lpc176x.git:

ValueError: invalid literal for int() with base 10: '7+sha':
  File "/home/mihai/.platformio/penv/lib/python3.8/site-packages/platformio/builder/main.py", line 177:
    env.SConscript("$BUILD_SCRIPT")
[..]
  File "/home/mihai/.platformio/platforms/nxplpc-arduino-lpc176x/builder/main.py", line 27:
    framework_version = str(int(''.join(['{0:0=3d}'.format(int(x)) for x in platform.get_package_version('framework-arduino-lpc176x').split('.')]))) + 'UL'

Not sure what I was expecting.

There's no third try as "just checkout my repository into platformios packages folder" is exactly what the framework-arduino-lpc176x @ https://github.com/mihai-dumitresq/pio-framework-arduino-lpc176x.git configuration change did:

$ cd ~/.platformio/packages/framework-arduino-lpc176x/
$ git branch
* patch-1

But on the seventh try, when I hackily set framework_version = '2007' in ~/.platformio/packages/nxplpc-arduino-lpc176x/builder/main.py, hey it worked.

Tested (less exhaustively) this pull request works: SERIAL_PORT 0 and 1 SKR v1.3 BAUDRATE 921600 and SERIAL_PORT 0 SKR v1.4 turbo BAUDRATE 2000000.

Pull request ready to merge.

p3p commented 3 years ago

PlatformIO must change the version string from .. well the version .. when you use a git link, my little hack to expose the framework version as a global define (so Marlin can see it) can't handle non numerics.

If you used the zip https://github.com/mihai-dumitresq/pio-framework-arduino-lpc176x/archive/refs/heads/patch-1.zip instead it probably would have worked as it should have used the normal version string.

Anyway thanks for testing, its a simple change I don't see any possible side effects so I don't see a problem merging .. although I've said that before and come to regret it ^^.

mh-dm commented 3 years ago

The framework-arduino-lpc176x @ https://[..].zip incantation worked, thanks!

Tool Manager: Installing https://github.com/mihai-dumitresq/pio-framework-arduino-lpc176x/archive/refs/heads/patch-1.zip
Downloading...
Tool Manager: framework-arduino-lpc176x @ 0.2.7 has been installed!

Anyway thanks for testing, its a simple change I don't see any possible side effects so I don't see a problem merging .. although I've said that before and come to regret it ^^.

It's a very small change and I've manually tested it. It'll be fine :)

mh-dm commented 3 years ago

Thank you!