Building from source in OSX

General discussion about anything related to Ultibo.
Poi
Posts: 17
Joined: Mon Jan 07, 2019 11:57 pm

Re: Building from source in OSX

Postby Poi » Fri Jan 11, 2019 12:44 am

I have been trying to get my bare bones example up and running, but failing at that :P

I was able to build a kernel.img from the following code, but when I turn on the Pi Zero, the screen is just blank. It is getting power, but nothing else seems to be going on. I should be seeing the text "Hello TFT", right?

My display is an Adafruit PiTFT Plus 3.5" and I have it stuck right on top the GPIO pins of the Pi Zero.

Code: Select all

program HelloTFT;

{$mode delphi}{$H+}

uses
  RaspberryPi,
  GlobalConfig,
  GlobalConst,
  GlobalTypes,
  Platform,
  Threads,
  SysUtils,
  Classes,
  Ultibo,

  Devices,
  Framebuffer,
  Console,

  PiTFT35;

var
  ConsoleHandle:THandle;
  TFTHandle:THandle;
  FramebufferDevice:PFramebufferDevice;
begin
  FramebufferDevice:=FramebufferDeviceFindByDescription('BCM2835 Framebuffer');

  ConsoleHandle:=ConsoleWindowCreate(ConsoleDeviceFindByDescription('Framebuffer Console (' + DeviceGetName(@FramebufferDevice.Device) + ')'),CONSOLE_POSITION_FULL,True);
  ConsoleWindowWriteLn(ConsoleHandle,'Hello Console');

  FramebufferDevice:=FramebufferDeviceFindByDescription('Adafruit PiTFT 3.5" LCD');

  TFTHandle:=ConsoleWindowCreate(ConsoleDeviceFindByDescription('Framebuffer Console (' + DeviceGetName(@FramebufferDevice.Device) + ')'),CONSOLE_POSITION_FULL,False);

  ConsoleWindowWrite(TFTHandle,'Hello TFT');
end.


Another thing I noticed is that the activity led turns green, when I turn on the Pi, then off and then blinks once, after that it remains off. Not sure if that means everything is OK, or if there a problem booting.

I have been looking at the documentation for the Console Unit, and there seems to be methods to actually draw the console windows, but I am still not too sure if I should be using those, or if they have a different purpose.

Again, any help or hints are greatly appreciated.
User avatar
Ultibo
Site Admin
Posts: 2150
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Building from source in OSX

Postby Ultibo » Fri Jan 11, 2019 9:45 am

Poi wrote:I was able to build a kernel.img from the following code, but when I turn on the Pi Zero, the screen is just blank. It is getting power, but nothing else seems to be going on. I should be seeing the text "Hello TFT", right?

We just tested the code and while it works fine on a PI 2 or 3 it doesn't initialize the TFT screen when run on a Pi A/B or Zero so there seems to be a problem with one of the drivers.

We'll look at it closer and figure out why the TFT is not being initialized, in the meantime you can prove that your compiler, rtl and setup is creating a working image by adding something like this to the end of your application (just before the final end).

Code: Select all

  ActivityLEDEnable;
  while True do
  begin
   ActivityLEDOn;
   Sleep(500);
   ActivityLEDOff;
   Sleep(500);
  end;

That should blink the LED slowly on and off which will confirm if everything else is working.
Ultibo.org | Make something amazing
https://ultibo.org
Poi
Posts: 17
Joined: Mon Jan 07, 2019 11:57 pm

Re: Building from source in OSX

Postby Poi » Fri Jan 11, 2019 11:50 am

Just tried out the blinking example and it works alright.
User avatar
Ultibo
Site Admin
Posts: 2150
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Building from source in OSX

Postby Ultibo » Sat Jan 12, 2019 12:51 am

Poi wrote:Just tried out the blinking example and it works alright.

