Gadget snap for olimex lime2

Hello team,

Actually i am trying to create a gadget snap for olimex lime2 board (allwinner chipset) and for that i am following gadget snap of beagle bone black.
While creating gadget.yaml i have one query what will be size parameter in that -

Command to make a bootable sunxi SD-card is "dd if=u-boot-sunxi-with-spl.bin of=/dev/sdX bs=1024 seek=8"

my understanding is i have to left the 1024*8 byte from the starting then what should my size in this case?.

device-tree: sun7i-a20-olinuxino-lime2
device-tree-origin: kernel
volumes:
olimex-lime2:
bootloader: u-boot
schema: mbr
structure:
- name: u-boot
type: bare
size: ?
offset: 8192
content:
- image: u-boot-sunxi-with-spl.bin
- name: system-boot
type: 0C
filesystem: vfat
filesystem-label: system-boot
size: 128M

Pls help me to understand this parameter.
I appreciate your support here.

Thanks,
Suvhm

here are a few allwinner based gadgets:



and here is a little (incomplete) guide:

Thanks @ogra for your quick reply i just go through your blog it was very well written.
It not help me to understand the size parameter in gadget.yaml even though it has clear many more doubt.

well, after you built the gadget, take a look at u-boot-sunxi-with-spl.bin with ls -l to find the size it has … you need to make sure the size: option in gadget.yaml defines space that is at least this big for the bin file to be written there … note that ubuntu-image expects the size to be diversible by 512 (thats the bytesize per block ubuntu-image uses when creating image partitions)

like this:

# get the size
$ ls -l orangepi-gadget/prime/u-boot-sunxi-with-spl.bin |cut -d' ' -f5
$ 419479
# add 1 block so we have enough space, divide by 512
$ echo $((419479/512+1))
820
# get the actual minimal size
$ echo $((820*512))
419840

after all the only important part is that the size is not smaller than the binary you write to it …

it can be bigger … as much as you want … what i nowadays do is to simply assign a fixed 1MB (1048576) for u-boot in all my newer gadgets, it rarely gets bigger than that.

Thank you @ogra i was done the mistake, i have written only the size of the bin file.

Blockquote
i.e - $ll prime/u-boot-sunxi-with-spl.bin | cut -d ’ ’ -f5
$548864
size: 548864

# get the size
$ ls -l prime/u-boot-sunxi-with-spl.bin |cut -d’ ’ -f5
548864
#add 1 block so we have enough space, divide by 512
$ echo $((419479/512))
$echo ((1072+1))
1073
get the actual minimal size
$ echo $((1073*512))
549376

this help me to calculate the correct size as well as help me to understand the size parameter in gadget.yaml, that how the ubuntu-image uses the size while creating the partitions in the chunks of 512bytes.

First of all thanks @ogra for your kind supports.
After reading your blogs and the information which you provided earlier, I am able to build the gadget and kernel snap for olimex-lime2 board.
But when i try to boot the device with the created image i got stuck in temporary file system i.e initrd

Attaching the error log ::
mount: mounting /tmpmnt_writable/system-data/var/lib/snapd/snaps/core_7398.snap on /root failed: No such file or directory
mount: mounting /tmpmnt_writable/system-data/var/lib/snapd/snaps[ 4.264715] initrd: mounting /run
olimex-kernel_x1.snap on /tmpmnt_kernel failed: No such file or directory

It seem like core snap is not present at tmpmnt_writable/system-data/var/lib/snapd/snaps path.
I think i missed somethings in kernel snap.

Any comment on this will act as a pointer for me to move forward.

Appreciate your support here!

the actual error (with possibly some more info) is very likely further up in your log

if you suspect your kernel, you can try mine instead (this is actually originally an ubuntu kernel, just with all allwinner options enabled) :wink:

looks like the lime2 is suported in it …

