Closed mdeweerd closed 2 years ago
That's an interesting idea and it's (to some extent) possible to add that, however, there are some things to consider:
TL;DR: It can be implemented, but would require additional components. Because of this, it would need to be a sort of firmware variant, or something that is only enabled if the user is targeting an Arduino-compatible platform with enough memory/hardware for it, or maybe as a feature that can be enabled/disabled by the user when the firmware is compiled, provided that they know that it will require additional parts. I'm also curious about the use cases or situations where this mode of operation is desired.
To continue with the discussion: @mdeweerd: You mention "in-circuit programming of a PIC from another controller". Could you elaborate a bit further ? If you could also speak a bit about the scenario in which this feature would be useful to you or others, that would be fantastic too.
"Arduino" today is a vast term for anything compatible with the Arduino platform. There's "a few" Arduino platforms out there that have enough memory to hold the software for a small PIC.
A scenario is the following: the display/keyboard is on board or on a separate board and controlled by a microcontroller. Some PICs are build for directly driving LCD screens (e.g., PIC16F913), or other more evolved screens (e.g. https://www.olimex.com/Products/Duino/Shields/SHIELD-LCD16x2/open-source-hardware ).
Programming from the main processor helps avoid a programming step or having multiple programmers. The main flash could be freed up after programming to use it for other purposes. For instance to allow "OTA" updates.
A "platform agnostic" way to do it would be to have a function that either reads from internal flash or external memory, but then there are a lot of external memories and the benefit from using a single chip would be lost. Using external memory would be useful for OTA programming for instance: the main processor receives the updated code, stores it in external flash, verifies it is ok and then sends it to the PIC.
Anyway, as far as I read, it's possible to adapt ZEPPP if the configuration is embedded with the build. I would create a script that transforms the "hex" file in a "C" file that can be added directly at build time.
I'll keep you posted if there is some concrete use, I am currently investigating the use of a PIC processor for "off board" driving of an LCD with push button handling.
Thanks for the detailed and quick response. There's definitely a lot of boards and platforms under the "Arduino" umbrella. That's why I mentioned that there's probably boards out there where space or extra buttons/LEDs are already provided. As it stands now, there's nothing in ZEPPP specific to one "Arduino" platform, so I'm quite reluctant to add a feature that would only work in a subset of the supported boards (although I can't claim full compatibility with EVERY Arduino-compatible board. For starters, I suspect that 3.3V boards will not work with PICs that require ~5V for LVP).
I don't know if I'm reading your use-case scenario correctly, but I think I get the general idea.
Creating a C file with the "HEX" embedded in the code along with the configuration so you can include it at compile-time is definitely possible. This is a bit more "involved" and "static" than the way that PicKit's "Programmer to Go" mode works, and a lot less convenient, but from what you say it seems like it would cover your needs and would bypass the need for external memory.
I recommend you to check the fw_commands.txt file, as well as the functions that each command calls inside the firmware to get an idea of how the differences between PICs are handled.
I will keep thinking on this, though. I'm not discarding the feature, but I am yet to think of a way in which this could be added in a more general, less-static fashion.
For the time being, I think I can help your experiments by isolating the PIC programming functions into its own file, separating them from the serial commands and wrapper methods. Would that be useful to you?
I am not sure I will build on this project, I do not want you to spent too much effort on this.
Separating the functions is always a good idea as it is a step towards possibilities for other uses.
Thank you for the pointers to the documents to read, first I'll have to check datasheets a bit further ;-).
Alright, so I refactored the firmware during the week, and tested it this weekend. Nothing seems broken and it's working exactly as before, so I committed the changes to the master branch without updating the firmware version number (as no features were introduced, and no bugs were fixed). All of the PIC programming functions should be in their own module now, with its corresponding header file.
This should make it easier for you, or anyone, who wants to get rid of the PC-communication side and make a standalone PIC programmer.
Regards,
@battlecoder Thank you for the update. The probability that I will build on this project decreased, but I'll keep this in mind ans maybe demonstrate that a computerless pic programmer is possible based on this.
Alright. I'll be closing the issue then!
Maybe you're not to far away from a stand-alone programmer.
The Pickit2 has a mode where the program can be loaded in Pickit2 which can then work without the computer and program pics with a push on the button.
If the hex file could be include in some way in the program itself, then the arduino would no longer require the CLI which is usefull for independent programming or in-circuit programming of a PIC from another controller.