(RPI) Changing the tty to an external device and validating functionality

General support for the Pi-Star System
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

(RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

Greetings Gurus,

I have designed up my own board to integrate several pieces of hardware, and I am wanting to leave the native UARTs on the rpi available for other expansions, hats, etc. In this train of thought, I elected to add in an I2C to dual uart (SC16IS752) which is shared with my GPS unit. The external UART is loaded up in the device tree successfully and reports as ttySC0 on the connection to the STM32F446 processor chip.

I *think* I have successfully programmed the microcontroller last night using openocd. Not sure yet how to confirm that is accurate or not, perhaps this will need to be the first task, but not sure how to do that since I cannot talk to the microcontroller using the GUI. The openocd reported success, but I have learned to not always trust success reports

So to start out, my first question is how do I include the ttySC0 as the communication uart between the PI and the microcontroller?

The specific area <I think> I need to change is highlighted below.
I: 2019-08-19 01:29:03.736 This software is for use on amateur radio networks only,
I: 2019-08-19 01:29:03.737 it is to be used for educational purposes only. Its use on
I: 2019-08-19 01:29:03.737 commercial networks is strictly prohibited.
I: 2019-08-19 01:29:03.737 Copyright(C) 2015-2018 by Jonathan Naylor, G4KLX and others
M: 2019-08-19 01:29:03.737 MMDVMHost-20181107_Pi-Star is starting
M: 2019-08-19 01:29:03.737 Built 09:24:10 Nov 12 2018 (GitID #9444eca)
I: 2019-08-19 01:29:03.737 General Parameters
I: 2019-08-19 01:29:03.737 Callsign: KG7PAR
I: 2019-08-19 01:29:03.737 Id: 1234567
I: 2019-08-19 01:29:03.737 Duplex: yes
I: 2019-08-19 01:29:03.737 Timeout: 240s
I: 2019-08-19 01:29:03.737 D-Star: disabled
I: 2019-08-19 01:29:03.737 DMR: disabled
I: 2019-08-19 01:29:03.737 YSF: disabled
I: 2019-08-19 01:29:03.737 P25: disabled
I: 2019-08-19 01:29:03.737 NXDN: disabled
I: 2019-08-19 01:29:03.737 POCSAG: disabled
I: 2019-08-19 01:29:03.737 Modem Parameters
I: 2019-08-19 01:29:03.737 Port: /dev/ttyAMA0
I: 2019-08-19 01:29:03.737 Protocol: uart
I: 2019-08-19 01:29:03.737 RX Invert: no
I: 2019-08-19 01:29:03.737 TX Invert: yes
I: 2019-08-19 01:29:03.737 PTT Invert: no
I: 2019-08-19 01:29:03.737 TX Delay: 100ms
I: 2019-08-19 01:29:03.737 RX Offset: 0Hz
I: 2019-08-19 01:29:03.737 TX Offset: 0Hz
I: 2019-08-19 01:29:03.737 RX DC Offset: 0
I: 2019-08-19 01:29:03.737 TX DC Offset: 0
I: 2019-08-19 01:29:03.737 RF Level: 100.0%
I: 2019-08-19 01:29:03.738 DMR Delay: 0 (0.0ms)
I: 2019-08-19 01:29:03.738 RX Level: 50.0%
I: 2019-08-19 01:29:03.738 CW Id TX Level: 50.0%
I: 2019-08-19 01:29:03.738 D-Star TX Level: 50.0%
I: 2019-08-19 01:29:03.738 DMR TX Level: 50.0%
I: 2019-08-19 01:29:03.738 YSF TX Level: 50.0%
I: 2019-08-19 01:29:03.738 P25 TX Level: 50.0%
I: 2019-08-19 01:29:03.738 NXDN TX Level: 50.0%
I: 2019-08-19 01:29:03.738 POCSAG TX Level: 50.0%
I: 2019-08-19 01:29:03.738 RX Frequency: 145999999Hz (145999999Hz)
I: 2019-08-19 01:29:03.738 TX Frequency: 146000000Hz (146000000Hz)
M: 2019-08-19 01:29:03.738 Opening the MMDVM
E: 2019-08-19 01:29:16.554 Unable to read the firmware version after six attempts
If my assumptions are way off base, please feel free to correct me and get me pointed in the right direction.

My schematic is a derivative of the Repeater Builder Version 3 board with regards to the STM32F446 circuitry.
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

I think I over explained it.

The pi talks i2c to the chip I have added. This part is all good, the I2c device driver loads properly and creates 2 new uart devices in the system, specifically /dev/ttySC0 and /dev/ttySC1. Again this part is fully tested and working.

I now need the mmdvm software to use the new uart at /dev/ttySC0 instead of the /dev/ttyAMA0 device for communications.

I will have a look at the /etc/mmdvmhost file tonight if I dont hear back again before then
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

Hmm, it definitely is the right driver for my hardware as I am talking to my gps unit through it on port ttySC1. Thry disappear when i remove the overlay. Perhaps the SCx is assigned for any expansion uarts? Not sure why the 3B+ would enumerate that way otherwise, or what chip would be doing it that is unique to the 3b+. I will have to dig my 3b+ out, I am on a 3b at the moment.

I made the change to the config and probed the pins of the serial port and I dont see any traffic at all going either direction. Is there some type of regular status message or such that I should be seeing? I am now sure the stm32 is programmed as I get a led light sequence at power up and then the heart beat led toggles.

I am pretty sure its just down to figuring out why I am not getting any communications and this should all start working.
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

I can use typical serial tools/commands to setup the port so that part should be simple enough, I think its 9600 8n1 by default. I may have an issue with the 115200 due to clock selection (higher than ideal error rates), but that will be addressed in the next version of the board.

Is there a way to poke a register to change the baud rate by chance until I can fix the clock source?

I will get some probes and or logic analyzer probes attached to the uart pins to watch during the entire boot process. I will report back with what I can come up with for data traffic.
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

Working on the board tonight I think I have made a few discoveries that will lead me forward.

for reference, I am using a design derivative of this one, version 3

http://repeater-builder.com/products/stm32-dvm.html

1, per this document, http://www.repeater-builder.com/product ... Hat_v3.pdf, which is the reference design and actual firmware I am using, the UART should be at 57600 which works out as a slightly better uart speed for my current design with a lower error rate (about half as high), but alas is not the default for pi-star

2) I found a reference for debuging online (https://amateurradionotes.com/pi-star-t ... ooting.htm) that failure to boot should look to pins 38 and 40 to start, these are "boot" and "nRST" respectively best I can tell. This didnt work for me as those are both reserved I2S audio pins for using I2S sound chips which I am using. As such, I moved those pins to physical pin16 for the nRST and 36 for boot.

3) from my probing the tx/rx I do see tx (from the pi) send a burst at 115200 on occasion, but never an RX, I am assuming this is a byproduct of #2 for now, but I can now confirm the uart is working in general


From what I have found tonight, I think I need to make 3 changes to the pi-star side of the configuration to match these settings.
1) uart speed as 57600
2) reset pin as physical pin 16
3) nRST pin as physical pin 36.

