Welcome, Guest
Username: Password: Remember me
CodeTyphon Cross-Build Development, discussions and problems
  • Page:
  • 1

TOPIC:

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14969

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0
Hi all,

I've been having issues building a simple GTK2 application (literally just a TForm with a "Helloworld!" label) targetting the Pi Zero W.

From looking at the specifications, the Pi Zero W uses the same CPU & FPU as the Pi 1 (ARMv6Z CPU + VFPv2 FPU w/o NEON Support), so I followed the guide here: www.pilotlogic.com/sitejoom/index.php/93...for-rasberry-pi.html to download the Toolchain + OS Libraries for the Raspberry Pi 1 and setup the project.

Unfortunately, every time I run the application on the Pi Zero, I get the following stack-trace:
[FORMS.PP] ExceptionOccurred
  Sender=EAccessViolation
  Exception=Access violation
  Stack trace:
  $00190544  MULDIV,  line 3046 of lcltype.pp
  $001A7D1C  CREATE,  line 628 of include/font.inc
  $00174EFC  CREATE,  line 5195 of include/control.inc
  $0016231C  CREATE,  line 6578 of include/wincontrol.inc
  $0017750C  CREATE,  line 24 of include/customcontrol.inc
  $000582DC  CREATE,  line 299 of include/scrollingwincontrol.inc
  $000587BC  CREATE,  line 16 of include/customdesigncontrol.inc
  $0005ECF4  CREATENEW,  line 2066 of include/customform.inc
  $0005E8B0  CREATE,  line 2014 of include/customform.inc
  $00061ABC  CREATE,  line 3147 of include/customform.inc
  $0006B7AC  CREATEFORM,  line 2241 of include/application.inc
  $0001DC00  main,  line 19 of PiPassV2.ppr

Debugging the application using GDB shows an Illegal Instruction is executed:
Reading symbols from ./PiPassV2...done.
(gdb) break
No default breakpoint address now.
(gdb) break lcltype.pp:3046
Breakpoint 1 at 0x19050c: file lcltype.pp, line 3046.
(gdb) cond 1 NDENOMINATOR = 0
(gdb) run
Starting program: /home/pi/PiPassV2
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
 
Program received signal SIGILL, Illegal instruction.
0x00190544 in MULDIV (NNUMBER=0, NNUMERATOR=72, NDENOMINATOR=95)
    at lcltype.pp:3046
3046    lcltype.pp: No such file or directory.
(gdb)

I looked into the binary further by decompiling it in Ghidra, specifically, the MULDIV function (Ghidra decompilation: pastebin.com/NuQP3jbR), and it would seem it's using the vmov instruction,
00190544 00 0b b6 ee     vmov.f64   d0,0x3fe0000000000000
which is only supported in VFPv3 (not VFPv2) and as such, is not supported by the Pi Zero W (or Pi 1), which is causing this fault. (ARM Docs: developer.arm.com/documentation/dui0204/...fp-instructions/vmov).

My config is currently as such:
- Libraries: C:\codetyphon\binLibraries\arm-linux-Raspbian\
- Target OS: Linux
- Target CPU family (-P): arm
- Target Processor (-Cp): (Default)
- Additions and Overrides: Stored in project -> Targets -> IDE Macro -> LCLWidgetType:=gtk2

I'm using the Cross element for arm-linux: win32-arm-linux--RapberryPi or win64-arm-linux--RapberryPi

I've tried cross-compiling using both Typhon-Win32/FPC-Win32 & Typhon-Win64/FPC-Win64, both give the same results. Compiling a simple "writeln('helloworld');" console application works without an issue, it's only when I try to use GTK2/Forms.

Is this a known issue? If so, what is the correct combination of cross-compile toolchain + os library to target the Raspberry Pi Zero W?

Regards,

Kieron

Please Log in or Create an account to join the conversation.

Last edit: by Kieron.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14970

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
Thanks Sir
please more info:
-Your Raspberry Pi Zero W OS ?

-Your CodeTyphon Version ?
-Your CT Hosts CPU-OS ?
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14971

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: Thanks Sir
please more info:
-Your Raspberry Pi Zero W OS ?

-Your CodeTyphon Version ?
-Your CT Hosts CPU-OS ?

- The OS on the Pi Zero W is Raspbian (Latest)
- CodeTyphon version is latest stable (updated today).
- My host OS is Windows 10 running on AMD64.

I'd also like to add that I've tried specifying ARMv6Z as the target processor and including "-CfVFPV2" as a Custom Option. Neither of these things has worked.

Please Log in or Create an account to join the conversation.

Last edit: by Kieron.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14972

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
If your OS is the latest Raspbian
please try
1)
win32-arm-linux--RapberryPi3.7z or
win64-arm-linux--RapberryPi3.7z
with OS-Libraries
arm-linux-Raspbian3.7z

