diff mbox

[v2] raspberrypi3: fix serial console (load pi3-miniuart-bt overlay)

Message ID 1462220744-6368-1-git-send-email-ps.report@gmx.net
State Accepted
Headers show

Commit Message

Peter Seiderer May 2, 2016, 8:25 p.m. UTC
- enable BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS in raspberrypi3_defconfig
- add copy of rpi-firmware/overlays directory to boot partition in genimage-raspberrypi3.cfg
- enhance post-image.sh script to add 'dtoverlay=pi3-miniuart-bt' on request
- add BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay" in raspberrypi3_defconfig

Signed-off-by: Peter Seiderer <ps.report@gmx.net>
---
Changes v1 --> v2:
  - use pi3-miniuart-bt instead of pi3-disable-bt
  - fix post-image.sh to add overlay lines only once
  - add overlay description (and alternative solution) to readme.txt
---
 board/raspberrypi/genimage-raspberrypi3.cfg |  1 +
 board/raspberrypi/post-image.sh             | 13 +++++++++++++
 board/raspberrypi/readme.txt                |  8 +++++++-
 configs/raspberrypi3_defconfig              |  3 ++-
 4 files changed, 23 insertions(+), 2 deletions(-)

Comments

Oscar Gomez Fuente May 3, 2016, 5:58 a.m. UTC | #1
Hi Peter Seiderer,


What's the difference between enabling pi3-miniuart-bt instead of
pi3-disable-bt?

With pi3-disable-bt enables it works fine the serial console on (14 [TxD] &
15 [RxD] pins).


Best regards.

Oscar Gomez Fuente.

On 2 May 2016 at 22:25, Peter Seiderer <ps.report@gmx.net> wrote:

