C code works, same code in FreePascal does not lazarus / 62-General ---------------------------------------------------------------------- TCH · 2018-08-22 19:05 There is this C code:Code: C  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include   #define SW_PORTC_IO_BASE 0x01c20800 int main(){        unsigned int * pc;        int fd;        char * ptr;                fd = open("/dev/mem", O_RDWR | O_SYNC);        if(fd < 0)        {              perror("Unable to open /dev/mem");                return(-1);        }                pc = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, SW_PORTC_IO_BASE & 0xfffff000);                if(pc == MAP_FAILED)        {                perror("Unable to mmap file");                return(-1);        }        ptr = (char *)pc + (SW_PORTC_IO_BASE & 0xfff);        *(unsigned int *)(ptr+0x00) = 0x11111111;        *(unsigned int *)(ptr+0x04) = 0x11111111;        *(unsigned int *)(ptr+0x08) = 0x11111111;        *(unsigned int *)(ptr+0x0c) = 0x11111111;        *(unsigned int *)(ptr+0x10) = 0xffffffff;        usleep(2000000);        *(unsigned int *)(ptr+0x10) = 0x00000000;        munmap(pc, 4096);        return 0;}and there it is converted to Pascal: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 sunxi_lofasz; uses baseunix, sysutils; const SW_PORTC_IO_BASE = $01c20800; var        pc: plongword;        fd: longint;        ptr: pbyte; begin        fd := fpopen('/dev/mem', O_RDWR or O_SYNC);        if(fd < 0) then        begin                writeln('Unable to open /dev/mem');                halt;        end;              pc := fpmmap(nil, 4096, PROT_READ or PROT_WRITE, MAP_SHARED, fd, SW_PORTC_IO_BASE and $fffff000);                if(pc = MAP_FAILED) then        begin                writeln('Unable to mmap file');                halt;        end;        ptr := pbyte(pc + (SW_PORTC_IO_BASE and $fff));        plongword(ptr+$00)^ := $11111111;        plongword(ptr+$04)^ := $11111111;        plongword(ptr+$08)^ := $11111111;        plongword(ptr+$0c)^ := $11111111;        plongword(ptr+$10)^ := $ffffffff;        sleep(2000);        plongword(ptr+$10)^ := $00000000;        fpmunmap(pc, 4096);end. The C code works perfectly on Orange Pi, lits up the LEDs and then shuts them off. The Pascal on the other hand halts at the fpmmap, that it cannot mmap the file. If i change the last parameter from 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 SW_PORTC_IO_BASE and $fffff000 to 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 SW_PORTC_IO_BASE shr 12then the code does not throws any error, but still don't works. What can be this? ---------------------------------------------------------------------- marcov · 2018-08-22 19:12 So use strace and find the two differences? How hard can it be? ---------------------------------------------------------------------- TCH · 2018-08-22 19:30 C:Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i execve("./sunxi_lofasz", ["./sunxi_lofasz"], [/* 54 vars */]) = 0brk(NULL)                               = 0x9c9000uname({sysname="Linux", nodename="orangepipcplus", ...}) = 0access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3fstat64(3, {st_mode=S_IFREG|0644, st_size=93978, ...}) = 0mmap2(NULL, 93978, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f71000close(3)                              = 0access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)open("/lib/arm-linux- gnueabihf/libc.so.6", O_RDONLY|O_CLOEXEC) = 3read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\331i\1\0004\0\0\0"..., 512) = 512lseek(3, 894128, SEEK_SET)              = 894128read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 2960) = 2960lseek(3, 888324, SEEK_SET)              = 888324read(3, "A2\0\0\0aeabi\0\1(\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\3\f"..., 51) = 51fstat64(3, {st_mode=S_IFREG|0755, st_size=897088, ...}) = 0mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f70000mmap2(NULL, 963928, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e84000mprotect(0xb6f5a000, 65536, PROT_NONE)  = 0mmap2(0xb6f6a000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xd6000) = 0xb6f6a000mmap2(0xb6f6d000, 9560, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f6d000close(3)                              = 0mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fae000set_tls(0xb6fae4c0, 0xb6faeb98, 0xb6fb0050, 0xb6fae4c0, 0xb6fb0050) = 0mprotect(0xb6f6a000, 8192, PROT_READ)   = 0mprotect(0x20000, 4096, PROT_READ)      = 0mprotect(0xb6faf000, 4096, PROT_READ)   = 0munmap(0xb6f71000, 93978)               = 0open("/dev/mem", O_RDWR|O_SYNC)         = 3mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x1c20000) = 0xb6fad000nanosleep({2, 0}, NULL)               = 0munmap(0xb6fad000, 4096)                = 0exit_group(0)                         = ?+++ exited with 0 +++ Pascal:Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i execve("./sunxi_lofasz", ["./sunxi_lofasz"], [/* 54 vars */]) = 0ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0rt_sigaction(SIGFPE, {0x3b140, [], SA_RESTORER|SA_SIGINFO, 0x19020}, {SIG_DFL, [], 0}, 8) = 0rt_sigaction(SIGSEGV, {0x3b140, [], SA_RESTORER|SA_SIGINFO, 0x19020}, {SIG_DFL, [], 0}, 8) = 0rt_sigaction(SIGBUS, {0x3b140, [], SA_RESTORER|SA_SIGINFO, 0x19020}, {SIG_DFL, [], 0}, 8) = 0rt_sigaction(SIGILL, {0x3b140, [], SA_RESTORER|SA_SIGINFO, 0x19020}, {SIG_DFL, [], 0}, 8) = 0ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0ioctl(2, TCGETS, 0xbed12160)            = -1 ENOTTY (Inappropriate ioctl for device)ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0ioctl(2, TCGETS, 0xbed12160)            = -1 ENOTTY (Inappropriate ioctl for device)readlink("/proc/self/exe", "/root/sunxi_lofasz", 255) = 18open("/etc/timezone", O_RDONLY|O_LARGEFILE) = 3read(3, "Europe/Budapest\n", 255)       = 16close(3)                                = 0open("/usr/share/zoneinfo/Europe/Budapest", O_RDONLY|O_LARGEFILE) = 3read(3, "TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\7\0\0\0\7\0\0\0\0"..., 2048) = 2048mmap2(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f7b000mmap2(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f73000mmap2(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f6b000mmap2(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f63000close(3)                                = 0gettimeofday({1534965612, 974462}, {tz_minuteswest=-60, tz_dsttime=0}) = 0open("/dev/mem", O_RDWR|O_DSYNC|O_LARGEFILE) = 3mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, 3, 0x1c20000) = 0xb6f62000nanosleep({2, 0}, 0xbed12288)           = 0munmap(0xb6f62000, 4096)                = 0--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x11111119} ---rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x11111119} ---rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0mmap2(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f5b000--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x11111119} ---rt_sigprocmask(SIG_UNBLOCK, [SEGV], NULL, 8) = 0munmap(0xb6f6b000, 32768)               = 0munmap(0xb6f73000, 32768)             = 0munmap(0xb6f7b000, 262144)              = 0exit_group(217)                         = ?+++ exited with 217 +++ The only relevant difference i see in the logs is that C does Code: [Select]open("/dev/mem", O_RDWR|O_SYNC) and Pascal does Code: [Select]open("/dev/mem", O_RDWR|O_DSYNC|O_LARGEFILE)Could that be the problem? And how is it possible? I gave exactly the same parameters to in the Pascal program to open. ---------------------------------------------------------------------- skalogryz · 2018-08-22 20:12 Quote from: TCH on August 22, 2018, 09:30:46 pmAnd how is it possible? I gave exactly the same parameters to in the Pascal program to open. RTL fpopen code looks like this: 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 function Fpopen(path: pchar; flags : cint; mode: mode_t):cint; [public, alias : 'FPC_SYSC_OPEN']; Begin Fpopen:=do_syscall(syscall_nr_open,TSysParam(p ath),TSysParam(flags or O_LARGEFILE),TSysParam(mode));End;  you might want to try it with your own version: 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 sunxi_lofasz; uses baseunix, sysutils  ,oldlinux; // this is needed for syscall_nr_open ... function Fpopen2(path: pchar; flags : cint; mode: mode_t):cint; Begin Fpopen:=do_syscall(syscall_nr_open,TSysParam (path),TSysParam(flags),TSysParam(mode));End;... var        pc: plongword;        fd: longint;        ptr: pbyte; begin        fd := fpopen2('/dev/mem', O_RDWR or O_SYNC); ---------------------------------------------------------------------- TCH · 2018-08-22 20:40 Compiler cannot find "oldlinux". It's there in /usr/share/fpcsrc/3.0.2/rtl/linux/, but no avail. ---------------------------------------------------------------------- marcov · 2018-08-22 20:45 oldlinux is a 23 year old unit that has been deprecated 15 years. One of the reasons was that it was not portable to non x86 :-) Best to copy the constants from sysnr.inc. ---------------------------------------------------------------------- TCH · 2018-08-22 20:56 Something is not right. This fpopen has three parameters, but i only used two and the compiler accepted it. Now that i copied the constants and used this fpopen2, it does need the third parameter. Edit: I found it in oscdecl.inc: function  real_FpOpen(path: pchar; flags : cint):cint; varargs; cdecl; external 'c' name 'open'; Still, does not work. ---------------------------------------------------------------------- marcov · 2018-08-22 21:09 The 3rd parameter is irrelevant (from man(2)): The third parameter... Quote  mode specifies the permissions to use in case a new file is cre-               ated.  This argument must be supplied when O_CREAT or  O_TMPFILE               is specified in flags; if neither O_CREAT nor O_TMPFILE is spec-               ified, then mode is ignored. IOW the two parameter form is an extra shortcut, not a different function. ---------------------------------------------------------------------- TCH · 2018-08-22 21:14 Used the following parts: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 const{$ifdef FPC_ABI_EABI}  syscall_nr_base = $0;{$else FPC_ABI_EABI}   syscall_nr_base = $900000;{$endif FPC_ABI_EABI}   syscall_nr_open                       =  syscall_nr_base+ 5; type      TSysResult = longint;        TSysParam  = Longint; function Do_SysCall(sysnr,param1,param2,param3:TSysParam):TSysResult; external name 'FPC_SYSCALL3'; function Fpopen2(path: pchar; flags : cint; mode: mode_t):cint; Begin        Fpopen2 := do_syscall(5, TSysParam(path), TSysParam(flags), TSysParam(mode));End;and calling itCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fd := fpopen2('/dev/mem', O_RDWR or O_SYNC, 0);still results in mmap failure. ---------------------------------------------------------------------- skalogryz · 2018-08-22 21:31 Quote from: marcov on August 22, 2018, 10:45:20 pmoldlinux is a 23 year old unit that has been deprecated 15 years. yeah. but linux rtl is still sys call ids from oldlinux unit. I'd think Orange Pi is running linux anyway. Quote from: TCH on August 22, 2018, 11:14:05 pmstill results in mmap failure. do you have mmap used from libc as well? ---------------------------------------------------------------------- TCH · 2018-08-22 21:38 Quote from: skalogryz on August 22, 2018, 11:31:00 pmQuote from: TCH on August 22, 2018, 11:14:05 pmstill results in mmap failure. do you have mmap used from libc as well? Yeah, i tried. No use, still cannot do it. But perhaps i did not use it correctly from Pascal. Meanwhile i've checked the assembly. C:Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         .arch armv7-a        .eabi_attribute 28, 1        .fpu vfpv3-d16      .eabi_attribute 20, 1        .eabi_attribute 21, 1        .eabi_attribute 23, 3        .eabi_attribute 24, 1        .eabi_attribute 25, 1        .eabi_attribute 26, 2        .eabi_attribute 30, 6        .eabi_attribute 34, 1        .eabi_attribute 18, 4        .file   "sunxi_lofasz.c"        .section        .rodata        .align  2.LC0:        .ascii  "/dev/mem\000"      .align  2.LC1:        .ascii  "Unable to open /dev/mem\000"        .align  2.LC2:        .ascii  "Unable to mmap file\000"        .text      .align  2        .global main        .syntax unified        .thumb        .thumb_func        .type   main, %functionmain:        @ args = 0, pretend = 0, frame = 16        @ frame_needed = 1, uses_anonymous_args = 0        push    {r7, lr}        sub     sp, sp, #24        add     r7, sp, #8        movw    r1, #4098        movt    r1, 16        movw    r0, #:lower16:.LC0        movt    r0, #:upper16:.LC0        bl      open        str     r0, [r7, #4]        ldr     r3, [r7, #4]        cmp     r3, #0        bge     .L2        movw    r0, #:lower16:.LC1        movt    r0, #:upper16:.LC1        bl      perror        mov     r3, #-1        b       .L3.L2:        mov     r3, #29491200        str     r3, [sp, #4]        ldr     r3, [r7, #4]        str     r3, [sp]        movs    r3, #1        movs    r2, #3        mov     r1, #4096        movs    r0, #0        bl      mmap        str     r0, [r7, #8]        ldr     r3, [r7, #8]        cmp     r3, #-1        bne     .L4        movw    r0, #:lower16:.LC2      movt    r0, #:upper16:.LC2        bl      perror        mov     r3, #-1        b       .L3.L4:        ldr     r3, [r7, #8]        add   r3, r3, #2048        str     r3, [r7, #12]        ldr     r3, [r7, #12]        mov     r2, #286331153        str     r2, [r3]        ldr   r3, [r7, #12]        adds    r3, r3, #4        mov     r2, #286331153        str     r2, [r3]        ldr     r3, [r7, #12]      adds    r3, r3, #8        mov     r2, #286331153        str     r2, [r3]        ldr     r3, [r7, #12]        adds    r3, r3, #12        mov     r2, #286331153        str     r2, [r3]        ldr     r3, [r7, #12]        adds    r3, r3, #16        mov     r2, #-1        str     r2, [r3]        movw    r0, #33920        movt    r0, 30        bl    usleep        ldr     r3, [r7, #12]        adds    r3, r3, #16      movs    r2, #0        str     r2, [r3]        mov     r1, #4096      ldr     r0, [r7, #8]        bl      munmap        movs    r3, #0.L3:      mov     r0, r3        adds    r7, r7, #16        mov     sp, r7      @ sp needed        pop     {r7, pc}        .size   main, .-main      .ident  "GCC: (Ubuntu/Linaro 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609"        .section        .note.GNU- stack,"",%progbitsPascal:Code: ASM  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i         .file "sunxi_lofasz.pas"# Begin asmlist al_procedures .section .text.n_main        .balign 4.globl  PASCALMAIN        .type   PASCALMAIN,#functionPASCALMAIN:.globl  main        .type   main,#functionmain:        mov     r12,r13        stmfd r13!,{r3,r4,r11,r12,r14,r15}        sub     r11,r12,#4        sub   r13,r13,#64        blx     FPC_INITIALIZEUNITS        mov     r1,#2      orr     r1,r1,#4096        ldr     r0,.Lj9        blx     BASEUNIX_$$_FPOPEN$SHORTSTRING$LONGINT$$LONGINT        ldr     r1,.Lj10        str     r0,[r1]        ldr     r0,.Lj10        ldr   r0,[r0]        cmp     r0,#0        blt     .Lj11        b       .Lj12.Lj11:        blx     fpc_get_output        mov     r4,r0        ldr     r2,.Lj18        mov     r1,r4        mov     r0,#0        blx   fpc_write_text_shortstr        blx     FPC_IOCHECK        mov     r0,r4        blx     fpc_writeln_end        blx     FPC_IOCHECK      mov     r0,#0        blx     SYSTEM_$$_HALT$LONGINT.Lj12:        ldr   r0,.Lj10        ldr     r0,[r0]        str     r0,[r13]        mov   r0,#0        str     r0,[r13, #12]        mov     r0,#16777216      orr     r0,r0,#12713984        str     r0,[r13, #8]        mov     r3,#1        mov     r2,#3        mov     r1,#4096        mov     r0,#0        blx     FPC_SYSC_MMAP        ldr     r1,.Lj42        str   r0,[r1]        ldr     r0,.Lj42        ldr     r0,[r0]        mvn   r1,#0        cmp     r0,r1        beq     .Lj43        b       .Lj44.Lj43:        blx     fpc_get_output        mov     r4,r0        ldr     r2,.Lj50        mov     r1,r4        mov     r0,#0        blx   fpc_write_text_shortstr        blx     FPC_IOCHECK        mov     r0,r4        blx     fpc_writeln_end        blx     FPC_IOCHECK      mov     r0,#0        blx     SYSTEM_$$_HALT$LONGINT.Lj44:        ldr   r0,.Lj42        ldr     r0,[r0]        add     r0,r0,#8192        ldr     r1,.Lj62        str     r0,[r1]        ldr     r0,.Lj62      ldr     r0,[r0]        ldr     r1,.Lj66        str     r1,[r0]        ldr     r0,.Lj62        ldr     r1,[r0]        ldr     r0,.Lj66      str     r0,[r1, #4]        ldr     r0,.Lj62        ldr     r1,[r0]      ldr     r0,.Lj66        str     r0,[r1, #8]        ldr     r0,.Lj62        ldr     r0,[r0]        ldr     r1,.Lj66        str   r1,[r0, #12]        ldr     r0,.Lj62        ldr     r0,[r0]        mvn     r1,#0        str     r1,[r0, #16]        mov     r0,#2000        blx     SYSUTILS_$$_SLEEP$LONGWORD        ldr     r0,.Lj62        ldr   r0,[r0]        mov     r1,#0        str     r1,[r0, #16]        ldr     r0,.Lj42        ldr     r0,[r0]        mov     r1,#4096        blx     FPC_SYSC_MUNMAP        blx     FPC_DO_EXIT        ldmea   r11,{r3,r4,r11,r13,r15}.Lj9:        .long   _$SUNXI_LOFASZ$_Ld1.Lj10:        .long   U_$P$SUNXI_LOFASZ_$$_FD.Lj18:        .long   _$SUNXI_LOFASZ$_Ld2.Lj42:        .long   U_$P$SUNXI_LOFASZ_$$_PC.Lj50:        .long   _$SUNXI_LOFASZ$_Ld3.Lj62:        .long   U_$P$SUNXI_LOFASZ_$$_PTR.Lj66:        .long   286331153.Le0:        .size   main, .Le0 - main .section .text# End asmlist al_procedures# Begin asmlist al_globals .section .bss        .balign 4        .type U_$P$SUNXI_LOFASZ_$$_PC,%object        .size U_$P$SUNXI_LOFASZ_$$_PC,4U_$P$SUNXI_LOFASZ_$$_PC:        .zero 4 .section .bss        .balign 4        .type U_$P$SUNXI_LOFASZ_$$_FD,%object        .size U_$P$SUNXI_LOFASZ_$$_FD,4U_$P$SUNXI_LOFASZ_$$_FD:        .zero 4 .section .bss        .balign 4        .type U_$P$SUNXI_LOFASZ_$$_PTR,%object        .size U_$P$SUNXI_LOFASZ_$$_PTR,4U_$P$SUNXI_LOFASZ_$$_PTR:        .zero 4 .section .data.n_INITFINAL        .balign 4.globl  INITFINAL        .type   INITFINAL,#objectINITFINAL:        .long   5,0        .long   INIT$_$SYSTEM        .long   0,0        .long   FINALIZE$_$OBJPAS      .long   INIT$_$UNIX        .long   FINALIZE$_$UNIX        .long   SYSUTILS$_$TENCODING_$__$$_create        .long   SYSUTILS$_$TENCODING_$__$$_destroy        .long   INIT$_$SYSUTILS      .long   FINALIZE$_$SYSUTILS.Le1:        .size   INITFINAL, .Le1 - INITFINAL .section .data.n_FPC_THREADVARTABLES        .balign 4.globl  FPC_THREADVARTABLES        .type   FPC_THREADVARTABLES,#objectFPC_THREADVARTABLES:        .long   1      .long   THREADVARLIST_$SYSTEM.Le2:        .size   FPC_THREADVARTABLES, .Le2 - FPC_THREADVARTABLES .section .data.n_FPC_RESOURCESTRINGTABLES        .balign 4.globl  FPC_RESOURCESTRINGTABLES        .type   FPC_RESOURCESTRINGTABLES,#objectFPC_RESOURCESTRINGTABLES:        .long   1        .long   RESSTR_$SYSCONST_$$_START        .long   RESSTR_$SYSCONST_$$_END.Le3:        .size   FPC_RESOURCESTRINGTABLES, .Le3 - FPC_RESOURCESTRINGTABLES .section .data.n_FPC_WIDEINITTABLES      .balign 4.globl  FPC_WIDEINITTABLES        .type   FPC_WIDEINITTABLES,#objectFPC_WIDEINITTABLES:        .long   0.Le4:      .size   FPC_WIDEINITTABLES, .Le4 - FPC_WIDEINITTABLES .section .data.n_FPC_RESSTRINITTABLES        .balign 4.globl  FPC_RESSTRINITTABLES        .type   FPC_RESSTRINITTABLES,#objectFPC_RESSTRINITTABLES:        .long   0.Le5:        .size   FPC_RESSTRINITTABLES, .Le5 - FPC_RESSTRINITTABLES .section .fpc.n_version        .balign 8        .ascii  "FPC 3.0.2 [2017/02/17] for arm - Linux" .section .data.n___stklen        .balign 4.globl  __stklen        .type   __stklen,#object__stklen:        .long   8388608 .section .data.n___heapsize        .balign 4.globl  __heapsize        .type   __heapsize,#object__heapsize:        .long   0 .section .data.n___fpc_valgrind.globl  __fpc_valgrind        .type   __fpc_valgrind,#object__fpc_valgrind:        .byte   0 .section .data.n_FPC_RESLOCATION        .balign 4.globl  FPC_RESLOCATION      .type   FPC_RESLOCATION,#objectFPC_RESLOCATION:        .long   0# End asmlist al_globals# Begin asmlist al_typedconsts .section .rodata.n__$SUNXI_LOFASZ$_Ld1        .balign 4.globl  _$SUNXI_LOFASZ$_Ld1_$SUNXI_LOFASZ$_Ld1:        .ascii  "\010/dev/mem\000" .section .rodata.n__$SUNXI_LOFASZ$_Ld2        .balign 4.globl  _$SUNXI_LOFASZ$_Ld2_$SUNXI_LOFASZ$_Ld2:        .ascii  "\027Unable to open /dev/mem\000" .section .rodata.n__$SUNXI_LOFASZ$_Ld3        .balign 4.globl  _$SUNXI_LOFASZ$_Ld3_$SUNXI_LOFASZ$_Ld3:        .ascii  "\023Unable to mmap file\000"# End asmlist al_typedconsts.section .note.GNU- stack,"",%progbitsIt's entirely different inside. Perhaps FPC_SYSC_MMAP is broken under ARM? ---------------------------------------------------------------------- skalogryz · 2018-08-22 22:11 just for fun try to replace this line 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 ptr := pbyte(pc + (SW_PORTC_IO_BASE and $fff));with 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 ptr := pbyte(pbyte(pc) + (SW_PORTC_IO_BASE and $fff)));or a shorter version (if it compiles) 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 ptr := pbyte(pc) + (SW_PORTC_IO_BASE and $fff)); strace drop indicates some SIGSEGV. That makes me think that pointer arithmetic fails somewhere. ---------------------------------------------------------------------- PascalDragon · 2018-08-23 05:44 Quote from: skalogryz on August 22, 2018, 11:31:00 pmQuote from: marcov on August 22, 2018, 10:45:20 pmoldlinux is a 23 year old unit that has been deprecated 15 years. yeah. but linux rtl is still sys call ids from oldlinux unit. I'd think Orange Pi is running linux anyway. The Linux RTL pulls the syscall IDs from the sysnr.inc files located inside the platform specific directories cause the syscall IDs can and do differ between Linux platforms. ---------------------------------------------------------------------- TCH · 2018-08-23 07:45 @skalogryz: In the meanwhile my collegaue solved it, but he suggested exactly the same thing as you: it was a pointer offset flaw in my code. So, thanks to you too. ---------------------------------------------------------------------- skalogryz · 2018-08-23 13:09 it's good to know that fpc is not that bad ---------------------------------------------------------------------- Thaddy · 2018-08-23 13:22 Quote from: skalogryz on August 23, 2018, 03:09:40 pmCode: [Select]uses baseunix, sysutils   ,oldlinux; // this is needed for syscall_nr_openTo bad oldlinux has just been removed from trunk.... ---------------------------------------------------------------------- marcov · 2018-08-23 13:25 It was already not compiled in 3.0.x anymore, requires getting the source and manually compiling it. This thread reminded me that it was still staged to be phased out with the next major version. p.s. unit libc is also not supported on non x86. ---------------------------------------------------------------------- skalogryz · 2018-08-23 13:33 Quote from: Thaddy on August 23, 2018, 03:22:43 pmTo bad oldlinux has just been removed from trunk.... why? ---------------------------------------------------------------------- PascalDragon · 2018-08-24 07:39 Quote from: skalogryz on August 23, 2018, 03:33:28 pmQuote from: Thaddy on August 23, 2018, 03:22:43 pmTo bad oldlinux has just been removed from trunk.... why? - it's been deprecated for more than 6 years - it hasn't been automatically build in more than 11 years - it's i386 only No one has complained so far that it isn't part of the release, so good riddance! ---------------------------------------------------------------------- marcov · 2018-08-24 08:09 Quote from: PascalDragon on August 24, 2018, 09:39:24 am- it's been deprecated for more than 6 years While that is strictly true, it actually is quite a bit longer than that. (think Christmas holiday 2003 in trunk, and then definitively with FPC 2.0 in may 2005 when it was no longer needed for bootstrapping) Quote- it hasn't been automatically build in more than 11 years - it's i386 only No one has complained so far that it isn't part of the release, so good riddance!  - it was actually never verified that the port from 1.x to 2.x (fpcoldcall and all that) actually (still?) fully works. Most people since used it only in very limited ways - and of course the main reason: I don't want to have this discussion around 3.4 again for what would be the (1.9,2.0,2.2,2.4,3.0,3.2,3.4) seventh time. ---------------------------------------------------------------------- Thaddy · 2018-08-24 17:06 To me it was a rather amusing situation that the same unit (I can't remember using it, I probably did) was deprecated and on the same day mentioned in an example on the forum.... Well that was - the use in an example - probably also at least a couple of years ago?