Adding ultibohub/Demo to the kernel sampler

General discussion about anything related to Ultibo.
mark
Posts: 1325
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Adding ultibohub/Demo to the kernel sampler

Postby mark » Thu Dec 13, 2018 12:45 am

I tried modifying ultibohub/Demo to check for an escape key (to exit to the kernel sampler) but I could not find the best place to put it - I tried one place but it did not seem to be executing when I pressed the escape key.

Could you be so kind, as time permits, at your convenience, provide some guidance on how to modify the keyboard processing of ultibohub/Demo to check for an escape key?

As it stands, simply including the SystemRestartStack unit implements a restart of the kernel sampler when the pi is turned off then on again. The current sampler repository does not include this change for the Demo, even though it does include the Demo in a subtree - I did not want to include the Demo without the keyboard escape at this time.

I am aware of some changes you've pushed to support rpi3a+ and I'll see if I have to update the Examples or Demo subtrees in the sampler.

Thanks,
Mark

Using 04-KeyboardInput as an example, it was modified so:

https://github.com/markfirmware/ultibo- ... ut.lpr#L23

https://github.com/markfirmware/ultibo- ... pr#L75-L78

The SystemRestartStack unit is copied to the source directory at build time (to avoid, at this point in development, modifying .lpi files or having fragile paths in the uses clause.)

https://github.com/markfirmware/ultibo- ... tstack.pas

For completeness, this is the SystemRestartStackWithKeyboard unit that is used by all the other modified samples that do not themselves use the keyboard. It has a thread that monitors for an escape key.

https://github.com/markfirmware/ultibo- ... yboard.pas
User avatar
Ultibo
Site Admin
Posts: 2226
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Adding ultibohub/Demo to the kernel sampler

Postby Ultibo » Mon Dec 17, 2018 9:07 am

mark wrote:Could you be so kind, as time permits, at your convenience, provide some guidance on how to modify the keyboard processing of ultibohub/Demo to check for an escape key?

While there is a way to do this that is actually quite simple it turned out to be one of those things that takes more words to describe than lines of code to write, so we've created a branch in the demo and added the relevant bit of code to make this possible.

If you have a look at the RestartOnEscapeKey branch you will find a new TRestartThread in the DemoMain unit that shows how to use keyboard enumeration and notification to set all keyboards to direct read. The thread then reads keys from every attached keyboard looking for the escape key and passing on any other keys to the global keyboard buffer which is used for everything else.

Let us know if you need any more info.
Ultibo.org | Make something amazing
https://ultibo.org
pik33
Posts: 863
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Adding ultibohub/Demo to the kernel sampler

Postby pik33 » Mon Dec 17, 2018 5:18 pm

As I can understand the code, you implemented kernel selecting via config.txt "kernel=" line instead of copying full kernels as I did in MicroDOS??
mark
Posts: 1325
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Adding ultibohub/Demo to the kernel sampler

Postby mark » Mon Dec 17, 2018 7:06 pm

Ultibo wrote:
mark wrote:Could you be so kind, as time permits, at your convenience, provide some guidance on how to modify the keyboard processing of ultibohub/Demo to check for an escape key?

While there is a way to do this that is actually quite simple it turned out to be one of those things that takes more words to describe than lines of code to write, so we've created a branch in the demo and added the relevant bit of code to make this possible.

If you have a look at the RestartOnEscapeKey branch you will find a new TRestartThread in the DemoMain unit that shows how to use keyboard enumeration and notification to set all keyboards to direct read. The thread then reads keys from every attached keyboard looking for the escape key and passing on any other keys to the global keyboard buffer which is used for everything else.

Let us know if you need any more info.


Thank you. I will build and test that branch to see it restart on escape. Then I will add it to the sampler and change the SystemRestart call to a PopKernel call and test it. Mark.
mark
Posts: 1325
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Adding ultibohub/Demo to the kernel sampler

Postby mark » Mon Dec 17, 2018 7:20 pm

pik33 wrote:As I can understand the code, you implemented kernel selecting via config.txt "kernel=" line instead of copying full kernels as I did in MicroDOS??

Yes that is right. There is also a /boot/systemrestartstack.txt file that implements the stack of kernels so that "./build.sh test" will put default-config.txt as the first line (top of stack) so as to return to raspbian. The default-config.txt file needs to be manually copied from raspbian config.txt once during initial development. (For the time being ./build.sh test only copies a kernel or two due to a small /boot size whereas the release zip has all of the sample kernels.) There is a little dance at the beginning of each kernel to pre-pop the stack in case of power restart (including such a deliberate restart due to a kernel not working well.) So, a sampler sd card can have two frames (sampler and sample) and testing from raspbian adds a third frame.

It is intended that the lowest level kernel can be tested independently returning to raspbian and an empty or missing stack file will just restart the same kernel when deployed as the sole system on an sd card.

I'd like to include your repos with your guidance. There are some obvious design decisions that need to be made regarding how much your repo is already prepared to be included, and what gesture(s) the user makes to pop the kernel stack.

Mark
pik33
Posts: 863
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Adding ultibohub/Demo to the kernel sampler

Postby pik33 » Mon Dec 17, 2018 8:12 pm

The GUI uses Microdos like convention: before start, Raspbian kernel is renamed to kernel7_l.img by a shell script. The same script copies GUI kernel to /boot/kernel7.img so the GUI will start after this every time the RPi is swtched on
The return to Raspbian is done after double clicking its icon or pressing R on the keyboard by renaming itself and restoring kernel7.img. This is done in the main file project1

