Em, hm. I thought the whole idea behind using u-boot is to let care about
device drivers and other low level stuff to u-boot and compiler.
We can use u-boot's API. u-boot has examples folder and I just tried to run
those examples in qemu. Below is my notes. The workflow for PRI, OrangePi
or your phone should be very similar.
I would assume that to port something like miniPicolisp.tgz is the matter
of configuring correct LDFLAGS and CPPFLAGS. But I'm not sufficiently
familiar with u-boot, picolisp and other stuff to make it as easy as it
sounds.

If anything, right now I'm more concerned about my rent and perspective to
lose it, if I don't pay. Such cool projects like picolisp running in u-boot
environment, as of right now is very low on my ToDo list. But if somebody
wants to pick it up from here, I attach my notes about it. Have fun!


https://picolisp.com/wiki/?embedded
https://stackoverflow.com/questions/20190116/serial-pty-in-qemu-how-to-open
https://serverfault.com/questions/1066243/what-is-the-use-case-of-qemu-chardev-pty
https://krinkinmu.github.io/2023/08/12/getting-started-with-u-boot.html
https://www.bidouilliste.com/blog/2015/11/27/Porting-FreeBSD-to-a-new-ARM-Board-Part-1/
https://forums.freebsd.org/threads/compiling-out-of-tree-u-boot.89366/
https://tomscii.sig7.se/2022/03/Patches-for-OpenBSD-on-the-PinebookPro
https://flak.tedunangst.com/post/OpenBSD-on-BeagleBone-Black
https://github.com/elewarr/openbsd-ports-u-boot
https://forum.banana-pi.org/t/bpi-r3-how-i-was-able-to-boot-openbsd-7-5-and-failed/18770
https://github.com/ndhwyd/roc-rk3399-pc_openbsd
https://briancallahan.net/blog/20231119.html


doas pkg_add -r -U picocom qemu u-boot-aarch64 aarch64-none-elf-binutils
aarch64-none-elf-gcc py3-pip py3-pipx autoconf--%2.72 gsed gcc--%8 bison

git clone --depth 1 https://source.denx.de/u-boot/u-boot.git u-boot-github1
zip -r u-boot-github1.zip u-boot-github1/
cd u-boot-github1
gmake help

/usr/bin/env MAKE=gmake PYTHON="/usr/local/bin/python3.12"
PKG_CONFIG=pkg-config

lap1$ gmake SED=gsed HOSTCC=egcc CROSS_COMPILE=aarch64-none-elf- YACC=bison
menuconfig

 Compile API examples
 CONFIG_EXAMPLES:
  U-Boot provides an API for standalone applications. Examples are provided
in directory examples.

lap1$ grep -ir '*defconfig'
board/cortina/presidio-asic/MAINTAINERS:F:
configs/cortina_presidio-asic*defconfig
board/raspberrypi/rpi/MAINTAINERS:F:    configs/rpi_*defconfig

export CROSS_COMPILE=aarch64-none-elf-
gmake SED=gsed HOSTCC=egcc CROSS_COMPILE=aarch64-none-elf- YACC=bison
orangepi_2_defconfig
gmake SED=gsed HOSTCC=egcc CROSS_COMPILE=aarch64-none-elf- YACC=bison


export CROSS_COMPILE=aarch64-none-elf-
gmake SED=gsed HOSTCC=egcc CROSS_COMPILE=aarch64-none-elf- YACC=bison
rpi_4_acpi_defconfig
gmake

/bin/sh: iasl: not found
gmake[1]: *** [scripts/Makefile.lib:540:
board/raspberrypi/rpi/dsdt_generated.c] Error 127
gmake: *** [Makefile:1919: board/raspberrypi/rpi] Error 2

///make qemu_aarch64_virt_defconfig
///make menuconfig

ls configs/qemu_arm64_defconfig
export CROSS_COMPILE=aarch64-none-elf-
gmake SED=gsed HOSTCC=egcc CROSS_COMPILE=aarch64-none-elf- YACC=bison
qemu_arm64_defconfig
# make sure to select General setup -> Enable U-Boot API -> API -> Compile
API examples!
gmake SED=gsed HOSTCC=egcc CROSS_COMPILE=aarch64-none-elf- YACC=bison
menuconfig
gmake SED=gsed HOSTCC=egcc CROSS_COMPILE=aarch64-none-elf- YACC=bison

lap1$ file u-boot.bin
u-boot.bin: PCX ver. 2.5 image data
lap1$ strings u-boot.bin | grep qemu
board=qemu-arm
board_name=qemu-arm
qemu,fw-cfg-mmio

lap1$ cat examples/api/demo.c
..
int main(int argc, char *const argv[])

