iPXE discussion forum
Flashing Yocto Image using iPXE - Printable Version

+- iPXE discussion forum (http://forum.ipxe.org)
+-- Forum: iPXE user forums (/forumdisplay.php?fid=1)
+--- Forum: General (/forumdisplay.php?fid=2)
+--- Thread: Flashing Yocto Image using iPXE (/showthread.php?tid=15518)



Flashing Yocto Image using iPXE - mm185399 - 2018-11-22 07:59

Hi Guys,

How can i flash an hddimg or .wic yocto image over iPXE

Here is what I got working

The intel machine (Apollo lake SoC) gets it's ip over DHCP Server , loads ipxe.efi and then the test script (test.ipxe)

#!ipxe
echo test
kernel bzImage
initrd initrd
imgargs bzImage rw root=/dev/ram0 initrd=initrd
boot

Which loads the bzImage and initrd and then boots, it is working fine till here.

How can I transfer a dd image and flash it using dd command, is this possible using ipxe


RE: Flashing Yocto Image using iPXE - NiKiZe - 2018-11-28 15:58

You can always have iPXE load more files, and with some magic append it to the initrd.
However it will still be up to the scripts in your linux initrd to handle that


RE: Flashing Yocto Image using iPXE - mm185399 - 2018-11-30 11:04

Do you have any example of appending a file to initrd, i am trying imgfetch but it is not showing in the initrd.

I just want to copy a dd image to ram file system which I can then do a 'dd' call using the script


RE: Flashing Yocto Image using iPXE - NiKiZe - 2018-11-30 16:30

I'm assuming this is PCBIOS (not EFI)
in that case use:
initrd http://server/file.dd /file.dd

the extra /file.dd should make sure that a cpio archive header is created, and all files are appended together.
This is called initrd argument in the documentation, and when booting a bzImage this magic happens.

In EFI mode this magic does not work, so there you need to add CPIO head on your own.


RE: Flashing Yocto Image using iPXE - mm185399 - 2018-11-30 18:14

I am using EFI..You mean adding the dd image inside the initrd.. Will it not make initrd too large


RE: Flashing Yocto Image using iPXE - NiKiZe - 2018-11-30 18:19

"too large" depends on how much ram you have.

here is how you need to prepare the dd image for it to get CPIO header (copied from some notes of mine)
Code:
# ipxe does currently only support adding cpio headers on the fly to bzImage boots,
# but not efi, for now use preadded cpio header
# generate with: echo sysrcd.dat | cpio -H newc -o > sysrcd.dat.cpio
initrd sysrcd.dat.cpio

if RAM is less then double the dd image then you would want to use something else.
for example using curl or wget to download it from scripts within you linux - but again that then is an "disk imaging issue" rather than related to iPXE


RE: Flashing Yocto Image using iPXE - mm185399 - 2018-12-03 11:58

What is the utility you suggest for tftp and dhcp, i am using tftpd32 which has both in it, the problem is I need to manually replace ipxe.efi with test.ipxe the test script after ipxe.efi is loaded else it will run in a loop of fetching ipxe.efi.. Can we make this two step process a single one


RE: Flashing Yocto Image using iPXE - NiKiZe - 2018-12-03 16:29

You can embed a script into iPXE during build, (see http://ipxe.org/embed or maybe start at http://ipxe.org/howto/chainloading#breaking_the_infinite_loop )
But using a linux machine as DHCP and running ISC dhcpd is the most compatible way.


RE: Flashing Yocto Image using iPXE - mm185399 - 2018-12-04 10:21

Thanks for all your help,

I got iPXE working on our setup after embedding iPXE script.

To compile, I run the following command

make bin-x86_64-efi/ipxe.efi EMBED=test.ipxe

And here is my test script.

#!ipxe
dhcp
set BootServer tftp://${dhcp-server}
echo ${BootServer}
kernel ${BootServer}/bzImage
initrd ${BootServer}/initrd.gz
imgargs bzImage rw root=/dev/ram0 initrd=initrd.gz
boot