[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 4/7] Support for ARM/U-Boot platforms
From: |
Vladimir 'φ-coder/phcoder' Serbinenko |
Subject: |
Re: [PATCH 4/7] Support for ARM/U-Boot platforms |
Date: |
Mon, 08 Apr 2013 12:47:48 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 |
On 03.04.2013 18:32, Leif Lindholm wrote:
> On Mon, Apr 01, 2013 at 04:15:03AM +0200, Vladimir '??-coder/phcoder'
> Serbinenko wrote:
>>> +#define GRUB_KERNEL_MACHINE_STACK_SIZE 0x40000
>>> +#define GRUB_KERNEL_MACHINE_HEAP_SIZE (grub_size_t) (2 * 1024 * 1024)
>>
>> Why so small heap?
>
> I copied ieee1275 HEAP_MIN_SIZE to begin with, and it was always enough.
> (Since U-Boot doesn't provide any memory mapping service, kernel and
> initrd are not going on the heap.)
On x86 we reuse heap for kernels as well
> I could increase it?
>
If we want to support any kind of graphics (gfxterm, gfxmenu) on arm as well,
we'll need more heap
>>> === modified file 'util/grub-install.in'
>>> --- util/grub-install.in 2013-01-27 15:17:21 +0000
>>> +++ util/grub-install.in 2013-03-24 13:03:31 +0000
>>> @@ -319,6 +319,8 @@
>>> target=i386-pc
>>> fi
>>> ;;
>>> + x"arm"*)
>>> + target="arm-uboot";;
>>> *)
>>> gettext "Unable to determine your platform. Use --target." ;
>>> echo ;;
>>> @@ -338,7 +340,7 @@
>>> if [ x$disk_module = xunspecified ]; then
>>> disk_module=biosdisk
>>> fi
>>> -elif [ "${grub_modinfo_platform}" = "ieee1275" ] || [
>>> "${grub_modinfo_platform}" = "efi" ] || [ "${grub_modinfo_platform}" =
>>> "arc" ] ; then
>>> +elif [ "${grub_modinfo_platform}" = "ieee1275" ] || [
>>> "${grub_modinfo_platform}" = "efi" ] || [ "${grub_modinfo_platform}" =
>>> "arc" ] || [ "${grub_modinfo_platform}" = "uboot" ] ; then
>>> disk_module=
>>> else
>>> disk_module=native
>>> @@ -854,6 +856,14 @@
>>> -L "$bootloader_id" -l "\\EFI\\$efi_distributor\\$efi_file"
>>> fi
>>> fi
>>> +elif [ x"${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = xarm-uboot
>>> ]; then
>>> +
>>> grub_imgname="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}"
>>> + raw_imgname="${uboot_imgname}.raw"
>>
>> Where is uboot_imgname set?
>
> *cough* that would be a typo then - should be grub_imgname.
>
>>> + mv "$grub_imgname" "$raw_imgname"
>>> + mkimage -T kernel -A ARM -O Linux -a 0x08000000 -e 0x08000000 -C none
>>> -d "$raw_imgname" "$grub_imgname"
>>
>> Is it from uboot? You need to check for its availability
>
> Yes.
>
the header is trivial. I added it to grub-mkimage (patch at the bottom).
Trouble is that grub-install now rightfully warns about the lack of
platform-specific install.
What do we have to do to register the image at u-boot? Put it in specific
location?
Also you spoke about relocatable image but AFAICT header always specifies load
address. Do you have a way around it?
=== modified file 'util/grub-install.in'
--- util/grub-install.in 2013-04-07 00:41:07 +0000
+++ util/grub-install.in 2013-04-08 10:42:46 +0000
@@ -833,14 +833,6 @@
-L "$bootloader_id" -l "\\EFI\\$efi_distributor\\$efi_file"
fi
fi
-elif [ x"${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = xarm-uboot ];
then
-
grub_imgname="${grubdir}/${grub_modinfo_target_cpu}-$grub_modinfo_platform/core.${imgext}"
- raw_imgname="${uboot_imgname}.raw"
- mv "$grub_imgname" "$raw_imgname"
- mkimage -T kernel -A ARM -O Linux -a 0x08000000 -e 0x08000000 -C none -d
"$raw_imgname" "$grub_imgname"
- if [ $? -eq 0 ]; then
- rm -f "$raw_imgname"
- fi
else
gettext "WARNING: no platform-specific install was performed" 1>&2
echo 1>&2
=== modified file 'util/grub-mkimage.c'
--- util/grub-mkimage.c 2013-04-07 00:41:07 +0000
+++ util/grub-mkimage.c 2013-04-08 09:40:18 +0000
@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <assert.h>
#include <grub/efi/pe32.h>
+#include <grub/uboot/image.h>
#define _GNU_SOURCE 1
#include <argp.h>
@@ -1499,6 +1500,42 @@
core_size = rom_size;
}
break;
+
+ case IMAGE_UBOOT:
+ {
+ struct grub_uboot_image_header *hdr;
+ GRUB_PROPERLY_ALIGNED_ARRAY (crc32_context, GRUB_MD_CRC32->contextsize);
+
+ hdr = xmalloc (core_size + sizeof (struct grub_uboot_image_header));
+ memcpy (hdr + 1, core_img, core_size);
+
+ memset (hdr, 0, sizeof (*hdr));
+ hdr->ih_magic = grub_cpu_to_be32_compile_time (GRUB_UBOOT_IH_MAGIC);
+ hdr->ih_time = grub_cpu_to_be32 (time (0));
+ hdr->ih_size = grub_cpu_to_be32 (core_size);
+ hdr->ih_load = grub_cpu_to_be32 (image_target->link_addr);
+ hdr->ih_ep = grub_cpu_to_be32 (image_target->link_addr);
+ hdr->ih_os = GRUB_UBOOT_IH_OS_LINUX;
+ hdr->ih_arch = GRUB_UBOOT_IH_ARCH_ARM;
+ hdr->ih_type = GRUB_UBOOT_IH_TYPE_KERNEL;
+ hdr->ih_comp = GRUB_UBOOT_IH_COMP_NONE;
+
+ GRUB_MD_CRC32->init(crc32_context);
+ GRUB_MD_CRC32->write(crc32_context, hdr + 1, core_size);
+ GRUB_MD_CRC32->final(crc32_context);
+ hdr->ih_dcrc = grub_get_unaligned32 (GRUB_MD_CRC32->read
(crc32_context));
+
+ GRUB_MD_CRC32->init(crc32_context);
+ GRUB_MD_CRC32->write(crc32_context, hdr, sizeof (*hdr));
+ GRUB_MD_CRC32->final(crc32_context);
+ hdr->ih_hcrc = grub_get_unaligned32 (GRUB_MD_CRC32->read
(crc32_context));
+
+ free (core_img);
+ core_img = (char *) hdr;
+ core_size += sizeof (struct grub_uboot_image_header);
+ }
+ break;
+
case IMAGE_MIPS_ARC:
{
char *ecoff_img;
@@ -1725,9 +1762,6 @@
core_size = program_size + header_size + footer_size;
}
break;
- case IMAGE_UBOOT:
- /* Raw image, header added by grub-install */
- break;
}
grub_util_write_image (core_img, core_size, out, outname);
signature.asc
Description: OpenPGP digital signature