Giter VIP home page Giter VIP logo

bluepill-serial-monster's Introduction

bluepill-serial-monster

bluepill-serial-monster is a firmware for STM32 Blue Pill that turns it into a 3 Port USB-to-Serial adapter. The firmware implements a USB 2.0 full-speed composite device that consists of 3 USB CDC devices.

STM32 Blue Pill is a ridiculously cheap STM32 development board which is available in many stores around the globe. The board contains decent hardware that supports USB 2.0 Full-Speed, has 3 independent USARTs and enough processing power to handle high-speed UART communications.

Note: some Blue Pill clones have an incorrect pull-up resistor soldered to the USB D+ line (PA12) which prevents them from being successfully detected by the host. Please refer to Fixing USB on Blue Pill Boards for more information.

Some USB controllers work fine even with faulty Blue Pill boards. If your board works with your computer, don't bother fixing it.

Features

  • 3 independent UART ports;
  • Hardware flow control (RTS/CTS) support1;
  • DSR/DTR/DCD/RI signals support;
  • 7 or 8 bit word length;
  • None, even, odd parity;
  • 1, 1.5, and 2 stop bits;
  • Works with CDC Class drives on Linux, macOS, and Windows;
  • Supports all baud rates up to 2 MBaud;
  • TXA signal for controlling RS-485 transceivers (DE, /RE);
  • DMA RX/TX for high-speed communications;
  • IDLE line detection for short response time;
  • Signed INF driver for Windows XP, 7, and 8;
  • Built-in command shell for device parameters configuration;
  • No external dependencies other than CMSIS;
  • DFU Bootloaders Compartible (see the FIRMWARE_ORIGIN option);

(1) UART1 does not support CTS because it is occupied by USB (PA11) and cannot be remapped. RTS can still be used.

Donations

If this project helped you with whatever you use it for or you just want to say thanks, you can buy me a coffee :)

"Buy Me A Coffee"

UART Signal Levels

Although STM32F103C8T6 installed on the Blue Pill board is a 3.3 V device, a number of its inputs are actually 5 V tolerant. This means you can safely use the selected inputs with 3.3 and 5 V TTL devices.

Do not use non 5 V tolerant inputs with 5 V devices as doing that will result in permanent damage of MCU inputs or MCU itself.

When configured as an output, none of the STM32F103C8T6 pins is 5 V tolerant. Make sure you don't accidentally get more than 4.0 V on such pin or damage may occur.

5 V tolerant pins are shown in bold in the next section.

UART Pinout

Signal Direction UART1 UART2 UART3
RX IN PA10 PA3 PB11
TX OUT PA9 PA2 PB10
RTS OUT PA15 PA1 PB14
CTS IN N/A PA0 PB13
DSR IN PB7 PB4 PB6
DTR OUT PA4 PA5 PA6
DCD IN PB15 PB8 PB9
RI IN PB3 PB12 PA8
TXA OUT PB0 PB1 PA7

Note: 5 V tolerant input pins are shown in bold.

Control Signals (Default Configuration)

RTS, CTS, DSR, DTR, DCD, RI are active-low signals, TXA is an active-high signal.

TXA (TX Active) is active when UART is transmitting data and can be used to control DE and /RE pins of RS-485 transceivers.

TXA goes inactive within 0.6 us after the transmission is complete, which meets RS-485 and IO-link timing requirements at speeds up to 920 kBaud with almost double safety margin.

DSR, DTR, and DCD, RI are connected to the internal weak pull-up resistors, so they remain inactive at rest.

CTS is pulled down internally, which enables UART TX when nothing is connected to CTS. Hardware flow control is always on, but it does not get in the way of communications as long as nothing is connected to the flow control lines.

RTS can be controlled by the host, but as soon as the UART RX buffer is half-full, RTS is forced to the inactive state. As long as more than one half of the buffer space is available, RTS remains in the state set by the host. Please take this behaviour into account if you rely on the RTS signal to control non-standard periphery.

DSR, DCD, and RI are polled 50 times per second.

UART DMA RX/TX buffer size is 1024 bytes.

Mapping Logical Port Names to Physical Ports

Unfortunately, operating systems ignore CDC port names reported by the firmware. Linux and macOS tend to assign device numbers incrementally so that UART1 gets the lowest and UART3 the highest /dev/ttyACM... (Linux) or /dev/tty.usbmodem... (macOS) numbers. On the other hand, Windows can get pretty creative when assigning COM port numbers to USB CDC devices.

