Saturday, July 4, 2015

First Haskell Program

For a while I've wanted to start writing in a functional language. However, I never really knew how to start or what to do. I read most of the way through Learn You A Haskell. Then I read about a functional language called Erlang which looked really cool. I read a bit of Learn You Some Erlang. Things made a bit more sense, but I still didn't know what to do.

Yesterday, I finally wrote my first program in Haskell. It's called Python Class Creator. Python Class Creator is a pretty simple program. It takes in two strings and then dumps out a basic python class implementation. Check it out on my Github page.

Saturday, April 25, 2015

Autobooted to FreeBSD's loader

The GPS addon I use with for my RaspberryPi starts sending information to the RPi through the GPIO the second it tuns on. The RPi reads this as input to the serial console and this interrupts UBoot's autoboot process.

In order to fix this you had to use set autoboot to only stop when a certain string is typed in during the autoboot countdown. The following changes are made to UBoot/include/configs/rpi.h.

First we enable autoboot by adding #define CONFIG_BOOT_DELAY N, where N is a number of seconds. Then we enable the advanced autoboot controls by adding #define CONFIG_AUTOBOOT_KEYED.

Next we need to print out a prompt to the user to let them know that we are waiting for autoboot. To do this we define "#define CONFIG_AUTOBOOT_PROMPT str,bootdelay, where "str" is a string that takes the format of a call to printf() and allows variable input. I set my str to "autoboot in %d seconds\ntype 'stop' to get to UBoot\n",bootdelay.

Finally we define the string that must be typed in after the prompt appears in order to get into UBoot. This is achieved by adding #define CONFIG_AUTOBOOT_STOP_STR str, where str is the string that needs to be typed in.

Now when I turn on my RaspberryPi I still have serial access if I need it. Now I have to configure loader.conf to not listen to the serial port.

Thursday, April 16, 2015

Build Process Automated

I finished automating the build process for Crochet Using the newest U-Boot.

Clone my Crochet Fork and then inside that clone my UBoot Fork. Set up your Crochet config file and run sh crochet.sh -c <config_file> and enjoy a bootable FreeBSD image for your RaspberryPi.

Please read <u-boot-top>/doc/README.clang since is a little bit of set up to do. Don't worry about the gmake stuff that's already taken care of =)

Friday, March 27, 2015

Finally Booted!

I finally got Crochet-FreeBSD to build an image that can boot the Raspberry Pi using the newest version of UBoot. Specifically U-Boot-2015.01.tar.gz

There are three define statements that need to get added to the configuration file. There are also three files that need patches.

The define statements get added to u-boot/include/configs/rpi.h. They are "#define CONFIG_API", "#define CONFIG_CMD_ELF", and "#define CONFIG_SYS_MMC_MAX_DEVICE 1".

The first patch includes libc in the make process. To do this change line 668 in u-boot/Makefile from "PLATFORM_LIBS += $(PLATFORM_LIBGCC)" to "PLATFORM_LIBS += $(PLATFORM_LIBGCC) -lc".

The second patch is to change line 40 in u-boot/examples/api/Makefile from "cmd_link_demo = $(LD) --gc-sections -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)" to "cmd_link_demo = $(LD) --gc-sections -static -Ttext $(LOAD_ADDR) -o $@ $(filter-out $(PHONY), $^) $(PLATFORM_LIBS)".

These two patches and the define statements are described in Crochet's NewBoardExample's README.

The last patch is to disable high speed sdhci support. To do this change line 494 in u-boot/drivers/mmc/sdhci.c from "host->cfg.host_caps = MMC_MODE_HS | MMC_MODE_HS_52MHz | MMC_MODE_4BIT;" to "host->cfg.host_caps = MMC_MODE_4BIT;".

This last patch is bundled with Crochet, but is Raspberry Pi specific.

In addition to these changes, there are changes to Crochet itself.

Line 144 in crochet-freebsd/lib/uboot.sh needs to change from "if gmake SED=gsed HOSTCC=cc CROSS_COMPILE=${FREEBSD_XDEV_PREFIX} $2 > $1/_.uboot.configure.log 2>&1; then" to "if gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/armv6-freebsd -no-integrated-as -mllvm -arm-use-movt=0" $2 > $1/_.uboot.configure.log 2>&1; then".

In that same file line 168 changes from "if gmake SED=gsed HOSTCC=cc CROSS_COMPILE=${FREEBSD_XDEV_PREFIX} > $1/_.uboot.build.log 2>&1; then" to "if gmake CC="clang -target arm-freebsd-eabi --sysroot /usr/armv6-freebsd -no-integrated-as -mllvm -arm-use-movt=0" -j8 > $1/_.uboot.build.log 2>&1; then"

These changes are required by UBoot when building with clang. There is a bit of configuring to be done described in u-boot/docs/README.clang.

Friday, March 6, 2015

Crochet Builds U-Boot!

Part of this process has involved me getting Crochet to build the newest release version (U-Boot-2015.01.tar.gz) of U-Boot for the Raspberry Pi.

I got it working today. Now crochet will build the image with the latest U-Boot!

Thursday, February 26, 2015

U-Boot Update

I've set up a way to build the project without having Crochet involved in building U-Boot. Unfortunately, I'm running into an issue. U-Boot drops me directly into the U-Boot shell but I'm unable to use my USB keyboard.

First things first, I disabled net booting. Removing func(PXE, pxe, na) \ and func(DHCP, dhcp, na) from uboot/include/configs/rpi.h disables net booting. I removed this since I'm only booting from the SD card in the RPI.

The README in uboot/ shows that USB Keyboards can be used inside the U-Boot environment. However, there's not a list of devices supporting USB Keyboards so I assumed that they worked on all devices. That was not the case.

U-Boot USB Keyboard support for the Raspberry Pi is currently under development by Stephen Warren. According to a recent commit he is having trouble getting U-Boot's drivers to work with USB Keyboards.

Since the GPS device uses the Raspberry Pi's GPIO slot, I'm going to disable serial input and output in uboot/include/configs/rpi.h by removing "serial," from "stdin=serial,lcd\0" \ "stdout=serial,lcd\0" \ "stderr=serial,lcd\0". The GPS's communication will not get interpreted as commands for the U-Boot prompt.

Since I'm removing the ability to interact with the U-Boot prompt, I'm going to use Oleksandr Tymoshenko's approach. This involves setting up environment variables and using CONFIG_BOOTCOMMAND. Since the memory layout is the same as Oleksadr Tymosheko's, I'm going to see if his boot commands will work.

Friday, February 6, 2015

Stratum-1 Pi

This winter I asked one of my professors for a project to work on. We pitched a couple of ideas back and forth before settling on a Stratum-1 time server.

I decided to use a Raspberry PI and FreeBSD 10.1. Since this will be a Stratum-1 time server a GPS device was required. I chose the Raspberry PI GPS Add-on by iteadstudio.

I chose Crochet-FreeBSD as my build tool. Crochet uses an older version of Das U-Boot. I forked Crochet and am working on making it compatible with the newest version of U-Boot.