Hello,
There is an old code that runs fine on 32bit OSes.
Code is not my own and from a MPL v2 licensed library. It is not developed any more.
https://github.com/ultibohub/Asphyre
Now, I am trying to run it on 64bit OS and getting error when trying to access GPIO using /dev/gpiomem device.
Relevant code parts (pascal)Above code works just fine on Raspbeyy Pi 2 - Raspberry Pi 4 if the operating system is 32bit but not on 64bit OS.
My best guess is that it calculate offset based on 32bit OS. I have no idea what it should be for 64bit OS.
Any help is appreciated.
Thanks & Regards,
Ertan
                       
                           
                       
                     There is an old code that runs fine on 32bit OSes.
Code is not my own and from a MPL v2 licensed library. It is not developed any more.
https://github.com/ultibohub/Asphyre
Now, I am trying to run it on 64bit OS and getting error when trying to access GPIO using /dev/gpiomem device.
Relevant code parts (pascal)
Code:
const  ChipMapPath = '/dev/gpiomem';  DeviceTreeRangesPath = '/proc/device-tree/soc/ranges';constructor TFastSystemCore.Create;begin  inherited;  FChipOffsetBase := {$IFDEF RPi2} $3F000 {$ELSE} $20000 {$ENDIF}; // in pages (x 4096 bytes)  // SOME ADDITIONAL OFFSET CALCULATIONS ARE DONE IN BELOW FUNCTION  UpdateIOValuesFromKernel;  // ERROR HERE. CANNOT OPEN DEVICE  FHandle := FpOpen(ChipMapPath, O_RDWR or O_SYNC);  if FHandle < 0 then  begin    FHandle := 0;    raise ERPiOpenFile.Create(Format(SCannotOpenFileToMap, [ChipMapPath]));  end;  FMemory := PortionMap('ST', FHandle, GetChipOffsetST, PageSize);end;function TFastSystemCore.UpdateIOValuesFromKernel: Boolean;const  OffsetForIOStart = 4;var  LHandle: TUntypedHandle;  DataValue: Cardinal;begin  LHandle := FpOpen(DeviceTreeRangesPath, O_RDONLY);  if LHandle < 0 then    Exit(False);  try    if FpLseek(LHandle, OffsetForIOStart, Seek_Set) <> OffsetForIOStart then      Exit(False);    if FpRead(LHandle, DataValue, SizeOf(DataValue)) <> SizeOf(DataValue) then      Exit(False);    FChipOffsetBase := BEtoN(DataValue) div PageSize;  finally    FpClose(LHandle);  end;  Result := True;end;My best guess is that it calculate offset based on 32bit OS. I have no idea what it should be for 64bit OS.
Any help is appreciated.
Thanks & Regards,
Ertan
Statistics: Posted by ertank — Mon Mar 04, 2024 2:52 pm