also, not sure what I did but the GUI seems to have died on me, wont load up on either the lan or wifi page

the mmdvmhost service as well as the nginx service are both running okay
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

Thanks for the quick replies and knowledgable insights, I appreciate you saving me going down the dead ends.

I have a dual channel scope that I am doing most of the debugging work with.

Can you tell me what the interrogation packet is thst is sent to the stm chip? I can loop it back into the native uart on the pi or a usb interface to confirm its coming out okay (assuming its a printable characters).

I think for now I can work around the programmer using the openocd utility, but in parallel I already have a physical programmer on its way, hopefully here Saturday. I know openocd did something as I started with a blank ic and now it at least has the running led pattern and then the HB signal at powerup. Not saying there is/isn't corruption in the transfer though. I am new to that utility and there is a bit of code hacking to be done with it.

I can try to get a fresh card programmed up, have plenty of quality cards to use. Should be able to do the basics tomorrow and will let you know how it comes along with the fresh card.

If you are willing, can you compile/provide a fresh hex for the stm32f446ret6 chipset to try? Im open to whatever makes sense to eliminate variables
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

I will poke on this more this weekend, but I did a fresh burn of the same pi-star download and still can't get the GUI to load even with the pristine image. I can ssh in without any issues at all, so I am suspecting it is an issue with CHROME but I haven't yet dug into it enough to fully establish that it is in fact a browser related issue.

I will keep you posted as I make more progress
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

Scratch that last one, I decided to remote in to my home computer and try IE having thought about the browser being the culprit and I now know it is a CHROME issue. I tried using incognito mode and still won't connect, but I switched to IE and it loaded right up.

I suspect chrome is trying to load up the Open Repeater GUI or something else that is hidden in a cache/DNS somewhere which is normally at the same address and is getting confused.

Since I have the other image already configured for all the peripherals, I will switch back to it tonight and make sure it is doing the same thing with CHROME vs IE.
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

I just finally got it after flushing the entire DNS, and then using http://pi-star.local, the weird thing is a direct IP fails still...
KG7PAR
Posts: 28
Joined: Mon Aug 19, 2019 3:20 am

Re: (RPI) Changing the tty to an external device and validating functionality

Post by KG7PAR »

I finally broke out my USB to UART dongle and got it setup to sniff the output of the MMDVM UART going from the pi to the stm. The codes I am getting are

0xF0 vs 0xE0 (bit 4 error)
0x83 vs 0x03 (bit 7 error)
0x80 vs 0x00 (bit 7 error)

this looks suspiciously close to the right codes you provided, but not quite there.

I next have gotten realterm setup and send the right sequence using a USB to UART device, and I am getting the following back (as ascii characters)

ؠMMDVM 20190130 (D-Star/DMR/System Fusion/P25/NXDN/POCSAG) 12.0000 MHz GitID #ff7a9fd

Based on this I think I can conclude that the woes I am facing really all stem from having a non ideal clock source for the UART. The error rates seem to be consistent enough to break things. I am going to see if I have anything around that can generate the right frequency (like perhaps another rpi) until I can get the right crystal ordered.
Post Reply