[BPI-R2] How to build an Ubuntu/Debian SD image from scratch

please do not copy any files to /boot in rootfs because it is the mountpoint for boot-partition and boot will fail if it is not empty. where do you call pkgbuild?

if you do not change filename of kernel (leave uImage and replace the old) you do not need to create a uEnv.txt, only if the name changes or you want to change/extend other vars in the environment. uEnv.txt/uImage needs to be located in the folder you’ve seen above. if you add a new uImage without replacing the old, say uImage_5.3 you create a uEnv.txt and add this at the end (if it exists or you copy an existing file):

kernel=uImage_5.3

btw. instead of copying the 4 files you can simply copy the first 1M from my image to yours…re-read partition table, create filesystems and add kernel+rootfs+modules

Yes boot directory in rootfs will be empty as it is cleaned after using its files What I used to do is compile kernel along with files needed for boot partition using pkgbuild and then build the whole manjaro linux using manjaro-arm-tool official tool this gives us manjaro img to be flashed on media for booting.

No will go with the standard practice of using uImage and will not be changing the name instead will compile kernel separately for every build.

Yes this I can use for testing if the first method fails but to maintain the device with updates I think the first method is stable. Is that correct?

as the 3 headers (and in your case uboot too) do not change, you can simple use the 1MB-DD from my image…as i said you still can update uboot by overwriting the old one…had no problems with this method and i did it many many times :slight_smile:

now i load uboot for testing via tftp to protect my card :smiley:

I can just DD 1M from you image, you means this one?

dd if=/dev/zero of=…/bpi-r2-buster.img bs=1M count=7168

For this I have to always keep a copy of 7GB img :frowning: But Both method will work right ? Either DD 3 imgs or 1MB of your buster img

Also not able to find u-boot.bin ready file anywhere.

This makes the img-file empty

dd if=…/bpi-r2-buster.img bs=1M count=1 of=bpi-r2-bootsect.img

And then write this created images to your sd/img at position 0 (without bs,count,seek,skip)

1 Like

Thanks for this guidance. But why do you suggest to use 7GB img against small multiple imgs? also Is there latest u-boot.bin file pre-compiled? Just to test once this approach works fine then will built it from scratch.

I think you have it already downloaded :smiley: and also if you have uboot inside

Imho i have some on my gdrive…but don’t know how old

Yes But to copy it again and again everytime I build a new release then thats time consuming. As the rootfs is prepared in qemu, I hope you understand that this img will be copied to boot until theyre dd’ed to the partition, Thats my concern.

Oh I think I can get the uboot from the Flashed img of ubuntu.

Why do this everytime? My way saves time because you have 1 image with 1mb size you can use multiple times and only need to create filesystems. also this does not need to be done everytime…just replace content on your rootfs-partition

Which img is 1mb? Are we talking about this img which I downloaded from your gdrive.

bpi-r2-buster.img

Compressed = 187.2MB

Uncompressed = 7GB

Screenshot_20190905_175451

The img i created from 7gb-image above

Oh so these 3 img’s are all blank ?

  • BPI-R2-HEAD440-0k.img
  • BPI-R2-HEAD1-512b.img
  • PI-R2-preloader-DDR1600-20190722-2k.img

Now I get it I will create a blank img of 1M with zero’s and flash it to the start of the boot partition using this.

dd if=/dev/zero of=$TMPDIR/boot/bpi-r2-head.img bs=1M count=7168

dd if=$TMPDIR/boot/bpi-r2-head.img bs=1M count=1 of=${LDEV}

The common name made me think I had to use the actual Ubuntu full img.

You do the dd-commands wrong

You read zeros (if=zero) and write them to image.

I guess your imagea are now blank…they should not be…

You need to write from my image above with bs=1m and count=1 to get 1mb-file with boot-information

From what I understood here, is to create a blank img file of 7gb and then just dd that zero’s img to boot partition with just 1M count=1 that means only 1MB space is zero’ed

After going through the steps mentioned in this thread and your wiki tutorial my initial plan was to follow it step by step but the shortcut you’re following got me confused. So I am sharing the script I will be using to achieve a bootable image Here. I have written the whole script to be used with bpi-r2. If you think this will work fine then let me try this way then once I understand it further then you can explain me your method of 1m.

Please advice thanks

First is right…you create a new img file (you file should be names e.g. bpi-r2-manjaro.img ) only containing zeros with size 7168mb

Second step i’ve mention is to copy boot-related bytes (first 1mb) from my image to yours (using a separat img-file to reuse it later without extracting it again and you can delete my 7g image). Of course you can use the smaller official head-imgs,but this is more work (3 img+parttable+uboot) and everytime you want to do this you have to look which file needs to be on which offset…the 1mb bootsect.img is simply burned to offset 0 (leave all bs,seek,skip options so you have a simpler dd-command with only if and of param)

if you have flashed the bootheaders,you can re-read the partition-table (eject and reinsert sd). Then create filesystems on both partitions (p1 fat,p2 ext). Then copy your rootfs to p2 and then kernel+modules

Oh ok so you mean the1m boot sector Image will do the work of head-440-0k, head1-512b and preloader?

Where is this img? I cant find it. Am I right in the above message?

Sorrry to ask you so many times. Just little confused.

I did now reading from your wiki.

You mean this image?

Right, you don’t need 4 files,only the one and no need for manually create partition table…use same as from my debian image

you create it by yourself from my 7g image like i wrote above (and linked),or use the 1mb image from my wiki (but this has older uboot)

1 Like

Ok i will re-write the bootloader script and share it with you.

After that I will make pkgbuild for your kernel branch.

Basicly you can also use my debian-image and replace content of rootfs (except /lib/modules if you don’t want newer kernel)

I understand what you’re trying to tell me is to save time, If I just wanted to test I would have used as you recommended, but I would like to maintain it regularly and not always copy paste.

Well I have pkgbuild script to build kernel from source. I will update that after going through your source branch. Which is the latest stable version of your kernel branch?