How to create gadget.yaml for olimex lime2


#1

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


#2

here are a few allwinner based gadgets:



and here is a little (incomplete) guide:


#3

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.


#4

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.


#5

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.


#6

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!


#7

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

#8

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!!


#9

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


#10

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.


#11

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!!


#12

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.