Brief overview on help to use uboot/usb serial and compile a kernel
#1
My current experiences with Mobian, and compiling the kernel:

Brief overview:

- My main objective was to compile ZRAM module in to the kernel of Mobian.

What ended up happening I learned the following:
  • uBoot
  • Kernel
  • (Mobian had a small partition so I had to modify uBoot to put a new kernel and module system on there)

  • Serial Modules, and converting my raspberry pi connector to a  headphone UART option by cutting both a headphone cable, and a raspberry pi uart cable, and tying the wires together.
  • Possible cheap option (by uARt, chip on amazon and cut a headphones  that the speakers are broken to make your own.
    12 bucks....max it looks like Canadian
[*]How to cross compile on the kernel, and install it on the PinePhone
[*]How to edit the initrd, add use existing image, to make my own custom image


Example serial module:

COVVY CP2102 Module USB to TTL 5PIN Serial Converter Adapter Module, UART STC Downloader for 3.3V and 5V with Jumper Wires (2pcs)
by LYCHEE LIMITED
Learn more: https://www.amazon.ca/dp/B07VMKYZD6/ref=...8EbG2TYKA3


Result:

Telegram started working properly
ZRAM sped things up
Wifi stopped breaking!



(Example above)


Debugging  from uboot on OSX system:

- Install Uart Drivers
 - Plug in USB cable to Mac book


You can access like the following:

screen /dev/cu.SLAB_USBtoUART 115200

(Above depends on module using)

UBOOT INFORMATION:


Once connected, when you boot up you get the following, hit ESC right away to get into options:

Note: DO not use the initrd RAM  feature for uboot, you won’t get any booting going on
  • Kernels that images are gzipped  I couldn’t get to work correctly, I had to unzip it to use it within uboot

  • Example working solution using boot.text compile boot.scr
[*](You can also use these as raw commands in uBoot to boot and test new kernels)



ext4load mmc 1:2 0x40080000 /boot/Image
ext4load mmc 1:2 0x4FA00000 /boot/dtb/sun50i-a64-pinephone-1.2.dtb

Or 

ext4load mmc 1:2 ${kernel_addr_r}  /boot/Image
ext4load mmc 1:2 ${fdt_addr_r} /boot/dtb/sun50i-a64-pinephone-1.2.dtb

setenv bootargs root=/dev/mmcblk2p2 rw console=ttyS0,115200 console=tty1 initrd=/boot/initrd.img
booti 0x40080000 - 0x4FA00000


Common commands  in uboot settings:


  • the bootargs environment
  • ext4load for loading binary files into memory of uboot
  • help
  • help command
  •  booti
  •  bootm
  •  boot
[*]
Example:
    - help ext4load
    - mmc list
    - mmc info
    - printenv


Common environment helpful variables inside boot that I found:

${kernel_addr_r} (where I can load the image but I don’t think it matters where you put  (not sure)
${ftb_addr_r} where I put the pine phone DTB files.

The following raw commands start up the kernel 


Example boot up: of kernel

Trying to boot from MMC2
NOTICE:  BL31: v2.3():
NOTICE:  BL31: Built : 17:34:37, Apr 26 2020
NOTICE:  BL31: Detected Allwinner A64/H64/R18 SoC (1689)
NOTICE:  BL31: Found U-Boot DTB at 0x40635c0, model: Pine64 PinePhone (1.2)
INFO:    ARM GICv2 driver initialized
INFO:    Configuring SPC Controller
INFO:    PMIC: Probing AXP803 on RSB
INFO:    PMIC: dcdc1 voltage: 3.300V
INFO:    PMIC: dcdc5 voltage: 1.200V
INFO:    PMIC: dcdc6 voltage: 1.100V
INFO:    PMIC: dldo1 voltage: 3.300V
INFO:    BL31: Platform setup done
INFO:    BL31: Initializing runtime services
INFO:    BL31: cortex_a53: CPU workaround for 843419 was applied
INFO:    BL31: cortex_a53: CPU workaround for 855873 was applied
NOTICE:  PSCI: System suspend is available via SCPI
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry point address = 0x4a000000
INFO:    SPSR = 0x3c9


U-Boot 2020.04+dfsg-2+pinephone4 (Jun 11 2020 - 07:21:23 +0000)

DRAM:  2 GiB
MMC:   mmc@1c0f000: 0, mmc@1c11000: 1
Loading Environment from FAT... Unable to use mmc 1:2... starting USB...
No working controllers found
Hit any key to stop autoboot:  0 
=> 


KERNEL I USED:

origin https://gitlab.com/mobian1/devices/pinephone-linux.git (fetch)
origin https://gitlab.com/mobian1/devices/pinephone-linux.git (push)


How to compile kernel and setup uboot on mobian:

  • Installed docker
  • Download docker Debian image (latest version) using docker pull
  • Install the build essentials for Debian
  • Install the cross compilers needed
  • Download the kernel using git
[*]
> docker run / or docker exec to get on docker instance

Once all prerequisites installed:

> git clone linuxkernel
>

Copy mobians /proc/config.gz for a starting point of previous config

cd kernelfolder/
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- mrproper
> cp config.gz .config

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- oldconfig
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- menuconfig

(Add the features you want)

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs


Then make the modules into a separate folder, so you can copy the over,

cp $LINUX/arch/arm64/boot/Image  /build
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- modules_install  INSTALL_MOD_PATH=/build/lib

cp./arch/<arch>/boot/dts/ 

Probably only need one but I copied all dtbs to /build folder
sun50i-a64-pine64-lts.dtb     sun50i-a64-pinephone-1.2.dts
sun50i-a64-pine64-lts.dts     sun50i-a64-pinephone.dtb
sun50i-a64-pine64-plus.dtb    sun50i-a64-pinephone.dts
sun50i-a64-pine64-plus.dts    sun50i-a64-pinephone.dtsi
sun50i-a64-pine64.dtb       sun50i-a64-pinetab.dtb
sun50i-a64-pine64.dts       sun50i-a64-pinetab.dts
sun50i-a64-pinebook.dtb       sun50i-a64-sopine-baseboard.dtb
sun50i-a64-pinebook.dts       sun50i-a64-sopine-baseboard.dts
sun50i-a64-pinephone-1.0.dtb  sun50i-a64-sopine.dtsi
sun50i-a64-pinephone-1.0.dts  sun50i-h6-pine-h64-model-b.dtb
sun50i-a64-pinephone-1.1.dtb  sun50i-h6-pine-h64-model-b.dts
sun50i-a64-pinephone-1.1.dts  sun50i-h6-pine-h64.dtb
sun50i-a64-pinephone-1.2.dtb  sun50i-h6-pine-h64.dts

How to make the initrd:

cd /build/initrd
zcat existingimg.img | cpio -idmv


Usually all you need to do is copy over only the latest modules folder, or replace them

Then zip it up


find . | cpio -o -c | gzip -9 > /build/new.img


Now you should probably have all the files:

On mobian (Due to small boot folder do this)

mkdir /realboot

Copy dtbs folder to the /realboot folder
Copy image to the /realboot folder
Copy initrd to the /realboot folder
Copy the new modules created to the proper folder on /lib/modules folder

unmount /boot (the small folder)
copy all these files on /boot (on mmcblk2p2)

create the following text file:

ext4load mmc 1:2 ${kernel_addr_r}  /boot/Image
ext4load mmc 1:2 ${fdt_addr_r} /boot/dtb/sun50i-a64-pinephone-1.2.dtb

setenv bootargs root=/dev/mmcblk2p2 rw console=ttyS0,115200 console=tty1 initrd=/boot/initrd.img
booti 0x40080000 - 0x4FA00000

run mkimage:
bash-3.2# mkimage -C none -A arm -T script -d boot.text boot.scr
then fdisk /dev/mmcblk2
and make the /dev/mmcblk2p2 the active partition
reboot.
#2
Pretty cool! Thanks for sharing!


Possibly Related Threads…
Thread Author Replies Views Last Post
  Linux Kernel development Uturn 10 3,535 11-09-2023, 08:46 AM
Last Post: Kevin Kofler
  Differences bwteeen megi's kernel e sunxi64 user641 2 1,767 03-12-2023, 06:39 PM
Last Post: Kevin Kofler
  Megi's Kernel and Battery Life biketool 3 2,733 01-09-2023, 11:33 PM
Last Post: Canyonless
  Compile spacebar wizardofthemodem 2 2,974 05-15-2021, 08:49 AM
Last Post: wizardofthemodem
  My First Experience Connecting to the PinePhone via Serial Console dustfinger 2 3,951 09-12-2020, 01:13 AM
Last Post: eKeith

Forum Jump:


Users browsing this thread: 1 Guest(s)