當(dāng)前位置:首頁 > 技術(shù)學(xué)院 > 技術(shù)前線
[導(dǎo)讀]ch340usb轉(zhuǎn)串口在linux上波特率誤差

前段時(shí)間在使用linux mint 19.01系統(tǒng)上使用ch340的usb轉(zhuǎn)串口工具,發(fā)現(xiàn)波特率在961200的情況下數(shù)據(jù)總是不正確,而在115200波特率下又是正常的,于是在谷歌上搜索了一下,發(fā)現(xiàn)我使用的系統(tǒng)采用的linux內(nèi)核版本4.15.0上ch340的驅(qū)動存在波特率誤差的問題。

在一番搜索下在這里找到了一個(gè)對內(nèi)核驅(qū)動的patch:https://patchwork.kernel.org/patch/10983017/

這個(gè)作者針對內(nèi)核里的ch341驅(qū)動進(jìn)行了詳細(xì)的測試并提供了一份新的驅(qū)動,目前該驅(qū)動已合并到內(nèi)核main line上5.5版本了,可以在這里查看該驅(qū)動源碼:https://elixir.bootlin.com/linux/v5.5-rc5/source/drivers/usb/serial/ch341.c

另外驅(qū)動的作者在github上創(chuàng)建了一個(gè)項(xiàng)目,專門針對ch340的波特率問題進(jìn)行了相關(guān)研究,其中給出了非常詳細(xì)的波特率計(jì)算公式和誤差測試,地址如下:https://github.com/nospam2000/ch341-baudrate-calculation

由于目前大多數(shù)的linux發(fā)行版都還使用較老的內(nèi)核版本。因此該問題一直沒被解決,那么我們這里就將5.5版本的驅(qū)動代碼在目前使用的發(fā)行版上重新編譯替換自帶的驅(qū)動以修復(fù)這個(gè)問題。

PC

首先創(chuàng)建ch341.c文件,內(nèi)容如下:

// SPDX-License-Identifier: GPL-2.0

/*

* Copyright 2007, Frank A Kingswood

* Copyright 2007, Werner Cornelius

* Copyright 2009, Boris Hajduk

*

* ch341.c implements a serial port driver for the Winchiphead CH341.

*

* The CH341 device can be used to implement an RS232 asynchronous

* serial port, an IEEE-1284 parallel printer port or a memory-like

* interface. In all cases the CH341 supports an I2C interface as well.

* This driver only supports the asynchronous serial interface.

*/

#include

#include

#include

#include

#include

#include

#include

#include

#define DEFAULT_BAUD_RATE 9600

#define DEFAULT_TIMEOUT 1000

/* flags for IO-Bits */

#define CH341_BIT_RTS (1 << 6)

#define CH341_BIT_DTR (1 << 5)

/******************************/

/* interrupt pipe definitions */

/******************************/

/* always 4 interrupt bytes */

/* first irq byte normally 0x08 */

/* second irq byte base 0x7d + below */

/* third irq byte base 0x94 + below */

/* fourth irq byte normally 0xee */

/* second interrupt byte */

#define CH341_MULT_STAT 0x04 /* multiple status since last interrupt event */

/* status returned in third interrupt answer byte, inverted in data

from irq */

#define CH341_BIT_CTS 0x01

#define CH341_BIT_DSR 0x02

#define CH341_BIT_RI 0x04

#define CH341_BIT_DCD 0x08

#define CH341_BITS_MODEM_STAT 0x0f /* all bits */

/* Break support - the information used to implement this was gleaned from

* the Net/FreeBSD uchcom.c driver by Takanori Watanabe. Domo arigato.

*/

#define CH341_REQ_READ_VERSION 0x5F

#define CH341_REQ_WRITE_REG 0x9A

#define CH341_REQ_READ_REG 0x95

#define CH341_REQ_SERIAL_INIT 0xA1

#define CH341_REQ_MODEM_CTRL 0xA4

#define CH341_REG_BREAK 0x05

#define CH341_REG_LCR 0x18

#define CH341_NBREAK_BITS 0x01

#define CH341_LCR_ENABLE_RX 0x80

#define CH341_LCR_ENABLE_TX 0x40

#define CH341_LCR_MARK_SPACE 0x20

#define CH341_LCR_PAR_EVEN 0x10

