2020-07-14 08:58 AM
2020-07-14 01:05 PM
As predecesors says: It makes (almost) no sense to study USB (or any other protocols) from assembly language for specific CPU/microcontroller. But If you really want this:
I'm using gcc suite for building of projects, and there is a tool/binary named objdump, which is able disasembly of binary target and part of Makefile looks like:
#######################################
# binaries
#######################################
BINPATH = /opt/arm-tools/arm-none-eabi/bin
PREFIX = arm-none-eabi-
CC = $(BINPATH)/$(PREFIX)gcc
AS = $(BINPATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(BINPATH)/$(PREFIX)objcopy
AR = $(BINPATH)/$(PREFIX)ar
SZ = $(BINPATH)/$(PREFIX)size
OBJDUMP = $(BINPATH)/$(PREFIX)objdump
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
...
$(BUILD_DIR)/$(TARGET).uasm: $(BUILD_DIR)/$(TARGET).elf Makefile.linux
$(OBJDUMP) -d $(BUILD_DIR)/$(TARGET).elf > $@
And result looks like (this is non related to USB_HID but USB_CDC/Serial Comm port)
08004380 <MX_USB_DEVICE_Init>:
8004380: b510 push {r4, lr}
8004382: 4c09 ldr r4, [pc, #36] ; (80043a8 <MX_USB_DEVICE_Init+0x28>)
8004384: 2200 movs r2, #0
8004386: 4909 ldr r1, [pc, #36] ; (80043ac <MX_USB_DEVICE_Init+0x2c>)
8004388: 4620 mov r0, r4
800438a: f004 fe1c bl 8008fc6 <USBD_Init>
800438e: 4908 ldr r1, [pc, #32] ; (80043b0 <MX_USB_DEVICE_Init+0x30>)
8004390: 4620 mov r0, r4
8004392: f004 fe2d bl 8008ff0 <USBD_RegisterClass>
8004396: 4620 mov r0, r4
8004398: 4906 ldr r1, [pc, #24] ; (80043b4 <MX_USB_DEVICE_Init+0x34>)
800439a: f004 fc40 bl 8008c1e <USBD_CDC_RegisterInterface>
800439e: 4620 mov r0, r4
80043a0: e8bd 4010 ldmia.w sp!, {r4, lr}
80043a4: f004 be2b b.w 8008ffe <USBD_Start>
2020-07-14 09:43 AM
coding USB in assembly language seems like a bad choice. There are usb examples in the cube repositories.
2020-07-14 09:54 AM
Thanks for your opinon.
i know but i want to do with assembly language because i want to learn everything about usb hid.
Just i need, hid signature with assembly language for windows.
2020-07-14 10:13 AM
Ok, so what's stopping you reviewing the register level implementation, docs on HID classes (irrespective of the STM32), the C code, or disassembly thereof, and then coding in whatever language you want.
The learning here can be done via "doing" rather than "showing"
The mechanics of the hardware, interrupts and descriptors really isn't going to be any different.
2020-07-14 10:36 AM
Thanks for reply.
But i want to make that with assembly.
Can i convert c program to assembly program ?
Or
How can i learn the protocol ?
2020-07-14 12:05 PM
Just i could not do this , How can i do this with assembly language ?
2020-07-14 01:05 PM
As predecesors says: It makes (almost) no sense to study USB (or any other protocols) from assembly language for specific CPU/microcontroller. But If you really want this:
I'm using gcc suite for building of projects, and there is a tool/binary named objdump, which is able disasembly of binary target and part of Makefile looks like:
#######################################
# binaries
#######################################
BINPATH = /opt/arm-tools/arm-none-eabi/bin
PREFIX = arm-none-eabi-
CC = $(BINPATH)/$(PREFIX)gcc
AS = $(BINPATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(BINPATH)/$(PREFIX)objcopy
AR = $(BINPATH)/$(PREFIX)ar
SZ = $(BINPATH)/$(PREFIX)size
OBJDUMP = $(BINPATH)/$(PREFIX)objdump
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
...
$(BUILD_DIR)/$(TARGET).uasm: $(BUILD_DIR)/$(TARGET).elf Makefile.linux
$(OBJDUMP) -d $(BUILD_DIR)/$(TARGET).elf > $@
And result looks like (this is non related to USB_HID but USB_CDC/Serial Comm port)
08004380 <MX_USB_DEVICE_Init>:
8004380: b510 push {r4, lr}
8004382: 4c09 ldr r4, [pc, #36] ; (80043a8 <MX_USB_DEVICE_Init+0x28>)
8004384: 2200 movs r2, #0
8004386: 4909 ldr r1, [pc, #36] ; (80043ac <MX_USB_DEVICE_Init+0x2c>)
8004388: 4620 mov r0, r4
800438a: f004 fe1c bl 8008fc6 <USBD_Init>
800438e: 4908 ldr r1, [pc, #32] ; (80043b0 <MX_USB_DEVICE_Init+0x30>)
8004390: 4620 mov r0, r4
8004392: f004 fe2d bl 8008ff0 <USBD_RegisterClass>
8004396: 4620 mov r0, r4
8004398: 4906 ldr r1, [pc, #24] ; (80043b4 <MX_USB_DEVICE_Init+0x34>)
800439a: f004 fc40 bl 8008c1e <USBD_CDC_RegisterInterface>
800439e: 4620 mov r0, r4
80043a0: e8bd 4010 ldmia.w sp!, {r4, lr}
80043a4: f004 be2b b.w 8008ffe <USBD_Start>
2020-07-14 01:39 PM
Thanks for reply.
Unfortunately, i can't download uvison and stmcube now but i will try.
Is there another way to learn protocol?
2020-07-14 11:41 PM
https://stm32f4-discovery.net/2014/09/library-34-stm32f4-usb-hid-device/
I will try to make this library with assembly language.
2020-07-15 06:35 AM