eMMC Flash Layout

Question3.1 Pack update.img for eMMC installation:

Will update Khdas Docs then, just paste brief at here for your reference first:

  1. Create upgrade folder and copy all the images and files into it:
gouwa@Server:~/project/khadas/ubuntu$ ls upgrade/
aml_sdc_burn.ini          boot.img  logo.img       rootfs.img  u-boot.bin.sd.bin   u-boot.bin.usb.tpl
aml_upgrade_package.conf  kvim.dtb  platform.conf  u-boot.bin  u-boot.bin.usb.bl2
gouwa@Server:~/project/khadas/ubuntu$ 

2.Pack images:

$ ./utils/aml_image_v2_packer -r upgrade/aml_upgrade_package.conf upgrade/ images/update.img
1 Like

Question3.2 & Question4: will do that in next week.

About partitions, paste some code here first (u-boot/include/emmc_partitions.h):

#ifndef CONFIG_AML_MMC_INHERENT_PART
#define     PARTITION_RESERVED              (8*SZ_1M)  // 8MB
#define     MMC_BOOT_PARTITION_RESERVED     (32*SZ_1M) // 32MB

#define     MMC_BOOT_NAME                   "bootloader"
#define     MMC_BOOT_DEVICE_SIZE            (0x4*SZ_1M)

#define     MMC_RESERVED_NAME               "reserved"
#define     MMC_RESERVED_SIZE               (64*SZ_1M)
#define     MMC_BOTTOM_RSV_SIZE             (0)
#endif      /* CONFIG_AML_MMC_INHERENT_PART */

#define     MMC_CACHE_NAME                  "cache"
// #define     MMC_CACHE_SIZE                  (512*SZ_1M) // this is not used and should be get from spl

#define     MMC_ENV_NAME                    "env"
#define     MMC_ENV_SIZE                    (8*SZ_1M)
1 Like

The same procedure can be done by fill image directly by dd without using android-tools.

Regarding partitions created by fdisk and placed at addresses which we have in the U-Boot partition tables I can say that after next system start this partitions become invisible probably U-Boot erases information during init on boot time.

Yes, I will give a try to do that without android-tools.

Still not quite understand the contents on your question2:

And here:

Did you say same things?

Yes.

We have the U-Boot partition table entries:

  5: boot                         ac00000           2000000                  1
  6: rootfs                       d400000         1c4c00000                  4

and if we create entries in the MBR () using fdisk utility which has the same addresses and sise:

(the sector size is 512 bites)
boot:
  start sector: 352256
   end sector: 417791

rootfs:
  start sector: 417892
   end sector: (last sector of eMMC)

we will have inodes:

/dev/mmcblk1p1
/dev/mmcblk1p2

and we will can create file systems:

mke2fs -t ext4 -L boot /dev/mmcblk1p1
mke2fs -t ext4 -L rootfs /dev/mmcblk1p2

Also at first time we can to mount these file systems and use its.

But after the system reboot we dowsn’t have inodes:

/dev/mmcblk1p1
/dev/mmcblk1p2

it is strange. It seems like U-Boot erases data or kernel cannot find these partitions on the eMMC.

The question is that how to use boot and rootfs partitions on the userspace?

I haven’t met the issue yet.

You can install the Ubuntu ROM on eMMC installation in this topic and do the comparison.

And you said first time okay, but with wrong nodes when reboot, can you post the whole log from 1st boot and 2nd boot? (u-boot printing & dmesg)

Full logs is the same.

Issue is that when we create partitions by fdisk and make file systems we have inodes /dev/mmcblk1p{1,2}. After reboot we have not inodes /dev/mmcblk1p{1,2} but if we start fdisk and repeat the wtite command:

fdisk /dev/mmcblk1
. . .
Command (m for help): w

then we can see the inodes /dev/mmcblk1p{1,2} again and can mount partitions. All data in that partitions exists and available.

MBR partition table is same and U-Boot doesn’t take this table.

Probably U-Boot rewrite some data in the partition or I have to use another values of start/end sectors?

No idea yet.

As you didn’t provide any further details, i.e. full log or so, so I just can’t locate the issue.

Hi Gouwa,

I found the root cause of this issue.

After reboot the Linux kernel create inodes

/dev/boot
/dev/rootfs

according the names of partitions in the U-Boot partition table. And I can mount /dev/boot partition created before as /dev/mmcblk1p1.

But the partition /dev/rootfs recognised by kernel as read only data:

# file -s /dev/rootfs
/dev/rootfs: data

So it seems like in the ubuntu linux branch we have code from android staff where the last partition recognized as data Android partition.