#define CH341_LCR_ENABLE_PAR 0x08

#define CH341_LCR_STOP_BITS_2 0x04

#define CH341_LCR_CS8 0x03

#define CH341_LCR_CS7 0x02

#define CH341_LCR_CS6 0x01

#define CH341_LCR_CS5 0x00

static const struct usb_device_id id_table[] = {

{ USB_DEVICE(0x4348, 0x5523) },

{ USB_DEVICE(0x1a86, 0x7523) },

{ USB_DEVICE(0x1a86, 0x5523) },

{ },

};

MODULE_DEVICE_TABLE(usb, id_table);

struct ch341_private {

spinlock_t lock; /* access lock */

unsigned baud_rate; /* set baud rate */

u8 mcr;

u8 msr;

u8 lcr;

};

static void ch341_set_termios(struct tty_struct *tty,

struct usb_serial_port *port,

struct ktermios *old_termios);

static int ch341_control_out(struct usb_device *dev, u8 request,

u16 value, u16 index)

{

int r;

dev_dbg(&dev->dev, "%s - (%02x,%04x,%04x)\n", __func__,

request, value, index);

r = usb_control_msg(dev, usb_sndctrlpipe(dev, 0), request,

USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_OUT,

value, index, NULL, 0, DEFAULT_TIMEOUT);

if (r < 0)

dev_err(&dev->dev, "failed to send control message: %d\n", r);

return r;

}

static int ch341_control_in(struct usb_device *dev,

u8 request, u16 value, u16 index,

char *buf, unsigned bufsize)

{

int r;

dev_dbg(&dev->dev, "%s - (%02x,%04x,%04x,%u)\n", __func__,

request, value, index, bufsize);

r = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), request,

USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN,

value, index, buf, bufsize, DEFAULT_TIMEOUT);

if (r < (int)bufsize) {

if (r >= 0) {

dev_err(&dev->dev,

"short control message received (%d < %u)\n",

r, bufsize);

r = -EIO;

}

dev_err(&dev->dev, "failed to receive control message: %d\n",

r);

return r;

}

return 0;

}

#define CH341_CLKRATE 48000000

#define CH341_CLK_DIV(ps, fact) (1 << (12 - 3 * (ps) - (fact)))

#define CH341_MIN_RATE(ps) (CH341_CLKRATE / (CH341_CLK_DIV((ps), 1) * 512))

static const speed_t ch341_min_rates[] = {

CH341_MIN_RATE(0),

CH341_MIN_RATE(1),

CH341_MIN_RATE(2),

CH341_MIN_RATE(3),

};

/*

* The device line speed is given by the following equation:

*

* baudrate = 48000000 / (2^(12 - 3 * ps - fact) * div), where

*

* 0 <= ps <= 3,

* 0 <= fact <= 1,

* 2 <= div <= 256 if fact = 0, or

* 9 <= div <= 256 if fact = 1

*/

static int ch341_get_divisor(speed_t speed)

{

unsigned int fact, div, clk_div;

int ps;

/*

* Clamp to supported range, this makes the (ps < 0) and (div < 2)

* sanity checks below redundant.

*/

speed = clamp(speed, 46U, 3000000U);

/*

* Start with highest possible base clock (fact = 1) that will give a

* divisor strictly less than 512.

*/

fact = 1;

for (ps = 3; ps >= 0; ps--) {

if (speed > ch341_min_rates[ps])

break;

}

if (ps < 0)

return -EINVAL;

/* Determine corresponding divisor, rounding down. */

clk_div = CH341_CLK_DIV(ps, fact);

div = CH341_CLKRATE / (clk_div * speed);

/* Halve base clock (fact = 0) if required. */

if (div < 9 || div > 255) {

div /= 2;

clk_div *= 2;

fact = 0;

}

if (div < 2)

return -EINVAL;

/*

* Pick next divisor if resulting rate is closer to the requested one,

* scale up to avoid rounding errors on low rates.

*/

if (16 * CH341_CLKRATE / (clk_div * div) - 16 * speed >=

16 * speed - 16 * CH341_CLKRATE / (clk_div * (div + 1)))

div++;

return (0x100 - div) << 8 | fact << 2 | ps;

}

static int ch341_set_baudrate_lcr(struct usb_device *dev,

struct ch341_private *priv, u8 lcr)