2)
you can try and:
win32-arm-linux--RapberryPi2.7z
win64-arm-linux--RapberryPi2.7z with
with OS-Libraries
arm-linux-Raspbian2.7z

Always you can Install CodeTyphon to Pi3 or Pi4 with the latest Raspbian
in this case any APP you build for Pi3/Pi4 can run direct and to Raspberry Pi Zero W

CodeTyphon target's to CPU family,
CPU type and specifications are OS problem (Raspbian etc)...

...
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14973

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: If your OS is the latest Raspbian
please try
1)
win32-arm-linux--RapberryPi3.7z or
win64-arm-linux--RapberryPi3.7z
with OS-Libraries
arm-linux-Raspbian3.7z

2)
you can try and:
win32-arm-linux--RapberryPi2.7z
win64-arm-linux--RapberryPi2.7z with
with OS-Libraries
arm-linux-Raspbian2.7z.
...

I have tried to use both RapberryPi2 & RapberryPi3 already, these didn't work, they fault on execution due to invalid opcodes (Pi Zero W uses a ARMv6Z + VFPv2, same as the Pi 1, the Pi 2 + 3 use different FPUs, thus instructions compiled to target this architecture will not work).

CodeTyphon target's to CPU family, CPU type and specifications are OS problem..

This doesn't sound right, I've literally shown that the compiler generated an opcode that cannot be run on an ARMv6Z/VFPv2 system, it literally uses an FVPv3 instruction, as shown in the documentation I provided in the OP, this same OPCode cannot run on an Raspberry Pi 1 as it also uses an ARMv6Z with VFPv2 - how is this not the compilers job, and why would it be generating instructions meant for VFPv3?

Please Log in or Create an account to join the conversation.

Last edit: by Kieron.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14974

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
Lets try something

Copy
codetyphon\binCenter\arm-linux-gtk2\CodeTyphon
to your Raspberry Pi Zero W
give execute permissions and try to run it

PS: We don't have Raspberry Pi Zero W in our lab
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14975

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: Lets try something

Copy
codetyphon\binCenter\arm-linux-gtk2\CodeTyphon
to your Raspberry Pi Zero W
give execute permissions and try to run it

PS: We don't have Raspberry Pi Zero W in our lab

That binary seems to work absolutely fine.

Please Log in or Create an account to join the conversation.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14976

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
This
build on Pi3 with the latest Raspbian
I can post screens from our 2xPi3 arm-boards

So try
win32-arm-linux--RapberryPi3.7z
with OS-Libraries
arm-linux-Raspbian3.7z


and let's focus in your app building procedure

PS: you can try to your Raspberry Pi Zero W all executables from
codetyphon\allzips\binfpc\arm-linux.7z
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14977

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: This
build on Pi3 with the latest Raspbian
I can post screens from our 2xPi3 arm-boards

So try
win32-arm-linux--RapberryPi3.7z
with OS-Libraries
arm-linux-Raspbian3.7z


and let's focus in your app building procedure

PS: you can try to your Raspberry Pi Zero W all executables from
codetyphon\allzips\binfpc\arm-linux.7z


Hi there, here is a video of me trying this as suggested, it's only a few minutes long: www.loom.com/share/6051049fcc274f8f91e5f25c34b2d2f2

If I do a readelf -a on your binary (i.e. CodeTyphon), I get:
Tag_CPU_name: "6"
Tag_CPU_arch: v6
 Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-1
Tag_FP_arch: VFPv2
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_VFP_args: VFP registers

If I do a readelf -a on my binary (i.e. "project1"), I get:
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: Deprecated
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6

The compiler seems to be generating code intended for v7+VFPv3.

Run output:
sudo ./project1
An unhandled exception occurred at $0001E300:
EAccessViolation: Access violation
  $0001E300

gdb output:
pi@raspberrypi:~$ sudo gdb ./project1
GNU gdb (Raspbian 8.2.1-2) 8.2.1
Copyright (C) 2018 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 "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
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 ./project1...done.
(gdb) run
Starting program: /home/pi/project1
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".

Program received signal SIGILL, Illegal instruction.
0x0001e300 in SYSTEM_$$_BARRIER ()
(gdb)

P.S. I've looked into the file: C:\codetyphon\typhon\lcl\units\arm-linux\lcltype.o and using readelf -a on this shows:
No version information found in this file.
Attribute Section: aeabi
File Attributes
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_CPU_name: "7-A"
  Tag_FP_arch: VFPv3-D16
  Tag_Advanced_SIMD_arch: No
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_ABI_VFP_args: VFP registers
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: None
  Tag_ABI_align_preserved: 8-byte, except leaf SP