To find out which physical UART corresponds to a particular COM port on Windows, open Device Manager, right click on the COM port under Ports (COM & LPT), and choose Properties. Open the Details tab and select the Bus reported device description property. The Value field will indicate the physical UART name.

Windows Usbser.sys RTS Bug

All versions of Windows have a bug in the USB CDC system driver (usbser.sys) that affects RTS signal handling.

The driver does not send USB SET_CONTROL_LINE_STATE messages when the RTS state changes. However, on the DTR state change, the driver sends a SET_CONTROL_LINE_STATE message containing the updated states for both RTS and DTR signals.

It is unknown why usbser.sys does this, but the disassembled code of the driver suggests that sending SET_CONTROL_LINE_STATE on RTS change is simply left out by mistake. It looks like Microsoft is not going to fix this bug. However, it can be easily worked around.

The workaround for this bug is to update DTR (even to the same state) each time RTS needs to be updated as in the example below:

#include <windows.h>
#include <stdio.h>

int main() {
    HANDLE hComm = CreateFileA("\\\\.\\COM5", GENERIC_READ | GENERIC_WRITE,
        0, NULL, OPEN_EXISTING, 0, NULL);
    if (hComm == INVALID_HANDLE_VALUE) {
        printf("Error opening serial port\n");
    } else {
        printf("Serial port opened\n");
    }
    while (1) {
        // I don't know any easy (and reliable) way to get current DTR state in WinAPI unfortunately.
        // Probably the simplest solution is to keep current DTR value in a variable.
        EscapeCommFunction(hComm, SETRTS);
        EscapeCommFunction(hComm, CLRDTR); // or SETDTR, does not matter
        (void)getc(stdin);
        EscapeCommFunction(hComm, CLRRTS);
        EscapeCommFunction(hComm, CLRDTR); // or SETDTR, does not matter
        (void)getc(stdin);
    }
    CloseHandle(hComm);
    return 0;
}

Some existing software already does that. CwType, Win-Test, CoolTerm are the examples of such software. Others like N1MM Logger Plus or Termite do not implement the workaround.

The RTS issue does not affect Linux or macOS.

Unexpected Echo or Garbage Characters in Linux

Linux terminal subsystem echoes characters coming from a bluepill-serial-monster port back to this port until it is switched to the raw more (see man 3 cfmakeraw).

This behaviour is Linux-specific and is not related to bluepill-serial-monster itself. See this Stack Overflow post for details.

Usually, this is not an issue; however, it may lead to garbage characters appearing when the configuration shell is started. For instance, if PA5 is tied to the ground when bluepill-serial-monster is plugged in, the device sends the configuration mode banner to the host. The host echoes the content of the banner back to the device, which in turn tries to parse it as if it was a sequence of configuration shell commands. When screen or another terminal emulation software is started, its output may contain garbage characters left due to the above exchange.

Advanced Configuration

bluepill-serial-monster provides a configuration shell that allows controlling various parameters of the UART signal lines.

To access the configuration shell, open the first USB serial port (UART1) with any terminal emulator application (such as screen, Tera Term, etc.) and connect PB5 to ground. Serial port settings do not matter.

You should see the configuration shell prompt:

*******************************
* Configuration Shell Started *
*******************************

>

The configuration shell has minimal support for ANSI escape sequences. You can use the arrow keys to move the cursor when editing a command, erase text with Backspace, and insert text anywhere in the command. You can also recall the last command by pressing UP.

Command and parameter names are case-sensitive.

To get the list of available commands, type:

>help

To get command-specific help, type:

>help command-name

UART Port Parameters

UART port parameters can be viewed and set with the uart command:

>help uart
uart: set and view UART parameters
Usage: uart port-number|all show|signal-name-1 param-1 value-1 ... [param-n value-n] [signal-name-2 ...]
Use "uart port-number|all show" to view current UART configuration.
Use "uart port-number|all signal-name-1 param-1 value-1 ... [param-n value-n] [signal-name-2 ...]"
to set UART parameters, where signal names are rx, tx, rts, cts, dsr, dtr, dcd,
and params are:
  output        [pp|od]
  active        [low|high]
  pull          [floating|up|down]