{

int val;

int r;

if (!priv->baud_rate)

return -EINVAL;

val = ch341_get_divisor(priv->baud_rate);

if (val < 0)

return -EINVAL;

/*

* CH341A buffers data until a full endpoint-size packet (32 bytes)

* has been received unless bit 7 is set.

*/

val |= BIT(7);

r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x1312, val);

if (r)

return r;

r = ch341_control_out(dev, CH341_REQ_WRITE_REG, 0x2518, lcr);

if (r)

return r;

return r;

}

static int ch341_set_handshake(struct usb_device *dev, u8 control)

{

return ch341_control_out(dev, CH341_REQ_MODEM_CTRL, ~control, 0);

}

static int ch341_get_status(struct usb_device *dev, struct ch341_private *priv)

{

const unsigned int size = 2;

char *buffer;

int r;

unsigned long flags;

buffer = kmalloc(size, GFP_KERNEL);

if (!buffer)

return -ENOMEM;

r = ch341_control_in(dev, CH341_REQ_READ_REG, 0x0706, 0, buffer, size);

if (r < 0)

goto out;

spin_lock_irqsave(&priv->lock, flags);

priv->msr = (~(*buffer)) & CH341_BITS_MODEM_STAT;

spin_unlock_irqrestore(&priv->lock, flags);

out: kfree(buffer);

return r;

}

/* -------------------------------------------------------------------------- */

static int ch341_configure(struct usb_device *dev, struct ch341_private *priv)

{

const unsigned int size = 2;

char *buffer;

int r;

buffer = kmalloc(size, GFP_KERNEL);

if (!buffer)

return -ENOMEM;

/* expect two bytes 0x27 0x00 */

r = ch341_control_in(dev, CH341_REQ_READ_VERSION, 0, 0, buffer, size);

if (r < 0)

goto out;

dev_dbg(&dev->dev, "Chip version: 0x%02x\n", buffer[0]);

r = ch341_control_out(dev, CH341_REQ_SERIAL_INIT, 0, 0);

if (r < 0)

goto out;

r = ch341_set_baudrate_lcr(dev, priv, priv->lcr);

if (r < 0)

goto out;

r = ch341_set_handshake(dev, priv->mcr);

out: kfree(buffer);

return r;

}

static int ch341_port_probe(struct usb_serial_port *port)

{

struct ch341_private *priv;

int r;

priv = kzalloc(sizeof(struct ch341_private), GFP_KERNEL);

if (!priv)

return -ENOMEM;

spin_lock_init(&priv->lock);

priv->baud_rate = DEFAULT_BAUD_RATE;

/*

* Some CH340 devices appear unable to change the initial LCR

* settings, so set a sane 8N1 default.

*/

priv->lcr = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX | CH341_LCR_CS8;

r = ch341_configure(port->serial->dev, priv);

if (r < 0)

goto error;

usb_set_serial_port_data(port, priv);

return 0;

error: kfree(priv);

return r;

}

static int ch341_port_remove(struct usb_serial_port *port)

{

struct ch341_private *priv;

priv = usb_get_serial_port_data(port);

kfree(priv);

return 0;

}

static int ch341_carrier_raised(struct usb_serial_port *port)

{

struct ch341_private *priv = usb_get_serial_port_data(port);

if (priv->msr & CH341_BIT_DCD)

return 1;

return 0;

}

static void ch341_dtr_rts(struct usb_serial_port *port, int on)

{

struct ch341_private *priv = usb_get_serial_port_data(port);

unsigned long flags;

/* drop DTR and RTS */

spin_lock_irqsave(&priv->lock, flags);

if (on)

priv->mcr |= CH341_BIT_RTS | CH341_BIT_DTR;

else

priv->mcr &= ~(CH341_BIT_RTS | CH341_BIT_DTR);

spin_unlock_irqrestore(&priv->lock, flags);

ch341_set_handshake(port->serial->dev, priv->mcr);

}

static void ch341_close(struct usb_serial_port *port)

{

usb_serial_generic_close(port);

usb_kill_urb(port->interrupt_in_urb);

}

/* open this device, set default parameters */

static int ch341_open(struct tty_struct *tty, struct usb_serial_port *port)