Please Log in or Create an account to join the conversation.

Last edit: by Kieron.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14978

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
Try this
remove Debug info from your project


PilotLogic Architect and Core Programmer
Attachments:

Please Log in or Create an account to join the conversation.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14979

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: Try this
remove Debug info from your project

Same issue, now it just doesn't have the debugging symbols...
[FORMS.PP] ExceptionOccurred
  Sender=EAccessViolation
  Exception=Access violation

The generated code is still targetting ARMv7 + VFPv3:
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: Deprecated
  Tag_ABI_VFP_args: VFP registers
  Tag_DIV_use: Not allowed

Please Log in or Create an account to join the conversation.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14980

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
chmod 777 project1
./project1
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14981

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: chmod 777 project1
./project1

I am very aware of how to make a file executable in Linux, I didn't have to perform this task as the file was overwritten and thus the permissions remained the same. Had the file not had execute permissions then I wouldn't have gotten a stack-trace. In fact, the output of a non-executable file would be:
pi@raspberrypi:~$ ./project1
-bash: ./project1: Permission denied

I'll post a screenshot just to be clear:

Please Log in or Create an account to join the conversation.

Last edit: by Kieron.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14982

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
NO Sir
it's NOT
-bash: ./project1
it's
./project1

You build a GUI app, you don't need "bash" to run GUI APP on Linux
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Last edit: by Sternas Stefanos.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14983

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: NO Sir
it's NOT

-bash: ./project1
it's
./project1

You build a GUI app, you don't need "bash" to run GUI APP on Linux

Once again, thank you for the Linux lesson. However, I did not run "-bash ./project1", that was the output from bash when trying to run a binary "./project1" without the +x flag applied, this was to demonstrate that I HAD ALREADY applied chmod +x to binary previously, hence why I got the stack trace.

I'd appreciate it if you could stop condescending to me on my usage of Linux, I am well versed in Linux and use it day-to-day in a professional capacity.

To recap, the commands I ran are as follows:
chmod +x project1
export DISPLAY=:0
sudo ./project1
Nothing more, nothing less.

Please Log in or Create an account to join the conversation.

Last edit: by Kieron.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14984

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
Sir
we build a project1 with the same parameters as your project
you can download from here
has and project1 executable inside.

We Copy this executable to a Pi3 B+ with the latest Raspberry Pi more info here

and execute






what else we must do ?

Did you add libraries to your Pi Zero W ?
PilotLogic Architect and Core Programmer
Attachments:

Please Log in or Create an account to join the conversation.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14985

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: Sir
we build a project1 with the same parameters as your project
you can download from here
has and project1 executable inside.

We Copy this executable to a Pi3 B+ with the latest Raspberry Pi more info here

and execute






what else we must do ?

Did you add libraries to your Pi Zero W ?

Can you do an 'readelf -a' on the resulting binary and share the target CPU+FPU? I expect this works on the Pi 3 B+ because the Pi 3 B+ is an ARMv7 CPU with VFPv3 extensions, the Pi1 & Pi Zero W are ARMv6 with VFPv2 extensions.

I just tried to run your binary on the Pi Zero W:
pi@raspberrypi:~$ chmod +x project1
pi@raspberrypi:~$ ./project1
An unhandled exception occurred at $0001E4B0:
EAccessViolation: Access violation
  $0001E4B0

pi@raspberrypi:~$

and as expected, the readelf -a on your binary:
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: [b]"7-A"[/b]
  Tag_CPU_arch: [b]v7[/b]
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: [b]VFPv3[/b]
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_HardFP_use: Deprecated
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6

Please Log in or Create an account to join the conversation.

Last edit: by Kieron.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14986

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4512
  • Thank you received: 1101
Can you post a screen of you piw desktop ?
PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14987

  • zeljko
  • zeljko's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 207
  • Thank you received: 38
on linux, it was often a problem

{$IFDEF UseCThreads}

maybe here too

should be enabled
cthreads,

Please Log in or Create an account to join the conversation.

Last edit: by zeljko.

Cross Build Issues - Windows -> Pi Zero W 3 years 8 months ago #14988

  • Kieron
  • Kieron's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 14
  • Thank you received: 0

Sternas Stefanos wrote: Can you post a screen of you piw desktop ?

- Top left is an application compiled and working using Lazarus on the machine natively.
- Bottom right ('project1') is the binary you supplied as working.

zeljko wrote: on linux, it was often a problem

{$IFDEF UseCThreads}

maybe here too

should be enabled
cthreads,

I don't think that's the issue in this case, adding cthreads doesn't make a difference.

Please Log in or Create an account to join the conversation.

Last edit: by Kieron.
  • Page:
  • 1