# ubldr



## balanga (Apr 17, 2019)

arm/BootProcess - FreeBSD Wiki
		




```
Other Bootloaders
U-Boot
Many modern boards and ARM-based systems come with U-Boot. Something like the first-level bootloader described above often runs first, and gets the low-level hardware (clocks and ram) running enough to load and launch u-boot. U-boot can be customized with support for a wide variety of storage systems, network interfaces, filesystems, and even utilities to test and format hardware devices and copy data to them.

Generally you need a copy of u-boot that has been customized and compiled for your particular chip and board.

[ need more info here. ]
ubldr
[ need more here too ]
```

?????

So where do I find out anything about `ubldr`?


----------



## T-Daemon (Apr 17, 2019)

> ubldr is simply a version of loader(8) that uses the U-Boot API.


https://www.bidouilliste.com/blog/2015/11/27/Porting-FreeBSD-to-a-new-ARM-Board-Part-1/



> Booting FreeBSD on an ARM device has three primary steps:
> 
> 1 U-Boot
> 2 ubldr
> ...


http://blog.khubla.com/freebsd/how-does-the-crochet-freebsd-arm-boot-work


----------



## ComradeSlice (May 4, 2019)

When you run buildworld you pass UBLDR_LOADADDR to make. This is the address you would tell u-boot to load ubldr with. I find it the preferred way of booting armv7 with Das U-Boot. You can also boot using kernel.bin but this is not very intuitive because you'd have to update the kernel file on the fat partition (assuming you are using a fat partition) every time you update the system. When I build armv7 I use 0x88000000 for UBLDR_LOADADDR.


----------



## ComradeSlice (May 4, 2019)

The default UBLDR_LOADADDR can be found in /usr/src/stand/arm/uboot/Makefile. This is where ubldr and ubldr.bin are built.


----------



## balanga (May 4, 2019)

ComradeSlice said:


> This is where ubldr and ubldr.bin are built.



I have no idea what ubldr.bin is used for.... having said that I just did a Google search and found:-



			ubldr vs ubldr.bin?
		


Does this sound correct?


----------



## ComradeSlice (May 5, 2019)

Looks accurate. Why don't you try both and see which one works best for you? This boot command should work for ubldr.bin assuming U-Boot is on a FAT partition:

`if mmc rescan; then
fatload mmc 0 0x80200000 ubldr.bin;
go 0x80200000;
fi;`

Change the address if it doesn't work. This one is for ubldr but you _must_ know what the UBLDR_LOADADDR is. I built for 0x88000000 but it _will_ be different for you:

`if mmc rescan; then
fatload mmc 0 0x88000000 ubldr;
bootelf 0x88000000;
fi;`

You could try dumping ubldr and searching for the symbol. If it is not overridden elsewhere it will be 0x1000000.


----------



## balanga (May 5, 2019)

I don't actually have a problem with ubldr it works just fine when loaded on a FAT partition on my USB stick, I was just interested in how ubldr and ubldr.bin worked since I've never seen any documentation on them.

Just FYI my FAT partition just contains ubldr and /boot/uEnv.txt which contains:-

```
bootfile=ubldr
kernel_addr_r=0x01000000
loadaddr=0x02000000
bootcmd_bsd=fatload ide 0:1 ${loadaddr} ${bootfile} && bootelf ${loadaddr}
```

This is used to boot FreeBSD on a GoFlex Home (Marvel Kirkwood armv5) device.


----------



## ComradeSlice (May 5, 2019)

Looks like the image you are using wants you to use ubldr and if that's all it contains you'll have to use it. If you `nm ubldr` you can look for UBLDR_LOADADDR. It's a global symbol located at the address you'll need to load ubldr at. Confirm that the UBLDR_LOADADDR is actually located at 0x02000000. Then you'll see that's why it's being loaded at that particular address.


```
880515f0 r Te2
880519f0 r Te3
8804f9c8 r Te4
88000000 A UBLDR_LOADADDR
         w _DYNAMIC
8804ed9c d _GLOBAL_OFFSET_TABLE_
880407b4 W ___longjmp
88049c2c T __aeabi_idiv
8804085c T __aeabi_idivmod
```


----------

