-
Notifications
You must be signed in to change notification settings - Fork 26
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
Add two Nucleo boards, GDB debugging and SVD files for all boards #38
Conversation
Also corrects the logic that derives the value for -p switch in the stm8flash invocation (would do 'stm8s207?8' and not 'stm8s207k8')
Both the boards have the user-LED connected to PC5 per board manual. E.g. https://www.st.com/resource/en/user_manual/dm00489875-stm8-nucleo32-board-mb1442-stmicroelectronics.pdf
Many thanks, looks promising! Please see my comments in review. |
I'll address the comments tomorrow and also fix a still wrongly built |
Switching from SDCC to stm8-objcopy to Intel HEX file generation has the advantage of just copying the relevant sections (and ignoring the debug sections that sdcc would otherwise include), but also care must be taken that all sections which do not end up in FLASH are removed. Two more sections are removed during copying, which are created when initialized and uninitialized global variables are used within a project.
I've addressed the review comments and also fixed a bug in the Intel Hex file generation logic which previously prevented an upload as soon as a global variable was being created. |
Thanks for the fixes! BTW, that new hex file generation logic works fine with the Arduino framework, right? |
I can confirm that it does in normal release build mode. I've forked an Arduino project that plays the Tetris theme on a buzzer at https://github.com/maxgerhardt/TetrisThemeArduino, and it works with the my new platform perfectly. I've tested it on my STM8S103F3 board ( However, debugging the Arduino framework code is currently not possible because of one freaking file failing compilation in |
This will be re-downloaded before a debugging session starts and we do not need to worry.
Many thanks for such a great contribution! I'm working on updates for SDCC and Sduino in a separate branch, so it will be a great release! |
Awesome! Might also consider merging PR #28 for a STM8S003 chip and add the few extra items for debug support there? :) |
I've just merged my branch into dev and also added minor changes to your previous code, would be great if you could take a look. Unfortunately, I don't have any ST8-based board at hand so it would be really great if you could test the latest revision (compiling, uploading, debugging). |
I've built my stm8-headers-pio project from the PR decsription with the latest dev platform; it updated some packages, then compiled and uploaded just fine. Also works (blinks LED).
However, debugging broke. There doesn't seem to be any debug information in the ELF file anymore, also it doesn't halt at the initial breakpoint anymore (
|
Ah, I think I figured out the cause. The My platform:
Yours:
You removed it in e16be52 If I add |
That's interesting. IIRC, the
But if it's helps to produce a proper binary for debugging, let's then add it to |
Seems to be not well documented, but per https://sourceforge.net/p/sdcc/discussion/1864/thread/aa45ea7ea2/#fad2/429a
The comment below says
|
With the latest commit, debugging functionality is restored again with no extra flags needed. But, the updated Arduino core does not run anymore on my STM8S103F3 board. It simply outputs nothing (refer Tetris example above), like it doesn't even reach If I roll back just the Arduino core version but still use the latest platform version, it works again
Compile output from 0.40.0 Arduino core:
from new 0.50.0 core:
The size decreased quite a bit, but maybe something important was removed? I'll see what I can find out that makes this non-working.. |
Hm, it works out of the box when installing the 0.5.0 core in the Arduino IDE (https://github.com/tenbaht/sduino#installation) and using the same Tetris code. I'll see what the differences during build are. In the Arduino IDE, the build size is
But the build there also uses SDCC |
This is pretty absurd. Adding a |
Any better if you downgrade the toolchain? |
Downgrading to 3.8.4 ( But if I use the exact toolchain that SDCC does, 3.9.1 (which isn't even listed in https://sourceforge.net/projects/sdcc/files/sdcc-win64/ so I had to pull it from
which is resolved by the two lines of code found in tenbaht/sduino#76 (comment). Then it compiles, uploads and runs correctly. So for some magical reason, that exact SDCC version has to be used and that dummy variable trick. If I read tenbaht/sduino@c7ebb07 correctly that's also what they do with
I'll retry with SDCC 4.0 though. |
A SDCC 4.0 downloaded straight from https://sourceforge.net/projects/sdcc/files/sdcc-win64/4.0.0/ works too but also needs the So I guess it's best to use either SDCC 4.0 or their exact SDCC 3.9.1 with that dummy variable inclusion, and open an issue in SDCC on why SDCC 4.1 won't make it work correctly? I've looked in to the If only I could debugging with the Arduino framework to work, then I could look where the chip is stuck.. |
Thanks for the help, let's stick to that SDCC 3.9.1 at least for Sduino. |
Arduino is now switched to SDCC v3.9.1. I also added a hacky workaround to avoid the |
Just tested with standard
The firmware size now also is 100% equal to what the Arduino IDE outputs per #38 (comment). So, all works normally in release mode :) The debugging issue with Still sad that the 0.50 core can't be compiled to a working firmware with SDCC 4.1 but 0.40 could. I'll open a separate issue in sduino for that (or SDCC if that's the culprit). |
Slightly off-topic, but with platformio/platformio-core#3872 resolved this would make an even better release / less frustration and weirdness for more users 😄 |
Oh, but debugging has broken again. Pressing the debug button VSCode results in a short loading time, then the debug buttons disappear. I'll check if that change did that. |
Yes 100%. Commenting out Lines 46 to 47 in acb8a45
makes debugging working again with my pio-stm8-headers example from the PR description. The
Maybe has something to do with that
(for |
Thanks, I see now. Removed that lines. |
Retested with latest commit and now debugging is working again, Arduino sketch works as before. |
This superseedes my PR #37.
See explanations in PR#37 why certain things were done to support and flash the new boards.
To get debugging working, I fixed a few things, restructured a bit and added a bit of code:
.cfg
file is placed in the board manifest asopenocd_target
as with other platforms (e.g. stm32)built_type = debug
mode was broken because SDCC was given the defaultdebug_build_flags
with-Og -g2
etc., which it does not understand. Thanks to research in Add debug support using STLink(/V2) via OpenOCD #31, the right flags were found,--debug --out-fmt-elf
.ihx
build output file in debug mode because when converting it with SDCC to hex it also dumps the debug information in there, at address 0x0000, which crashes the uploader program and makes no sense at all. The ELF file is fine however, so I usedstm8-objcopy
to convert the ELF to IHX (while removing the wrong sections).This brings debugging from nothing for most boards to full debugging support for all boards with peripheral view thanks to SVD files!
Closes #33, #34 and #31.