Generating a single image file from binaries for bootable SD card

Moderator: nferre

zdhovey2000
Posts: 16
Joined: Fri Oct 13, 2017 9:52 pm

Generating a single image file from binaries for bootable SD card

Fri Mar 16, 2018 9:56 pm

I am attempting to create a bootable SD card for the sama5d4ek (not the Xplained version...it's a long story). However, I noticed that there doesn't appear to be an option under buildroot/configs for the sama5d4ek. There seems to be residual support under buildroot/board/atmel though.

I *think* I can generate the binaries (boot.bin, u-boot.bin, zImage, sama5d4ek.dtb) using the latest git repositories and building the binaries individually, but how can I combine them all into one "sdcard.img" file so I can then use Etcher to load the SD card? I noticed that there seems to be some residual support for the sama5d4ek under buildroot/board/atmel, but has anyone created a script that combines the binaries into one .img file?
sirdan
Posts: 25
Joined: Thu Jun 25, 2009 4:19 pm

Re: Generating a single image file from binaries for bootable SD card

Sun Mar 18, 2018 8:09 pm

Hello zdhovey2000,

We build sdcard.img files with buildroot for the sama5d27 SOM ek. I have outlined below how it works for that board. You can adapt it to your board.

In buildroot (make menuconfig) under system configuration you need to add:
support/scripts/genimage.sh to the option "Custom scripts to run after creating filesystem images"

Also add:
-c board/atmel/sama5d4_ek_mmc/genimage.cfg to the option "Extra argumants passed to custom scripts"

In the buildroot/board/atmel folder, create another folder with the name of your board, make sure it matches the name you used in the "Extra arguments passed to custom scripts" above. In that folder create a new genimage.cfg file for your board.

Note: Some people get weird about calling directories folders. In your mind, replace the word folder with directory if it bothers you. :lol:

For the SAMA5D27 SOM, the contents of the genimage.cfg file is below. You will have to adjust it for your board.

Code: Select all


# Image for SD card boot on Atmel SAMA5D2 Xplained boards
#
image boot.vfat 
{
	vfat 
	{
		files = 
		{
			"zImage",
			"at91-sama5d27_som1_ek.dtb",
			"at91-sama5d27_som1_ek_pda4.dtb",
			"at91-sama5d27_som1_ek_pda7.dtb",
			"at91-sama5d27_som1_ek_pda7b.dtb",
			"boot.bin",
			"u-boot.bin"
		}
	}
	size = 16M
}

image sdcard.img 
{
	hdimage 
	{
	}

	partition boot 
	{
		partition-type = 0xC
		bootable = "true"
		image = "boot.vfat"
		offset = 1M
	}

	partition rootfs 
	{
		partition-type = 0x83
		image = "rootfs.ext4"
		size = 512M
	}
}


If all goes well, you should see an sdcard.img file in the buildroot/output/images/ folder.

I hope this helps.
Best Regards,
Dan

Return to “SAMA5-based”

Who is online

Users browsing this forum: No registered users and 1 guest