{

struct ch341_private *priv = usb_get_serial_port_data(port);

int r;

if (tty)

ch341_set_termios(tty, port, NULL);

dev_dbg(&port->dev, "%s - submitting interrupt urb\n", __func__);

r = usb_submit_urb(port->interrupt_in_urb, GFP_KERNEL);

if (r) {

dev_err(&port->dev, "%s - failed to submit interrupt urb: %d\n",

__func__, r);

return r;

}

r = ch341_get_status(port->serial->dev, priv);

if (r < 0) {

dev_err(&port->dev, "failed to read modem status: %d\n", r);

goto err_kill_interrupt_urb;

}

r = usb_serial_generic_open(tty, port);

if (r)

goto err_kill_interrupt_urb;

return 0;

err_kill_interrupt_urb:

usb_kill_urb(port->interrupt_in_urb);

return r;

}

/* Old_termios contains the original termios settings and

* tty->termios contains the new setting to be used.

*/

static void ch341_set_termios(struct tty_struct *tty,

struct usb_serial_port *port, struct ktermios *old_termios)

{

struct ch341_private *priv = usb_get_serial_port_data(port);

unsigned baud_rate;

unsigned long flags;

u8 lcr;

int r;

/* redundant changes may cause the chip to lose bytes */

if (old_termios && !tty_termios_hw_change(&tty->termios, old_termios))

return;

baud_rate = tty_get_baud_rate(tty);

lcr = CH341_LCR_ENABLE_RX | CH341_LCR_ENABLE_TX;

switch (C_CSIZE(tty)) {

case CS5:

lcr |= CH341_LCR_CS5;

break;

case CS6:

lcr |= CH341_LCR_CS6;

break;

case CS7:

lcr |= CH341_LCR_CS7;

break;

case CS8:

lcr |= CH341_LCR_CS8;

break;

}

if (C_PARENB(tty)) {

lcr |= CH341_LCR_ENABLE_PAR;

if (C_PARODD(tty) == 0)

lcr |= CH341_LCR_PAR_EVEN;

if (C_CMSPAR(tty))

lcr |= CH341_LCR_MARK_SPACE;

}

if (C_CSTOPB(tty))

lcr |= CH341_LCR_STOP_BITS_2;

if (baud_rate) {

priv->baud_rate = baud_rate;

r = ch341_set_baudrate_lcr(port->serial->dev, priv, lcr);

if (r < 0 && old_termios) {

priv->baud_rate = tty_termios_baud_rate(old_termios);

tty_termios_copy_hw(&tty->termios, old_termios);

} else if (r == 0) {

priv->lcr = lcr;

}

}

spin_lock_irqsave(&priv->lock, flags);

if (C_BAUD(tty) == B0)

priv->mcr &= ~(CH341_BIT_DTR | CH341_BIT_RTS);

else if (old_termios && (old_termios->c_cflag & CBAUD) == B0)

priv->mcr |= (CH341_BIT_DTR | CH341_BIT_RTS);

spin_unlock_irqrestore(&priv->lock, flags);

ch341_set_handshake(port->serial->dev, priv->mcr);

}

static void ch341_break_ctl(struct tty_struct *tty, int break_state)

{

const uint16_t ch341_break_reg =

((uint16_t) CH341_REG_LCR << 8) | CH341_REG_BREAK;

struct usb_serial_port *port = tty->driver_data;

int r;

uint16_t reg_contents;

uint8_t *break_reg;

break_reg = kmalloc(2, GFP_KERNEL);

if (!break_reg)

return;

r = ch341_control_in(port->serial->dev, CH341_REQ_READ_REG,

ch341_break_reg, 0, break_reg, 2);

if (r < 0) {

dev_err(&port->dev, "%s - USB control read error (%d)\n",

__func__, r);

goto out;

}

dev_dbg(&port->dev, "%s - initial ch341 break register contents - reg1: %x, reg2: %x\n",

__func__, break_reg[0], break_reg[1]);

if (break_state != 0) {

dev_dbg(&port->dev, "%s - Enter break state requested\n", __func__);

break_reg[0] &= ~CH341_NBREAK_BITS;

break_reg[1] &= ~CH341_LCR_ENABLE_TX;

} else {

dev_dbg(&port->dev, "%s - Leave break state requested\n", __func__);

break_reg[0] |= CH341_NBREAK_BITS;

break_reg[1] |= CH341_LCR_ENABLE_TX;

}

dev_dbg(&port->dev, "%s - New ch341 break register contents - reg1: %x, reg2: %x\n",

__func__, break_reg[0], break_reg[1]);

reg_contents = get_unaligned_le16(break_reg);

r = ch341_control_out(port->serial->dev, CH341_REQ_WRITE_REG,

ch341_break_reg, reg_contents);

if (r < 0)

dev_err(&port->dev, "%s - USB control write error (%d)\n",

__func__, r);

out:

kfree(break_reg);

}

static int ch341_tiocmset(struct tty_struct *tty,

unsigned int set, unsigned int clear)

{

struct usb_serial_port *port = tty->driver_data;

struct ch341_private *priv = usb_get_serial_port_data(port);

unsigned long flags;

u8 control;

spin_lock_irqsave(&priv->lock, flags);

if (set & TIOCM_RTS)

priv->mcr |= CH341_BIT_RTS;

if (set & TIOCM_DTR)

priv->mcr |= CH341_BIT_DTR;

if (clear & TIOCM_RTS)

priv->mcr &= ~CH341_BIT_RTS;

if (clear & TIOCM_DTR)

priv->mcr &= ~CH341_BIT_DTR;

control = priv->mcr;

spin_unlock_irqrestore(&priv->lock, flags);

return ch341_set_handshake(port->serial->dev, control);

}

static void ch341_update_status(struct usb_serial_port *port,

unsigned char *data, size_t len)

{

struct ch341_private *priv = usb_get_serial_port_data(port);

struct tty_struct *tty;

unsigned long flags;

u8 status;

u8 delta;

if (len < 4)

return;

status = ~data[2] & CH341_BITS_MODEM_STAT;

spin_lock_irqsave(&priv->lock, flags);

delta = status ^ priv->msr;

priv->msr = status;

spin_unlock_irqrestore(&priv->lock, flags);

if (data[1] & CH341_MULT_STAT)

dev_dbg(&port->dev, "%s - multiple status change\n", __func__);

if (!delta)

return;

if (delta & CH341_BIT_CTS)

port->icount.cts++;

if (delta & CH341_BIT_DSR)

port->icount.dsr++;

if (delta & CH341_BIT_RI)

port->icount.rng++;

if (delta & CH341_BIT_DCD) {

port->icount.dcd++;

tty = tty_port_tty_get(&port->port);

if (tty) {

usb_serial_handle_dcd_change(port, tty,

status & CH341_BIT_DCD);

tty_kref_put(tty);

}

}

wake_up_interruptible(&port->port.delta_msr_wait);

}

static void ch341_read_int_callback(struct urb *urb)

{

struct usb_serial_port *port = urb->context;

unsigned char *data = urb->transfer_buffer;

unsigned int len = urb->actual_length;

int status;

switch (urb->status) {

case 0:

/* success */

break;

case -ECONNRESET:

case -ENOENT:

case -ESHUTDOWN:

/* this urb is terminated, clean up */

dev_dbg(&urb->dev->dev, "%s - urb shutting down: %d\n",

__func__, urb->status);

return;

default:

dev_dbg(&urb->dev->dev, "%s - nonzero urb status: %d\n",

__func__, urb->status);

goto exit;

}

usb_serial_debug_data(&port->dev, __func__, len, data);

ch341_update_status(port, data, len);

exit:

status = usb_submit_urb(urb, GFP_ATOMIC);

if (status) {

dev_err(&urb->dev->dev, "%s - usb_submit_urb failed: %d\n",

__func__, status);

}

}

static int ch341_tiocmget(struct tty_struct *tty)

{

struct usb_serial_port *port = tty->driver_data;

struct ch341_private *priv = usb_get_serial_port_data(port);

unsigned long flags;

u8 mcr;

u8 status;

unsigned int result;

spin_lock_irqsave(&priv->lock, flags);

mcr = priv->mcr;

status = priv->msr;

spin_unlock_irqrestore(&priv->lock, flags);

result = ((mcr & CH341_BIT_DTR) ? TIOCM_DTR : 0)

| ((mcr & CH341_BIT_RTS) ? TIOCM_RTS : 0)

| ((status & CH341_BIT_CTS) ? TIOCM_CTS : 0)

| ((status & CH341_BIT_DSR) ? TIOCM_DSR : 0)

| ((status & CH341_BIT_RI) ? TIOCM_RI : 0)

| ((status & CH341_BIT_DCD) ? TIOCM_CD : 0);

dev_dbg(&port->dev, "%s - result = %x\n", __func__, result);

return result;

}

