Alternate Firmware for the Motor Shield
I asked around a little, and one of my friends wrote an alternate implementation of the firmware for the motor shield for the D1 Mini. It's written by hand, without using auto-generated code, and in my experience it works much better -- in particular, it doesn't crash when it receives a wrong command or when it times out. I still need to do some more testing, and I'm sure we will find some bugs, but at least the worst bugs from the original firmware are fixed.
The firmware is backward-compatible with the original, in the sense that you can use the same libraries and the same code with it.
I wrote the instructions for flashing it on the original WeMos shields here: https://hackaday.io/project/18439-motor-shield-reprogramming/log/57852-we-have-a-fixed-firmware
Unfortunately, since the boards are locked, you will need an ST-Link programmer and you will need to solder two wires directly to one of the chips on the shield. Perhaps @wemos could break those (and all other unused pins too) out in the next version of the shield, that would make it much easier.
I have heard that there are also some clone shields that are sold by other manufacturers than WeMos, and that those come un-programmed. If that is true, you should be able to flash them over the serial pins that are broken out, without a special programmer and without soldering, using the stm32flash utility. I have never had such a shield in my hands, though, so I can't confirm this.
Update: I have now figured out how to reprogram the shields without the need of any soldering or a programmer. All you need is a serial to usb adapter: https://hackaday.io/project/18439-motor-shield-reprogramming/log/57855-reprogramming-without-soldering
unfortunately I can only upvote once !
Thanks man for this effort
Hello @deshipu ,
I followed your explanation this morning and re-programmed successfully one of my motor shields. Haven't tested it with real software, yet. But the I2C scanner runs without problems, which is at least a very good indicator. Thanks again for your help!
If you set this board to work with 3.3V and RTS on the R/C pin you would expect that it works immediately as programming adapter for the motor shield. Under Linux this is not the case! Very likely there is an issue with the parity support in the Linux driver for CH340/CH341. Finally I used a FTDI adapter. I have not tested it under windows or on a mac.
Yes, I used that USB2TTL board initially too, as it had exactly the right pinout, and I did assume that it sets the RTS pin high -- that's what made me think that locked chips can't be programmed over serial, and made me go this whole roundabout route with soldering the wires and using an ST-Link programmer. In the end, it made me waste a few weeks, but I did learn a bit about programming STM32 chips.
Then I tried with a different usb2ttl and with the RTS pin held high with a wire -- just because I was too lazy to search for this particular usb2ttl in my drawer -- and it suddenly just worked.
I wonder if someone got this shield working with nodemcu? I've tried for some hours now, but had no louck to get it work.
Does someone know how to really use the shield directly using i2c? Even in the new Firmware I don't see any documentation about that and this makes it hard to understand how it works.
Maybe someone already did this, I'd be really happy to know how to.
if you're talking about nodemcu, do you mean implementation for lua?
I wrote a library for MicroPython, it's a bit easier to read that code than the original Arduino library: https://bitbucket.org/thesheep/micropython-d1motor/src/tip/d1motor.py