[MeMO Pad 7 Q&A, Help & Troubleshooting] mk3pq28:
But I don`t see any other kind of solution.

I think it won`t get worse anyway, so...

Thanks a lot for your general information about efi. I took that and was able to get started. I did some experiments and had interesting results. Little notice - i`m on debian.

At first

I had installed gnu-efi and mason. Also googled "Hello world" in efi-style. I still cant post links to outside but the code is below. Looking ahead - had no result with one Print because it was closed very fast so i added a loop.

#include <efi.h>
#include <efilib.h>

EFI_STATUS
EFIAPI

efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
{
InitializeLib(ImageHandle, SystemTable);

for (int i = 0; i < 5000; ++i)
{
Print(L"B It works!!!\r\n");
}
return EFI_SUCCESS;
}

Looks simple.

Also i took your meson.build and replaced file names with mine. But i got a few conpilation errors so i had removed some keys from target. Here it is:

project('tutorial', 'c')

arch = host_machine.cpu_family()

efi_include_dir = '/usr/include/efi'

efi_include = include_directories(
efi_include_dir,
join_paths(efi_include_dir, arch),
is_system: true
)

efi_lds = '/usr/lib/elf_' + arch + '_efi.lds'
efi_crt = '/usr/lib/crt0-efi-' + arch + '.o'

bootstrap_lib = shared_library('bootstrap',
'hello_efi.c',

include_directories: [efi_include],
objects: [efi_crt],
link_args: [
'-T', efi_lds,
'-nostdlib',
'-z', 'nocombreloc',
'-Wl,-Bsymbolic',
'-lefi', '-lgnuefi'
]
)

objcopy = find_program('objcopy')

custom_target('bootstrap.efi',
output: 'bootstrap.efi',
input: bootstrap_lib,

command: [objcopy,
'--target=efi-app-' + arch,
'-j', '.text',
'-j', '.sdata',
'-j', '.data',
'-j', '.dynamic',
'-j', '.dynsym',
'-j', '.rel',
'-j', '.rela',
'-j', '.reloc',
'@INPUT@', '@OUTPUT@'
],

install: true,
install_dir: ''
)

hello_efi.c contains source code from above.

This is my first meson build so if yoy see some obvious mistakes or excess options - i would be much appreciated if you point on them.

At second

I created builddir, commanded "meson" and "ninja" and got such output:

[1/3] Compiling c object 'bootstrap@sha/hello_efi.c.o'
../hello_efi.c: In function ‘efi_main’:
../hello_efi.c:13:9: warning: passing argument 1 of ‘Print’ from incompatible pointer type [-Wincompatible-pointer-types]
Print(L"B It works!!!\r\n");
^~~~~~~~~~~~~~~~~~~~
In file included from ../hello_efi.c:2:0:
/usr/include/efi/efilib.h:404:1: note: expected ‘CHAR16 * {aka short unsigned int *}’ but argument is of type ‘int *’
Print (
^~~~~
[3/3] 'Generating bootstrap.efi with a custom command.'

I am not very familiar with C and can`t get rid of warning to print my message properly. As far as Print requires CHAR16 pointer only first symbol is printed. How to properly get and array of CHAR16 from "a string"?

Anyway, it`s a bite of success.

And at third, final

I was very happy and connected tab (in DNX, ofc) with pc and commaned: "fastboot flash osloader bootstrap.efi".

target didn't report max-download-size
sending 'osloader' (44 KB)...

And nothing more. Command is still running untill tablet reboot. But!

I have another ont efilinux.efi was downloaded from somewhere. And it flashes correctly! The only difference is on size: 44KB vs 2MB.

I did some research with dd-util and found one interesting thing. It is allowed to flash osloader partition in dnx mode with completely any binary data within (nearly) 1MB .. 20MB. In this case "fastboot flash osloader ..." says OK twice and finishes properly.

So, my flow after compilation have a such look (2057216 - is a size of my working example efilinux.efi)

$ dd if=/dev/zero of=container.efi count=2057216 iflag=count_bytes
$ dd if=bootstrap.efi of=container.efi conv=nocreat,notrunc
# fastboot flash osloader container.efi
# fastboot boot droidboot.img

... and i have a char 'B' on screen printed 5000 times. I think it`s another one bite of success :)

But i can`t find any docs for efi.h (efilib.h). Which capabilities they provides? What is set of functinos?

There is another example with

uefi_call_wrapper(ST->ConOut->OutputString, 2, ST->ConOut, L"Hello World!\n");"

but it is not obvious how to work with uefi services in this way.

I googled that most of uefi settings are stored in "Setup" variable. I think it may be useful at least to print them. But don`t know how, yet.

I will google it further but in general i don`t know what is the next step should be.