static int ch341_reset_resume(struct usb_serial *serial)

{

struct usb_serial_port *port = serial->port[0];

struct ch341_private *priv = usb_get_serial_port_data(port);

int ret;

/* reconfigure ch341 serial port after bus-reset */

ch341_configure(serial->dev, priv);

if (tty_port_initialized(&port->port)) {

ret = usb_submit_urb(port->interrupt_in_urb, GFP_NOIO);

if (ret) {

dev_err(&port->dev, "failed to submit interrupt urb: %d\n",

ret);

return ret;

}

ret = ch341_get_status(port->serial->dev, priv);

if (ret < 0) {

dev_err(&port->dev, "failed to read modem status: %d\n",

ret);

}

}

return usb_serial_generic_resume(serial);

}

static struct usb_serial_driver ch341_device = {

.driver = {

.owner = THIS_MODULE,

.name = "ch341-uart",

},

.id_table = id_table,

.num_ports = 1,

.open = ch341_open,

.dtr_rts = ch341_dtr_rts,

.carrier_raised = ch341_carrier_raised,

.close = ch341_close,

.set_termios = ch341_set_termios,

.break_ctl = ch341_break_ctl,

.tiocmget = ch341_tiocmget,

.tiocmset = ch341_tiocmset,

.tiocmiwait = usb_serial_generic_tiocmiwait,

.read_int_callback = ch341_read_int_callback,

.port_probe = ch341_port_probe,

.port_remove = ch341_port_remove,

.reset_resume = ch341_reset_resume,

};

static struct usb_serial_driver * const serial_drivers[] = {

&ch341_device, NULL

};

module_usb_serial_driver(serial_drivers, id_table);

MODULE_LICENSE("GPL v2");

創(chuàng)建Makefile,內(nèi)容如下

ifeq ($(KERNELRELEASE), )

KERNELDIR := /lib/modules/$(shell uname -r)/build

PWD :=$(shell pwd)

default:

$(MAKE) -C $(KERNELDIR) M=$(PWD)

clean:

rm -rf .tmp_versions Module.symvers *.mod.c *.o *.ko .*.cmd Module.markers modules.order .cache.mk

load:

modprobe usbserial

insmod ch341.ko

unload:

rmmod ch341

install:

cp ch341.ko /lib/modules/$(shell uname -r)/kernel/drivers/usb/serial/ch341.ko

else

obj-m := ch341.o

endif

在終端依次執(zhí)行

make

sudo make install

重新載入驅(qū)動或者重啟系統(tǒng),驅(qū)動更新完成,實(shí)測ch340波特率正常通信正常

樹莓派

最后,這個(gè)問題筆者在樹莓派上使用ch340也發(fā)現(xiàn)有相同問題,因此想更新樹莓派上的驅(qū)動,樹莓派上沒有相關(guān)驅(qū)動編譯工具,只能在pc上進(jìn)行交叉編譯,所以編譯ko時(shí)還得先編譯內(nèi)核

首先去樹莓派官方git倉庫找到你使用的系統(tǒng)版本,切記要找到和你使用內(nèi)核版本一致的那一次提交,可以在這里查找:https://github.com/raspberrypi/linux/releases ,使用git命令拉取,示例如下:

git clone --depth=1 --branch raspberrypi-kernel_1.20190925-1 https://github.com/raspberrypi/linux.git

安裝必要的工具,拉取交叉編譯工具鏈,并配置環(huán)境變量,請根據(jù)自己的路徑指定,注意這里環(huán)境變量是一次性的,關(guān)閉終端之后就沒有了

sudo apt install bc bison flex libssl-dev make libc6-dev libncurses5-dev

git clone https://github.com/raspberrypi/tools

export PATH="$PATH:$HOME/Desktop/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin"

然后進(jìn)入源碼的linux/drivers/usb/serial目錄內(nèi)修改ch341.c文件

