-
Notifications
You must be signed in to change notification settings - Fork 183
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
autodetect first working version #147
base: master
Are you sure you want to change the base?
Conversation
I'll try to find a bit of time for testing next week or the week after. |
I tried with an STM8AF5288:
|
With a STM8S003K3 I get a segfault:
P.S.: Same with STM8S105C6. Maybe the segfault is triggered by the use of stlink instead of stlinkv2? |
not good. it means no part was autodetected. do you mind activating and sharing debug output? It will indicate if there is just a bug in the algorithm, or just that the autodetect approach isn't going to work at all. |
Yes, it is linked to the use of stlink; the stlinkv2 driver code was updated, but not stlink. |
The STM8AF5288 debug output:
|
Well, I was assuming the tables in STVP were correct. |
Hi @spth @vdudouyt,
For your consideration, this proposal for a STM8 device auto-detection.
For the moment only device reads are performed for the auto-detection. Based on the device table provided with STVP, it is possible to auto-detect STM8 families, sufficiently, to identify the flash block size, eeprom base address, read-out-protection (S or L), and regs (S or L).
In proposed code the auto-detection is currently added under the -a option, and works instead of the -p option. For instance, this command to perform autodetection only (on STM8S105):
-a option can be combined with existing actions in stm8flash, for example read from flash below on STM8S103. For now it reads/writes the smallest size detected.
The changes are essentially in autodetect.*
in main.c the auto-detection stage is added.
in stlinkv2.c the open() function was modified to effectively stall the CPU (there was a comment that CPU was stalled, but in reality only SWIM_DM was activated). For the auto-detection it was more convenient to have the CPU stalled immediately after reset, because then SP points to the top of RAM, and ram size can be deduced.
In stm8.c I adapted the ROP_UNKNOWN read_out_protection_mode values based on the datasheets/reference manuals. For instance there is a single reference manual for STM8AF and STM8S, so obviously these devices have the same handling for ROP.
The other changed files are cosmetic changes.
PR is not ready for merging yet, but I'm interested to know your results on other devices, and happy to take comments.
Thanks for testing & reviewing!