6b13f685e
김민수
BSP 최초 추가
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
config BR2_TARGET_GRUB2
bool "grub2"
depends on BR2_i386 || BR2_x86_64
help
GNU GRUB is a Multiboot boot loader. It was derived from
GRUB, the GRand Unified Bootloader, which was originally
designed and implemented by Erich Stefan Boleyn. GRUB 2 has
replaced what was formerly known as GRUB (i.e. version
0.9x), which has, in turn, become GRUB Legacy.
Amongst others, GRUB2 offers EFI support, which GRUB Legacy
doesn't provide.
Notes on using Grub2 for BIOS-based platforms
=============================================
1. Create a disk image
dd if=/dev/zero of=disk.img bs=1M count=32
2. Partition it (either legacy or GPT style partitions work)
cfdisk disk.img
- Create one partition, type Linux, for the root
filesystem. The only constraint is to make sure there
is enough free space *before* the first partition to
store Grub2. Leaving 1 MB of free space is safe.
3. Setup loop device and loop partitions
sudo losetup -f disk.img
sudo partx -a /dev/loop0
4. Prepare the root partition
sudo mkfs.ext3 -L root /dev/loop0p1
sudo mount /dev/loop0p1 /mnt
sudo tar -C /mnt -xf output/images/rootfs.tar
sudo umount /mnt
5. Install Grub2
sudo ./output/host/usr/sbin/grub-bios-setup \
-b ./output/host/usr/lib/grub/i386-pc/boot.img \
-c ./output/images/grub.img -d . /dev/loop0
6. Cleanup loop device
sudo partx -d /dev/loop0
sudo losetup -d /dev/loop0
7. Your disk.img is ready!
Using genimage
--------------
If you use genimage to generate your complete image,
installing Grub can be tricky. Here is how to achieve Grub's
installation with genimage:
partition boot {
in-partition-table = "no"
image = "path_to_boot.img"
offset = 0
size = 512
}
partition grub {
in-partition-table = "no"
image = "path_to_grub.img"
offset = 512
}
The result is not byte to byte identical to what
grub-bios-setup does but it works anyway.
To test your BIOS image in Qemu
-------------------------------
qemu-system-{i386,x86-64} -hda disk.img
Notes on using Grub2 for EFI-based platforms
============================================
1. Create a disk image
dd if=/dev/zero of=disk.img bs=1M count=32
2. Partition it with GPT partitions
cgdisk disk.img
- Create a first partition, type EF00, for the
bootloader and kernel image
- Create a second partition, type 8300, for the root
filesystem.
3. Setup loop device and loop partitions
sudo losetup -f disk.img
sudo partx -a /dev/loop0
4. Prepare the boot partition
sudo mkfs.vfat -n boot /dev/loop0p1
sudo mount /dev/loop0p1 /mnt
sudo cp -a output/images/efi-part/* /mnt/
sudo cp output/images/bzImage /mnt/
sudo umount /mnt
5. Prepare the root partition
sudo mkfs.ext3 -L root /dev/loop0p2
sudo mount /dev/loop0p2 /mnt
sudo tar -C /mnt -xf output/images/rootfs.tar
sudo umount /mnt
6 Cleanup loop device
sudo partx -d /dev/loop0
sudo losetup -d /dev/loop0
7. Your disk.img is ready!
To test your EFI image in Qemu
------------------------------
1. Download the EFI BIOS for Qemu
Version IA32 or X64 depending on the chosen Grub2
platform (i386-efi vs. x86-64-efi)
http://sourceforge.net/projects/edk2/files/OVMF/
2. Extract, and rename OVMF.fd to bios.bin and
CirrusLogic5446.rom to vgabios-cirrus.bin.
3. qemu-system-{i386,x86-64} -L ovmf-dir/ -hda disk.img
4. Make sure to pass pci=nocrs to the kernel command line,
to workaround a bug in the EFI BIOS regarding the
EFI framebuffer.
http://www.gnu.org/software/grub/
if BR2_TARGET_GRUB2
choice
prompt "Platform"
config BR2_TARGET_GRUB2_I386_PC
bool "i386-pc"
help
Select this option if the platform you're targetting is a
x86 or x86-64 legacy BIOS based platform.
config BR2_TARGET_GRUB2_I386_EFI
bool "i386-efi"
help
Select this option if the platform you're targetting has a
32 bits EFI BIOS. Note that some x86-64 platforms use a 32
bits EFI BIOS, and this option should be used in this case.
config BR2_TARGET_GRUB2_X86_64_EFI
bool "x86-64-efi"
depends on BR2_ARCH_IS_64
help
Select this option if the platform you're targetting has a
64 bits EFI BIOS.
endchoice
if BR2_TARGET_GRUB2_I386_PC
config BR2_TARGET_GRUB2_BOOT_PARTITION
string "boot partition"
default "hd0,msdos1"
help
Specify the partition where the /boot/grub/grub.cfg file is
located. Use 'hd0,msdos1' for the first partition of the
first disk if using a legacy partition table, or 'hd0,gpt1'
if using GPT partition table.
endif # BR2_TARGET_GRUB2_I386_PC
config BR2_TARGET_GRUB2_BUILTIN_MODULES
string "builtin modules"
default "boot linux ext2 fat squash4 part_msdos part_gpt normal biosdisk" if BR2_TARGET_GRUB2_I386_PC
default "boot linux ext2 fat squash4 part_msdos part_gpt normal efi_gop" \
if BR2_TARGET_GRUB2_I386_EFI || BR2_TARGET_GRUB2_X86_64_EFI
config BR2_TARGET_GRUB2_BUILTIN_CONFIG
string "builtin config"
help
Path to a Grub 2 configuration file that will be embedded
into the Grub image itself. This allows to set the root
device and other configuration parameters, but however menu
entries cannot be described in this embedded configuration.
endif # BR2_TARGET_GRUB2
|