Page MenuHomeFreeBSD

U-Boot loader (ubldr) support for MIPS
AbandonedPublic

Authored by Sgalabov_gmail.com on Feb 4 2016, 10:36 AM.
Tags
Referenced Files
Unknown Object (File)
Sat, Dec 14, 7:04 PM
Unknown Object (File)
Nov 11 2024, 5:07 PM
Unknown Object (File)
Oct 6 2024, 2:14 AM
Unknown Object (File)
Oct 5 2024, 10:33 AM
Unknown Object (File)
Oct 5 2024, 4:20 AM
Unknown Object (File)
Oct 3 2024, 2:01 PM
Unknown Object (File)
Oct 3 2024, 6:31 AM
Unknown Object (File)
Oct 3 2024, 12:13 AM

Details

Reviewers
ray
imp
adrian
Group Reviewers
MIPS
Summary

This revision implements ubldr support for MIPS.
A lot of it just mimics the ARM support for ubldr, basically the biggest change is in the start.S file.

Apart from that, several Makefiles in sys/boot were not including the bsd.stand.mk, which prevented proper build for MIPS targets (due to some things compiled as PIC and others - as non-PIC). These Makefiles now include bsd.stand.mk and things build fine for MIPS (everything is build as non-PIC).

Currently the self relocation feature does not work and is disabled by default. I am not certain if this will be useful to pursue in the future, but I've left the relevant parts of code in case we want to do it some day.

I've used the head version of U-Boot and modified it to support the FreeBSD API for MIPS architectures. I've submitted the patch to U-Boot as well:
http://lists.denx.de/pipermail/u-boot/2016-February/244723.html

The corresponding U-Boot patch was applied as of commit 7c60423106bebafedbdd9879d84d105b3fb03930:
http://git.denx.de/?p=u-boot.git;a=commit;h=7c60423106bebafedbdd9879d84d105b3fb03930

Test Plan

I've tested this with the following setup:

  • QEMU with its 'mips' target in little endian mode
  • u-boot compiled for quemu-mips (little endian)
  • ubldr compiled for mipsel
  • a kernel quickly put together for the qemu-mips target that only supports basic UART (so we can see the bootlog).

Output of the whole thing booting can be seen below:

> qemu-system-mipsel -M mips -bios u-boot.bin -nographic -net nic,macaddr=00:16:3e:00:00:01 -net tap -hda hda.img -cpu 24Kc

W: /etc/qemu-ifup: no bridge for guest interface found
Could not open option rom 'vgabios-cirrus.bin': No such file or directory


U-Boot 2016.03-rc1-dirty (Feb 04 2016 - 11:41:10 +0200)

Board: Qemu -M mips CPU: 24Kc proc_id=0x19300
DRAM: 128 MiB
Using default environment

In: serial
Out: serial
Err: serial
Net: NE2000
IDE: Bus 0: OK Bus 1: OK
Device 0: Model: QEMU HARDDISK Firm: 2.0.0 Ser#: QM00001
Type: Hard Disk
Capacity: 50.0 MB = 0.0 GB (102400 x 512)
Device 1: not available
Device 2: not available
Device 3: not available
Hit any key to stop autoboot: 0
qemu-mipsel # tftp; bootelf
Using NE2000 device
TFTP from server 192.168.78.1; our IP address is 192.168.78.10
Filename 'demo'.
Load address: 0x80500000
Loading: #################
5.6 MiB/s
done
Bytes transferred = 244995 (3bd03 hex)
## Starting application at 0x80800080 ...
Consoles: U-Boot console
Compatible U-Boot API signature found @87f6e0a8

FreeBSD/mipsel U-Boot loader, Revision 1.2
(root@stassi-bsd9, Wed Feb 3 17:44:10 EET 2016)

DRAM: 128MB
Number of U-Boot devices: 2
U-Boot env: loaderdev not set, will probe all devices.
Found U-Boot device: disk
Probing all disk devices...
Checking unit=0 slice=<auto> partition=<auto>... good.
Booting from disk0s1:
/
/boot/kernel/kernel data=0x3ebaa8+0x27ff8 syms=[0x4+0x43a90+0x4+0x5e7cf]
Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [/boot/kernel/kernel]...
Kernel entry at 0x80100100...
Kernel args: (null)
U-Boot args (from -2141491201 args):
Environment:
???m??
disk0s1:

entry: mips_init()
Cache info:
picache_stride = 4096
picache_loopcount = 0
pdcache_stride = 1024
pdcache_loopcount = 2
cpu0: MIPS Technologies processor v0.147
MMU: Standard TLB, 16 entries (4K 16K 64K 256K 1M 16M 64M 256M pg sizes)
L1 i-cache: 2 ways of 64 sets, 16 bytes per line
L1 d-cache: 2 ways of 64 sets, 16 bytes per line
L2 cache: disabled
Config1=0x9e190c8e<WatchRegs,MIPS16,EJTAG>
Config2=0x80000000
Physical memory chunk(s):
0x514000 - 0x1ffffff, 28229632 bytes (6892 pages)
Maxmem is 0x2000000
KDB: debugger backends: ddb
KDB: current backend: ddb
Copyright (c) 1992-2016 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 11.0-CURRENT #0 733656d(local/sgalabov_mtk)-dirty: Wed Feb 3 19:56:05 EET 2016
root@stassi-bsd9:/usr/obj/mips.mipsel/src/sgalabov/sys/QEMU-MIPS mips
gcc version 4.2.1 20070831 patched [FreeBSD]
Preloaded elf kernel "kernel" at 0x8050dfe0.
real memory = 33554432 (32768K bytes)
Physical memory chunk(s):
0x005a8000 - 0x01f47fff, 26869760 bytes (6560 pages)
avail memory = 26456064 (25MB)
ULE: setup cpu 0
random: entropy device external interface
null: <full device, null device, zero device>
mem: <memory>
nfslock: pseudo-device
nexus0: <MIPS32 root nexus>
random: harvesting attach, 8 bytes (4 bits) from nexus0
clock0: <Generic MIPS32 ticker> on nexus0
Timecounter "MIPS32" frequency 50000000 Hz quality 800
Event timer "MIPS32" frequency 50000000 Hz quality 800
random: harvesting attach, 8 bytes (4 bits) from clock0
obio0 at mem 0x10000000-0x1fffffff on nexus0
uart0: <16550 or compatible> on obio0
uart0: console (-1,n,8,1)
uart0: fast interrupt
uart0: PPS capture mode 2 (DCD)
random: harvesting attach, 8 bytes (4 bits) from uart0
random: harvesting attach, 8 bytes (4 bits) from obio0
Device configuration finished.
Timecounters tick every 10.000 msec
tcp_init: net.inet.tcp.tcbhashsize auto tuned to 512
lo0: bpf attached
Trying to mount root from ufs:ada0 []...
mountroot: waiting for device ada0...
Mounting from ufs:ada0 failed with error 19.

Loader variables:
<snip>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped