Has anyone tried using the SuperB to update the M2? Is that possible?
Not possible since it needs to be flashed via the USB port. As far as I know unless someone else has worked out a way to do it.
From https://docs.macchina.cc/m2-docs
A wireless socket on the M2 Processor Board accommodates a wide variety of wireless options using the popular DIGI XBee form factor socket. Many inexpensive, plug-and-play boards already exist including BLE, WIFI, GSM, 3G, LTE, GPS and others. This can even be used to reprogram the M2 wirelessly.
I’d also love to hear from Macchina how to actually do this with a SuperB.
Hey All, flashing an M2 wirelessly via SuperB would definitely be cool. This functionality needs some work. Bounty time?!
Here is what I know:
M2 is based on Arduino DUE and the Arduino DUE can be programmed over the UART port (they call it the Programming port).
That UART port is found on the XBEE socket on M2, so that makes it easier.
The challenge comes in where the DUE uses a ATmega16U2 to convert USB to UART and how it handles resets during that process. The SuperB would need to interact with the SAM3X8E the same way, and I am not sure how SuperB could reset the host processor the same way.
Does this mean a custom bootloader for this case? This is possible, of course in fact @CollinK wrote a CAN-based bootloader here: https://github.com/collin80/FirmwareReceiver
Next step would be to figure out the Arduino IDE to SuperB interfacing. Looks like there are a few projects out there that turn the SuperB into a Serial bridge, for example:
I see 2 ways to actually flash the M2:
-
SuperB would act as a webserver with a webpage. You’d select the .bin from your computer via the webpage and click “Flash”. Or something like that.
-
Maybe directly through Arduino IDE? You’d have your new sketch ready, select a … IP address and port? and click Upload in the IDE.
So, back to that bounty question - anyone out there interested in giving this a shot?
Bounty:
Besides the satisfaction of knowing you are helping to move the car-hacking community forward, we’ll send you a copy of The Car Hacker’s handbook and a OBD3way if you can wirelessly flash a M2 over SuperB and document so anyone else can reproduce.
Thanks for the pointers @josh! I like the idea of using Colin’s approach, and adapting it to work with Arduino OTA and SuperB.
I’m going to give the following a shot:
In Arduino IDE:
- Add a
network
option to the M2boards.txt
, effectively making it so you can use wifi instead of the usb port to upload a sketch - Configure /bin/ArduinoOTA to work with this and the endpoints to be implemented on the SuperB
On SuperB:
- Add an mDNS “Arduino Service Request” broadcast to make the device appear in the Arduino IDE
- Implement an “upload endpoint” that simply stores the sketch on SPIFF, and signals to M2 that it should reboot into bootloader mode
- Implement a way for M2 to “read” the .bin file
On M2:
- Implement a bootloader, and store it in FLASH1, which reads the sketch .bin file from SuperB and writes it into FLASH0, and then resets to FLASH0 after signaling to SuperB a success
- Implement a handler that runs as part of the main sketch and is able to set the GPNVM bits to boot into FLASH1 bank and reset on a signal from SuperB
If this works, it’ll net us a neat little “push” wireless update mechanism, which should be nice for a hobbyist system like this.