digistump / BuildOne

14 stars 1 forks source link

BuildOne Bounties: Serial Pass-through Mode #2

Closed ekettenburg closed 6 years ago

ekettenburg commented 6 years ago

Serial Pass-through Mode - We want to ensure that the ESP8266 module which provides the WiFi connection for the BuildOne can be updated via USB. Currently we allow this by changing jumpers on the board to connect that module to the on-board USB to Serial converter, instead of the main MCU being connected. A much better user experience would be to be able to send a command to the Marlin firmware to put the main MCU in passthrough mode where it passes the programming commands for the ESP8266 modules from the USB pins (TX0/RX0) to the WiFi pins (TX2/RX2) by having the ESP8266's programming and reset pins also connected to the main MCU it can then be reflashed without having to change any jumpers.

We will handle the desktop software for flashing so the programming and reset pins can be pulled high/low by that software using regular Marlin M42 commands - we are just looking for someone to implement the pass through serial mode and decide how the end of it should be detected as well to switch back to Marlin or just reboot the whole board.

Bounty: $100 cash / $200 credit towards adding to your order

Terms:

If you are sure you can do this, and able to do this quickly - please feel free to respond to this issue and say that you are working on it and when you will complete it, so that others don't waste their time on it. If you are just entertaining the idea/unsure if you can do it, please don't "claim" it until you are sure.

Cash or credit is your choice. Cash to be paid via Paypal. Credit will be applied to your BuildOne order for additional items, it cannot be refunded to cash and other items cannot be refunded to cash and then credit used to pay for them.

You may credit yourself in the files as well, leaving in tact existing licenses and credits.

Legal Stuff: We will choose a winner at our sole discretion. The winner will be the first pull request/issue update/etc that submits fully working code meeting the above requirements and following good coding practices, based on the timestamp of the pull request. If the pull request is to an existing software project the winner will be expected to follow through and make the best effort to get it merged. Cash awards will be made in USD. This is not an offer for hire. All work submitted becomes the property of Digistump LLC/Robotic Industries LLC to be used at our discretion in compliance with any associated licenses. Void where prohibited by law.

the-real-orca commented 6 years ago

Wouldn't it be easier using the build in Over-The-Air Update of the ESP8266 itself, instead of passing it through the main PCB and Marlin? (see https://github.com/esp8266/Arduino/blob/master/doc/ota_updates/readme.rst)

ekettenburg commented 6 years ago

Yes, that will be the primary way to update the ESP8266 firmware - however it is not fail safe and there are many situations where it may not work - so we want to ensure we have this as a fail safe. In addition if the "whole printer" gets a firmware update it would be nice to be able to allow users to download and run one file and have it update the whole thing regardless of the current state or settings.

herrold commented 6 years ago

The Espressif 'sweet spot' on ESP devices has moved, and an ESP-32 family device is often less expensive, and has always been more powerful than the 8266

Are you open to a SOC upgrade?

ekettenburg commented 6 years ago

ESP32 is about 2.5x the price and we have a large existing stock of 8266 as well as tons of experience with it (I've used over 25k of them in production devices). I would have loved to use a ESP32 as the main MCU and do away with the MEGA2560 completely, but it isn't that mature yet, doesn't have enough pins, and has quite a few quirks like the 8266 did in the early days that made it a real challenge to run a stable printer from it

pfeerick commented 6 years ago

Plus you need to make sure you have room for a v2 control board in say a years time... hopefully by then the ESP32 codebase will have matured enough ;)

the-real-orca commented 6 years ago

ESP32 would be nice, but for the moment, let's solve the ESP8266 problem :)

@Erik: Would it be possible to trigger a pin with the ESP8266 when the new firmware was flashed, so that the MEGA knows when to switch back to normal mode?

ekettenburg commented 6 years ago

GPIO0 is already connected so the MEGA can hold it LOW during the reboot into programming mode - once in Serial Pass Through Mode the MEGA could switch the connected pin to INPUT_PULLUP and the ESP8266 could pull it LOW on a successful flash?

Also you want @ekettenburg not erik

the-real-orca commented 6 years ago

Than the pass-through mode should be straight forward. Since I’ve already patched the serial port, I can add the pass-through as well.

I’ll add some proprietary G-Code with an exit pin number as argument. (The pin on the Mega, GPIO0 is connected to.) After this command all data will be (bi-directionally) passed to the second serial port. This should be ok for normal data transfer, but will not work for timing sensitive operations like bit-banging. The exit pin will use the internal pullups of the Mega and once it is pulled low, the pass-through mode will be exited. I’m not sure if it is possible to switch back to normal operation, or if Marlin needs to be restarted after pass-through.

the-real-orca commented 6 years ago

The beta version for the WiFi module firmware update a.k.a. serial pass-through is ready. https://github.com/the-real-orca/Marlin/tree/Serial_Passthrough

_FIRMWAREUPDATEPASSTHROUGH needs to be enabled in the config. The pass-through mode is activated with the M997 (firmware update) command. All data from the primary serial will be passed directly to the secondary serial, and vice-versa. To exit the pass-through mode, pull the _FIRMWAREUPDATEPIN to low. The default _FIRMWAREUPDATEPIN is set in the config file, or can be overwritten with the P parameter of the M997 command.

@ekettenburg Please let me know if it is working for you, or if you need some other feedback on the serial line about activation / deactivation of the pass-through mode.

ekettenburg commented 6 years ago

Awesome - thanks @the-real-orca !

I will do some testing with this - but it looks like everything we need - in the meantime please email me at support@digistump.com to claim your bounty for both this and the dual ports.

Closing this - will reopen if I find any issues in testing.

Thanks!