> - enable BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS in
> raspberrypi3_defconfig
> - add copy of rpi-firmware/overlays directory to boot partition in
> genimage-raspberrypi3.cfg
> - enhance post-image.sh script to add 'dtoverlay=pi3-miniuart-bt' on
> request
> - add BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay" in
> raspberrypi3_defconfig
>
> Signed-off-by: Peter Seiderer <ps.report@gmx.net>
> ---
> Changes v1 --> v2:
>   - use pi3-miniuart-bt instead of pi3-disable-bt
>   - fix post-image.sh to add overlay lines only once
>   - add overlay description (and alternative solution) to readme.txt
> ---
>  board/raspberrypi/genimage-raspberrypi3.cfg |  1 +
>  board/raspberrypi/post-image.sh             | 13 +++++++++++++
>  board/raspberrypi/readme.txt                |  8 +++++++-
>  configs/raspberrypi3_defconfig              |  3 ++-
>  4 files changed, 23 insertions(+), 2 deletions(-)
>
> diff --git a/board/raspberrypi/genimage-raspberrypi3.cfg
> b/board/raspberrypi/genimage-raspberrypi3.cfg
> index 7ba89c5..baab0c4 100644
> --- a/board/raspberrypi/genimage-raspberrypi3.cfg
> +++ b/board/raspberrypi/genimage-raspberrypi3.cfg
> @@ -7,6 +7,7 @@ image boot.vfat {
>        "rpi-firmware/config.txt",
>        "rpi-firmware/fixup.dat",
>        "rpi-firmware/start.elf",
> +      "rpi-firmware/overlays",
>        "kernel-marked/zImage"
>      }
>    }
> diff --git a/board/raspberrypi/post-image.sh
> b/board/raspberrypi/post-image.sh
> index 73ffd65..c009752 100755
> --- a/board/raspberrypi/post-image.sh
> +++ b/board/raspberrypi/post-image.sh
> @@ -5,6 +5,19 @@ BOARD_NAME="$(basename ${BOARD_DIR})"
>  GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
>  GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
>
> +case "${2}" in
> +       --add-pi3-miniuart-bt-overlay)
> +       if ! grep -qE '^dtoverlay='
> "${BINARIES_DIR}/rpi-firmware/config.txt"; then
> +               echo "Adding 'dtoverlay=pi3-miniuart-bt' to config.txt
> (fixes ttyAMA0 serial console)."
> +               cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
> +
> +# fixes rpi3 ttyAMA0 serial console
> +dtoverlay=pi3-miniuart-bt
> +__EOF__
> +       fi
> +       ;;
> +esac
> +
>  # Mark the kernel as DT-enabled
>  mkdir -p "${BINARIES_DIR}/kernel-marked"
>  ${HOST_DIR}/usr/bin/mkknlimg "${BINARIES_DIR}/zImage" \
> diff --git a/board/raspberrypi/readme.txt b/board/raspberrypi/readme.txt
> index a170f8f..03178ff 100644
> --- a/board/raspberrypi/readme.txt
> +++ b/board/raspberrypi/readme.txt
> @@ -60,7 +60,8 @@ After building, you should obtain this tree:
>      |   +-- cmdline.txt
>      |   +-- config.txt
>      |   +-- fixup.dat
> -    |   `-- start.elf
> +    |   +-- start.elf
> +    |   `-- overlays/               [3]
>      +-- sdcard.img
>      `-- zImage
>
> @@ -69,6 +70,11 @@ After building, you should obtain this tree:
>
>  [2] This is the mkknlimg DT-marked kernel.
>
> +[3] Only for the Raspberry Pi 3 Model (overlay pi3-miniuart-bt is needed
> +    to enable the RPi3 serial console otherwise occupied by the bluetooth
> +    chip). Alternative would be to disable the serial console in
> cmdline.txt
> +    and /etc/inittab.
> +
>  How to write the SD card
>  ========================
>
> diff --git a/configs/raspberrypi3_defconfig
> b/configs/raspberrypi3_defconfig
> index 4eb5333..8600cd8 100644
> --- a/configs/raspberrypi3_defconfig
> +++ b/configs/raspberrypi3_defconfig
> @@ -21,7 +21,7 @@ BR2_LINUX_KERNEL_DTS_SUPPORT=y
>  BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b"
>
>  BR2_PACKAGE_RPI_FIRMWARE=y
> -# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
> +BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS=y
>
>  # Required tools to create the SD image
>  BR2_PACKAGE_HOST_DOSFSTOOLS=y
> @@ -34,3 +34,4 @@ BR2_TARGET_ROOTFS_EXT2_4=y
>  # BR2_TARGET_ROOTFS_TAR is not set
>  BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh"
>  BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3/post-image.sh"
> +BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay"
> --
> 2.8.1
>
>
Peter Korsgaard May 3, 2016, 6:18 a.m. UTC | #2
>>>>> "Oscar" == Oscar Gomez Fuente <oscargomezf@gmail.com> writes:

 > Hi Peter Seiderer,
 > What's the difference between enabling pi3-miniuart-bt instead of
 > pi3-disable-bt?

 > With pi3-disable-bt enables it works fine the serial console on (14 [TxD] &
 > 15 [RxD] pins).

From the names I would guess it is the difference between completely
disabling access to the bluetooth module and providing access to it
though the secondary (mini) uart.

The miniuart has some limitations, but I guess basic bluetooth stuff
should work with it.
Martin Bark May 3, 2016, 10:23 a.m. UTC | #3
All,

On 3 May 2016 at 07:18, Peter Korsgaard <peter@korsgaard.com> wrote:
>>>>>> "Oscar" == Oscar Gomez Fuente <oscargomezf@gmail.com> writes:
>
>  > Hi Peter Seiderer,
>  > What's the difference between enabling pi3-miniuart-bt instead of
>  > pi3-disable-bt?
>
>  > With pi3-disable-bt enables it works fine the serial console on (14 [TxD] &
>  > 15 [RxD] pins).
>
> From the names I would guess it is the difference between completely
> disabling access to the bluetooth module and providing access to it
> though the secondary (mini) uart.
>
> The miniuart has some limitations, but I guess basic bluetooth stuff
> should work with it.

I've got a bit lost in the rpi3 serial console issues but as i
understand the current situation all you need to do is set
enable_uart=1 in config.txt.  See
https://github.com/raspberrypi/firmware/issues/553#issuecomment-199486644.
I've not tested this.

I think you also need to change cmdline.txt to use console=serial0 as
the pi3-miniuart-bt will replace it with the correct serial device
(ttyAMA0 or ttyS0) depending if it's enabled or not.  See the comments
in https://github.com/raspberrypi/linux/blob/rpi-4.1.y/arch/arm/boot/dts/overlays/pi3-miniuart-bt-overlay.dts.

Thanks

Martin

>
> --
> Venlig hilsen,
> Peter Korsgaard
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Peter Seiderer May 3, 2016, 7:02 p.m. UTC | #4
Hello Martin,

On Tue, 3 May 2016 11:23:50 +0100, Martin Bark <martin@barkynet.com> wrote:

> All,
> 
> On 3 May 2016 at 07:18, Peter Korsgaard <peter@korsgaard.com> wrote:
> >>>>>> "Oscar" == Oscar Gomez Fuente <oscargomezf@gmail.com> writes:
> >
> >  > Hi Peter Seiderer,
> >  > What's the difference between enabling pi3-miniuart-bt instead of
> >  > pi3-disable-bt?
> >
> >  > With pi3-disable-bt enables it works fine the serial console on (14 [TxD] &
> >  > 15 [RxD] pins).
> >
> > From the names I would guess it is the difference between completely
> > disabling access to the bluetooth module and providing access to it
> > though the secondary (mini) uart.
> >
> > The miniuart has some limitations, but I guess basic bluetooth stuff
> > should work with it.
> 
> I've got a bit lost in the rpi3 serial console issues but as i
> understand the current situation all you need to do is set
> enable_uart=1 in config.txt.  See
> https://github.com/raspberrypi/firmware/issues/553#issuecomment-199486644.
> I've not tested this.
> 
> I think you also need to change cmdline.txt to use console=serial0 as
> the pi3-miniuart-bt will replace it with the correct serial device
> (ttyAMA0 or ttyS0) depending if it's enabled or not.  See the comments
> in https://github.com/raspberrypi/linux/blob/rpi-4.1.y/arch/arm/boot/dts/overlays/pi3-miniuart-bt-overlay.dts.
> 

This works too, not sure whats the better solution, explicit via device tree overlay
or some firmware magic....

- pi3-miniuart-bt 'dmesg | grep tty':
[    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200
[    0.001320] console [tty1] enabled
[    0.318181] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 50000000) is a 16550
[    2.008162] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
[    3.296233] console [ttyAMA0] enabled

- enable-uart=1, serial0 dmesg | grep tty':
[    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyS0,115200
[    0.001318] console [tty1] enabled
[    0.318270] console [ttyS0] disabled
[    0.318389] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 31250000) is a 16550
[    1.042714] console [ttyS0] enabled
[    3.020277] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2

Regards,
Peter


> Thanks
> 
> Martin
> 
> >
> > --
> > Venlig hilsen,
> > Peter Korsgaard
> > _______________________________________________
> > buildroot mailing list
> > buildroot@busybox.net
> > http://lists.busybox.net/mailman/listinfo/buildroot
Martin Bark May 9, 2016, 1:19 p.m. UTC | #5
Peter,

On 3 May 2016 at 20:02, Peter Seiderer <ps.report@gmx.net> wrote:
> Hello Martin,
>
> On Tue, 3 May 2016 11:23:50 +0100, Martin Bark <martin@barkynet.com> wrote:
>
>> All,
>>
>> On 3 May 2016 at 07:18, Peter Korsgaard <peter@korsgaard.com> wrote:
>> >>>>>> "Oscar" == Oscar Gomez Fuente <oscargomezf@gmail.com> writes:
>> >
>> >  > Hi Peter Seiderer,
>> >  > What's the difference between enabling pi3-miniuart-bt instead of
>> >  > pi3-disable-bt?
>> >
>> >  > With pi3-disable-bt enables it works fine the serial console on (14 [TxD] &
>> >  > 15 [RxD] pins).
>> >
>> > From the names I would guess it is the difference between completely
>> > disabling access to the bluetooth module and providing access to it
>> > though the secondary (mini) uart.
>> >
>> > The miniuart has some limitations, but I guess basic bluetooth stuff
>> > should work with it.
>>
>> I've got a bit lost in the rpi3 serial console issues but as i
>> understand the current situation all you need to do is set
>> enable_uart=1 in config.txt.  See
>> https://github.com/raspberrypi/firmware/issues/553#issuecomment-199486644.
>> I've not tested this.
>>
>> I think you also need to change cmdline.txt to use console=serial0 as
>> the pi3-miniuart-bt will replace it with the correct serial device
>> (ttyAMA0 or ttyS0) depending if it's enabled or not.  See the comments
>> in https://github.com/raspberrypi/linux/blob/rpi-4.1.y/arch/arm/boot/dts/overlays/pi3-miniuart-bt-overlay.dts.
>>
>
> This works too, not sure whats the better solution, explicit via device tree overlay
> or some firmware magic....
>
> - pi3-miniuart-bt 'dmesg | grep tty':
> [    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200
> [    0.001320] console [tty1] enabled
> [    0.318181] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 50000000) is a 16550
> [    2.008162] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
> [    3.296233] console [ttyAMA0] enabled
>
> - enable-uart=1, serial0 dmesg | grep tty':
> [    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyS0,115200
> [    0.001318] console [tty1] enabled
> [    0.318270] console [ttyS0] disabled
> [    0.318389] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 31250000) is a 16550
> [    1.042714] console [ttyS0] enabled
> [    3.020277] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
>

I wonder if the solution is to just document the situation in
board/raspberrypi/readme.txt.  The documentation could just detail the
available choices for Bluetooth and serial console on the rpi3 and how
to configure each manually.  A summary of the available choices is:

1) Default setup - Serial console does not work, Bluetooth works
2) Add enable-uart=1 - Serial console works but the core frequency is
fixed.  Serial console max baud rate is less than the rpi2. Bluetooth
works.
3) Use pi3-miniuart-bt - Serial console works the same as the rpi2 but
Bluetooth runs slow.
4) Use pi3-disable-bt - Serial console works the same as the rpi2 but
Bluetooth is disabled.

What do you think?

Thanks

Martin

> Regards,
> Peter
>
>
>> Thanks
>>
>> Martin
>>
>> >
>> > --
>> > Venlig hilsen,
>> > Peter Korsgaard
>> > _______________________________________________
>> > buildroot mailing list
>> > buildroot@busybox.net
>> > http://lists.busybox.net/mailman/listinfo/buildroot
>
Peter Seiderer May 9, 2016, 8:51 p.m. UTC | #6
Hello Martin,

On Mon, 9 May 2016 14:19:48 +0100, Martin Bark <martin@barkynet.com> wrote:

> Peter,
> 
> On 3 May 2016 at 20:02, Peter Seiderer <ps.report@gmx.net> wrote:
> > Hello Martin,
> >
> > On Tue, 3 May 2016 11:23:50 +0100, Martin Bark <martin@barkynet.com> wrote:
> >
> >> All,
> >>
> >> On 3 May 2016 at 07:18, Peter Korsgaard <peter@korsgaard.com> wrote:
> >> >>>>>> "Oscar" == Oscar Gomez Fuente <oscargomezf@gmail.com> writes:
> >> >
> >> >  > Hi Peter Seiderer,
> >> >  > What's the difference between enabling pi3-miniuart-bt instead of
> >> >  > pi3-disable-bt?
> >> >
> >> >  > With pi3-disable-bt enables it works fine the serial console on (14 [TxD] &
> >> >  > 15 [RxD] pins).
> >> >
> >> > From the names I would guess it is the difference between completely
> >> > disabling access to the bluetooth module and providing access to it
> >> > though the secondary (mini) uart.
> >> >
> >> > The miniuart has some limitations, but I guess basic bluetooth stuff
> >> > should work with it.
> >>
> >> I've got a bit lost in the rpi3 serial console issues but as i
> >> understand the current situation all you need to do is set
> >> enable_uart=1 in config.txt.  See
> >> https://github.com/raspberrypi/firmware/issues/553#issuecomment-199486644.
> >> I've not tested this.
> >>
> >> I think you also need to change cmdline.txt to use console=serial0 as
> >> the pi3-miniuart-bt will replace it with the correct serial device
> >> (ttyAMA0 or ttyS0) depending if it's enabled or not.  See the comments
> >> in https://github.com/raspberrypi/linux/blob/rpi-4.1.y/arch/arm/boot/dts/overlays/pi3-miniuart-bt-overlay.dts.
> >>
> >
> > This works too, not sure whats the better solution, explicit via device tree overlay
> > or some firmware magic....
> >
> > - pi3-miniuart-bt 'dmesg | grep tty':
> > [    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200
> > [    0.001320] console [tty1] enabled
> > [    0.318181] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 50000000) is a 16550
> > [    2.008162] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
> > [    3.296233] console [ttyAMA0] enabled
> >
> > - enable-uart=1, serial0 dmesg | grep tty':
> > [    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyS0,115200
> > [    0.001318] console [tty1] enabled
> > [    0.318270] console [ttyS0] disabled
> > [    0.318389] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 31250000) is a 16550
> > [    1.042714] console [ttyS0] enabled
> > [    3.020277] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
> >
> 
> I wonder if the solution is to just document the situation in
> board/raspberrypi/readme.txt.  The documentation could just detail the
> available choices for Bluetooth and serial console on the rpi3 and how
> to configure each manually.  A summary of the available choices is:
> 
> 1) Default setup - Serial console does not work, Bluetooth works
> 2) Add enable-uart=1 - Serial console works but the core frequency is
> fixed.  Serial console max baud rate is less than the rpi2. Bluetooth
> works.
> 3) Use pi3-miniuart-bt - Serial console works the same as the rpi2 but
> Bluetooth runs slow.
> 4) Use pi3-disable-bt - Serial console works the same as the rpi2 but
> Bluetooth is disabled.
> 
> What do you think?

Agreed, with bias to 3) as the default (or one of the other solutions with
serial console enabled)...

Regards,
Peter

> 
> Thanks
> 
> Martin
> 
> > Regards,
> > Peter
> >
> >
> >> Thanks
> >>
> >> Martin
> >>
> >> >
> >> > --
> >> > Venlig hilsen,
> >> > Peter Korsgaard
> >> > _______________________________________________
> >> > buildroot mailing list
> >> > buildroot@busybox.net
> >> > http://lists.busybox.net/mailman/listinfo/buildroot
> >
Thomas Petazzoni May 9, 2016, 8:53 p.m. UTC | #7
Hello,

On Mon, 9 May 2016 22:51:50 +0200, Peter Seiderer wrote:

> > I wonder if the solution is to just document the situation in
> > board/raspberrypi/readme.txt.  The documentation could just detail the
> > available choices for Bluetooth and serial console on the rpi3 and how
> > to configure each manually.  A summary of the available choices is:
> > 
> > 1) Default setup - Serial console does not work, Bluetooth works
> > 2) Add enable-uart=1 - Serial console works but the core frequency is
> > fixed.  Serial console max baud rate is less than the rpi2. Bluetooth
> > works.
> > 3) Use pi3-miniuart-bt - Serial console works the same as the rpi2 but
> > Bluetooth runs slow.
> > 4) Use pi3-disable-bt - Serial console works the same as the rpi2 but
> > Bluetooth is disabled.
> > 
> > What do you think?  
> 
> Agreed, with bias to 3) as the default (or one of the other solutions with
> serial console enabled)...

Yes, sounds like a good idea.

Thomas
Thomas Petazzoni June 9, 2016, 8:46 p.m. UTC | #8
Hello,

On Tue, 3 May 2016 21:02:00 +0200, Peter Seiderer wrote:

> This works too, not sure whats the better solution, explicit via device tree overlay
> or some firmware magic....
> 
> - pi3-miniuart-bt 'dmesg | grep tty':
> [    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200
> [    0.001320] console [tty1] enabled
> [    0.318181] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 50000000) is a 16550
> [    2.008162] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
> [    3.296233] console [ttyAMA0] enabled
> 
> - enable-uart=1, serial0 dmesg | grep tty':
> [    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyS0,115200
> [    0.001318] console [tty1] enabled
> [    0.318270] console [ttyS0] disabled
> [    0.318389] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 31250000) is a 16550
> [    1.042714] console [ttyS0] enabled
> [    3.020277] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2

For the Buildroot defconfig, I believe passing enable-uart=1 in
config.txt would be the easiest solution. Could you send a patch that
does this instead of messing with the overlays ?

Thanks!

Thomas
Peter Seiderer Aug. 11, 2016, 10:02 p.m. UTC | #9
Hello Thomas,

On Thu, 9 Jun 2016 22:46:13 +0200, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:

> Hello,
> 
> On Tue, 3 May 2016 21:02:00 +0200, Peter Seiderer wrote:
> 
> > This works too, not sure whats the better solution, explicit via device tree overlay
> > or some firmware magic....
> > 
> > - pi3-miniuart-bt 'dmesg | grep tty':
> > [    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyAMA0,115200
> > [    0.001320] console [tty1] enabled
> > [    0.318181] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 50000000) is a 16550
> > [    2.008162] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
> > [    3.296233] console [ttyAMA0] enabled
> > 
> > - enable-uart=1, serial0 dmesg | grep tty':
> > [    0.000000] Kernel command line: 8250.nr_uarts=1 dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1920 bcm2708_fb.fbheight=1200 bcm2709.boardrev=0xa02082 bcm2709.serial=0xa60340 smsc95xx.macaddr=B8:27:EB:A6:03:40 bcm2708_fb.fbswap=1 bcm2709.uart_clock=48000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000  root=/dev/mmcblk0p2 rootwait console=tty1 console=ttyS0,115200
> > [    0.001318] console [tty1] enabled
> > [    0.318270] console [ttyS0] disabled
> > [    0.318389] 3f215040.uart: ttyS0 at MMIO 0x3f215040 (irq = 59, base_baud = 31250000) is a 16550
> > [    1.042714] console [ttyS0] enabled
> > [    3.020277] 3f201000.uart: ttyAMA0 at MMIO 0x3f201000 (irq = 87, base_baud = 0) is a PL011 rev2
> 
> For the Buildroot defconfig, I believe passing enable-uart=1 in
> config.txt would be the easiest solution. Could you send a patch that
> does this instead of messing with the overlays ?

Sorry for the delay, I tried the 'enable-uart=1' solution some time ago and it did not work (I think
I messed something up), retried today and it worked, patch will follow...

Regards,
Peter

> 
> Thanks!
> 
> Thomas
Thomas Petazzoni Sept. 18, 2016, 5:23 p.m. UTC | #10
Hello,

On Mon,  2 May 2016 22:25:44 +0200, Peter Seiderer wrote:
> - enable BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS in raspberrypi3_defconfig
> - add copy of rpi-firmware/overlays directory to boot partition in genimage-raspberrypi3.cfg
> - enhance post-image.sh script to add 'dtoverlay=pi3-miniuart-bt' on request
> - add BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay" in raspberrypi3_defconfig
> 
> Signed-off-by: Peter Seiderer <ps.report@gmx.net>
> ---
> Changes v1 --> v2:
>   - use pi3-miniuart-bt instead of pi3-disable-bt
>   - fix post-image.sh to add overlay lines only once
>   - add overlay description (and alternative solution) to readme.txt
> ---
>  board/raspberrypi/genimage-raspberrypi3.cfg |  1 +
>  board/raspberrypi/post-image.sh             | 13 +++++++++++++
>  board/raspberrypi/readme.txt                |  8 +++++++-
>  configs/raspberrypi3_defconfig              |  3 ++-
>  4 files changed, 23 insertions(+), 2 deletions(-)

What I understood from the discussions on your new patch "raspberrypi3:
fix serial console (add enable_uart=1", this older proposal is actually
what is preferred. It is a bit more complicated than just passing
enable_uart=1, but it allows to have the UART *and* run the CPU as its
normal frequency.

So, I've applied this patch, and marked the newer one (enable_uart=1)
as rejected.

It would be good if you could rebuild the raspberrypi3_defconfig, and
check that it works for you. While you're at it, it would be useful if
you could look at the bug report
https://bugs.busybox.net/show_bug.cgi?id=9196 and see if you can
reproduce the issue and/or help solve the problem.

Thanks a lot for your contribution!

Thomas
Peter Seiderer Sept. 19, 2016, 9:57 p.m. UTC | #11
Hello Thomas,

On Sun, 18 Sep 2016 19:23:43 +0200, Thomas Petazzoni <thomas.petazzoni@free-electrons.com> wrote:

> Hello,
> 
> On Mon,  2 May 2016 22:25:44 +0200, Peter Seiderer wrote:
> > - enable BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS in raspberrypi3_defconfig
> > - add copy of rpi-firmware/overlays directory to boot partition in genimage-raspberrypi3.cfg
> > - enhance post-image.sh script to add 'dtoverlay=pi3-miniuart-bt' on request
> > - add BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay" in raspberrypi3_defconfig
> > 
> > Signed-off-by: Peter Seiderer <ps.report@gmx.net>
> > ---
> > Changes v1 --> v2:
> >   - use pi3-miniuart-bt instead of pi3-disable-bt
> >   - fix post-image.sh to add overlay lines only once
> >   - add overlay description (and alternative solution) to readme.txt
> > ---
> >  board/raspberrypi/genimage-raspberrypi3.cfg |  1 +
> >  board/raspberrypi/post-image.sh             | 13 +++++++++++++
> >  board/raspberrypi/readme.txt                |  8 +++++++-
> >  configs/raspberrypi3_defconfig              |  3 ++-
> >  4 files changed, 23 insertions(+), 2 deletions(-)
> 
> What I understood from the discussions on your new patch "raspberrypi3:
> fix serial console (add enable_uart=1", this older proposal is actually
> what is preferred. It is a bit more complicated than just passing
> enable_uart=1, but it allows to have the UART *and* run the CPU as its
> normal frequency.
> 
> So, I've applied this patch, and marked the newer one (enable_uart=1)
> as rejected.
> 
> It would be good if you could rebuild the raspberrypi3_defconfig, and
> check that it works for you. While you're at it, it would be useful if

Still works as expected for me, tested with buildroot git d4db4277ffbd1fae478ba748c626eddc7c220e67,
login via serial and login via hdmi/usb-keyboard possible...

> you could look at the bug report
> https://bugs.busybox.net/show_bug.cgi?id=9196 and see if you can
> reproduce the issue and/or help solve the problem.

Will check the systemd case tomorrow...

Regards,
Peter

> 
> Thanks a lot for your contribution!
> 
> Thomas
diff mbox

Patch

diff --git a/board/raspberrypi/genimage-raspberrypi3.cfg b/board/raspberrypi/genimage-raspberrypi3.cfg
index 7ba89c5..baab0c4 100644
--- a/board/raspberrypi/genimage-raspberrypi3.cfg
+++ b/board/raspberrypi/genimage-raspberrypi3.cfg
@@ -7,6 +7,7 @@  image boot.vfat {
       "rpi-firmware/config.txt",
       "rpi-firmware/fixup.dat",
       "rpi-firmware/start.elf",
+      "rpi-firmware/overlays",
       "kernel-marked/zImage"
     }
   }
diff --git a/board/raspberrypi/post-image.sh b/board/raspberrypi/post-image.sh
index 73ffd65..c009752 100755
--- a/board/raspberrypi/post-image.sh
+++ b/board/raspberrypi/post-image.sh
@@ -5,6 +5,19 @@  BOARD_NAME="$(basename ${BOARD_DIR})"
 GENIMAGE_CFG="${BOARD_DIR}/genimage-${BOARD_NAME}.cfg"
 GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp"
 
+case "${2}" in
+	--add-pi3-miniuart-bt-overlay)
+	if ! grep -qE '^dtoverlay=' "${BINARIES_DIR}/rpi-firmware/config.txt"; then
+		echo "Adding 'dtoverlay=pi3-miniuart-bt' to config.txt (fixes ttyAMA0 serial console)."
+		cat << __EOF__ >> "${BINARIES_DIR}/rpi-firmware/config.txt"
+
+# fixes rpi3 ttyAMA0 serial console
+dtoverlay=pi3-miniuart-bt
+__EOF__
+	fi
+	;;
+esac
+
 # Mark the kernel as DT-enabled
 mkdir -p "${BINARIES_DIR}/kernel-marked"
 ${HOST_DIR}/usr/bin/mkknlimg "${BINARIES_DIR}/zImage" \
diff --git a/board/raspberrypi/readme.txt b/board/raspberrypi/readme.txt
index a170f8f..03178ff 100644
--- a/board/raspberrypi/readme.txt
+++ b/board/raspberrypi/readme.txt
@@ -60,7 +60,8 @@  After building, you should obtain this tree:
     |   +-- cmdline.txt
     |   +-- config.txt
     |   +-- fixup.dat
-    |   `-- start.elf
+    |   +-- start.elf
+    |   `-- overlays/               [3]
     +-- sdcard.img
     `-- zImage
 