$ ls /boot/uboot/linux-generic-allwinner_57.snap/dtbs/*lime*
/boot/uboot/linux-generic-allwinner_57.snap/dtbs/sun4i-a10-olinuxino-lime.dtb
/boot/uboot/linux-generic-allwinner_57.snap/dtbs/sun7i-a20-olimex-som-evb.dtb
/boot/uboot/linux-generic-allwinner_57.snap/dtbs/sun7i-a20-olinuxino-lime.dtb
/boot/uboot/linux-generic-allwinner_57.snap/dtbs/sun7i-a20-olinuxino-lime2-emmc.dtb
/boot/uboot/linux-generic-allwinner_57.snap/dtbs/sun7i-a20-olinuxino-lime2.dtb

Sorry @ogra i was bit busy with my work.
I tried to use your kernel but while creating image i found an below error ::

Its seems i am not authorize to use this pre-build snap.

Model assertion file ::
image

Pls. show me some pointer to move forward.

Appreciate your help here!!

While booting with local created kernel snap i am running with below errors::

All the above dir. are exist but some of it is of 0 byte-size
image

Do we need to change something while building kernel snap.
If needed i will share my code at somewhere where you can check if i am missing something.

Thanks

hello @ogra i found the root cause for this error.
i.e in kernel .config file there is no any confi variable for loop devices & because of that they have created approx lakh of virtual loop devices in dev.

Now i have enabled below two config variable -

CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_LOOP_MIN_COUNT=10

After enabling these two parameters when i tried to boot the device i am running below errors:

It seems squashfs compression is not support in the prescribed format .

Any comment on this will help me move forward.
I appreciate your support here.

Thanks @ogra for being supportive.
I have successfully created the bootable image for olimex lime2 board and booted the device with the same.
I let you know of my further findings/observations.

Thanks once again!!

hello @ogra sorry for bothering you again i have couple of query -

I still searching why i am not be able to pull kernel image from the store while creating image where as hello-world is easily pulled.

1- I pushed my public key again to my ubuntu-login account but still i am getting error that snap published by xyz account can’t use by ABC model.
Is this the problem with my public key ?

2- I need to boot the device using USB stick should i need to tell snapd to read the environment variable from device 2:1 as in case of sdcard it is 0:1 and for emmc it is 1:1.

Pls correct my understanding i appreciate you help.

hi, sorry, i was on vacation for two weeks …

no, this is a policy restriction, you will not be able to build an image if the kernel and model are not signed by the same person/entitiy … the way to override this is (as you found out already) to build the image from a locally stored kernel snap …
if you’d want to use my kernel from the store you’d have to first use snap download <name of the kernel snap> and then point the --extra-snaps argument to the downloaded .snap file.

whatever uboot uses to access the usb device should be fine, just adjust it in the various “load*” scripts in uboot.env …

thanks, @ogra for being supportive !!

Yes, I did the same first I downloaded the kernel snap from the store and make it as a local snap for the image.

For this, I am referring Ubuntu Core USB Booting for Raspberry pi.
“https://medium.com/@penk/how-to-boot-the-raspberry-pi-3-from-usb-with-ubuntu-core-24df33b0fd60”
will let you know my further findings in this.
meanwhile, I came to know that my SOC(olimex lime2) is also supporting FEL booting.
When I go through with different documents, I came to now that first I need to copy uboot in the internal emmc of the SOC, which will let me in fastboot mode from where i can copy my created image to its internal emmc.
i think you can help me out in this process regarding my concern :

  1. i don’t know which Uboot i need to use in this Process to get in fastboot mode.
  2. How my SOC would know where the kernal and Uboot are being placed. is there any need to do modification in MBR.
  3. Ubuntu-image tool will provide me raw .img file which will contain the Vfat as well as writeable part. but i want to make it sparse image for android. please suggest whether i need to make the sparse image from it or is there any other tool which will help me out to make sparse image for Ununtu Core writeable part.

if you have done this kind of thing then please guide or provide any reference for the same.

i appreciate your support.

for 1 and 2 i cant really help. you need to read the hardware documentation and tutorials for how to install android and how android works on this device …

for 3 i cant help you either, note that i consider android bootloaders personally a gross hack and wouldnt touch them with a ten foot pole … but said that, there is @ondra, who is the exact opposite of me and loves all this android and fastboot hackery, i guess he can help you with hacking up what ubuntu-image produces to get you sparse files suitable for fastboot … i for one would simply create a usb based installer script with a special initrd instead :wink:

1 Like

Hello @ogra sorry for bothering you again,

When I tried to boot from emmc I got below error -
image

Its seems it is still looking for env file in mmc.

Here is my uboot.patch file -
image
In this i made changes for emmc and informed my bootloader that this time FAT-ENV-DEVICE-&-PART are in emmc second part.
When i cross verifed i found that this patch file is successfully applied.
sunxi-common.h file after build $cat /parts/uboot/include/configs/sunxi-common.h
image

But when i check .config file it is still 0:auto
image

I don’t know why it is still 0:auto in .config any idea is really appreciable.

Thanks,

take a look at board/sunxi/Kconfig … some u-boot ports switched to a kernel style configuration management which might override hacks from header files (you should get compile warnings from redefining such options though … )

alternatively … also take a look at your defconfig (or any defconfig that one sources)

Thanks @ogra for your prompt response.
Yes, it was my mistake i am using defconfig of mmc inspite of emmc.

Hello @ogra,

I have a couple of query related to emmc partition, before writing my query I would like to tell you till now what i have done -
1- I segregate Ubuntu-Core image into different sections. i.e system-boot.img, writeable.img …
2- Convert the same in sparse formate.
3- Now for partitioning I would come to know that I can do this by updating the mbr (Master Boot ROM).

4- Above docs state that MBR must be at the 1st sectors (first 512K) of the emmc, but I am not able to access the first sector using fdisk (fdisk default sector start with 2048), I am figuring out how can I do that.

Now my query is -
1- Where should I place my first stage boot loader is it specific to SOC (in my case it is part0.img), whereas in the case of SD-Card I have only two partitions.
2- Should I go with multiple partition for each of these part0.img, part1.img and part2.img respectively?
3- How kernel/gadget snap will come to know where to check once it is booted with faulty kernel/gadget snap after update?

Thanks!

at the very beginning of your disk since it carries the partition table (and the SPL) usually

as i said before, i’m neither a fan of manually hacking a half built image nor am i working a lot with these hacked up fastboot bits. you have to ask @ondra, i personally would still go with a properly built image and install it with godd (or build an image that shps a modified godd plus a copy of the emmc image and auto-installs it from usb key/SD card) as i mentioned above …

through the snappy_boot script in your uboot.env
see

1 Like