Please give me point of linux kernel code where Linux kernel initializes partitions???

Hi Gouwa,

As we have following entries:

5: boot ac00000 2000000 1
6: rootfs d400000 1c4c00000 4

in U-Boot partition table and ac00000 + 2000000 = cc00000 I can say that the last partition haw wrong addres d400000 !

So if we create partitions with following addresses by fdisk:

(the sector size is 512 bites)
boot:
  start sector: 352256
   end sector: 434175

rootfs:
  start sector: 434176
   end sector: (last sector of eMMC)

The issue will be fixes.

I think we have to fix partitions addresses in the kvim.dts file and share our experience with other people!

Thank you very much for your attention. We have found a solution thanks to your support.

Best Regards,
Andrey K.

Andrey

Where is that FTP server?

Have you been able to build an image with a corrected partn table? If so I’d love to try it here.

Thanks
Ed

Hi Gouwa,

I think is correct because in the U-Boot declared reserved 8Mb space after each partition

#define PARTITION_RESERVED (8*SZ_1M) // 8MB

so you can use current image and create partitions with offset in my second post:

(the sector size is 512 bites)
boot:
  start sector: 352256
   end sector: 434175

rootfs:
  start sector: 434176
   end sector: (last sector of eMMC)

Probably for the future we can remove cache and reserved partitions and do not declare reserved space after each partition. What do you think about it?

The current images here ftp://ftp.radix.pro/radix/platform/releases/1.1.617/s9xx-glibc/khadas-vim/

Thank you for the best technical support.

Let me known if you need some changed images and I will create for you!

Best Regards,
Andrey K.

For my purpose I think I will remove the /dev/boot partition because it don’t needed and also too small.

Hi Gouwa,

Please note that the RESERVED partition cannot be removed because in this partition the partition table is located for U-Boot an Kernel.

Also if you change the bootloder partition size then you have to do the same in kernel include/linux/mmc/emmc_partitions.h file. The kernel use this size for finding the offset of RESERVED partition where partition table is placed.

Best Regards,
Andrey K.

P.S.
I need more tests before I can share my patches.

1 Like

Will keep research that. Sometimes I just wanna keep everything simple :blush:

Andrey

Downloaded your image last night and (once I erased emmc) had no problems with it booting. As an experiment I took the S950X image available at arch arm and replaced the kernel, modules and boot dir in that image with the files from your build. The resulting Frankenstein image, with arch user space, works with the exception that I get errors like:

[ 915.084822@1] systemd-tmpfile[3385]: syscall 278
[ 915.084851@1] Code: aa0503e4 aa0603e5 aa0703e6 d4000001 (b13ffc1f)
[ 915.090014@1] CPU: 1 PID: 3385 Comm: systemd-tmpfile Not tainted 3.14.29 #1

which seems to be a problem with the aarch64 getrandom syscall. I suspect that the arch arm source with the correct board file (I know x86 linux builds well - not familiar with aarch64/arm yet) and config and, if required khadas firmware blobs, would probably fix this. The arch kernel is at 3.14.79.

I have not tested wifi or bluetooth. Network & usb seem okay. For now its still running from SD. The other issue is that arch expects an initrd so when the boot ends / is ro - but a simple remount fixes that…

Any pointers on where I can find an arm guide for people who know x86 well?

Thanks
Ed

I build my system by my toolchains based on GNU Libc 2.24 and GGC 5.3.0. Also I have normal system start scripts instead of systemd.

I think that is bad odea to mix binaries created by different toolchains and binaries linked with different libc. Also monolytic system exactly follows to dependencies between packages.

If you would like to use another kernel or add some package into the Radix.pro system please set up build environment and check out my platform branch radix-1.1

After build the whole system you wil can create your owm Makefiles for build other kernel and affitional packages.

Also your log say that you take 32bit binaries for armv8l architecture but my system is build for AArch64.

Best Regards,
Andrey K.

Andrey,

I agree 100% that mixing like I have done is NOT a great idea (hence the Frankenstein image comment). It does let me boot strap into arch though. Next steps are to get a build system working and rebuild the radix-1.1 kernel here. Then I want to see if I can merge and end up with a 3.14.79 build - if I get this working I will share the tree. The version I used is 64 bit though arch, at least on x86, handles both 32 & 63 bit with little pain.

Thanks
Ed

Please remember that not all AArch64 based chips can run 32 bit lba32 binaries on 64bit system. And anycase the kernel and libc should be patched for such feature.

I’ve created a workaround for this issue. If you boot the kernel with an initramfs image you can call /sbin/partprobe /dev/mmcblk1 just before the rootfs is mounted. This will give you the device nodes back.