That's excellent, you are the first we know of to have a working build on OSX (might be others who haven't told us yet). If there is any way you could write down the steps you used and note any specific versions required etc we'd be happy to publish it on the wiki for others to follow.
Ultibo.org | Make something amazing
https://ultibo.org
Poi
Posts: 17
Joined: Mon Jan 07, 2019 11:57 pm

Re: Building from source in OSX

Postby Poi » Mon Jan 14, 2019 1:15 am

To sum it all up.

I am using macOS version 10.13.1 (High Sierra)

Downloaded the latest code for Ultibo Core from https://github.com/ultibohub/Core

Downloaded the latest code for FPC Ultibo edition from https://github.com/ultibohub/FPC

I then checked the main Makefile from the repo FPC Ultibo edition and found that the variable REQUIREDVERSION tells you which version of the regular FPC you need to install in your system.

So I downloaded and installed version 3.0.2 from here https://sourceforge.net/projects/freepascal/files/Mac%20OS%20X/3.0.2/.
I used the file called fpc-3.0.2.intel-macosx.dmg

With everything installed, I pretty much followed the instructions in the Wiki to build for Debian https://ultibo.org/wiki/Building_for_Debian

There are a few differences though.

Building Free Pascal (Ultibo Edition)

OS_TARGET should be darwin. So these two steps

Code: Select all

make all OS_TARGET=linux CPU_TARGET=i386
make install OS_TARGET=linux CPU_TARGET=i386 INSTALL_PREFIX=$HOME/ultibo/core/fpc


become this

Code: Select all

make all OS_TARGET=darwin CPU_TARGET=i386
make install OS_TARGET=darwin CPU_TARGET=i386 INSTALL_PREFIX=$HOME/ultibo/core/fpc


Installing the arm-none-eabi Toolchain

Make sure you download the toolchain for mac from here https://launchpad.net/gcc-arm-embedded/+download

Building the FPC ARM Cross Compiler

In here, watch out for your target because some of the arguments in each step might need to change.

SUBARCH might need to change
CROSSOPT => -Cp argument might need to change
=> -Cf argument might need to change

at the end of this step, you end up with a file called ppcrossarm. In my case I needed to rename that file to ppcarm in order for the following steps to work.

After that I didn't encounter anymore problems.
User avatar
Ultibo
Site Admin
Posts: 2150
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Building from source in OSX

Postby Ultibo » Wed Jan 23, 2019 10:32 pm

Ultibo wrote:We just tested the code and while it works fine on a PI 2 or 3 it doesn't initialize the TFT screen when run on a Pi A/B or Zero so there seems to be a problem with one of the drivers.

We'll look at it closer and figure out why the TFT is not being initialized, in the meantime you can prove that your compiler, rtl and setup is creating a working image by adding something like this to the end of your application (just before the final end).

Just a quick follow up on this one, we've narrowed the problem down to an issue with the DMA transfers to the TFT screen, it appears to be related to timing but so far it won't give up the secret of exactly what is going wrong.

We're continuing to work on it and will post back as soon as we know more.
Ultibo.org | Make something amazing
https://ultibo.org
Poi
Posts: 17
Joined: Mon Jan 07, 2019 11:57 pm

Re: Building from source in OSX

Postby Poi » Thu Jan 24, 2019 1:15 am

That's great to hear, I was wondering if you guys were working on that or if you were too busy with other things.
User avatar
Ultibo
Site Admin
Posts: 2150
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Building from source in OSX

Postby Ultibo » Sat Feb 09, 2019 12:07 am

We have now committed a fix which resolves the SPI DMA issue and your HelloTFT example should now work correctly on all models including the Pi Zero.

See the Announcement for more information, please let us know your results.
Ultibo.org | Make something amazing
https://ultibo.org
Poi
Posts: 17
Joined: Mon Jan 07, 2019 11:57 pm

Re: Building from source in OSX

Postby Poi » Sat Feb 09, 2019 11:07 pm

Just tried it out and it is working just fine. Thanks for the support :)

Now I only need to do something amazing :P

Return to “Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest