Repository

Pl2303Dxe

AI Generated Pl2303 UEFI driver

README

Build Status
Release
Licence
Downloads

Pl2303Dxe - UEFI driver/library for PL2303 devices

Description

This is a TX-only, AI port of the Linux Kernel's pl2303 driver for UEFI because, from
time to time, you want to debug UEFI stuff through good old serial interface, and platforms
either don't offer a serial port, or, if they have one, don't make it available to UEFI.

If you have PL2303 USB-Serial adapters lying around, this should be of interest to you,
especially as this project also comes with a Pl2303SerialPortLib that can be used for
UEFI debugging along with BaseDebugLibSerialPort.

Oh, and because I don't have all day and this is exactly what AI is supposed to be about,
this port was generated by AI. Therefore, the quality of the code or its actual fitness for
any expected purpose is NOT guaranteed in the slightest. And it is TX-only (no RX of
data) because what AI suggested for reading data was utterly dreadful in terms of perf on
some platforms, and TX is all you need for debug.

All I will state is that it did appear to work for me, for the specific PL2303 devices I
happen to have, and for the specific environment I was testing it in. Caveat emptor.

The original sources (and original authors) for the Linux driver can be found at:

  • https://github.com/torvalds/linux/blob/master/drivers/usb/serial/pl2303.h
  • https://github.com/torvalds/linux/blob/master/drivers/usb/serial/pl2303.c

This repository also includes the EDK2 SerialTest application, from:

  • https://github.com/jljusten/edk2/tree/0b0002292ca2fb0a4e0fc3b6cc4dd44f67b9a33e/SerialTestPkg/Application/SerialTest

Usage

Create a bootable media with the UEFI Shell, such as the one you can download from
https://github.com/pbatard/UEFI-Shell and extract the driver that is relevant to your
platform on that media.

Then boot that media and, after making sure you have a PL2303 USB adapter loaded, load the
driver with:

load Pl2303Dxe.efi

You should then be able to use the serial interface from your UEFI applications or drivers.
If needed, you can use the SerialTest application to test the serial device.

For debugging with the Pl2303SerialPortLib library, you can also add something like the
following to your application/driver's .dsc:

!if $(TARGET) == DEBUG
  DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
  SerialPortLib|Pl2303Dxe/Pl2303SerialPortLib.inf
!else
  DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
!endif

Compilation

On Linux, after either cloning or creating a symbolic link to edk2/ in the directory where
you cloned this repository, you should be able to invoke the following command (for x64
compilation):

export WORKSPACE=$PWD
export PACKAGES_PATH=$WORKSPACE:$WORKSPACE/edk2
source edk2/edksetup.sh
build -a X64 -b RELEASE -t GCC -p Pl2303Dxe.dsc -m Pl2303Dxe.inf
build -a X64 -b RELEASE -t GCC -p Pl2303Dxe.dsc -m SerialTest.inf