進(jìn)入源碼根目錄,對于樹莓派4,其他樹莓派版本可查看:https://www.raspberrypi.org/documentation/linux/kernel/building.md

cd linux

KERNEL=kernel7l

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2711_defconfig

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時(shí)聯(lián)系本站刪除。
換一批
延伸閱讀

9月2日消息,不造車的華為或?qū)⒋呱龈蟮莫?dú)角獸公司,隨著阿維塔和賽力斯的入局,華為引望愈發(fā)顯得引人矚目。

關(guān)鍵字: 阿維塔 塞力斯 華為

加利福尼亞州圣克拉拉縣2024年8月30日 /美通社/ -- 數(shù)字化轉(zhuǎn)型技術(shù)解決方案公司Trianz今天宣布,該公司與Amazon Web Services (AWS)簽訂了...

關(guān)鍵字: AWS AN BSP 數(shù)字化

倫敦2024年8月29日 /美通社/ -- 英國汽車技術(shù)公司SODA.Auto推出其旗艦產(chǎn)品SODA V,這是全球首款涵蓋汽車工程師從創(chuàng)意到認(rèn)證的所有需求的工具,可用于創(chuàng)建軟件定義汽車。 SODA V工具的開發(fā)耗時(shí)1.5...

關(guān)鍵字: 汽車 人工智能 智能驅(qū)動 BSP

北京2024年8月28日 /美通社/ -- 越來越多用戶希望企業(yè)業(yè)務(wù)能7×24不間斷運(yùn)行,同時(shí)企業(yè)卻面臨越來越多業(yè)務(wù)中斷的風(fēng)險(xiǎn),如企業(yè)系統(tǒng)復(fù)雜性的增加,頻繁的功能更新和發(fā)布等。如何確保業(yè)務(wù)連續(xù)性,提升韌性,成...

關(guān)鍵字: 亞馬遜 解密 控制平面 BSP

8月30日消息,據(jù)媒體報(bào)道,騰訊和網(wǎng)易近期正在縮減他們對日本游戲市場的投資。

關(guān)鍵字: 騰訊 編碼器 CPU

8月28日消息,今天上午,2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會開幕式在貴陽舉行,華為董事、質(zhì)量流程IT總裁陶景文發(fā)表了演講。

關(guān)鍵字: 華為 12nm EDA 半導(dǎo)體

8月28日消息,在2024中國國際大數(shù)據(jù)產(chǎn)業(yè)博覽會上,華為常務(wù)董事、華為云CEO張平安發(fā)表演講稱,數(shù)字世界的話語權(quán)最終是由生態(tài)的繁榮決定的。

關(guān)鍵字: 華為 12nm 手機(jī) 衛(wèi)星通信

要點(diǎn): 有效應(yīng)對環(huán)境變化,經(jīng)營業(yè)績穩(wěn)中有升 落實(shí)提質(zhì)增效舉措,毛利潤率延續(xù)升勢 戰(zhàn)略布局成效顯著,戰(zhàn)新業(yè)務(wù)引領(lǐng)增長 以科技創(chuàng)新為引領(lǐng),提升企業(yè)核心競爭力 堅(jiān)持高質(zhì)量發(fā)展策略,塑強(qiáng)核心競爭優(yōu)勢...

關(guān)鍵字: 通信 BSP 電信運(yùn)營商 數(shù)字經(jīng)濟(jì)

北京2024年8月27日 /美通社/ -- 8月21日,由中央廣播電視總臺與中國電影電視技術(shù)學(xué)會聯(lián)合牽頭組建的NVI技術(shù)創(chuàng)新聯(lián)盟在BIRTV2024超高清全產(chǎn)業(yè)鏈發(fā)展研討會上宣布正式成立。 活動現(xiàn)場 NVI技術(shù)創(chuàng)新聯(lián)...

關(guān)鍵字: VI 傳輸協(xié)議 音頻 BSP

北京2024年8月27日 /美通社/ -- 在8月23日舉辦的2024年長三角生態(tài)綠色一體化發(fā)展示范區(qū)聯(lián)合招商會上,軟通動力信息技術(shù)(集團(tuán))股份有限公司(以下簡稱"軟通動力")與長三角投資(上海)有限...

關(guān)鍵字: BSP 信息技術(shù)
關(guān)閉
關(guān)閉