Date: Sun, 04 Feb 2018 01:01:07 +0000 From: Shamim Shahriar <shamim.shahriar@gmail.com> To: Ralph Smith <ralph@ralphsmith.org> Cc: freebsd-arm@freebsd.org Subject: Re: Adding a GPS Module (hat/shield) on a Raspberry Pi Message-ID: <CAOyJeZRSAyqVCzUwT8rqPSNfrHU1BEsjTmCSfc%2BXTr=Sr4Ca1w@mail.gmail.com> In-Reply-To: <38EBA4C3-C5C2-4816-BA2A-7607C271D0DD@ralphsmith.org> References: <fb0e6260-a526-fd29-2a36-d474b8022eac@gmail.com> <38EBA4C3-C5C2-4816-BA2A-7607C271D0DD@ralphsmith.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 3 Feb 2018, 22:23 Ralph Smith, <ralph@ralphsmith.org> wrote: > I=E2=80=99ve 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@gmail.com> > wrote: > > Good morning all > > I had been searching for a solution for the last 3 days, and tried variou= s > 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 corre= ct > 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) =E2=80=94 same board > GPS Module: Adafruit Ultimate GPS HAT - connected to UART, PPS is on GPIO= 4 > FreeBSD Version: FreeBSD 11.1-STABLE #0 r328620 =E2=80=94 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, an= d > 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 th= e > 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-consol= e-in-the-freebsd-on-the-raspberry-pi/ > > I have managed to get to the point where I can see that if I have only th= e > 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 th= at > 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 i= s > 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, bu= t > I am seriously baffled by how difficult (nearly impossible) it had been t= o > 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-consol= e-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=3Dy > CONFIG_CONSOLE_SCROLL_LINES=3D10 > CONFIG_PHYS_TO_BUS=3Dy > CONFIG_OF_LIBFDT_OVERLAY=3Dy > +CONFIG_SILENT_CONSOLE=3Dy > > 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=3Dnulldev\0" \ > + "stdout=3Dnulldev\0" \ > + "stderr=3Dnulldev\0"\ > + "silent=3D1\0" > +#else > #define ENV_DEVICE_SETTINGS \ > "stdin=3Dserial,usbkbd\0" \ > "stdout=3Dserial,vidconsole\0" \ > "stderr=3Dserial,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=E2=80=99t us= e the > serial port as the console, and 2 - recognize the PPS attached to the GPI= O > 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 =3D "pps-gpio"; > + label =3D "pps"; > + gpios =3D <&gpio 4 0>; > + }; > + > power: regulator { > compatible =3D "broadcom,bcm2835-power-mgr", > "broadcom,bcm2708-power-mgr", > @@ -391,8 +397,10 @@ > > chosen { > bootargs =3D ""; /* Set by VideoCore */ > +/* > stdin =3D "uart0"; > stdout =3D "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=3D=E2=80=9CYES=E2=80=9D=E2=80=99 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 =F0=9F=98=8B)= , and if you could please confirm, I'll start working on both at the same time. Thanks again for your excellent instructions. Best regards -- > >
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOyJeZRSAyqVCzUwT8rqPSNfrHU1BEsjTmCSfc%2BXTr=Sr4Ca1w>