mirzak / meta-coral

Yocto/OE-core BSP Layer for Coral Dev Board
MIT License
40 stars 21 forks source link

Flash yocto image to Coral emmc #37

Closed benjydel closed 4 years ago

benjydel commented 4 years ago

Hello, I'm quite novice in yocto and SOM but I would like to flash your yocto image to the Coral emmc, how could I do please ? I tried to use fastboot according to the flash script written by google but I don't know how to get the gpt partition table and divide the wic file into boot and root parts. Also I tried to burn the wic image directly to the emmc via serial usb and uboot u-boot=> ums 0 mmc 1 but I get the error : ---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,3) Your help would be very appreciate.

mirzak commented 4 years ago

I seem to recall that I did something like this at some point:

1. Flash SD card with an bootable image, insert to board and boot it
2. Halt U-boot
3. Run `ums 0 mmc 0` in U-Boot (need to have usb connect to PC, eMMC will show up as storage block device)
4. Flash `wic` image
5. Run `fastboot 0` in U-Boot
6. Flash U-Boot by running `fastboot flash bootloader0 imx-boot`
7. Powered off the board
8. Adjusted boot switches for eMMC
9. Power on board

Step 1. and 9. can probably be skipped if you have something that is booting of eMMC already.

---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(179,3)

Could be related that the index changes mmcblk0 vs mmcblk1. The logic in boot.scr should be able to handle this, but there might be something missing.

I will have a test on on this my self and try to write down more detail instructions.

mirzak commented 4 years ago

Could be related that the index changes mmcblk0 vs mmcblk1. The logic in boot.scr should be able to handle this, but there might be something missing

Aah, see the issue in the boot.scr.

https://github.com/mirzak/meta-coral/blob/master/meta-coral-bsp/recipes-bsp/coral-boot-script/files/boot.txt#L4

I never set the part uuid in the wks file

mirzak commented 4 years ago

So the fix could be either to:

  1. Update boot.scr to `mmc_root="/dev/mmcblk0p2"
  2. Add part uuid in wks file

Maybe I would opt for 2. becuase the boot.txt is pretty much a copy/paste from Mendel OS

benjydel commented 4 years ago

Thank you very much for your reply, I managed to do it ! Here is how I did :

  1. I had to had the partuuid indeed and also had to change the partition table to gpt in the wks file :

`part / --source rootfs --ondisk mmcblk --fstype=ext4 --label root --align 4096 --use-uuid --uuid=70672ec3-5eee-49ff-b3b1-eb1fbd406bf5

bootloader --ptable gpt`

  1. started the coral emmc mode and ran the u-boot command ums 0 mmc 0
  2. flashed the wic image with bmaptool sudo bmaptool copy tmp/deploy/images/coral-dev/core-image-minimal-coral-dev.wic /dev/sdc
  3. stop ums and ran fastboot 0 in u-boot
  4. flashed the bootloader with fastboot flash bootloader0 tmp/deploy/images/coral-dev/imx-boot-coral-dev-sd.bin-flash_evk
  5. reboot

I also to tried to flash the image on an SDcard and it works so I suggest you definitely modify the wks file to work for both sd and emmc.

mirzak commented 4 years ago

@benjydel, would you care to create a pull-request since you tested it?

benjydel commented 4 years ago

I closed the issue as I managed to do it but I still have a question. Could you please tell me where I should look or how I should do to use "fastboot flash" command and be able to create a flash script as the coral original one ? I do not understand how to create a partition table/map image and also how to divide the wic image into 2 separate boot and root images. Thank you in advance for your help.

benjydel commented 4 years ago

@benjydel, would you care to create a pull-request since you tested it?

Yes I'll do that !

mirzak commented 4 years ago

Could you please tell me where I should look or how I should do to use "fastboot flash" command and be able to create a flash script as the coral original one ?

What is the motivation of doing this? The wic image already contains everything needed and you can just write that directly.

I do not understand how to create a partition table/map image and also how to divide the wic image into 2 separate boot and root images.

This would involve some work as this is not something that is produced by default in Yocto. Though the root filesystem image should be available in your deploy directory.

benjydel commented 4 years ago

What is the motivation of doing this? The wic image already contains everything needed and you can just write that directly.

I would like to simplify the flashing process a little bit as I will have to flash a mini serial production.

This would involve some work as this is not something that is produced by default in Yocto. Though the root filesystem image should be available in your deploy directory.

Ok thank you, I should dig a little bit more on my side as it is not really linked to yocto anymore. The filesystem is indeed available but I have partition size conflicts with fastboot as the partition table isn't the same as the original one.

mirzak commented 4 years ago

Ok thank you, I should dig a little bit more on my side as it is not really linked to yocto anymore. The filesystem is indeed available but I have partition size conflicts with fastboot as the partition table isn't the same as the original one.

In the end, I think you need to create a custom image type in Yocto that mimics the behavior of the Mendel scripts.

This can probably be used as a reference on how to create a custom image type.

benjydel commented 4 years ago

In the end, I think you need to create a custom image type in Yocto that mimics the behavior of the Mendel scripts.

This can probably be used as a reference on how to create a custom image type.

Oh yes that is what I thought but I wasn't able to find a such good example, I will look at it ! Thank you very much for your help ;)