After countless hours of writing and debuggin (mainly debugging ;-)) bootloader software I can finally program the device via its external SPI interface. The bootloader was originally a pure USB MSD (MassStorageDevice) bootloader. To make it more universal, particularly in an embedded context, the idea was to allow file access via an API which can then be made available via SPI, I2C as well as USB HID (HumanInterfaceDevice).
An important milestone on this journey has now been reached. One can now create, delete, rename and modify files via the API. Once a firmware file has been created in this manner, the original bootloader can do its job and program the new firmware.
Why did it take so long? Hard to tell, really. With hindsight, there was nothing too difficult about it. But as so often with embedded software, sometimes it takes days to get a seemingly simple piece of code to do what it should.
At an early stage, I reviewed and re-wrote a pice of code so many times trying to find out what's going wrong. I read the PIC data sheet back and forth thinking I must have overlooked something. In the end it turned out to be a bad soldering joint...
I've also archieved a massive performance increase in terms of time it takes to write the firmware. It's now impressively fast and only takes seconds - Something I very much appreciate during testing when I re-program the charger many times a day.
That said, some more work needs to be done to further improve the FAT16 implementation. It's still quite inefficient when writing files. I'll need to change that so the flash won't wear out over time. The flash chip I use has a guaranteed 100k write cycles which sounds like a lot but is quite easy to reach if your code is not careful.
It's 2:05 a.m. here so no photos for today but I hope to post a video of the bootloader in action tomorrow.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.