From owner-freebsd-arm@freebsd.org Thu Dec 24 10:51:12 2015 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 063ADA5101C for ; Thu, 24 Dec 2015 10:51:12 +0000 (UTC) (envelope-from sylgar@gmail.com) Received: from mail-wm0-x22e.google.com (mail-wm0-x22e.google.com [IPv6:2a00:1450:400c:c09::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7E26C1731 for ; Thu, 24 Dec 2015 10:51:11 +0000 (UTC) (envelope-from sylgar@gmail.com) Received: by mail-wm0-x22e.google.com with SMTP id l126so178177992wml.0 for ; Thu, 24 Dec 2015 02:51:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=M/uWTZOyQM8lge6LME/4xfIXAveLOxCfOezKlQo4mXs=; b=ZEyzOklZCNI2MFhonhszFX7De3e4PDL9cyv6zJA7tWMEEXf1nwDWSpFYMrdrGhGkB8 d3Ybdk9dLd4q5f8zg+NJ/uZ3D5kQ1kQG1Y+Nkd+87Y6Dk182ROSa4baOQX4if/eR6FpO kOQFtvdSjEplIvpe08yRaKoPhZqNo4fsqsf3yRKYBiXt1E0pCsCNlADjkkqIp29fmfJu xQQtKxKFPv6zgMBXSg5qM8hE9KCL0F3MkKpcJ8VWjqR2laHl/atHsN8ljp8zcbvxDAh0 Oq626yJfHyjPNGiDX9h6S7qm1n8ZdrGv88KEah/V1FdnnebrQoAqifmFxE4AneDjvpA2 Kv/g== X-Received: by 10.28.13.138 with SMTP id 132mr41997702wmn.62.1450954269746; Thu, 24 Dec 2015 02:51:09 -0800 (PST) Received: from [192.168.0.5] (lns-bzn-50f-81-56-235-196.adsl.proxad.net. [81.56.235.196]) by smtp.gmail.com with ESMTPSA id m70sm30654253wmb.0.2015.12.24.02.51.08 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 24 Dec 2015 02:51:08 -0800 (PST) Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Subject: Re: Booting the ELF kernel without ubldr on Raspberry Pi From: Sylvain Garrigues In-Reply-To: <32849B9F-C7B8-4A86-B8F1-043F62D2E64C@kientzle.com> Date: Thu, 24 Dec 2015 11:51:07 +0100 Cc: freebsd-arm Message-Id: <8F62699C-126D-492D-8B7E-8C250ED5BC07@gmail.com> References: <32849B9F-C7B8-4A86-B8F1-043F62D2E64C@kientzle.com> To: Tim Kientzle X-Mailer: Apple Mail (2.3112) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.20 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Dec 2015 10:51:12 -0000 If I look at what gonzo did for VERSATILEPB, I think it can be done = easily by writing a tiny assembly code that does something like what he = did: # set r0..r3 to zero /usr/bin/printf "\0\0\240\343" > ${WORKDIR}/first_commands /usr/bin/printf "\0\020\240\343" >> ${WORKDIR}/first_commands /usr/bin/printf "\0\040\240\343" >> ${WORKDIR}/first_commands /usr/bin/printf "\0\060\240\343" >> ${WORKDIR}/first_commands =20 # jump to kernel entry point /usr/bin/printf "\001\366\240\343" >> ${WORKDIR}/first_commands =20 # install kernel [ ! -d ${WORKDIR}/_.kernel.bin ] && mkdir ${WORKDIR}/_.kernel.bin board_default_installkernel ${WORKDIR}/_.kernel.bin dd of=3D$VERSATILEPB_FLASH bs=3D1M count=3D4 if=3D/dev/zero dd of=3D$VERSATILEPB_FLASH bs=3D1 conv=3Dnotrunc = if=3D${WORKDIR}/first_commands dd of=3D$VERSATILEPB_FLASH bs=3D64k oseek=3D15 conv=3Dnotrunc = if=3D${WORKDIR}/_.kernel.bin/boot/kernel/kernel.bin The only problem for the Raspberry pi is that, if I am correct, the DTB = is modified by the firmware (bootcode.bin) so I can=E2=80=99t statically = compile the DTB in the kernel like for VERSATILEPB :( I would need to = mimic what loader does and create a kernel environment variable which = contains the address to the DTB. This is a good exercice, but it doesn=E2=80=99t solve my project which = is to: 1/ have a self-extracting kernel or have a loader which uncompress the = kernel, so that it takes much less time to start (my benchmark is = raspbian or openelec).=20 =3D=3D> I compiled ubldr with LOADER_GZIP_SUPPORT and compressed kernel = to kernel.gz, reducing the size by 2. The loader does manage to load, = uncompress and boot the kernel.gz, but the loading time is worse than = when uncompressed, so I=E2=80=99m stuck I don=E2=80=99t know what=E2=80=99= s wrong? 2/ have the bootloader / kernel display a nice splash screen while the = kernel boots =3D=3D> for that I looked at u-boot splash screen but the quality of the = rendering is too poor (8-bit bitmap). I looked at the VT frame buffer = but the slash screen feature is also limited. So I might now look into = the misc/raspberrypi-userland port and understand how the hello_jpeg = sample code does that with the GPU, then I plan to port it in the kernel = initialization code, not sure it=E2=80=99s going to work)=20 Have a good day > Le 24 d=C3=A9c. 2015 =C3=A0 07:18, Tim Kientzle a = =C3=A9crit : >=20 > Actually, it would be more interesting to go a step further and boot = the FreeBSD kernel directly from the firmware, bypassing both U-Boot and = ubldr. >=20 > Warner did some work long ago to allow the FreeBSD kernel to boot from = a Linux boot loader, which should make this possible. You might try = looking at that code and seeing if you can get it to work. >=20 > Cheers, >=20 > Tim >=20 >=20 >> On Dec 21, 2015, at 7:48 PM, Sylvain Garrigues > wrote: >>=20 >> Hello, >>=20 >> I=E2=80=99d like to boot FreeBSD directly with u-boot, without ubldr, = using an image provided by the u-boot mkimage tool. The reason is = simple: mkimage can deal with compressed kernels and will therefore = speed my boot time. And I want to try it anyway, as it seems possible = reading = http://bsdcan.org/2008/schedule/attachments/49_2008_uboot_freebsd.pdf = > = and various other=20 >>=20 >> Before going there and using an mkimage, I=E2=80=99d like to boot the = kernel image just with the same bootelf version provided by the = sysutils/u-boot-rpi2 port. It doesn=E2=80=99t display anything and = crashes (I think I can see =C2=AB illegal instruction =C2=BB just before = the board reboots). I don=E2=80=99t understand why, and this is my first = question. >>=20 >> Then I looked at the mkimage utility, although we can specify and = freebsd kernel type through the -O flag, the bootm command only = understands linux and NetBSD. I guess I should use linux there? >>=20 >> Thanks for your help, >> Sylvain >>=20 >>=20 >> PS: FYI, below is: >>=20 >> 1/ info about my kernel (I can see the entry point is at 0xc0100100), = copied into the fat partition >>=20 >> # readelf -h = /root/crochet/work/obj/arm.armv6/root/crochet/src/sys/RPI2/kernel = =20 >> ELF Header: >> Magic: 7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00=20 >> Class: ELF32 >> Data: 2's complement, little endian >> Version: 1 (current) >> OS/ABI: UNIX - System V >> ABI Version: 0 >> Type: EXEC (Executable file) >> Machine: ARM >> Version: 0x1 >> Entry point address: 0xc0100100 >> Start of program headers: 52 (bytes into file) >> Start of section headers: 6235080 (bytes into file) >> Flags: 0x5000202, has entry point, = Version5 EABI, >> Size of this header: 52 (bytes) >> Size of program headers: 32 (bytes) >> Number of program headers: 6 >> Size of section headers: 40 (bytes) >> Number of section headers: 38 >> Section header string table index: 35 >> [root@clad /usr/ports/sysutils/u-boot-rpi2]# =20 >>=20 >> 2/ the interesting part of my include/configs/rpi-common.h from = u-boot: >>=20 >> #define CONFIG_EXTRA_ENV_SETTINGS \ >> ENV_DEVICE_SETTINGS \ >> "loadaddr=3D0x02000000\0" \ >> "Fatboot=3D" \ >> "env exists loaderdev || env set loaderdev ${fatdev}; " \ >> "echo Booting from: ${fatdev} ${bootfile}; " \ >> "fatload ${fatdev} ${loadaddr} ${bootfile} && bootelf = ${loadaddr}; " \ >> "\0" \ >> "preboot=3D" \ >> "fdt addr 0x100; " \ >> "env set bootfile kernel; " \ =20 >> "env set fatdev 'mmc 0'; " \ >> "\0" >> #undef CONFIG_BOOTCOMMAND >> #define CONFIG_BOOTCOMMAND "run Fatboot" >> #undef CONFIG_PREBOOT >> #define CONFIG_PREBOOT "run preboot" >> _______________________________________________ >> freebsd-arm@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-arm = >> To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org = "