@@ -69,6 +70,11 @@  After building, you should obtain this tree:
 
 [2] This is the mkknlimg DT-marked kernel.
 
+[3] Only for the Raspberry Pi 3 Model (overlay pi3-miniuart-bt is needed
+    to enable the RPi3 serial console otherwise occupied by the bluetooth
+    chip). Alternative would be to disable the serial console in cmdline.txt
+    and /etc/inittab.
+
 How to write the SD card
 ========================
 
diff --git a/configs/raspberrypi3_defconfig b/configs/raspberrypi3_defconfig
index 4eb5333..8600cd8 100644
--- a/configs/raspberrypi3_defconfig
+++ b/configs/raspberrypi3_defconfig
@@ -21,7 +21,7 @@  BR2_LINUX_KERNEL_DTS_SUPPORT=y
 BR2_LINUX_KERNEL_INTREE_DTS_NAME="bcm2710-rpi-3-b"
 
 BR2_PACKAGE_RPI_FIRMWARE=y
-# BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS is not set
+BR2_PACKAGE_RPI_FIRMWARE_INSTALL_DTB_OVERLAYS=y
 
 # Required tools to create the SD image
 BR2_PACKAGE_HOST_DOSFSTOOLS=y
@@ -34,3 +34,4 @@  BR2_TARGET_ROOTFS_EXT2_4=y
 # BR2_TARGET_ROOTFS_TAR is not set
 BR2_ROOTFS_POST_BUILD_SCRIPT="board/raspberrypi3/post-build.sh"
 BR2_ROOTFS_POST_IMAGE_SCRIPT="board/raspberrypi3/post-image.sh"
+BR2_ROOTFS_POST_SCRIPT_ARGS="--add-pi3-miniuart-bt-overlay"