Merge lp:~lool/linaro-image-tools/samsung-v310 into lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310

Proposed by Loïc Minier
Status: Merged
Merged at revision: 302
Proposed branch: lp:~lool/linaro-image-tools/samsung-v310
Merge into: lp:~angus-akkea/linaro-image-tools/Samsung-SMDKV310
Diff against target: 262 lines (+100/-77)
2 files modified
linaro_media_create/boards.py (+98/-75)
linaro_media_create/tests/test_media_create.py (+2/-2)
To merge this branch: bzr merge lp:~lool/linaro-image-tools/samsung-v310
Reviewer Review Type Date Requested Status
Angus Ainslie Pending
Review via email: mp+50671@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'linaro_media_create/boards.py'
2--- linaro_media_create/boards.py 2011-02-17 21:22:59 +0000
3+++ linaro_media_create/boards.py 2011-02-21 23:54:54 +0000
4@@ -65,6 +65,41 @@
5 # root partition; at least 50 MiB; XXX this shouldn't be hardcoded
6 ROOT_MIN_SIZE_S = align_up(50 * 1024 * 1024, SECTOR_SIZE) / SECTOR_SIZE
7
8+# Samsung v310 implementation notes
9+# * BL1 (SPL) is expected at offset +1s and is 32s long
10+# * BL2 (u-boot) is loaded at a raw MMC offset of +65s by BL1 which currently
11+# doesn't support FAT
12+# * the u-boot environment is at +33s and is 32s long (16 KiB)
13+# * currently, some hardware issues on certain boards causes u-boot to not be
14+# able to use FAT to load uImage and uInitrd (or boot.scr); as a temporary
15+# workaround, these are loaded from +1089s and +9281s respectively
16+# * hence we hardcode all offsets, make sure that the files aren't larger than
17+# their reserved spot, and create a bootloader partition from the first
18+# sector after MBR up to end of initrd
19+SAMSUNG_V310_BL1_START = 1
20+SAMSUNG_V310_BL1_LEN = 32
21+SAMSUNG_V310_ENV_START = SAMSUNG_V310_BL1_START + SAMSUNG_V310_BL1_LEN
22+SAMSUNG_V310_ENV_LEN = 32
23+assert SAMSUNG_V310_ENV_START == 33, "BL1 expects u-boot environment at +33s"
24+assert SAMSUNG_V310_ENV_LEN * SECTOR_SIZE == 16 * 1024, (
25+ "BL1 expects u-boot environment to be 16 KiB")
26+SAMSUNG_V310_BL2_START = SAMSUNG_V310_ENV_START + SAMSUNG_V310_ENV_LEN
27+SAMSUNG_V310_BL2_LEN = 1024
28+assert SAMSUNG_V310_BL2_LEN * SECTOR_SIZE == 512 * 1024, (
29+ "BL1 expects BL2 (u-boot) to be 512 KiB")
30+SAMSUNG_V310_UIMAGE_START = SAMSUNG_V310_BL2_START + SAMSUNG_V310_BL2_LEN
31+SAMSUNG_V310_UIMAGE_LEN = 8192
32+assert SAMSUNG_V310_UIMAGE_START == 1089, (
33+ "BL2 (u-boot) expects uImage at +1089s")
34+assert SAMSUNG_V310_UIMAGE_LEN * SECTOR_SIZE == 4 * 1024 * 1024, (
35+ "BL2 (u-boot) expects uImage to be 4 MiB")
36+SAMSUNG_V310_UINITRD_START = (
37+ SAMSUNG_V310_UIMAGE_START + SAMSUNG_V310_UIMAGE_LEN)
38+SAMSUNG_V310_UINITRD_LEN = 204800
39+assert SAMSUNG_V310_UINITRD_START == 9281, (
40+ "BL2 (u-boot) expects uInitrd at +9281s")
41+assert SAMSUNG_V310_UINITRD_LEN * SECTOR_SIZE == 100 * 1024 * 1024, (
42+ "BL2 (u-boot) expects uInitrd to be 100 MiB")
43
44 def align_partition(min_start, min_length, start_alignment, end_alignment):
45 """Compute partition start and end offsets based on specified constraints.
46@@ -424,7 +459,7 @@
47
48 class SamsungConfig(BoardConfig):
49 boot_env = [
50- 'bootargs=root=/dev/mmcblk0p3 rootwait rw init=/bin/bash console=ttySAC1,115200',
51+ 'bootargs=root=/dev/mmcblk0p2 rootwait rw init=/bin/bash console=ttySAC1,115200',
52 'bootcmd=movi read kernel 40007000; movi read rootfs 41000000 600000;'
53 'bootm 40007000 41000000',
54 'ethact=smc911x-0',
55@@ -433,23 +468,24 @@
56
57 @classmethod
58 def get_sfdisk_cmd(cls, should_align_boot_part=False):
59- # Create a fixed-offset bootloader data at
60- # the beginning of the image (size is 214080 512 byte sectors
61- # with the first sector for MBR).
62+ # bootloader partition needs to hold everything from BL1 to uInitrd
63+ # inclusive
64+ min_len = (
65+ SAMSUNG_V310_UINITRD_START + SAMSUNG_V310_UINITRD_LEN -
66+ SAMSUNG_V310_BL1_START)
67+
68+ # bootloader partition
69 loader_start, loader_end, loader_len = align_partition(
70- 1, 214080, 1, PART_ALIGN_S)
71-
72- boot_start, boot_end, boot_len = align_partition(
73- loader_end + 1, BOOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
74-
75+ 1, min_len, 1, PART_ALIGN_S)
76+
77+ # root partition
78 # we ignore _root_end / _root_len and return a sfdisk command to
79 # instruct the use of all remaining space; XXX if we had some root size
80 # config, we could do something more sensible
81 root_start, _root_end, _root_len = align_partition(
82- boot_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
83+ loader_end + 1, ROOT_MIN_SIZE_S, PART_ALIGN_S, PART_ALIGN_S)
84
85- return '%s,%s,0xDA\n%s,%s,0x0C,*\n%s,,,-' % (
86- loader_start, loader_len, boot_start, boot_len, root_start)
87+ return '%s,%s,0xDA\n%s,,,-' % (loader_start, loader_len, root_start)
88
89 @classmethod
90 def _make_boot_files(cls, uboot_parts_dir, boot_cmd, chroot_dir,
91@@ -458,13 +494,13 @@
92 chroot_dir, 'usr', 'lib', 'u-boot', 'smdkv310', 'u-boot.v310')
93 install_smdkv310_boot_loader(uboot_file, boot_device_or_file)
94
95- env_file = os.path.join(boot_dir, 'boot_env.flash')
96- # SMDK v310 uses a 16K environment
97- make_flashable_env(cls.boot_env, 16384, env_file)
98+ env_file = os.path.join(uboot_parts_dir, 'boot_env.flash')
99+ make_flashable_env(
100+ cls.boot_env, SAMSUNG_V310_ENV_LEN * SECTOR_SIZE, env_file)
101 install_smdkv310_boot_env(env_file, boot_device_or_file)
102
103 uImage_file = make_uImage(
104- cls.load_addr, uboot_parts_dir, cls.kernel_suffix, boot_dir)
105+ cls.load_addr, uboot_parts_dir, cls.kernel_suffix, uboot_parts_dir)
106 install_smdkv310_uImage(uImage_file, boot_device_or_file)
107
108 uInitrd_file = make_uInitrd(
109@@ -496,6 +532,21 @@
110 }
111
112
113+def _dd(input_file, output_file, block_size=SECTOR_SIZE, count=None, seek=None,
114+ skip=None):
115+ cmd = [
116+ "dd", "if=%s" % input_file, "of=%s" % output_file,
117+ "bs=%s" % block_size, "conv=notrunc"]
118+ if count is not None:
119+ cmd.append("count=%s" % count)
120+ if seek is not None:
121+ cmd.append("seek=%s" % seek)
122+ if skip is not None:
123+ cmd.append("skip=%s" % skip)
124+ proc = cmd_runner.run(cmd, as_root=True)
125+ proc.wait()
126+
127+
128 def _run_mkimage(img_type, load_addr, entry_point, name, img_data, img,
129 stdout=None, as_root=True):
130 cmd = ['mkimage',
131@@ -582,14 +633,9 @@
132
133
134 def install_mx51evk_boot_loader(imx_file, boot_device_or_file):
135- proc = cmd_runner.run([
136- "dd",
137- "if=%s" % imx_file,
138- "of=%s" % boot_device_or_file,
139- "bs=1024",
140- "seek=1",
141- "conv=notrunc"], as_root=True)
142- proc.wait()
143+ # XXX need to check that the length of imx_file is smaller than
144+ # LOADER_MIN_SIZE_S
145+ _dd(imx_file, boot_device_or_file, seek=2)
146
147
148 def _get_mlo_file(chroot_dir):
149@@ -629,63 +675,40 @@
150
151 return "%s/boot.ini" % boot_disk
152
153+
154 def install_smdkv310_uImage(uImage_file, boot_device_or_file):
155- # seek offset of 9281 is the MBR + BL1 + u-boot env + u-bbot
156- cmd = [
157- "dd",
158- "if=%s" % uImage_file,
159- "of=%s" % boot_device_or_file,
160- "bs=512",
161- "seek=1089",
162- "conv=notrunc"]
163-
164- proc = cmd_runner.run( cmd, as_root=True)
165-
166- proc.wait()
167+ # XXX need to check that the length of uImage_file is smaller than
168+ # SAMSUNG_V310_UIMAGE_LEN
169+ _dd(uImage_file, boot_device_or_file, count=SAMSUNG_V310_UIMAGE_LEN,
170+ seek=SAMSUNG_V310_UIMAGE_START)
171+
172
173 def install_smdkv310_initrd(initrd_file, boot_device_or_file):
174- # seek offset of 9281 is the MBR + BL1 + u-boot env + u-bbot + uImage
175- proc = cmd_runner.run([
176- "dd",
177- "if=%s" % initrd_file,
178- "of=%s" % boot_device_or_file,
179- "bs=512",
180- "seek=9281",
181- "conv=notrunc"], as_root=True)
182- proc.wait()
183+ # XXX need to check that the length of initrd_file is smaller than
184+ # SAMSUNG_V310_UINITRD_LEN
185+ _dd(initrd_file, boot_device_or_file, count=SAMSUNG_V310_UINITRD_LEN,
186+ seek=SAMSUNG_V310_UINITRD_START)
187+
188
189 def install_smdkv310_boot_env(env_file, boot_device_or_file):
190- # seek offset of 65 is the MBR + BL1 + u-boot env
191- proc = cmd_runner.run([
192- "dd",
193- "if=%s" % env_file,
194- "of=%s" % boot_device_or_file,
195- "bs=512",
196- "seek=33",
197- "count=32",
198- "conv=notrunc"], as_root=True)
199- proc.wait()
200+ # XXX need to check that the length of env_file is smaller than
201+ # SAMSUNG_V310_ENV_LEN
202+ _dd(env_file, boot_device_or_file, count=SAMSUNG_V310_ENV_LEN,
203+ seek=SAMSUNG_V310_ENV_START)
204+
205
206 def install_smdkv310_boot_loader(v310_file, boot_device_or_file):
207- # seek offset of 1 preserves the MBR
208- proc = cmd_runner.run([
209- "dd",
210- "if=%s" % v310_file,
211- "of=%s" % boot_device_or_file,
212- "bs=512",
213- "seek=1",
214- "count=32",
215- "conv=notrunc"], as_root=True)
216- proc.wait()
217- # seek offset of 65 is the MBR + BL2 + u-boot env
218- proc = cmd_runner.run([
219- "dd",
220- "if=%s" % v310_file,
221- "of=%s" % boot_device_or_file,
222- "bs=512",
223- "seek=65",
224- "skip=64",
225- "conv=notrunc"], as_root=True)
226- proc.wait()
227+ # v310_file is a binary with the same layout as BL1 + u-boot environment +
228+ # BL2; write BL1 (SPL) piece first (SAMSUNG_V310_BL1_LEN sectors at +0s in
229+ # the file and +SAMSUNG_V310_BL1_START on disk), then write BL2 (u-boot)
230+ # piece (rest of the file starting at +(SAMSUNG_V310_BL1_LEN +
231+ # SAMSUNG_V310_ENV_LEN)s in the file which is the same as
232+ # +(SAMSUNG_V310_BL2_START - SAMSUNG_V310_BL1_START)s)
233+ _dd(v310_file, boot_device_or_file, count=SAMSUNG_V310_BL1_LEN,
234+ seek=SAMSUNG_V310_BL1_START)
235+ # XXX need to check that the length of v310_file - 64s is smaller than
236+ # SAMSUNG_V310_BL2_LEN
237+ _dd(v310_file, boot_device_or_file, seek=SAMSUNG_V310_BL2_START,
238+ skip=(SAMSUNG_V310_BL2_START - SAMSUNG_V310_BL1_START))
239
240
241
242=== modified file 'linaro_media_create/tests/test_media_create.py'
243--- linaro_media_create/tests/test_media_create.py 2011-02-17 21:09:31 +0000
244+++ linaro_media_create/tests/test_media_create.py 2011-02-21 23:54:54 +0000
245@@ -379,7 +379,7 @@
246
247 def test_smdkv310(self):
248 self.assertEquals(
249- '1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-',
250+ '1,221183,0xDA\n221184,,,-',
251 board_configs['smdkv310'].get_sfdisk_cmd())
252
253
254@@ -709,7 +709,7 @@
255 # every time we run sfdisk it actually repartitions the device,
256 # erasing any partitions created previously.
257 self.assertEqual(
258- [('1,221183,0xDA\n221184,106496,0x0C,*\n327680,,,-', 255, 63, '',
259+ [('1,221183,0xDA\n221184,,,-', 255, 63, '',
260 self.media.path)], sfdisk_fixture.mock.calls)
261
262 def test_create_partitions_for_beagle(self):

Subscribers

People subscribed via source and target branches