Example: "uart 1 tx output od" sets UART1 TX output type to open-drain
Example: "uart 3 rts active high dcd active high pull down" allows to set multiple parameters at once.

Changes to the UART parameters are applied instantly; however, the configuration is not stored in the flash memory until you explicitly save it with:

>config save

To view current configuration of all UART ports, type:

>uart all show

To view current configuration of a particular UART port, type:

>uart port-number show

where port-number is in range of 1 to 3.

Output type can be set for any output signal. Available output types are:

  • pp for push-pull output;
  • od for open-drain output;

Example:

uart 1 tx output od

Pull type can be set for any input signal. Available pull types are:

  • floating for floating input;
  • up for weak pull up;
  • down for weak pull down;

Example:

uart 1 dcd pull up

Signal polarity can be set for all input and output signals except for RX, TX, and CTS. Available signal polarities are:

  • low for active-low signal polarity;
  • high for active-high signal polarity;

Example:

uart 1 rts active high

It is possible to set multiple signal parameters for multiple signals in one command:

uart 1 tx output od rts output od active high

If the uart command encounters a syntax error or an invalid parameter in the middle of a multiple parameters command line, it stops execution immediately. However, it does not roll back valid parameters set before the point where the error occured.

It is also possible to set signal parameters for multiple ports in one command:

uart all tx output od

Saving and Resetting Configuration

To permanently save current device configuration, type:

config save

To reset the device to the default settings, type:

config reset

Printing the Firmware Version

To print the firmware version, type:

version

The default configuration is automatically stored in the flash memory after reset.

Flashing Firmware

Download binary firmware from the Releases page.

Flash with ST-LINK or similar programmer.

st-flash --format ihex write bluepill-serial-monster.hex

It is also possible to flash STM32F103C8T6 via a built-in serial bootloader. Visit https://www.st.com/en/development-tools/flasher-stm32.html for instructions and software.

You can also use bluepill-serial-monster-stm32duino-0x8002000.bin or bluepill-serial-monster-stm32duino-0x8005000.bin with STM32duino-bootloader and dfu-util.

Windows Driver (WinXP, 7, 8)

Windows versions prior to Windows 10 require an INF file that maps the device Vendor ID / Product ID to the Microsoft usbser.sys CDC ACM driver. Windows 10 does not require this and loads the standard driver automatically.

A signed INF file for Windows XP, 7, and 8 is included in the distribution. To install the INF file, plug in bluepill-serial-monster and point Windows to a directory containing both bluepill-serial-monster.inf and bluepill-serial-monster.cat files during a new device installation.

Alternatively, you can open Windows Device Manager, right-click on any of the Bluepill Serial Monster devices, choose Update driver and point Windows to the INF file directory from there.

Fixing USB on Blue Pill Boards

STM32 Blue Pill boards come in slightly different variations. Nevertheless, their schematic is very similar. Below you will find the instructions on how to identify and replace the incorrect USB pull-up resistor on any Blue Pill board.

With a digital multimeter, measure resistance between PA12 and 3.3 V pads on the board. If the resistance reads close to 1.5k (1500 ohms), then your board is either non-faulty or faulty for some other reason, and this section does not apply.

If the resistance if far away from 1.5k (such as 4.7k or 10k), you will have to locate the incorrect resistor on the board and replace it with a 1.5k or 1.8k resistor.

If your board has component names on it, locate R10. Otherwise, trace the board to find the incorrect resistor.

Once you identified the incorrect resistor, replace it with a 1.5k or 1.8k resistor.

Building Firmware

Prerequisites

Install the following software:

Here is an example assuming everything is installed in ~/stm32/, and we use bash:

ARM toolchain and st-link must be added to PATH.

# add ARM toolchain path
export PATH=~/stm32/gcc-arm-none-eabi/bin:$PATH
# add stlink path
export PATH=~/stm32/stlink-install/bin:$PATH

Path to STM32CubeF1 should be also exported (use ~/.bash_profile):

# export STM32Cube
export STM32CUBE_PATH=~/stm32/stm32cube

Building

To build the firmware, cd to the project directory and run

make

To flash the MCU using st-link, run

make flash

To remove object and dependency files, run

make clean

To remove object, dependency, and firmware files, run

make distclean

Building for DFU Bootloaders

