Diskussions- und Newsboard des DARC-Ortsverbandes I40
allgemeine Kategorie => mcHF Projekt Deutsch / English (here you can discuss everything related to mcHF) => Message started by: dl8mby on 22. November 2016, 11:52:07

Title: QEMU und STM32F
Post by: dl8mby on 22. November 2016, 11:52:07

Hallo OM's
und vor allem hallo STM32F Experten,
Danilo, Ulrich und Co.

Falls nicht schon bekannt, es gibt einen STM32F
Emulator.

https://github.com/beckus/qemu_stm32

Diesen habe ich heruntergeladen und Übersetzt.

Hilfreich beim Aufruf waren auch die beiden Seiten:

http://cgi.cs.indiana.edu/~geobrown/stm32/Main/Simulation
https://balau82.wordpress.com/2010/11/04/qemu-arm-semihosting/

Leider wird als Maschine z.Z. nur ein stm32-p103 Board von Olimex
unterstützt.

Ein Aufruf in der Form:

qemu-system-arm -machine stm32-p103 -kernel mchf.bin -d in_asm,unimp,guest_errors
STM32_UART: ADC1 clock is set to 0 Hz.
STM32_UART: ADC1 BRR set to 0.
STM32_UART: ADC1 Baud is set to 0 bits per sec.
STM32_UART: ADC2 clock is set to 0 Hz.
STM32_UART: ADC2 BRR set to 0.
STM32_UART: ADC2 Baud is set to 0 bits per sec.
STM32_UART: ADC3 clock is set to 0 Hz.
STM32_UART: ADC3 BRR set to 0.
STM32_UART: ADC3 Baud is set to 0 bits per sec.
STM32_UART: DAC clock is set to 0 Hz.
STM32_UART: DAC BRR set to 0.
STM32_UART: DAC Baud is set to 0 bits per sec.
STM32_UART: TIM1 clock is set to 0 Hz.
STM32_UART: TIM1 BRR set to 0.
STM32_UART: TIM1 Baud is set to 0 bits per sec.
STM32_UART: TIM1 clock is set to 0 Hz.
STM32_UART: TIM1 BRR set to 0.
STM32_UART: TIM1 Baud is set to 0 bits per sec.
STM32_UART: DAC clock is set to 0 Hz.
STM32_UART: DAC BRR set to 0.
STM32_UART: DAC Baud is set to 0 bits per sec.
STM32_UART: ADC3 clock is set to 0 Hz.
STM32_UART: ADC3 BRR set to 0.
STM32_UART: ADC3 Baud is set to 0 bits per sec.
STM32_UART: ADC2 clock is set to 0 Hz.
STM32_UART: ADC2 BRR set to 0.
STM32_UART: ADC2 Baud is set to 0 bits per sec.
STM32_UART: ADC1 clock is set to 0 Hz.
STM32_UART: ADC1 BRR set to 0.
STM32_UART: ADC1 Baud is set to 0 bits per sec.
LED Off
CLKTREE: HSI Output Change (SrcClk:None InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
CLKTREE: HSI/2 Output Change (SrcClk:HSI InFreq:8000000 OutFreq:4000000 Mul:1 Div:2 Enabled:1)
CLKTREE: SYSCLK Output Change (SrcClk:HSI InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
CLKTREE: HCLK Output Change (SrcClk:SYSCLK InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
STM32_RCC: Cortex SYSTICK frequency set to 8000000 Hz (scale set to 125).
STM32_RCC: Cortex SYSTICK ext ref frequency set to 1000000 Hz (scale set to 1000).
CLKTREE: PCLK1 Output Change (SrcClk:HCLK InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
CLKTREE: PCLK2 Output Change (SrcClk:HCLK InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
----------------
IN:
0x08010768: f861 ee00 str??t   lr, [r1]

arm_gic: Set 6 pending cpu 0
arm_gic: Raised pending IRQ 6 (cpu 0)
arm_gic: ACK 6
----------------
IN:
0x08010274: 4621 mov   r1, r4
0x08010276: 005a lsls   r2, r3, #1
0x08010278: eeb8 0a67 fuitos   s0, s15

arm_gic: Set 6 pending cpu 0
----------------
IN:
0x08010278: eeb8 0a67 fuitos   s0, s15

Liefert den o.g. Output.

Mir ist klar, dass die verwendete emulierte HW noch ganz zum
mcHF passt, ich wollte aber diese Info hier posten.
Vielleicht könnt Ihr damit mehr anfangen und es hilft dem einen
oder anderen mehr Einblick in die MC-Seite zu bekommen.

Entsprechend den Anweisungen der schon genannten Seite

http://cgi.cs.indiana.edu/~geobrown/stm32/Main/Simulation

Kann man den Gun-Debugger gdb mit bei der Emulation
verwenden.

qemu-system-arm -machine stm32-p103 -nographic -monitor null -serial null -semihosting -kernel mchf.elf -gdb tcp::51234 -S
STM32_UART: ADC1 clock is set to 0 Hz.
STM32_UART: ADC1 BRR set to 0.
STM32_UART: ADC1 Baud is set to 0 bits per sec.
STM32_UART: ADC2 clock is set to 0 Hz.
STM32_UART: ADC2 BRR set to 0.
STM32_UART: ADC2 Baud is set to 0 bits per sec.
STM32_UART: ADC3 clock is set to 0 Hz.
STM32_UART: ADC3 BRR set to 0.
STM32_UART: ADC3 Baud is set to 0 bits per sec.
STM32_UART: DAC clock is set to 0 Hz.
STM32_UART: DAC BRR set to 0.
STM32_UART: DAC Baud is set to 0 bits per sec.
STM32_UART: TIM1 clock is set to 0 Hz.
STM32_UART: TIM1 BRR set to 0.
STM32_UART: TIM1 Baud is set to 0 bits per sec.
STM32_UART: TIM1 clock is set to 0 Hz.
STM32_UART: TIM1 BRR set to 0.
STM32_UART: TIM1 Baud is set to 0 bits per sec.
STM32_UART: DAC clock is set to 0 Hz.
STM32_UART: DAC BRR set to 0.
STM32_UART: DAC Baud is set to 0 bits per sec.
STM32_UART: ADC3 clock is set to 0 Hz.
STM32_UART: ADC3 BRR set to 0.
STM32_UART: ADC3 Baud is set to 0 bits per sec.
STM32_UART: ADC2 clock is set to 0 Hz.
STM32_UART: ADC2 BRR set to 0.
STM32_UART: ADC2 Baud is set to 0 bits per sec.
STM32_UART: ADC1 clock is set to 0 Hz.
STM32_UART: ADC1 BRR set to 0.
STM32_UART: ADC1 Baud is set to 0 bits per sec.
LED Off
CLKTREE: HSI Output Change (SrcClk:None InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
CLKTREE: HSI/2 Output Change (SrcClk:HSI InFreq:8000000 OutFreq:4000000 Mul:1 Div:2 Enabled:1)
CLKTREE: SYSCLK Output Change (SrcClk:HSI InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
CLKTREE: HCLK Output Change (SrcClk:SYSCLK InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
STM32_RCC: Cortex SYSTICK frequency set to 8000000 Hz (scale set to 125).
STM32_RCC: Cortex SYSTICK ext ref frequency set to 1000000 Hz (scale set to 1000).
CLKTREE: PCLK1 Output Change (SrcClk:HCLK InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
CLKTREE: PCLK2 Output Change (SrcClk:HCLK InFreq:8000000 OutFreq:8000000 Mul:1 Div:1 Enabled:1)
arm_gic: Set 6 pending cpu 0
arm_gic: Raised pending IRQ 6 (cpu 0)
arm_gic: ACK 6
arm_gic: Set 6 pending cpu 0

Window #2:
==========

arm-none-eabi-gdb mchf.elf
GNU gdb (GNU Binutils; home:wkazubski / openSUSE_13.2) 7.10.50.20151217-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://bugs.opensuse.org/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from mchf.elf...done.
(gdb) target remote localhost:51234
Remote debugging using localhost:51234
0x00000000 in ?? ()
(gdb) load
Loading section .text, size 0x68748 lma 0x8010000
Loading section .ARM.exidx, size 0x8 lma 0x8078748
Loading section .data, size 0x1544 lma 0x8078750
Start address 0x8010000, load size 433300
Transfer rate: 9198 KB/sec, 2015 bytes/write.
(gdb) break main
Breakpoint 1 at 0x801068e

Hat jemand von Euch eine Ahnung/Idee, wie man das
mchf.bin Image durchsteppen könnte (ohne HW Debugger
wie den J-Link).

vy73
Markus
DL8MBY

Title: Re:QEMU und STM32F
Post by: DF8OE on 22. November 2016, 12:25:57

Hallo Markus,

leider ist das p103-Board zum Testen der Firmware komplett ungeeignet, da es sich um eine ganz andere Hardwarestruktur (incl. Lage / Vorhandensein) diverser Register handelt. Du wirst das so nicht machen können!

vy 73
Andreas

Title: Re:QEMU und STM32F
Post by: dl8mby on 22. November 2016, 12:41:32

Hallo Andreas,

bin jetzt schon ein wenig weiter aber nur ein wenig!

Siehe:

https://www.mikrocontroller.net/topic/412784#4802248

qemu-system-arm -M virt -cpu ?
qemu-system-arm -M virt -cpu cortex-m3 -kernel mchf.bin

qemu-system-arm: mach-virt: CPU cortex-m3 not supported

Habe schon einen QEMU version gefunden die F1XX und F2XX
unterstützt.

https://github.com/martijnthe/qemu_stm32

Markus

Title: Re:QEMU und STM32F
Post by: DF8OE on 22. November 2016, 13:07:46

Hallo Markus,

auch die F1 und F2 Serie hat eine andere "innere" Hardware mit entsprechend anderen Registerlagen. Einige Register, die die F4 haben, fehlen sogar vollständig. Ich befürchte daher, dass auch das (wenn überhaupt) nur mit sehr viel Handarbeit zum Laufen zu bekommen ist.

Ganz davon abgesehen, dass so viele Hardwareaktionen im mcHF vorhanden sind, dass deren "händische Abarbeitung" (Register setzen bzw. prüfen) sehr aufwändig sein dürfte. Ich würde an deiner Stelle eher versuchen, das live-Debugging mit dem ST-LinkV2 aufzusetzen. Das bringt einen richtig weiter und ist vergleichsweise einfach...

Du kannst das vollständig in Eclipse integrieren - Danilo hat dazu ein ausgezeichnetes How-To geschrieben.

vy 73
Andreas

Title: Re:QEMU und STM32F
Post by: DB4PLE on 22. November 2016, 16:09:02

Hallo Markus,

der QEMU tut nicht. Wir brauchen einen Cortex M4 mit FPU + STM32F4 Peripherie. Leider noch nicht vorhanden. Habe selbst schon gesucht und habe sogar eine STM32F4 / Cortex M4 Emulation gefunden. Und zwar beim QEMU für ARM: https://gnuarmeclipse.github.io/qemu/

Da gibt es 2 STM32F4 Discoveryboards, die recht ähnlich sind. Auf denen würde mcHF.bin booten, wenn nicht die FPU Emulation fehlen würde. Und damit ist das komplett unbenutzbar mit einem normalen mcHF.bin. Man kann natürlich theoretisch auch eine Übersetzung ohne FPU machen, aber dann unterscheiden sich große Teil der SW und es muss auch der Buildprozess angepasst werden, damit die richtigen Bibliotheken gelinkt werden (z.B. die DSP Lib für Nicht FPU CPUs -> geht vermutlich).

Lange Rede, kurzer Sinn: geht derzeit nicht nach meinem Kenntnisstand.

Und dann fehlt noch die Emulation der Peripherie, zu allererst der Si570.

73
Danilo


Title: Re:QEMU und STM32F
Post by: dl8mby on 23. November 2016, 08:00:51

Hallo Danilo,

den von Dir genannten Link habe ich auch schon gefunden
und versuche das git-package zu compilieren, leider noch mit
Fehlern, s.u. (hast Du hierzu eine Idee für die Ursache?)

Andreas hat ja schon mir eingebläut, dass ich mich eher mit
dem HW-Debuggen beschäftigen soll, statt Zeit für QEMU
zu verlieren.

Da ich aber generell Erfahrung im Umgang mit den STM32F
MC's sammeln würde ist aus meiner Sicht die QEMU Emulation
durchaus ein nützlicher Helfer, auch wenn er nicht für den
mcHF Code taugen sollte.

vy73
Markus
DL8MBY

make
LINK arm-softmmu/qemu-system-arm
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: warning: libjpeg.so.8, needed by /usr/lib64/libSDL_image.so, may conflict with libjpeg.so.62
monitor.o: In function `hmp_wavcapture':
....mchfTRX/qemu-gnuarmeclipse-dev/monitor.c:1629: undefined reference to `wav_start_capture'
hw/char/omap_uart.o: In function `omap_uart_read':
....mchfTRX/qemu-gnuarmeclipse-dev/hw/char/omap_uart.c:77: undefined reference to `omap_badwidth_read8'
hw/char/omap_uart.o: In function `omap_uart_write':
....mchfTRX/qemu-gnuarmeclipse-dev/hw/char/omap_uart.c:115: undefined reference to `omap_badwidth_write8'
hw/display/omap_dss.o: In function `omap_diss_read':
....

....
....mchfTRX/qemu-gnuarmeclipse-dev/hw/usb/dev-bluetooth.c:516: undefined reference to `qemu_find_bt_vlan'
....mchfTRX/qemu-gnuarmeclipse-dev/hw/usb/dev-bluetooth.c:516: undefined reference to `bt_new_hci'
../hw/usb/dev-bluetooth.o: In function `usb_bt_init':
....mchfTRX/qemu-gnuarmeclipse-dev/hw/usb/dev-bluetooth.c:533: undefined reference to `hci_init'
....mchfTRX/qemu-gnuarmeclipse-dev/hw/usb/dev-bluetooth.c:535: undefined reference to `qemu_find_bt_vlan'
....mchfTRX/qemu-gnuarmeclipse-dev/hw/usb/dev-bluetooth.c:535: undefined reference to `bt_new_hci'
../ui/vnc.o: In function `audio_add':
....mchfTRX/qemu-gnuarmeclipse-dev/ui/vnc.c:1170: undefined reference to `AUD_add_capture'
../ui/vnc.o: In function `audio_del':
....mchfTRX/qemu-gnuarmeclipse-dev/ui/vnc.c:1179: undefined reference to `AUD_del_capture'
collect2: Fehler: ld gab 1 als Ende-Status zurück
make[1]: *** [qemu-system-arm] Fehler 1
make: *** [subdir-arm-softmmu] Fehler 2


Eine Installation von libjpeg.so.8 hat auch keinen Erfolg gebracht!

Title: Re:QEMU und STM32F
Post by: DF8OE on 23. November 2016, 13:44:29

Dir fehlen devel-Pakete. Schau doch nochmal nach, welche dev-Pakete als Voraussetzung für das Bauen von qemu aufgeführt sind.

Gibt es in dem Projekt ein configure-Script? Die geben meist richtig transparent Auskunft, wo noch was fehlt...

Die Sache mit den beiden libjpeg-Libs kann auch kritisch sein. Ich denke, es darf nur EINE von beiden installiert sein.

vy 73
Andreas

Title: Re:QEMU und STM32F
Post by: dl8mby on 23. November 2016, 13:58:51

Hallo Andreas,

ich habe das QEMU Packet mit

./configure --disable-werror --enable-debug
--target-list="arm-softmmu"

gebaut.

Danach mit
./configure --interp-prefix=arm-softmmu --enable-debug
--disable-werror --disable-fdt --disable-libiscsi --disable-libnfs --disable-libusb --disable-usb-redir

Was zwar die Anzahl der Fehler etwas reduziert hat aber
der Linkvorgang hat trotzdem nicht geklappt.

Was mich irritiert ist, dass trotz Angabe von
--interp-prefix=arm-softmmu

und Ausgabe von configure

-D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -lSDL -lpthread -lX11
-D_GNU_SOURCE=1 -D_REENTRANT -I/usr/include/SDL -lSDL -lpthread -lX11 -lSDL_image -lX11
Install prefix /usr/local
BIOS directory /usr/local/share/qemu
binary directory /usr/local/bin
library directory /usr/local/lib
module directory /usr/local/lib/qemu
libexec directory /usr/local/libexec
include directory /usr/local/include
config directory /usr/local/etc
local state directory /usr/local/var
Manual directory /usr/local/share/man
ELF interp prefix arm-softmmu
Source path /home/markus/Elektrotechnik/Afu/mchfTRX/qemu-gnuarmeclipse-dev
C compiler cc
Host C compiler cc
C++ compiler c++
Objective-C compiler clang
ARFLAGS rv
CFLAGS -pthread -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -g
QEMU_CFLAGS -I/usr/include/pixman-1 -fPIE -DPIE -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-all -I/usr/include/libpng12
LDFLAGS -Wl,--warn-common -Wl,-z,relro -Wl,-z,now -pie -m64 -g
make make
install install
python python -B
smbd /usr/sbin/smbd
module support no
host CPU x86_64
host big endian no
target list aarch64-softmmu alpha-softmmu arm-softmmu cris-softmmu gnuarmeclipse-softmmu i386-softmmu lm32-softmmu m68k-softmmu microblazeel-softmmu microblaze-softmmu mips64el-softmmu mips64-softmmu mipsel-softmmu mips-softmmu moxie-softmmu or32-softmmu ppc64-softmmu ppcemb-softmmu ppc-softmmu s390x-softmmu sh4eb-softmmu sh4-softmmu sparc64-softmmu sparc-softmmu tricore-softmmu unicore32-softmmu x86_64-softmmu xtensaeb-softmmu xtensa-softmmu aarch64-linux-user alpha-linux-user armeb-linux-user arm-linux-user cris-linux-user i386-linux-user m68k-linux-user microblazeel-linux-user microblaze-linux-user mips64el-linux-user mips64-linux-user mipsel-linux-user mips-linux-user mipsn32el-linux-user mipsn32-linux-user or32-linux-user ppc64abi32-linux-user ppc64le-linux-user ppc64-linux-user ppc-linux-user s390x-linux-user sh4eb-linux-user sh4-linux-user sparc32plus-linux-user sparc64-linux-user sparc-linux-user tilegx-linux-user unicore32-linux-user x86_64-linux-user
tcg debug enabled yes
gprof enabled no
sparse enabled no
strip binaries no
profiler no
static build no
pixman system
SDL support yes (1.2.15)
GTK support yes (2.24.31)
GTK GL support no
VTE support no
TLS priority NORMAL
GNUTLS support no
GNUTLS rnd no
libgcrypt yes
libgcrypt kdf yes
nettle no
nettle kdf no
libtasn1 no
curses support yes
virgl support no
curl support yes
mingw32 support no
Audio drivers oss
Block whitelist (rw)
Block whitelist (ro)
VirtFS support no
VNC support yes
VNC SASL support no
VNC JPEG support yes
VNC PNG support yes
xen support no
brlapi support no
bluez support no
Documentation yes
PIE yes
vde support no
netmap support no
Linux AIO support yes
ATTR/XATTR support yes
Install blobs yes
KVM support yes
RDMA support no
TCG interpreter no
fdt support yes
preadv support yes
fdatasync yes
madvise yes
posix_madvise yes
uuid support yes
libcap-ng support yes
vhost-net support yes
vhost-scsi support yes
Trace backends log
spice support no
rbd support no
xfsctl support no
smartcard support no
libusb no
usb net redir no
OpenGL support no
OpenGL dmabufs no
libiscsi support no
libnfs support no
build guest agent yes
QGA VSS support no
QGA w32 disk info no
QGA MSI support no
seccomp support no
coroutine backend ucontext
coroutine pool yes
GlusterFS support no
Archipelago support no
gcov gcov
gcov enabled no
TPM support yes
libssh2 support no
TPM passthrough yes
QOM debugging yes
vhdx yes
lzo support no
snappy support no
bzip2 support yes
NUMA host support no
tcmalloc support no
jemalloc support no
avx2 optimization yes

make auch andere Targets compiliert:


z.B.
CC disas/cris.o
CC disas/i386.o
CC disas/m68k.o
CC disas/microblaze.o
CC disas/mips.o
CC disas/moxie.o
CC disas/ppc.o
CC disas/s390.o
CC disas/sh4.o
CC disas/sparc.o
CC disas/lm32.o

...

Markus




Title: Re:QEMU und STM32F
Post by: DF8OE on 23. November 2016, 14:06:24

Schau mal hier (http://stackoverflow.com/questions/26664946/target-list-meaning-in-qemu-installation)

vy 73
Andreas


Diskussions- und Newsboard des DARC-Ortsverbandes I40 | Powered by YaBB SE
© 2001-2003, YaBB SE Dev Team. All Rights Reserved.