cross compiling from fpc_win32bit to arm lazarus / 32-Linux ---------------------------------------------------------------------- sporex · 2023-07-30 13:13 I was afraid to tackle this subject of crosscompiling for a long time but now it seems that I cannot avoid it anymore: I have used fpcupdeluxe to install the 32bit compiler/IDE package on a W10 64bit PC. Moreover I have installed the crosscompiler for ARM. My target system is a single core BCM2835 CPU that runs a 32bit Raspbian Bullseye lite  OS: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i processor     : 0model name      : ARMv6-compatible processor rev 7 (v6l)BogoMIPS        : 697.95Features        : half thumb fastmult vfp edsp java tlsCPU implementer : 0x41CPU architecture: 7CPU variant     : 0x0CPU part        : 0xb76CPU revision    : 7 Hardware        : BCM2835Revision        : 9000c1Serial          : 0000000036474c52Model           : Raspberry Pi Zero W Rev 1.1  I wrote a simple source code for testing it: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i program test32bit; {$mode objfpc}{$H+}  var i:word; begin         for i:= 1 to 32000 do writeln('I=',i);     end.                     and set the Project Options/Config and Target/Target OS : Linux CPU family : arm Target processor: here I compiled with different options: Default, ARMV6, ARMV6Z And transfer the executable file to the target CPU. When running it I will get the following error codes: - access violation if I compile with Target CPU=default - runtime error if I compile with Target CPU=ARMV6 or ARMV6Z What is wrong with my approach? Thank you ---------------------------------------------------------------------- TRon · 2023-07-30 15:35 Quote from: sporex on July 30, 2023, 03:13:05 pmAnd transfer the executable file to the target CPU. When running it I will get the following error codes: - access violation if I compile with Target CPU=default - runtime error if I compile with Target CPU=ARMV6 or ARMV6Z Target CPU=default means usually using the processor that your host uses Copy the produced executable over to your raspbian machine and then: what does the command $>file name-of-compiled-file show you and what does the command $>file name-of-native-working-executable show you ? does the output differ ? How do they differ ? That is the way you can check the executable result and compare with your (actual) target. The second, no idea. What is the run-time error (description/message) ? ---------------------------------------------------------------------- sporex · 2023-07-30 16:07 Hi, thank you for your time: This is what i get for the first command: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i root@PI0:/home/pi/ubx_recorder# file ./test32bit./test32bit: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 2.0.0, with debug_info, not stripped For the second one I am not quite sure what you mean: name-of-native- working-executable ? ---------------------------------------------------------------------- TRon · 2023-07-30 17:21 Quote from: sporex on July 30, 2023, 06:07:10 pmFor the second one I am not quite sure what you mean: name-of-native-working-executable ? I have no idea what applications you have installed on your raspbian but i meant any program executable that is supplied by your distribution will do (so not compiled with fpc but a program file (executable) that what is distributed by raspbian itself). For example midnight commander, open office, term, etc. If everything is as I presume then you should notice a different output. ---------------------------------------------------------------------- sporex · 2023-07-30 18:09 ok understood: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i root@PI0:/bin# file ./mc./mc: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux- armhf.so.3, BuildID[sha1]=d57aa7095b432f27a50428f6d757409f445caabf, for GNU/Linux 3.2.0, stripped versus Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  root@PI0:/home/pi/ubx_recorder# file ./testfile ./test32bit./test32bit: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, for GNU/Linux 2.0.0, with debug_info, not stripped And this is what I get when running ./test32bit Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error Runtime error RuSegmentation fault For every loop cycle Runtime error and in the end segmentation fault. ---------------------------------------------------------------------- DonAlfredo · 2023-07-30 18:21 It might be that you are linking against the wrong libs. These libs are installed by fpcupdeluxe in [installdirectory]\cross\lib\arm-linux You have a choice. See: https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/cros slibs_all/Linux_ARMHF_Raspbian_09.zip https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/cros slibs_all/Linux_ARMHF_Ubuntu_1604.zip https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/cros slibs_all/Linux_ARMHF_Ubuntu_1804.zip I would suggest the following. Delete all the libs inside the mentioned directory. Download: https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/dow nload/crosslibs_all/Linux_ARMHF_Ubuntu_1804.zip Unpack these libs inside the mentioned directory. Re-run fpcupdeluxe to install the cross-compiler for arm-linux. Re-compile your app and try again on your zero-system. This might help. I hope the instructions are clear enough. ---------------------------------------------------------------------- sporex · 2023-07-31 07:39 Quote from: DonAlfredo on July 30, 2023, 08:21:59 pmIt might be that you are linking against the wrong libs. These libs are installed by fpcupdeluxe in [installdirectory]\cross\lib\arm-linux You have a choice. See: https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/cros slibs_all/Linux_ARMHF_Raspbian_09.zip https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/cros slibs_all/Linux_ARMHF_Ubuntu_1604.zip https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases/download/cros slibs_all/Linux_ARMHF_Ubuntu_1804.zip This might help. I hope the instructions are clear enough. I was following your instrunctions (thank you) and tried the Linux_ARMHF_Raspbian_09.zip first. I discovered that there is a problem with the source code: This code example works: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  for i:=1 to 10 do j:=i;  writeln('sucess');  Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  root@PI0:/NAS/UBX_RTK# ./test32bitsucess This code example is not working: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i for i:=1 to 10 do j:=i;  writeln('sucess',IntToStr(j)); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i root@PI0:/NAS/UBX_RTK# ./test32bitAn unhandled exception occurred at $0001BE60:EAccessViolation: Access violation  $0001BE60 Perhaps I should install the Raspbian_09 image on the PI0? ---------------------------------------------------------------------- Thaddy · 2023-07-31 10:11 Looks to me missing is EABIHF - very important!- and ARMv7a -less important - instead of EABI5 and ARMv6 ---------------------------------------------------------------------- sporex · 2023-07-31 12:33 Quote from: Thaddy on July 31, 2023, 12:11:04 pmLooks to me missing is EABIHF - very important!- and ARMv7a -less important - instead of EABI5 and ARMv6 I give up. I will install a new IDE on a RPi with 32bit Linux and compiöe the code for the Rpi-zero from there. ---------------------------------------------------------------------- Thaddy · 2023-08-01 05:36 You don't have to: sudo apt-get update sudo apt-get install fpc Will install Freepascal. Note, for the zero, extend your swap file to about 1000. That enables you to actually compile FPC and Lazarus . Optionally you can change the swap size back to its old value after compilation. ---------------------------------------------------------------------- sporex · 2023-08-01 13:39 Quote from: Thaddy on August 01, 2023, 07:36:44 amYou don't have to: sudo apt-get update sudo apt-get install fpc Will install Freepascal. Note, for the zero, extend your swap file to about 1000. That enables you to actually compile FPC and Lazarus . Optionally you can change the swap size back to its old value after compilation. What I wanted to configure was a cross-compiler on a 64bit WIN10 PC that allows me to compile to LINUX ARM 32bit for the PI-ZERO headless. Obviously I failed. Now I have set up a RPi4 with Bullsey 32bit plus desktop where I compile the source and later transfer it to the PI- Zero. I will manage with this solution.