DFU bootloaders generally require the firmware origin to be relocated to a higher flash address to allow room for the bootloader itself. The bootloader documentation should specify the firmware upload address. By default, bluepill-serial-monster firmware starts at flash origin (0x8000000). To move the firmware to a custom address, use the FIRMWARE_ORIGIN Makefile variable:

make clean && make FIRMWARE_ORIGIN=0xXXXXXXXX

where 0xXXXXXXXX is the required firmware start address.

The firmware release package already includes two prebuilt binaries for use with STM32duino-bootloader.

bluepill-serial-monster's People

Contributors

cyrozap avatar r2axz avatar vnodeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bluepill-serial-monster's Issues

CDC ZLP May Be Sent When BULK IN Endpoint Is Not Ready

Code does not check is CDC BULK IN endpoint is ready to transmit before sending ZLP packets. This leads to RX data corruption. Surprisingly, nobody reported this behavior, but this issue is very visible when doing stress tests.

usb_send does not take into account usb_endpoints[ep_num].tx_size

size_t usb_send(uint8_t ep_num, const void *buf, size_t count) {
    ep_reg_t *ep_reg = ep_regs(ep_num);
    usb_pbuffer_data_t *ep_buf = (usb_pbuffer_data_t *)(USB_PMAADDR + (usb_btable[ep_num].tx_offset<<1));
    pb_word_t *buf_p = (pb_word_t*)buf;
    pb_word_t words_left  = count >> 1;
    size_t tx_space_available = usb_endpoints[ep_num].tx_size;
    if (count > tx_space_available) {
        count = tx_space_available;
    }
    while (words_left--) {
        (ep_buf++)->data = *buf_p++;
    }
    if (count & 0x01) {
        (ep_buf)->data = (uint8_t)*buf_p;
    }
    usb_btable[ep_num].tx_count = count;
    *ep_reg = ((*ep_reg ^ USB_EP_TX_VALID) & (USB_EPREG_MASK | USB_EPTX_STAT)) | (USB_EP_CTR_RX | USB_EP_CTR_TX);
    return count;
}

words_left is initialized before count > tx_space_available check, which leads to writing past the ep tx buffer. Surprisingly, this does not cause any major problems because usb_send is mostly used during the device USB enumeration phase and its circular buffer sibling (usb_circ_buf_send) does not have this issue.

Add binary file to project

Please create a release and upload the compiled firmware in .bin or .hex format.
You do not always want to build a project to get a binary.

Feature request: Add support for SendBreak requests

From the spec:

This request sends special carrier modulation that generates an RS-232 style break.

The wValue field contains the length of time, in milliseconds, of the break signal. If wValue contains a
value of FFFFh, then the device will send a break until another SendBreak request is received with the
wValue of 0000h.

The code that follows is my hacky attempt at implementing the functionality. I call it "hacky" because I used a loop to implement the delay time (which IIRC isn't accurate at all--I don't remember exactly because it's been almost 18 months since I last worked on this), and the pin mode change involves using memcpy to clone the old TX pin configuration, change it to GPIO, and then use the modified configuration to re-init the pin. Also, I'm not sure if it's a good idea to handle the delay inside the USB control endpoint event handler, since the delay can in theory be up to 65.534 seconds long. Also, now that I've thought about this more, if the delay was done outside of the event handler, what should be done if an indefinite SendBreak is sent, and then TX data is sent? Since the break is just holding the TX line low, if that data was transmitted during that time it would all be lost.

If anyone knows a better way to implement this, please let me know.

diff --git a/usb_cdc.c b/usb_cdc.c
index b48f4b5..300466c 100644
--- a/usb_cdc.c
+++ b/usb_cdc.c
@@ -241,6 +241,27 @@ static void usb_cdc_set_port_txa(int port, int txa_active) {
     }
 }
 