{

        printf("This demo were compiled in OpenBSD environment. Hopefully,
one beautiful day, I'll port miniPicolisp the similar way");
..


qemu-system-aarch64 -machine virt,virtualization=on,secure=off -cpu max
-bios u-boot.bin -nographic
lap1$ doas qemu-system-aarch64 -machine virt,virtualization=on,secure=off
-cpu max -bios u-boot.bin -nographic -serial pty
Another pane in tmux:
doas picocom /dev/ttyp5
poweroff

mkdir rootfs
lap1$ cp ./examples/standalone/hello_world* rootfs/
lap1$ cp ./examples/api/demo* rootfs/
lap1$ cd rootfs
lap1$ llvm-objcopy -O binary demo.o demo1.bin


lap1$ llvm-objcopy -O binary demo demo2.bin
lap1$ cd ..
lap1$ strings rootfs/hello_world | grep -i 'pico'


This hello world standalone example is compiled in OpenBSD environment.
Hopefully, one day, I'll port miniPicolisp.tgz to run in u-boot similar way!



qemu-system-aarch64 -machine virt,virtualization=on,secure=off -cpu max
-bios u-boot.bin -nographic -drive
file=fat:rw:./rootfs,format=raw,media=disk

=> virtio info
Device 0: 1af4 VirtIO Block Device
            Type: Hard Disk
            Capacity: 504.0 MB = 0.4 GB (1032192 x 512)

=> virtio part 0

Partition Map for virtio device 0  --   Partition Type: DOS

Part    Start Sector    Num Sectors     UUID            Type
  1     63              1032129         be1afdfa-01     06 Boot

=> fatls virtio 0:1
    72584   hello_world
      794   hello_world.bin
      669   hello_world.c
     7600   hello_world.o
     2488   hello_world.srec
       60   hello_world.su
   203744   demo
     7125   demo.c
    44552   demo.o
      239   demo.su

10 file(s), 0 dir(s)

=> bdinfo
boot_params = 0x0000000000000000
DRAM bank   = 0x0000000000000000
-> start    = 0x0000000040000000
-> size     = 0x0000000008000000
flashstart  = 0x0000000000000000
flashsize   = 0x0000000004000000
flashoffset = 0x000000000015db68
baudrate    = 115200 bps
relocaddr   = 0x000000004769e000
reloc off   = 0x000000004769e000
Build       = 64-bit
current eth = virtio-net#32

fatload virtio 0:1 0x40000000 hello_world.bin

=> fatload virtio 0:1 0x40000000 hello_world.bin
794 bytes read in 4 ms (193.4 KiB/s)
=> md.b 0x40000000 0x04
40000000: fd 7b bc a9

=> go 0x40000000
## Starting application at 0x40000000 ...
Example expects ABI version 9
Actual U-Boot ABI version 9
This hello world standalone example is compiled in OpenBSD environment.
Hopefully, one day, I'll port miniPicolisp.tgz to run in u-boot similar
way!Hello World
argc = 1
argv[0] = "0x40000000"
argv[1] = "<NULL>"
Hit any key to exit ...

## Application terminated, rc = 0x0
=>


=> fatload virtio 0:1 0x40000000 demo1.bin
1520 bytes read in 2 ms (742.2 KiB/s)
=> go 0x40000000
## Starting application at 0x40000000 ...


On Wed, May 21, 2025, 00:56 mayor84 <mayo...@gmail.com> wrote:

> Oh. Hi. Just saw your email.
>
> Not sure what driver are you talking about. I was thinking something like
> this
>
>
> https://www.amazon.com/RS232-3-5mm-Serial-Adapter-USB-RS232-AJ/dp/B08CQYJSFC
>
> FTDI drivers are there for any platform. Windows, linux. On openbsd I'm
> using picocom,
>
> picocom /dev/ttyU0
>
> The biggest quirk with it is to guess the correct connection parameters.
> They're limited like with old phone-line modems. It almost feels so
> obvious, that anybody should know how to use it. Just read man for picocom.
> It even knows how to do x-modem, so you can send files to/from the device
> right through the serial connection. ;)
>
>
> On Sun, May 18, 2025, 14:14 Alexander Burger <picolisp@software-lab.de>
> wrote:
>
>> Thanks mayor84!
>>
>> > Made a little research. Looks like Nexus7 does have jtag and uart. May
>> be
>> > Nexus9 is the same.
>> > ...
>>
>> Lots of promising details indeed :)
>>
>> It seems, however, that I still lack most of the necessary
>> infrastructure to tackle this. I did install LineageOS about ten years
>> ago on those devices via the HBOOT loader without problems, but I cannot
>> access them serially, don't have the toolchains, and don't dare to write
>> necessary device drivers even with the hardware documentation :(
>>
>> ☺/ A!ex
>>
>> --
>> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>>
>

Reply via email to