Recent

Author Topic: Access Violation on QEMU (ARM)  (Read 3511 times)

Tesla2k

  • New member
  • *
  • Posts: 6
Access Violation on QEMU (ARM)
« on: July 07, 2018, 04:55:11 pm »
Hello,
I am developing a software for my Raspberry Pi, with cross compilation from Windows. On the Pi the software runs without problems. To make testing easier I want to use QEMU to emulate the pi. I downloaded the package from https://sourceforge.net/projects/rpiqemuwindows/
But I get an access violation when starting the app:

Code: [Select]
An unhandled exception occurred at $0002F1EC:
EAccessViolation: Access violation
  $0002F1EC

This also happens when I try it with a newly created empty app.
I have intalled the stable version of Lazarus with fpcupdeluxe.

Why does it work on the real raspberry and not in QEMU? How can I fix it?

Thank You



sash

  • Sr. Member
  • ****
  • Posts: 287
Re: Access Violation on QEMU (ARM)
« Reply #1 on: July 07, 2018, 09:24:35 pm »
Since you didn't provide any code I could only guess there are some missing / wrong version libraries inside virtual image os. It's a good practice to wrap critical and suspicious places with try-except block, to know what and when goes wrong. Also, inspect your executable for missing library dependencies with
Code: Bash  [Select]
  1. ldd your_executable
Lazarus 2.0.6 FPC 3.0.4 x86_64-linux-gtk2 -- Ubuntu 19.10 XFCE

Tesla2k

  • New member
  • *
  • Posts: 6
Re: Access Violation on QEMU (ARM)
« Reply #2 on: July 08, 2018, 04:42:49 pm »
It is just an empty project, so no code written at all.

I checked the executable with ldd. All there were no missing libraries

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7592
Re: Access Violation on QEMU (ARM)
« Reply #3 on: July 08, 2018, 05:30:48 pm »
Then QEMU bug is most likely. IS there a list of know problems for the architecture that you use?

Tesla2k

  • New member
  • *
  • Posts: 6
Re: Access Violation on QEMU (ARM)
« Reply #4 on: July 13, 2018, 06:00:47 pm »
Then QEMU bug is most likely. IS there a list of know problems for the architecture that you use?

I found a Bug list for ARM. There are some entries resulting in an acces violation. But I don't know wether they are connected to my problem

https://bugs.launchpad.net/qemu/+bugs?field.tag=arm

If its a bug it must be something only Lazarus does. X and every programm installed with raspian which I tried works.

Tesla2k

  • New member
  • *
  • Posts: 6
Re: Access Violation on QEMU (ARM)
« Reply #5 on: July 13, 2018, 06:03:02 pm »
I made some more test:

1. I console programm with just writeln works
2. As soon as I add
Code: Pascal  [Select]
  1. uses Classes;

the error occurs.

Here is a backtrace from gdb
Code: [Select]
Starting program: /home/pi/project1

Program received signal SIGILL, Illegal instruction.
0x00010750 in SYSTEM_$$_BARRIER ()
(gdb) bt
#0  0x00010750 in SYSTEM_$$_BARRIER ()
#1  0x0001a0c8 in SYSTEM_$$_READWRITEBARRIER ()
#2  0x0008bd6c in SYSUTILS$_$TMULTIREADEXCLUSIVEWRITESYNCHRONIZER_$__$$_CREATE$$TMULTIREADEXCLUSIVEWRITESYNCHRONIZER ()
#3  0x0005cf0c in CLASSES_$$_COMMONINIT ()
#4  0x00066418 in CLASSES_$$_init$ ()
#5  0x00031f90 in fpc_initializeunits ()
#6  0x00010184 in main () at project1.lpr:71


Laksen

  • Hero Member
  • *****
  • Posts: 624
    • J-Software
Re: Access Violation on QEMU (ARM)
« Reply #6 on: July 13, 2018, 06:07:07 pm »
What parameters did you give to qemu?

