-
Notifications
You must be signed in to change notification settings - Fork 155
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
Enable qemu target for STM32 emulation #562
base: master
Are you sure you want to change the base?
Conversation
On the plus side, I can connect gdb to the qemu image, and trace it just fine. On the downside QEMU doesn't actually have profiler support. the 4.9 or newer embedded-gcc builds (I'm using 8-2019q4), come with python support for gdb. using this I can generate a full call-trace by single-stepping through the entire program. It is very slow, but it does work. I can also use this to map back to the current function as well so I can sot-of create a rudimentary profiler. keeping track of function calls and returns is theoretically possible, but I'm not sure how well it will work. I'm not sure how much more effort I want to put in this direction. |
well...I did some more work, and it is starting to be useful:
'ex' is the number of exclusive instructions (instructions executed directly in this function). 'inc' is the number of inclusive instructions (instructions executed in the current procedure and all its children). May still be buggy, but it seems to be working more or less |
LINKFILE = $(SDIR)/target/$(TARGET)/$(TARGET).ld | ||
LIBOPENCM3 = $(SDIR)/libopencm3/lib/libopencm3_stm32f1.a | ||
|
||
SRC_C := $(wildcard $(SDIR)/target/$(TARGET)/*.c) \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should create a Makefile.inc for all STM32 related parts. this makefile, the one under devo/common, and the one under at9 are largely duplicatd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes probably. This was only meant to be a proof-of-concept. certainly not ready for inclusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also need an instruction on qemu as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some documentation now.
// timer clock (RCC_APB1ENR_TIM4EN), Port (GPIOB), Pin (GPIO9) | ||
// Port clock RCC_APB2ENR_IOPBEN | ||
|
||
void BACKLIGHT_Init() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cna u just include another real implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some of these may be able to use a real implementation, but the qemu target does not have all STM32 features, and without proper SPI or clock support a lot of things won't work. Before I merge this, I'll clean up what can be done though.
Difference between curve options:
|
How can I map to the time from instruction #? look like there is no direct mapping between. |
It isn't working properly yet (maybe buggy in QEMU, I dunno yet), but you can query the systick timer ( -- |
After a lot of testing, I've concuded qemu does not accurately model the systick timer with regards to HCLK. This may note even be possible given that I'm note sure the details of pipeline stalling are even known. But currently systick cannot be reliably used to determine execution time in qemu. |
This is going to be a test of using QEMU to run STM32 code in a controlled environment to help with debug as well as do profiling.
There is a QEMU branch supporting STM32 here: https://github.com/beckus/qemu_stm32
It can be compiled from source, or used via docker
The STM32 target is somewhat limited (no SPI...limited timer modes) so it won't currently be able to run protocol code unaided, but I'm going to experiment with its capabilities in this pull-request.
The best supported board is the Olimex P103 which is an STM32F103RB based board. That is the same chip in the Devo7e, and it will be too small for a monolithic build. Likely we'll either need to patch Qemu to support a more capable chip (like the 'VC' variant used in the devo8) or we'll need to get SPI support so we can enable module loading. That is for another day.
The 1st task will be to get everything initialized, and try to profile the mixer code.
Currently the code jus