User avatar
monarco
Posts: 4
Joined: Sun Sep 17, 2017 3:25 pm
Location: Plzeň, Czech Republic
Contact: Website Facebook Twitter

Problem with DT overlay for UART remapping in Monarco HAT's EEPROM

Sun Sep 17, 2017 4:10 pm

Hi,
we have identified a problem with the recent Raspbian version when using the Monarco HAT on a Raspberry Pi.

On the Monarco HAT, the ID EEPROM contains the following device-tree overlay:
https://gist.github.com/vstk/e0f44d4763 ... b3457c19d6

The overlay in EEPROM is intended to do the same as pi3-miniuart-bt-overlay.dbo overlay distributed with Raspbian (can be enabled by setting dtoverlay=pi3-miniuart-bt in config.txt) = to remap ttyAMA0 back to GPIO header pins, and use ttyS0 for Bluetooth.
We only made a slight modification to make the same EEPROM working on both RPi2 and RPi3. Our solution worked well until (and including) Raspbian from 2017-04 with kernel 4.4.50-v7+

Unfortunatelly, since Raspbian 2017-06 with kernel 4.9.28-v7+, the ttyAMA0 remapping by overlay in Monarco HAT's EEPROM is broken!

The reason is the device-tree nodes for UARTs were renamed from "/soc/uart@7e201000" to "serial@7e201000", and we reference this name in the EEPROM:
https://gist.github.com/vstk/e0f44d4763 ... om-dts-L77
That's exactly the same approach which was used here:
https://github.com/raspberrypi/linux/bl ... ay.dts#L60

See v4.4: https://github.com/raspberrypi/linux/bl ... .dtsi#L139
See v4.9: https://github.com/raspberrypi/linux/bl ... .dtsi#L142

It is not possible to update EEPROMs in the field, because the i2c used for ID EEPROM is a bit "broken" on RPi3 after Linux boots (in the bootloader, which loads the overlay, it is OK).

Why the renaming from "/soc/uart@7e201000" to "serial@7e201000" in device tree? Any chance to get this back in some future release? Any advice how to make the overlay in EEPROM more future-proof? We shipped hundreds of Monarco HATs, and all of them will be facing this problem once their users decide to upgrade Raspbian...

Thanks for any hints or explanations!
Monarco HAT: Raspberry Pi in industrial automation!
Analog and digital I/O, RS-485 and 1-Wire bus.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1419
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Problem with DT overlay for UART remapping in Monarco HAT's EEPROM

Mon Sep 18, 2017 8:51 am

I understand how frustrating this is for you, and it's not what we would have chosen. In an ideal world, Device Trees are defined when a device is released and never changed. However, DT on BCM2835 platforms is still under development, with the standard "upstream" DTs still lagging behind our downstream trees (but catching up). Our aim is always to use as much upstream code as possible, and since the 4.8 kernel (not used in Raspbian) our DTs have been derived from the upstream DTs rather than being completely independent.

One of the differences between upstream and downstream was the naming of the UART nodes ("uart" vs "serial") so the change in 4.8 and later kernels has affected those few overlays that manipulate the serial aliases. I didn't anticipate that change, but I'm certain that it will never change again. As I see it you have a few options:

1. Flashing an EEPROM is actually much safer than you think. For some time now the standard eep_flash script has made use of a bit-bashed software I2C interface to avoid any contention with the VPU, so although it is a hassle for users, updating the EEPROM should be quick and safe.

2. If you want to avoid a similar update in future, it is now possible to replace the .DTB in an EEPROM with a file containing the name of an overlay. All DTBs start with a magic four-byte sequence, none of which are regular ASCII characters. If the firmware doesn't see the magic header it tries to interpret the section as an overlay name which it will load automatically just as if the user had put "dtoverlay=monarco-hat" in config.txt.

3. If you really don't want to reprogram the EEPROM then you'll have to ask users to load the overlay manually, by adding the following to config.txt before any other dt... directives:

Code: Select all

dtoverlay=  # Don't load the HAT overlay
dtoverlay=monarco-hat

User avatar
monarco
Posts: 4
Joined: Sun Sep 17, 2017 3:25 pm
Location: Plzeň, Czech Republic
Contact: Website Facebook Twitter

Re: Problem with DT overlay for UART remapping in Monarco HAT's EEPROM

Mon Sep 18, 2017 11:11 am

Hi PhilE,
pretty frustrating, you are right. Thanks for the explanation and guidelines for possible solutions. These will certainly help.
Monarco HAT: Raspberry Pi in industrial automation!
Analog and digital I/O, RS-485 and 1-Wire bus.

User avatar
monarco
Posts: 4
Joined: Sun Sep 17, 2017 3:25 pm
Location: Plzeň, Czech Republic
Contact: Website Facebook Twitter

Re: Problem with DT overlay for UART remapping in Monarco HAT's EEPROM

Mon Oct 02, 2017 5:56 pm

PhilE wrote:
Mon Sep 18, 2017 8:51 am
1. Flashing an EEPROM is actually much safer than you think. For some time now the standard eep_flash script has made use of a bit-bashed software I2C interface to avoid any contention with the VPU, so although it is a hassle for users, updating the EEPROM should be quick and safe.
Dear PhilE,
where can I find the mentioned standard eep_flash script? Is this what you mean:
https://github.com/raspberrypi/hats/blo ... epflash.sh

This script uses kernel driver for I2C EEPROM. Is this kernel driver updated to use bit-bashed access?

Or is there another utility?

Thanks!
Monarco HAT: Raspberry Pi in industrial automation!
Analog and digital I/O, RS-485 and 1-Wire bus.

PhilE
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 1419
Joined: Mon Sep 29, 2014 1:07 pm
Location: Cambridge

Re: Problem with DT overlay for UART remapping in Monarco HAT's EEPROM

Mon Oct 02, 2017 6:43 pm

Yes, that is the script, and it contains some runtime Device Tree magic that results in the i2c_gpio module being loaded and a bit-bashed I2C interface appearing as /dev/i2c3.

User avatar
monarco
Posts: 4
Joined: Sun Sep 17, 2017 3:25 pm
Location: Plzeň, Czech Republic
Contact: Website Facebook Twitter

Re: Problem with DT overlay for UART remapping in Monarco HAT's EEPROM

Mon Oct 02, 2017 6:57 pm

Cool, we'll try that. Thanks!
Monarco HAT: Raspberry Pi in industrial automation!
Analog and digital I/O, RS-485 and 1-Wire bus.

Return to “Device Tree”

Who is online

Users browsing this forum: No registered users and 2 guests