Tesla2k

  • New member
  • *
  • Posts: 6
Re: Access Violation on QEMU (ARM)
« Reply #7 on: July 13, 2018, 06:23:15 pm »
What parameters did you give to qemu?

qemu-system-arm.exe  -redir tcp:2222::22 -M versatilepb -cpu arm1176 -hda 2012-07-15-wheezy-raspbian.img -kernel kernel-qemu -m 192 -append "root=/dev/sda2"

Thaddy

  • Hero Member
  • *****
  • Posts: 9278
Re: Access Violation on QEMU (ARM)
« Reply #8 on: July 13, 2018, 06:28:32 pm »
Are you by any chance using the VideoCore? Because that is not supported by QEMU.
I ran into that while developing the OpenVG port.
Usually I develop on the pi itself (even Pi1)
also related to equus asinus.

Tesla2k

  • New member
  • *
  • Posts: 6
Re: Access Violation on QEMU (ARM)
« Reply #9 on: July 13, 2018, 08:25:42 pm »
Are you by any chance using the VideoCore? Because that is not supported by QEMU.
I ran into that while developing the OpenVG port.
Usually I develop on the pi itself (even Pi1)
I don't think so. This is my whole testprogramm

Code: Delphi  [Select]
  1. program project1;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. uses Classes;
  6.  
  7. begin
  8.  
  9. end.
  10.  
         


I don't know gdb so well, but it seems that the dmb command is the problem:

Code: [Select]
Dump of assembler code for function SYSTEM_$$_BARRIER:
=> 0x00010750 <+0>:     dmb     sy
   0x00010754 <+4>:     bx      lr
                 


Laksen

  • Hero Member
  • *****
  • Posts: 624
    • J-Software
Re: Access Violation on QEMU (ARM)
« Reply #10 on: July 14, 2018, 11:46:22 am »
You need to compile a new compiler and your program for armv6z. ARM1176 is an ARM6 core but often labelled as armv7l which is some marketing designation that doesn't exist

Thaddy

  • Hero Member
  • *****
  • Posts: 9278
Re: Access Violation on QEMU (ARM)
« Reply #11 on: July 14, 2018, 11:52:56 am »
You need to compile a new compiler and your program for armv6z. ARM1176 is an ARM6 core but often labelled as armv7l which is some marketing designation that doesn't exist
Ahum: he didn't mention his Raspberry Pi version. That makes a huge difference. later RPi 2's and 3 are definitely ARMv7+: ARM Cortex-A7 x4 , resp. ARM Cortex-A53 x4 and 3 also support AARCH64.
I suspect he has a 2 or 3. The 1 (and the zero family) are ARM1176 and armv6. The later models, except the zero, are as above.
A properly configured QEMU should have no problems (except it has no proper VideoCore IV simulation.)
« Last Edit: July 14, 2018, 12:02:18 pm by Thaddy »
also related to equus asinus.

Laksen

  • Hero Member
  • *****
  • Posts: 624
    • J-Software
Re: Access Violation on QEMU (ARM)
« Reply #12 on: July 14, 2018, 11:54:36 am »
You need to compile a new compiler and your program for armv6z. ARM1176 is an ARM6 core but often labelled as armv7l which is some marketing designation that doesn't exist
Ahum: he didn't mention his Raspberry Pi version.
The qemu commandline explicitly selects arm1176

Thaddy

  • Hero Member
  • *****
  • Posts: 9278
Re: Access Violation on QEMU (ARM)
« Reply #13 on: July 14, 2018, 12:03:37 pm »
Then he has indeed a higher version of the Pi and needs to specify the proper processor to emulate.
The other option is to rebuild an fpc compiler for ARMv6. That generates code that is compatible wit all three flavors.
« Last Edit: July 14, 2018, 01:08:57 pm by Thaddy »
also related to equus asinus.