Milliways
Posts: 377
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Where is /dev/serial0

Thu May 19, 2016 7:55 am

In the previous Raspbian release `/dev/serial0` accessed the miniUART on Pi3.

This no longer there although there is a `/dev/serial1 -> ttyAMA0` although on the Pi2 `/dev/serial0 -> ttyAMA0`.

`/dev/serial0` SHOULD allow access to the default UART.

What happened?

On further investigation I notice that there is no `/dev/ttyS0` and pins 8,10 (BMC 14,15) are IN mode.

DirkS
Posts: 9761
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Where is /dev/serial0

Thu May 19, 2016 10:34 am

I see the same after running update / upgrade today.

Code: Select all

sudo vcdbg log msg
shows that uart1 is switched off

Code: Select all

001241.327: Loading 'bcm2710-rpi-3-b.dtb' to 0x40ef30 size 0x3518
001309.615: dtparam: uart0_clkrate=48000000
001320.158: dtparam: i2c_arm=on
001328.467: dtparam: spi=on
001335.621: dtparam: audio=on
001351.665: dtparam: uart1=off
001414.866: dtparam: arm_freq=1200000000
001454.003: dtparam: core_freq=400000000
001464.132: dtparam: cache_line_size=64
I reverted to the first 4.4.9 kernel (https://github.com/Hexxeh/rpi-firmware/ ... e83a25bc0a) and it's back again.

Commit https://github.com/Hexxeh/rpi-firmware/ ... f403056882 looks suspicious and it indeed disables ttyS0 / serial0 again.
I get it working again by adding

Code: Select all

enable_uart=1
to config.txt
I don't think this should be necessary. It's a workaround rather than a fix.

Milliways
Posts: 377
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Where is /dev/serial0

Thu May 19, 2016 11:17 am

I found my config.txt had:-

Code: Select all

enable_uart=0
Changing this fixed it.

This was NOT in config.txt on the Pi2 DESPITE the fact that I did the upgrade on the Pi 2 and use SD Copier to duplicate the card which I ran on the Pi3 (although I did some other changes on the Pi3 - mostly related to Bluetooth).

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 21662
Joined: Sat Jul 30, 2011 7:41 pm

Re: Where is /dev/serial0

Thu May 19, 2016 11:31 am

Sounds like a mistake/regression.


I'll flag it up.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

DirkS
Posts: 9761
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Where is /dev/serial0

Thu May 19, 2016 12:17 pm

jamesh wrote:Sounds like a mistake/regression.


I'll flag it up.
Cheers. Saves me creating an issue on github...

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 21662
Joined: Sat Jul 30, 2011 7:41 pm

Re: Where is /dev/serial0

Thu May 19, 2016 12:21 pm

OK, had a message from RPF...
The ttyS0/serial0 behaviour w.r.t. enable_uart is as expected, but I wouldn't expect anything to spontaneously set it to zero in config.txt.

When ttyAMA0 is the main (console) UART (the normal case on a Pi2), enable_uart defaults to 1. When ttyS0 is the main (console) UART (the normal case on a Pi3), enable_uart defaults to 0. Perhaps this is what the guy is seeing?

Phil
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Milliways
Posts: 377
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Where is /dev/serial0

Thu May 19, 2016 12:31 pm

jamesh wrote:OK, had a message from RPF...
The ttyS0/serial0 behaviour w.r.t. enable_uart is as expected, but I wouldn't expect anything to spontaneously set it to zero in config.txt.

When ttyAMA0 is the main (console) UART (the normal case on a Pi2), enable_uart defaults to 1. When ttyS0 is the main (console) UART (the normal case on a Pi3), enable_uart defaults to 0. Perhaps this is what the guy is seeing?

Phil
This doesn't make any sense. On the Pi3 when ttyAMA0 is connected to Bluetooth ttyS0 should act as the normal console/default serial interface (as it used to in 4.1.19). I don't normally use console on tty, but use it as a serial interface. It makes absolutely no sense to set GPIO 14,15 as default inputs.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 21662
Joined: Sat Jul 30, 2011 7:41 pm

Re: Where is /dev/serial0

Thu May 19, 2016 12:46 pm

I'll see if I can get PhilE to help here, it's out of my knowledge area!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

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

Re: Where is /dev/serial0

Thu May 19, 2016 12:57 pm

It makes sense when you understand that UART1/ttyS0 shares the VPU clock. That renders it useless unless the VPU clock is fixed, i.e. you have set core_freq to 250.

We try to choose our config.txt setting so that you can plug your SD card into any Pi and have it work. The change in UART roles on the Pi3 made this more complicated, because artificially limiting a Pi2 to 250MHz in order to have a stable UART is unnecessary. The solution was to introduce the enable_uart setting, which does just what it says on all platforms. What differs are the default value of that setting and the effects it has. On a Pi2 enable_uart defaults to 1, and it only controls the UART initialisation and pin configuration in the firmware and the Linux image. On a Pi3 the default is 0, and when set it also sets core_freq to 250. The default differs because the vast majority of users don't care about the UART, so it is unreasonable to restrict their core clock without them agreeing to it.

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

Re: Where is /dev/serial0

Thu May 19, 2016 1:00 pm

P.S. It's a shame you didn't think to look in the troubleshooting section because there's a sticky post all about this:

viewtopic.php?f=28&t=141195

DirkS
Posts: 9761
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: Where is /dev/serial0

Thu May 19, 2016 1:03 pm

Thanks for the clarification, Phil.

Milliways
Posts: 377
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Where is /dev/serial0

Thu May 19, 2016 1:27 pm

PhilE wrote:P.S. It's a shame you didn't think to look in the troubleshooting section because there's a sticky post all about this:

viewtopic.php?f=28&t=141195
What about the vast bulk of users who don't peruse every word on this Forum. There was NO MENTION of this in the Foundation Blog announcing the release.

Setting core_freq=250 appears to have little impact. The SPI clock frequency and ARM Timer are also dependent on the system clock, but I can see no user impact.

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

Re: Where is /dev/serial0

Thu May 19, 2016 3:26 pm

> What about the vast bulk of users who don't peruse every word on this Forum.

They won't be using a UART. And when they do find a problem they do read the forum.

> The SPI clock frequency and ARM Timer are also dependent on the system clock, but I can see no user impact.

Yes, the SPI clock frequency is derived from the VPU clock, as is I2C, but because those interfaces include a clock signal the end result is that they just run slower when not in turbo mode - try it.

The ARM Timer is dependent on the ARM clock frequency, and the divisor gets recalculated whenever the ARM clock changes.

Milliways
Posts: 377
Joined: Fri Apr 25, 2014 12:18 am
Location: Sydney, Australia

Re: Where is /dev/serial0

Fri May 20, 2016 5:09 am

PhilE wrote:>
> The SPI clock frequency and ARM Timer are also dependent on the system clock, but I can see no user impact.

Yes, the SPI clock frequency is derived from the VPU clock, as is I2C, but because those interfaces include a clock signal the end result is that they just run slower when not in turbo mode - try it.

The ARM Timer is dependent on the ARM clock frequency, and the divisor gets recalculated whenever the ARM clock changes.
Would it be possible to recalculate the UART divisor whenever the ARM clock changes?

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

Re: Where is /dev/serial0

Fri May 20, 2016 8:06 am

We want to avoid a handshake with the ARM whenever the VPU needs to alter the clock, for safety and performance reasons. I don't think it's possible to update the clock divider from the VPU avoiding output corruption without a significant rewrite of the ARM-side driver, which up to now has been an upstream driver with a very small patch. The end result of such a rewrite would probably be to move some of the UART-driving logic onto the VPU, but there is a danger that in making the ARM driver dependent on the VPU, were the VPU to crash we would lose the ability to send diagnostic messages out on the UART console.

Return to “Raspbian”