+static usb_status_t usb_cdc_send_break(int port, uint16_t duration_ms) {
+    if (port < USB_CDC_NUM_PORTS) {
+        const gpio_pin_t *tx_pin = &device_config_get()->cdc_config.port_config[port].pins[cdc_pin_tx];
+        if (duration_ms != 0) {
+            gpio_pin_t tx_pin_new = { 0 };
+            memcpy(&tx_pin_new, tx_pin, sizeof(gpio_pin_t));
+            tx_pin_new.func = gpio_func_general;
+            gpio_pin_init(&tx_pin_new);
+            gpio_pin_set(tx_pin, 0);
+        }
+        if (duration_ms != 0xffff) {
+            for (int i=0; i < 8000*duration_ms; i++) {
+                __NOP();
+            }
+            gpio_pin_set(tx_pin, 1);
+            gpio_pin_init(tx_pin);
+        }
+    }
+    return usb_status_ack;
+}
+
 static usb_status_t usb_cdc_set_control_line_state(int port, uint16_t state) {
     usb_cdc_set_port_dtr(port, (state & USB_CDC_CONTROL_LINE_STATE_DTR_MASK));
     usb_cdc_set_port_rts(port, (state & USB_CDC_CONTROL_LINE_STATE_RTS_MASK));
@@ -741,6 +762,8 @@ usb_status_t usb_cdc_ctrl_process_request(usb_setup_t *setup, void **payload,
                     return usb_status_ack;
                 }
                 break;
+            case usb_cdc_request_send_break:
+                return usb_cdc_send_break(port, setup->wValue);
             default:
                 ;
             }
diff --git a/usb_cdc.h b/usb_cdc.h
index c37bc7c..86b01eb 100644
--- a/usb_cdc.h
+++ b/usb_cdc.h
@@ -42,7 +42,7 @@ typedef enum {
 #define USB_CDC_ACM_CAPABILITY_SEND_BREAK           0x04
 #define USB_CDC_ACM_CAPABILITY_NETWORK_CONNECTION   0x08
 
-#define USB_CDC_ACM_CAPABILITIES (USB_CDC_ACM_CAPABILITY_LINE_CODING)
+#define USB_CDC_ACM_CAPABILITIES (USB_CDC_ACM_CAPABILITY_SEND_BREAK | USB_CDC_ACM_CAPABILITY_LINE_CODING)
 
 /* USB CDC Header Functional Descriptor */
 

Garbage data on config console after reset

To reproduce: connect PB5 to GND and connect the USB cable. Open a screen session to the first serial port, observe some garbage data, no banner:

  *ed
Error, unknown command, use "help" to get the list of available commands.
>
>Ee    eree

This is reliably reproducible in my setup. Hitting enter does bring up the command prompt and the console can be used normally, the problem is just the garbage data at the beginning. Reproduces with main and r2axz-re-enumerate-on-reset.

Works OK if PB5 is connected to GND after the board has booted up and enumerated on the USB bus.

Suggestion: Blackpill support?

Its my understanding that the two chips are pretty close together in features and capabilities.
Would be fun to extend this to support both, if possible.

Probably erroneous usb_endpoint_address_cdc_0_interrupt usage

The usb_descriptors.c file at line 333 refers to the usb_endpoints parameters array via usb_endpoint_address_cdc_0_interrupt constant, which is a bit suspicious because this is done in the descriptor of third UART. This doesn't affect current functionality because parameters of control endpoints happens to match, but introduces minor inconsistency.

.inf file

Tested on W7 and W8. It seems, driver .inf file is necessary to extend usable OS range.
Thank you
Tadas LY1CE

Possible buffer overflow in the 7-bits data mode

The code in the usb_cdc.c:usb_cdc_port_send_rx_usb() function looks a little bit suspicious: in the 7-bits data mode it clears MSB of received data in the circular buffer treating it as linear buffer. Since the amount of affected bytes calculated as total number of bytes stored, this may lead buf_ptr pointer to run out of circular buffer bounds.

[info] communication with device powered at 5V

Sorry for my newbie question, I'm not electrical engineer.
From README

When configured as an output, none of the STM32F103C8T6 pins is 5 V tolerant. Make sure you don't accidentally get more than 4.0 V on such pin or damage may occur.

If I connect TX of BluePill to pin RX of a device powered at 5V, can I broken the STM32F103C8T6? RX should be high impedance or doesn't matter?
Other connection should be ok because RX on bluepill is 5V tolerant except for UART2.

I used bluepill for serialudpi where RX and TX are shorted with a resistor and a diode.
I powered the MCU at 3.3V and works no damage, but if I power the MCU at 5V damage may occur?

Windows compilation

All this of course is very good, but is there a way to compile it in Windows, preferable with known instruments: Cube, Keil, IAR...?

Reset of the MCU doesn't cause USB device re-enumeration

Maybe I'm doing something wrong, but while toying with the project I noticed that if I hit the reset button on the pill the host doesn't notice anything has happened. I have to pull the USB cable out to see the "USB disconnect" event in the kernel log. I don't have an STLink or other power source connected, bluepill is powered over the USB connector.

This is on linux 5.13.6. Everything else works fine otherwise.

73 de LZ1CK

Dude you ROCK!

where can I donate??!!
Seriously I've been head banging for weeks... trying to get a working USB-UART bridge, given that CH340g board seems to have electrical problems thus garbling all its TX, and replacement FT2232 is a long way from arriving.

I've tried other projects, only to find that the buffers overrun after 30 bytes. I tried myself, but gave up short of figuring out how to read the dtr/rts pins from USB (which is the whole point). Then I finally got your binary flashed. It didn't work the first time, so I lost several days, until I realized my stm32f103c8t6 boards (11 in total), were a mix of various clones. 5 were secretely stm32f103c6, and 3 were 128kb variants, and almost every one had its own set of codes printed on the MCU chip itself. I finally figured out which was vanilla, and now it works like charm!

Technically, so satisfy the category of "issues" (so nobody bites my head off), I'd like to mention its important to disconnect the ST-Link before testing the board, otherwise the LED will blink, but still no communication will happen. That one almost made me give up at the last breath.

LED indication enchancement

My 50 cents for improve User eXperience with Serial Monster:
As I can see in current moment Serial Monster used single LED to tell us any activity on UART ports (TX&RX).

I find very useful to use the second LED to help us to separating activity indication, e.g.:

  • LED1 - any TX activity on UART ports
  • LED2 - any RX activity on UART ports

To make accessability of second LED (by default use as POWER LED) we should move corresponding resistor.

So, LED1 already available on PC13 pin, and LED2 will be available on PC14 pin (in proposed setup).

Here is my example to moving resistor:

IMG_3877

IMG_3878

Hope this HW mod will be easy and useful for most Serial Monster's users.

Remove the existing clang format

.clang-format is not currently used by this project. What's worse, it does not match the existing coding style, which confuses those who try to use it. I believe it should be removed for now and possibly re-introduced later, when I figure out how to make the one that matches my coding style.

Recommended version of gcc-arm-none-eabi for building FW

What is your experience to building project with various versions of gcc-arm-none-eabi?

I tried gcc-arm-none-eabi-10-2020-q4-major and have some warnings:

usb_cdc.c: In function 'usb_cdc_port_start_tx':
usb_cdc.c:447:41: warning: array subscript '<unknown>' is outside the bounds of an interior zero-length array 'uint8_t[0]' {aka 'unsigned char[]'} [-Wzero-length-bounds]
  447 |             dma_tx_ch->CMAR = (uint32_t)&tx_buf->data[tx_buf->tail];
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from usb_cdc.c:10:
circ_buf.h:15:13: note: while referencing 'data'
   15 |     uint8_t data[0];
      |             ^~~~
usb_cdc.c: In function 'DMA1_Channel4_IRQHandler':
usb_cdc.c:447:41: warning: array subscript '<unknown>' is outside the bounds of an interior zero-length array 'uint8_t[0]' {aka 'unsigned char[]'} [-Wzero-length-bounds]
  447 |             dma_tx_ch->CMAR = (uint32_t)&tx_buf->data[tx_buf->tail];
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from usb_cdc.c:10:
circ_buf.h:15:13: note: while referencing 'data'
   15 |     uint8_t data[0];
      |             ^~~~
usb_cdc.c: In function 'DMA1_Channel7_IRQHandler':
usb_cdc.c:447:41: warning: array subscript '<unknown>' is outside the bounds of an interior zero-length array 'uint8_t[0]' {aka 'unsigned char[]'} [-Wzero-length-bounds]
  447 |             dma_tx_ch->CMAR = (uint32_t)&tx_buf->data[tx_buf->tail];
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from usb_cdc.c:10:
circ_buf.h:15:13: note: while referencing 'data'
   15 |     uint8_t data[0];
      |             ^~~~
usb_cdc.c: In function 'DMA1_Channel2_IRQHandler':
usb_cdc.c:447:41: warning: array subscript '<unknown>' is outside the bounds of an interior zero-length array 'uint8_t[0]' {aka 'unsigned char[]'} [-Wzero-length-bounds]
  447 |             dma_tx_ch->CMAR = (uint32_t)&tx_buf->data[tx_buf->tail];
      |                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from usb_cdc.c:10:
circ_buf.h:15:13: note: while referencing 'data'
   15 |     uint8_t data[0];
      |             ^~~~
usb_cdc.c: In function 'usb_cdc_poll':
usb_cdc.c:331:36: warning: array subscript '<unknown>' is outside the bounds of an interior zero-length array 'uint8_t[0]' {aka 'unsigned char[]'} [-Wzero-length-bounds]
  331 |                 uint8_t *buf_ptr = &rx_buf->data[rx_buf->tail];
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from usb_cdc.c:10:
circ_buf.h:15:13: note: while referencing 'data'
   15 |     uint8_t data[0];
      |             ^~~~

Screenshot from 2021-07-13 18-35-35

Maybe exists version of gcc-arm-none-eabi which works fine w/o these warnings?

[enhancement] virtual COM for config purposes

Hi and thanks for that great work.

It seems nice to have fourth COM port (virtual UART) for configuration purposes instead of jumper manipulation with PB5 pin.
The 4th COM doesn't required custom resources (like bandtwidth or latency) - will not affected to performance of remaining three UARTs.

Happy hacking!

Pull request for easier build and support maple mini

Hi, I cloned the repo locally and did slight modifications on the device config to enable some more features :

  • use platformio and vscode to automate build without all pre-install requirements ( basically create a platformio.ini file and vscode plugin takes care of the rest )
  • support maple mini with auto-enumeration ( adapt pin's in device config )
  • https://stm32duinoforum.com/forum/wiki_subdomain/index_title_Maple_Mini.html
  • debug via vscode and platformio ( adapt launch.json for .vscode )
    However I have no experience in how to create a pull request or I don't have enough access to push a proposal branch.
    How do I proceed to push this code ?
    Regards
    Lieven

[info] max baud rate

what is the maximum baud rate you have achieved on a uart?
I would like to avoid buying an expensive ftdi ft232h.

Thank you

RTS software control

RTS can operate only by hardware ? CwType, for example, need both RTS and DTR software controled

Проблема с работой с одним из устройств, может какие настройки?

Здравствуйте. Я вообще, на самом деле, не очень разбираюсь в теме работы с последовательным портом, определенно понимаю немного, потому может задаю тупой вопрос:
хочу использовать устройство для создания игрового устройства, которое использует 2 UART порта для связи с игрой Hatsune Miku Project Diva Arcade Future Tone и к Blue Pill подключается два устройсва, одно Arduino Micro, чтоб была возможность использования прерываний по последовательному порту, а второе плата на основе микроконтроллера Cypress cy8c4246azi-m445, с помощью которой работает сенсорная панель по последовательному порту (вот этот проект https://github.com/Project-Alpaca/LKP ) . Проблема в том, что по отдельности все проверенно работает, с STM32 Arduino работает без проблем, точно также как и плата сенсорной панели рабоатает без проблем с USB-TTL конвертером на основе CP2102, а вот при подключении к STM32 сенсорная панель определяется, но по сути не работает, ибо отзыв получается неверноятно медленно, раз в 5 секунд может быть. Я думал, что может быть проблема в UART, пробовал переключать между 1 и 3 портами (устройство работает от 5В, так что тут мне доступны только 1 и 3 порты, правильно?), также пробовал все предыдущие версии прошивок вплоть до 2.0, чтоб проверить, не временная ли это ошибка? Для подключения используется только RX/TX пины, ну и питание соответственно. Может доступные какие-то еще настройки или что-то в этом роде, потому что, как я уже писал, через CP2102 работает безукоризненно, потому не ожидал, что столкнусь с проблемами. На что обратить внимание? Заранее спасибо :)

[FR] Invert RX TX

Hi,
is it possible to add to configuration option to invert RX and TX or there is hardware limitation?

Advanced option for Pull-Up resistor value changing

Hi
Currently Pull-Up resistor is 1KΩ(?) and unchangeable, which I found is too small for receiving signals from some weak open-drain output.

In my case, I used the bluepill with another board with max 50mA output current. When the baud rate is 920k the bluepill can't receive message correctly. The current for switching from 0 to 1 is too big to finish ​in 1/920k second.

Finally I solved this issue by disabling the PU and put a external 10K PU.

Hope there will be an advanced option for changing PU value

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.