STLink Gnuk is not getting detected

NIIBE Yutaka gniibe at fsij.org
Fri Oct 18 03:50:00 CEST 2024


Hello,

# Note: I have been learning Chinese for years by a radio program in
# Japan and I think that I can read some technical documents in Chinese,
# but my Chinese skill is quite limited.

The MH2103A chip is new to me.  I learned that it's a variant (or alias)
of AIR32F103.

I found this repo for the chip:

    https://github.com/IOsetting/air32f103-template

Also, I found another repo (in Chinese):

    https://github.com/SoCXin/MH32F103A

Abhijith PA <abhijith at disroot.org> wrote:
> Sorry, I have no experience with inspecting physical hardware and identifying
> components. My device look exactly like this.

Thank you for the photo.

It seems that it's exactly the case (of USB-DP pull-up); I found an
explanation in this wiki (in Chinese):

    https://wiki.luatos.com/chips/air32f103/enhancement.html

USB-DP 1.5k ohm pull-up resistor is supported internally, as an
enhancement of the chip, so no extra external care is needed with the
chip.  It's a great enhancement, but when it's used, software-wise, it's
incompatible.  (If this new feature is not used, and the board still
keeps 1.5k ohm pull-up resistor, then software could be compatible.)

So, Gnuk requires a change to support boards with MH32F103A, if the
board in qustion takes advantage of the enhancement.

In the file:

    air32f103-template/Libraries/AIR32_USB-FS-Device_Driver/inc/use_regs.h

We can find a (new; not in original STM32F103) register, named DP_PUUP.
This should be initizlized by one.

We can find an example of use case of DP_PUUP:

    air32f103-template/Examples/NonFreeRTOS/USB/Virtual_COM_Port/main.c

Also, I found this document (in Chinese):

    https://wiki.luatos.com/chips/air32f103/switchFromSxx.html#usb

It explains that the interrupt handling in USB driver should be modified
for AIR32F103.  However, in the file, we can't find any modification:

    air32f103-template/Libraries/AIR32_USB-FS-Device_Driver/src/usb_int.c

So, I guess that it would be a problem for some version(s) of AIR32F103,
and it would be OK for other versions.

Attached is a highly experimental patch for Chopstx.  If it works, we
are lucky.

-- 

diff --git a/mcu/usb-st-common.c b/mcu/usb-st-common.c
index 58fe4fc..a9c43a1 100644
--- a/mcu/usb-st-common.c
+++ b/mcu/usb-st-common.c
@@ -37,8 +37,10 @@ struct USB {
   volatile uint16_t reserved2;
   volatile uint16_t DADDR;	/* Device address register */
   volatile uint16_t reserved3;
-  volatile uint16_t BTABLE;	/* Buffer Table address register */
+  volatile uint16_t BTABLE;     /* Buffer Table address register */
   volatile uint16_t reserved4;
+  volatile uint16_t DP_PULL_UP; /* DP Pull-up register found in some chips */
+  volatile uint16_t reserved5;
 };
 
 static struct USB *const USB = (struct USB *)REG_BASE;
@@ -240,6 +242,8 @@ usb_lld_init (struct usb_dev *dev, uint8_t feature)
   USB->BTABLE = 0;
   USB->CNTR = (CNTR_CTRM | CNTR_OVRM | CNTR_ERRM
 	       | CNTR_WKUPM | CNTR_SUSPM | CNTR_RESETM);
+  /* Experiment: does it work with  MH2103A? */
+  USB->DP_PULL_UP = 1;
 }
 
 void



More information about the Gnuk-users mailing list