Remapping NuttX serial port devices (dev/ttySx)

Hello everyone,

I have recently started to play with the CrazyFlie Port of PX4. As part of that I have also attached an uBlox M8 GNSS receiver.

While setting up the receiver using NuttX Shell I noticed that on the CrazyFlie-port still the default serial is defined /dev/ttyS3 as per drv_gps.h.

The crazyflie comes up with ttyS0 to ttyS2 (USART_2_1, USART_3_2, USART_6_1), they correspond in this order to Rx2 + Tx2 , Rx1 + Tx1 and NRF-Link on crazyflie.

As I am using USART_2_1 (Rx2 + Tx2 on CF Deck) → dev/ttyS0, GPS wont work out of the box - so had to change that. I already confirmed it working by stopping and then restarting the GPS-thread with ttyS0 as device. Now to make it stick, I do wonder what a proper way of remapping would be?

I had a look through the init.d scripts, but I could just find one file that starts the GPS-thread (rcS).

I’d do a platform check for crazyflie here, and then start GPS with -d /dev/ttyS0 as device…
But maybe there is another way? Is it possible to rename a device? Or create a link to a device? So ttyS3 would point to ttyS0.

For now I could just hardcode the default device… but I do wonder how to do it properly as I also would like to gain some more understanding how PX4 stack and NuttX works.

Any other ideas are appreciated as well :slight_smile:


That’s a good question! For this specific case, I think that the default GPS port per board is typically overriden per by a board_config.h definition or platform specific rcS scripts. I’m not sure about the NuttX capabilities for doing device linking. If I were you, I would have just hardcoded it too.

The Crazyflie in particular is an odd platform as it is the only PX4 supported board AFAIK that doesn’t have a dedicated GPS port so it wouldn’t make sense to default enable any serial ports for GPS as it may be used by something else. The firmware supports detection of attached decks, but that needs to be setup per deck id.

The most PX4-like way to make that decision would probably be to go with a setup like for the SYS_COMPANION param and allow a user to configure the purpose of the serial port and start a driver appropriately. Although this will only make sense for boards like the Crazyflie where serial ports aren’t dedicated to certain peripherals.