ElectricMotorcycleForum.com

Makes And Models => Zero Motorcycles Forum | 2013+ => Topic started by: ZeroPointZero on May 09, 2017, 10:50:07 PM

Title: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: ZeroPointZero on May 09, 2017, 10:50:07 PM
Its all in the subject...

What is the difference between the 2017 model year that allows DIY firmware updates via the Zero App, as opposed to the 2016 and older firmware that requires a trip to the dealer??

Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: Fred on May 09, 2017, 11:23:10 PM
Apparently the microcontroller on the 2017 has more flash memory - enough to store both the current and new firmware. This is needed so that the entire new firmware can be loaded onto the device and verified before it's reprogrammed. Imagine if the Bluetooth connection dropped halfway through.
Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: BrianTRice@gmail.com on May 10, 2017, 04:25:35 AM
Fred's understanding matches everything I've heard. Older models firmware is not equipped for it.

I've developed firmware, and being able to hot-switch versions with an atomic file system operation and reboot is a big deal.
Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: ZeroPointZero on May 11, 2017, 01:19:17 AM
Fred's understanding matches everything I've heard. Older models firmware is not equipped for it.

I've developed firmware, and being able to hot-switch versions with an atomic file system operation and reboot is a big deal.

The Zero app should enable backing up the existing firmware to the phone and flashing the new firmware to the bike, if the <=MY2016 bike doesnt have the measly amount of space required to store a couple firmware configs.  This way if the new firmware is faulty you can re-flash from backup.  Seem doable to me, if the App were better.  For those who cant handle such an operation, they could refer to their dealer.
Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: BrianTRice@gmail.com on May 11, 2017, 06:36:10 AM
Fred's understanding matches everything I've heard. Older models firmware is not equipped for it.

I've developed firmware, and being able to hot-switch versions with an atomic file system operation and reboot is a big deal.

The Zero app should enable backing up the existing firmware to the phone and flashing the new firmware to the bike, if the <=MY2016 bike doesnt have the measly amount of space required to store a couple firmware configs.  This way if the new firmware is faulty you can re-flash from backup.  Seem doable to me, if the App were better.  For those who cant handle such an operation, they could refer to their dealer.

That's unfortunately not a reasonable way to implement it; Bluetooth file transfer is very unreliable and this has a great risk of "bricking" the MBB or BMS or anything else requiring an update.

Basically, the base bootloader has to be able to run bluetooth communications, have a default and fallback listening mode, accept the firmware when the existing one is broken, and manage that mode transfer itself. At which point you've implemented something else you need to update.

Compared to serial mode transfer, it's just risky.

Firmware and boards really have to be designed up front to support this in concert.
Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: Doug S on May 11, 2017, 07:19:29 AM
That's unfortunately not a reasonable way to implement it; Bluetooth file transfer is very unreliable and this has a great risk of "bricking" the MBB or BMS or anything else requiring an update.

Agreed. Even for a robust, wired connection, you really need to download the whole image, verify its integrity via 32-bit CRC or something even more rigorous, THEN it's reasonably safe for the device to reprogram itself with the new image. Even if the bootloader doesn't overwrite itself, and is probably still intact, you still probably need at least some degree of functionality in the app to invoke the bootloader again so you can re-try. If the bootloader does "upgrade" itself with a bad image, you're completely out of luck...only a low-level reprogram is going to restore function.

All of which gets much riskier when using any sort of wireless connection. WiFi is very good at correcting bad transmissions because it's designed to transfer data files back and forth, but bluetooth isn't nearly as good....it's designed for microphones, earbuds, that sort of thing, where an occasional bad packet isn't life-threatening. But even with WiFi, errors are far more likely than with a wired connection, so it's even more critical to follow the protocol above....download the WHOLE image, verify the living crap out of it, THEN burn it. Anything else is just asking for trouble.
Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: Fred on May 11, 2017, 04:32:36 PM
Even if it was possible, there's little business sense in porting a new feature to a previous model. There's not that much to distinguish between the 2016 and 2017 models. Why remove one of them and potentially reduce new bike sales?
Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: ZeroPointZero on May 11, 2017, 08:59:53 PM
That's unfortunately not a reasonable way to implement it; Bluetooth file transfer is very unreliable and this has a great risk of "bricking" the MBB or BMS or anything else requiring an update.

Agreed. Even for a robust, wired connection, you really need to download the whole image, verify its integrity via 32-bit CRC or something even more rigorous, THEN it's reasonably safe for the device to reprogram itself with the new image. Even if the bootloader doesn't overwrite itself, and is probably still intact, you still probably need at least some degree of functionality in the app to invoke the bootloader again so you can re-try. If the bootloader does "upgrade" itself with a bad image, you're completely out of luck...only a low-level reprogram is going to restore function.

All of which gets much riskier when using any sort of wireless connection. WiFi is very good at correcting bad transmissions because it's designed to transfer data files back and forth, but bluetooth isn't nearly as good....it's designed for microphones, earbuds, that sort of thing, where an occasional bad packet isn't life-threatening. But even with WiFi, errors are far more likely than with a wired connection, so it's even more critical to follow the protocol above....download the WHOLE image, verify the living crap out of it, THEN burn it. Anything else is just asking for trouble.

So how does the 2017 model accomplish the firmware upgrade via the App, if not using the bluetooth connection?

Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: Doug S on May 11, 2017, 09:16:41 PM
So how does the 2017 model accomplish the firmware upgrade via the App, if not using the bluetooth connection?

It DOES use the bluetooth connection. The point is, the newer microprocessor used in the 2017 bikes has enough onboard flash RAM to download the new code image while still running the old image, verify the new package is valid and intact, and THEN program it as the new main image. During the process, it has two complete images, the older one that it's currently running, and the new one that it's verifying. If you don't have enough space to hold the two images, you can't do it this way, which is the only really safe way.
Title: Re: Firmware update 2016 SR to 2017 SR firmware level, enabling future DIY updates?
Post by: JaimeC on May 11, 2017, 09:54:11 PM
The point is, the newer microprocessor used in the 2017 bikes has enough onboard flash RAM to download the new code image while still running the old image, verify the new package is valid and intact, and THEN program it as the new main image. During the process, it has two complete images, the older one that it's currently running, and the new one that it's verifying. If you don't have enough space to hold the two images, you can't do it this way, which is the only really safe way.

I think anyone who has ever flashed a new BIOS on to a PC should be familiar with this process.  If something doesn't go right, your nice, fast PC becomes a big paperweight or doorstop.  This isn't something you want to "shortcut" or "jerry rig."  If Zero is making this available to the consumer one would hope they've worked out every conceivable scenario so we don't end up with an expensive lawn ornament.  However, as former Secretary of Defense Donald Rumsfeld so famously said:

"There are known knowns. These are things we know that we know. There are known unknowns. That is to say, there are things that we know we don't know. But there are also unknown unknowns. There are things we don't know we don't know."