agherzan / meta-raspberrypi

Yocto/OE BSP layer for the Raspberry Pi boards
https://www.yoctoproject.org/
MIT License
532 stars 410 forks source link

Building yocto image for RPi CM4 #993

Closed Sourabh1107 closed 2 years ago

Sourabh1107 commented 2 years ago

Description Hello All,

This is help request and not a bug/issue reporting.

I recently got my hands on a CM4 and now I want to build Yocto image with u-boot as bootloader. I have few doubts before I start the build.

  1. Which machine to use in local.conf file? In the meta-raspberrypi there is no specific machine for CM4 https://github.com/agherzan/meta-raspberrypi/tree/master/conf/machine. Will the "raspberrypi4-64" work for CM4?

  2. How to copy the final image to flash memory of CM4? I am using a custom IO board which has SD card slot. Can I use the SD card and boot from the SD card instead of in-built memory?

Can anyone please let me know how to get started?

barnco02 commented 2 years ago

I'm quite new to Yocto building with the CM4 as well but I do have it working so far. The "raspberrypi4-64" is what I am using and it seems to work fine, I've also seen mention elsewhere around this repo of people using thx machine for the CM4.

I don't think you can use an SD card with the CM4 with onboard memory unless you're using an external SD card controller since the builtin SD card controller is what controls the onboard eMMC when present. To use an external SD card controller and SD card I think you can disable the eMMC boot but I don't know much more than that. The image built by 'bitbake core-image-base' for 'raspberrypi4-64' is located in your build directory as 'tmp/deploy/images/raspberrypi4-64/core-image-base-raspberrypi4-64.wic.bz2' you just need to bunzip it then write it directly to your storage medium (with dd or the official raspberry pi image writer) whether its the built in eMMC or an SD card. You should probably try to find out if your SD card slot on the board you have is connected directly to the CM4 or an external controller.

Hope this helps.

jsebrd commented 2 years ago

The datasheet for the CM4 I/O board should have what you need to configure a different boot mode. https://datasheets.raspberrypi.com/cm4io/cm4io-datasheet.pdf

Sourabh1107 commented 2 years ago

Hello @barnco02 Thanks for the update. I will try with "raspberrypi4-64".

I have the CM4 Lite model so there won't be on board memory. I have to use the SD card.

Thanks in advance

Sourabh1107 commented 2 years ago

Hello @jsebrd

Thanks for the update.

I don't have the official CM4 I/O board from raspberry pi. It's a custom carrier board with SD card slot. I hope I can boot my CM4 lite from it.