Code: Select all

  if (raspbian.dblclicked) or (key=ord('r')) then
    begin
    raspbian.dblclicked:=false;
    if fileexists(drive+'\ultibo\Raspbian.u') then // a bug!!!
      begin
      pauseaudio(1);
      message:=twindow.create(500,112,'');
      message.cls(0);
      message.outtextxyz(16,16,'Preparing reboot to Raspbian',250,2,2);
      message.outtextxyz(16,64,'Please wait...',250,2,2);
      message.move(xres div 2 - 250, yres div 2 - 56, 600,200,0,0);
      message.select;
      if not fileexists(drive+'kernel7_c.img') then RenameFile(drive+'kernel7.img',drive+'kernel7_c.img') else deletefile(pchar(drive+'kernel7.img'));
      RenameFile(drive+'kernel7_l.img',drive+'kernel7.img');
      systemrestart(0);
      end;
end;


To make the program usable with your convention, these lines have to be replaced to "pop" a kernel from the stack instead of renaming it.
This is also important:

Code: Select all

if fileexists('C:\kernel7.img') then begin workdir:='C:\colors\'; drive:='C:\'; end
else if fileexists('D:\kernel7.img') then begin workdir:='D:\colors\' ; drive:='D:\'; end
else if fileexists('E:\kernel7.img') then begin workdir:='E:\colors\' ; drive:='E:\'; end
else if fileexists('F:\kernel7.img') then begin workdir:='F:\colors\' ; drive:='F:\'; end
else
  begin
  outtextxyz(440,1060,'Error. No Ultibo folder found. Press Enter to reboot',157,2,2);
  repeat until readkey=$141;
  systemrestart(0);
end;


In a multidrive environment you can't assume your boot disk is C, so it is detected here
mark
Posts: 1325
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Adding ultibohub/Demo to the kernel sampler

Postby mark » Tue Dec 18, 2018 12:05 am

mark wrote:
Ultibo wrote:
mark wrote:Could you be so kind, as time permits, at your convenience, provide some guidance on how to modify the keyboard processing of ultibohub/Demo to check for an escape key?

While there is a way to do this that is actually quite simple it turned out to be one of those things that takes more words to describe than lines of code to write, so we've created a branch in the demo and added the relevant bit of code to make this possible.

If you have a look at the RestartOnEscapeKey branch you will find a new TRestartThread in the DemoMain unit that shows how to use keyboard enumeration and notification to set all keyboards to direct read. The thread then reads keys from every attached keyboard looking for the escape key and passing on any other keys to the global keyboard buffer which is used for everything else.

Let us know if you need any more info.


Thank you. I will build and test that branch to see it restart on escape. Then I will add it to the sampler and change the SystemRestart call to a PopKernel call and test it. Mark.


I actually skipped the step of testing it before adding it to the sampler. It is included in https://github.com/markfirmware/ultibo- ... /v20181218

Due to the way I check for rpi2 kernels to run on rpi3 when there is no rpi3 kernel, both rpi2 and rpi3 kernels are listing when running on an rpi3. I have a note to fix that.

Thanks again,
Mark
mark
Posts: 1325
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Adding ultibohub/Demo to the kernel sampler

Postby mark » Tue Dec 18, 2018 12:11 am

pik33 wrote:The GUI uses Microdos like convention: before start, Raspbian kernel is renamed to kernel7_l.img by a shell script. The same script copies GUI kernel to /boot/kernel7.img so the GUI will start after this every time the RPi is swtched on
The return to Raspbian is done after double clicking its icon or pressing R on the keyboard by renaming itself and restoring kernel7.img. This is done in the main file project1

...

To make the program usable with your convention, these lines have to be replaced to "pop" a kernel from the stack instead of renaming it.
This is also important:

...

In a multidrive environment you can't assume your boot disk is C, so it is detected here


Testing it on raspbian (barely enough room for the sampler kernel, retro kernel and Colors/) it worked but when I tested a complete release alone on an sd card (including Colors/) all I got was a deep blue screen. Before I look into it, is this familiar? Thanks, Mark.
pik33
Posts: 863
Joined: Fri Sep 30, 2016 6:30 pm
Location: Poland
Contact:

Re: Adding ultibohub/Demo to the kernel sampler

Postby pik33 » Tue Dec 18, 2018 5:33 am

No, something went wrong. The /colors contains the desktop wallpaper, the player skns and 2 experimental icons by pjde. The rest of icons, fonts and the mouse cursor shape is intermal, so you shoud see them
There is a bug in the code which needs /ultibo folder with Raspbian.u in it (look at my earlier post) - this is not really needed and will be removed - try to create the folder and add a dummy Raspbian.u file, it can be even empty.
mark
Posts: 1325
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Adding ultibohub/Demo to the kernel sampler

Postby mark » Thu Dec 20, 2018 2:44 am

pik33 wrote:No, something went wrong. The /colors contains the desktop wallpaper, the player skns and 2 experimental icons by pjde. The rest of icons, fonts and the mouse cursor shape is intermal, so you shoud see them
There is a bug in the code which needs /ultibo folder with Raspbian.u in it (look at my earlier post) - this is not really needed and will be removed - try to create the folder and add a dummy Raspbian.u file, it can be even empty.


https://github.com/markfirmware/ultibo- ... /v20181220 includes ultibo_retro_gui. It is listed as 'Project1' since that is the name of the lpi file.

In the end I needed to include a (zero length) kernel7.img file to satisfy the multi-drive support. In the process of doing that I added start_x=1 and gpu_mem=128 to the config.txt for openmax camera support, and added the start_x.elf and fixup_x.dat firmware files.

Going forward there should be a reasonable git command that shows what changes are needed to ultibo_retro_gui for inclusion in the sampler and also what new ultibo_retro_gui commits are missing from the sampler. I will look that up.

Mark

Return to “Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 0 guests