-
Notifications
You must be signed in to change notification settings - Fork 381
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to detect version of application and not of the bootloader? #243
Comments
By design micronucleus is set up in a way where it is completely agnostic to the content that is uploaded. Therefore, no mechanism exists to read the content of the user space. In a normal setting, the bootloader also would only be invoked when a new firmware is uploaded, so the application itself should respond to version request while it is active. Of course, you can extend Micronucleus however you like for your own needs. For example, you could store version information in your application in a certain place and extend micronucleus to output that information. But, as said before, a cleaner architecture would for the application software to send out a version reply. |
For my device I am only using USB for firmware updates. So my application software does not report anything through USB (currently). I think for my case, extending Micronucleus will do. I added version bytes to beginning of my application.
and I see it in the application header at the beginning:
Not as familiar with C, any tips on how I could read those version bytes from flash memory and into |
It's actually not that simple. What you could do is to add a new function in the main command loop, like for the configuration reply: https://github.com/micronucleus/micronucleus/blob/master/firmware/main.c#L250 (You could also use the configuration reply to transfer your version information, it currently does not use the device id). You would also have to adjust the commandline tool to output the new information. |
You were right, this has not been simple. Still trying to figure out how to get the application version passed through the configuration reply. Once I do figure out how to pass that value, not sure how or where to put the value you in the usbDescriptorDevice. Also micronucleus command line or avrdude can not read the application but rather only program it? |
@cpldcpu I successfully added some dummy version data onto the configurationReply and have it render in the command line tool.
But I am having a hard time figuring out how to actually set these values on the fly in |
You could try removing the "PROGMEM const" keyword. Then the array will be mapped to SRAM. I hope the functions to send from sram are still in micronucleus, though :) |
Yea that was one of the first things I tried but when I do so micronucleus behaves as if that |
A lot of code has been removed from V-USB to reduce code size. It's possible that the function to send from SRAM are not there anymore. |
I think, with your extensions you get a macronucleus bootloader. Better think of printing a line at startup of your program like |
You have to add the original implementation of '''usbDeviceRead''' to usbdrv.c. Copying from RAM has indeed been removed in micronucleus. see here: https://github.com/obdev/v-usb/blob/7a28fdc685952412dad2b8842429127bc1cf9fa7/usbdrv/usbdrv.c#L497 Using the existing descriptor should be quite a small addition. |
@cpldcpu
How did you manage this? |
Some changes triggered by #243 Bumped version to 2.6 Added compile flag STORE_CONFIGURATION_REPLY_IN_RAM. Added 2 bytes USB config data for Bootloader feature flags and application version. Added --info flag for micronucleus executable. Minor housekeeping.
I read two bytes for program version here: https://github.com/micronucleus/micronucleus/compare/master...RobertDaleSmith:snes23do-app-version-lite?expand=1#diff-4c3b3752bbaffdc43c97424bc76d63e305bdca404f04c4aa3f2a92333f444b48R252. Then I grab it on the other end in the command line tool here: |
I am building a GUI to automate running the command line tool. I would like for my GUI application to be able to detect the version of the application installed on the device. I see the command line tool reports the version of the bootloader but would it be possible to update this version number set in the bootloader device information when flashing a new application firmware update through micronucleus?
Basically looking for a way I can programmatically detect versions of the application so my GUI can report whether an update is needed or not.
I have brainstormed that maybe I could download the flashed firmware and do an MD5 check on the file in order to make an educated guess of which previous version of my application is installed when compared to a hash table. But would be nice if when updating through micronucleus command line it just goes ahead and bumps the version defined in the bootloader device info.
Any help or direction on this topic is greatly appreciated. 🙏
The text was updated successfully, but these errors were encountered: