Emmanuel Vadot's Journal


FreeBSD, Electronics and more


Booting FreeBSD on C.H.I.P.

I've received my C.H.I.P. the day I left for EuroBSDCon. I took it with me to see if I could quickly port FreeBSD on it.

Since there is not SD/MMC on it, I would need to do boot on a usb drive, unfortunatly the U-Boot version that my CHIP came with is very old, it is based on 2015.04 and doesn't support USB. So I just put it in my bag and enjoy the conference.

Last week after unpacking I've given a shot a booting FreeBSD. The first step was compiling a recent U-Boot, and using the ports system for that is quite easy now. The ports will soon be commited, in the meantime your can download the patch here.

Now that we have U-Boot the problem is how to run this one instead of the flashed one. We have two options :

  • Replacing U-Boot on the NAND
  • Using FEL mode of the SoC

Since I didn't know if the new U-Boot will work correctly I've choose using FEL mode.

Read More

Use Binmisc for starting MegaDrive Roms

binmiscctl(8) is use to add binaries image activator in the kernel. When you execute a binary, the kernel will check what type of file it is and if it knows how to execute it it will do so.

binmiscctl is mainly use to execute arm or mips binary with the help of qemu-static (This is how the packages for thoses archs are built) but you can use it for almost anything and this is what I've done.

Every Sega Megadrive games comes with a header, this is used by the TMSS inside the console. The game needs to have the string "SEGA" at offset 0x100 (256) to be a valid binary so we'll use this to tell the kernel to start an emulator when we want to execute a megadrive rom.

The syntax for binmiscctl is simple, you add a name for the activator, a path (possibly with argument) to the interpreter some magic vaue to check and voila. Additionally you can add an offset for the magic value. I'll use mess here but it will works with every emulator.

# You need to be root of course do to the following
$ binmiscctl add megadrive --interpreter '/usr/local/bin/mess64 megadriv -cart' --magic "\x53\x45\x47\x41" --size 4 --offset 256 --set-enabled

That was hard. Let's check if everything is correct :

$ binmiscctl list
name: megadrive
interpreter: /usr/local/bin/mess64 megadriv -cart
flags: ENABLED
magic size: 4
magic offset: 256
magic: 0x53 0x45 0x47 0x41

Now all I need to do to play a megadrive rom is to go to the directory where all my roms are and do ./gamename.md

And if you're asking yourself what's the point of all that, the anwser is none, just fun.

Read More

FreeBSD GPIO Benchmark

I was reading this article that I find via hackaday and decided to do the same kind of benchmark with FreeBSD GPIO on my Olimex A20-SOM-EVN board.

So yeah, it's not the same board so result cannot really be compared but still this is interesting.

On FreeBSD for GPIO you have libgpio, an easy to use C library. There is no file-system access to gpio like Linux, but if your language of choice doesn't have binding for libgpio (most of them doesn't) you can still use gpioctl. If you use Python, I've made a CFFI based modue for libgpio named fbsd_gpio_py (For which I really need to write an article on ...).

Let's look at the result. Read More

Porting FreeBSD to a new ARM Board Part 3 - Driver Update

Driver-Update

On the last part we left with our kernel panic-ing because it was unable to find a timer source.

Since then a lot have change in the FreeBSD source tree. The last big update on allwinner files (Revision 295464), introduce a lots of changes.

First, it switches most of the Allwinner boards that we support to use the GNU DTS file from Linux 4.5-rc1 (See commit 295436), previously some custom made DTS were used (and still are for the Cubieboard and BananaPi). Using the GNU DTS files have one big advantage: when a new board is out, most of the time a DTS is made along a commited to Linux, If we support the SoC on the board we don't have anything else to do to support the board (at least on a basic level).

Read More

How to contribute to FreeBSD with phabricator and git

FreeBSD uses svn as it's main SCM but also offers a git mirror at github.

FreeBSD also have two website for submitting code, bugzilla and phabricator. The first is for bugs (duh) and the second is for new code (new platform, hardware, framework etc ...).

On this post I'll present how I work with git and arcanist (the phabricator cli tool). Please note that this is my way of doing things as an external contributor to the project and it's clearly not the only way.

Read More