Adding a GPS Module (hat/shield) on a Raspberry Pi

Shamim Shahriar shamim.shahriar at gmail.com
Sun Feb 4 01:01:20 UTC 2018


On Sat, 3 Feb 2018, 22:23 Ralph Smith, <ralph at ralphsmith.org> wrote:

> I’ve gotten this working on various flavors of the Raspberry Pi, just now
> verified this on the Pi Zero and on the Model B. Comments below
>
> On Feb 3, 2018, at 6:15 AM, Shamim Shahriar <shamim.shahriar at gmail.com>
> wrote:
>
> Good morning all
>
> I had been searching for a solution for the last 3 days, and tried various
> different things based on the google results, but so far no luck. Hope
> someone from the list can shed some light and maybe point me to the correct
> direction.
>
> Here is the scenario:
>
> Device: Raspberry Pi B (pi 1 model b, the 512M RAM version, or more
> precisely v1.2)
> GPS Module : Ublox hat that sits perfectly on the Pi, with PPS on GPIO-18
> FreeBSD version: 11.1 RELEASE for RPI-B
>
>
> Just built and verified on the following:
> Device: Raspberry Pi B (pi 1 model b, the 512M RAM version, or more
> precisely v1.2) — same board
> GPS Module: Adafruit Ultimate GPS HAT - connected to UART, PPS is on GPIO 4
> FreeBSD Version: FreeBSD 11.1-STABLE #0 r328620 — downloaded from
> ftp.freebsd.org
>
> This also works with custom builds built using crochet.
>
> As I understand, the serial ports on the GPIO is activated by default, and
> if I attach "ONLY" a serial console (USB to serial), I can interact with
> the Pi through the console. Remove serial console cable, attach the Pi to a
> display (via HDMI), boot it up -- it works just fine.
>
> If now I add the GPS module/hat/shield, all I get is series of dots
> (depending on how soon the GPS finds the satellites and starts sending the
> data) and the Pi does not boot at all.
>
> Based on
> https://forums.freebsd.org/threads/59485/
> https://lists.freebsd.org/pipermail/freebsd-arm/2017-March/015845.html
>
> https://vzaigrin.wordpress.com/2014/12/13/liberation-of-the-serial-console-in-the-freebsd-on-the-raspberry-pi/
>
> I have managed to get to the point where I can see that if I have only the
> serial console cable attached, it stops interacting with the boot process
> after a while (the boot continues, and I can see that on the HDMI output).
> But that also stops interacting with whatever signal is being sent via that
> console).
>
> And if I attach the GPS module now, it refuses to boot and drops me to a
> loader> prompt
>
> My understanding (and I might be very very wrong) is, the u-Boot system is
> now being affected and hence cannot boot.
>
>
> You are precisely correct, u-Boot is starting and seeing traffic on the
> serial port and happily thinks you are trying to tell it something.
>
> I am not new to FreeBSD, had been using it since the 4.4BSD Lite days, but
> I am seriously baffled by how difficult (nearly impossible) it had been to
> get rid of the serial console (something so easy and taken for granted on
> the i386 or other similar architecture). One of the links I found (
> https://www.cryptomonkeys.com/2014/01/freebsd-raspberry-pi-gps-ntp/) even
> suggested that I need to create custom image to get PPS working. Well,
> working PPS comes *after* being able to boot the device with the GPS
> hat/module/shield on -- and I am still stuck at that level.
>
>
> I derived the following based on hints from:
>
> https://vzaigrin.wordpress.com/2014/12/13/liberation-of-the-serial-console-in-the-freebsd-on-the-raspberry-pi/
>
> https://github.com/BobBallance/freebsd-gpio-pps/wiki/Regaining-Control-of-the-UART
>
> First, you will need to build a version of u-Boot that leaves the serial
> port alone. From a current ports tree you will
> build sysutils/u-boot-rpi, but with a few changes enabled.
> The sysutils/u-boot-rpi port is based on sysutils/u-boot-master. I have
> created the following patch files for the sysutils/u-boot-rpi port.
> First files/patch-configs_rpi__defconfig:
> --- configs/rpi_defconfig.orig 2018-02-03 16:08:52 UTC
> +++ configs/rpi_defconfig
> @@ -34,3 +34,4 @@ CONFIG_SYS_WHITE_ON_BLACK=y
>  CONFIG_CONSOLE_SCROLL_LINES=10
>  CONFIG_PHYS_TO_BUS=y
>  CONFIG_OF_LIBFDT_OVERLAY=y
> +CONFIG_SILENT_CONSOLE=y
>
> and also patch-include_configs_rpi.h
> --- include/configs/rpi.h.orig 2017-10-16 17:46:46 UTC
> +++ include/configs/rpi.h
> @@ -103,10 +103,21 @@
>
>  /* Environment */
>  #define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
> +#ifdef CONFIG_SILENT_CONSOLE
> +#define CONFIG_SYS_DEVICE_NULLDEV
> +#define CONFIG_SILENT_CONSOLE_UPDATE_ON_RELOC
> +#define CONFIG_SILENT_CONSOLE_UPDATE_ON_SET
> +#define ENV_DEVICE_SETTINGS \
> + "stdin=nulldev\0" \
> + "stdout=nulldev\0" \
> + "stderr=nulldev\0"\
> + "silent=1\0"
> +#else
>  #define ENV_DEVICE_SETTINGS \
>   "stdin=serial,usbkbd\0" \
>   "stdout=serial,vidconsole\0" \
>   "stderr=serial,vidconsole\0"
> +#endif
>
>  /*
>   * Memory layout for where various images get loaded by boot scripts:
>
> Build u-boot using this configuration and place it on the SD card in the
> MSDOS partition (/boot/msdos). This will keep u-Boot away from the serial
> port.
>
> Now we need to convince the kernel to do two things: 1 - don’t use the
> serial port as the console, and 2 - recognize the PPS attached to the GPIO
> pin. This is done by modifying the FDT. From a machine with source loaded,
> edit /usr/src/sys/boot/fdt/dts/arm/rpi.dts. My changes are:
>
> --- rpi.dts (revision 328830)
> +++ rpi.dts (working copy)
> @@ -345,6 +345,12 @@
>   };
>   };
>
> + pps {
> + compatible = "pps-gpio";
> + label = "pps";
> + gpios = <&gpio 4 0>;
> + };
> +
>   power: regulator {
>   compatible = "broadcom,bcm2835-power-mgr",
>       "broadcom,bcm2708-power-mgr",
> @@ -391,8 +397,10 @@
>
>   chosen {
>   bootargs = ""; /* Set by VideoCore */
> +/*
>   stdin = "uart0";
>   stdout = "uart0";
> +*/
>   };
>
>   __overrides__ {
>
> You would want to change the 4 to 18 above to reflect the connection of
> your PPS. Then build the DTB on your build machine by
> # cd /usr/src/sys/tools/fdt/
> # setenv MACHINE arm
> # ./make_dtb.sh /usr/src/sys /usr/src/sys/boot/fdt/dts/arm/rpi.dts .
>
> Copy the resulting rpi.dtb to two locations: The MSDOS partition
> (/boot/msdos) and to /boot/dtb/
>
> Finally to get the PPS loaded and recognized at boot time add
> 'gpiopps_load=“YES”’ to /boot/loader.conf
> . The PPS will then be available at /dev/gpiopps0
>
> Hope this helps.
>
> Ralph
>

Thanks Ralph for the extended instructions -- very much appreciated. I'll
try to arrange a system with both crochet and poudriere next week and see
how far I can get. But very details instruction, and I'm sure it will take
me to the objective.

Just one question, will I be correct in assuming that the instructions are
same/similar for rpi-3 but instead of rpi.dts I need to work on rpi2.dts?
Currently I have a rpi-3 which too is intended for similar task (trying to
have a fallback in case the pi-1b decides to push the daisies 😋), and if
you could please confirm, I'll start working on both at the same time.

Thanks again for your excellent instructions.

Best regards
--

>
>


More information about the freebsd-arm mailing list