Recent

Author Topic: Getting a USB stack to work on STM32  (Read 7104 times)

Laksen

  • Hero Member
  • *****
  • Posts: 794
    • J-Software
Re: Getting a USB stack to work on STM32
« Reply #15 on: February 10, 2021, 01:52:23 pm »
The old code would trigger zero length bulk TX writes all the time which would make the OS hammer the device. The requests coming when you open the port are also expected

But I would not recommend wasting time with the old code. It had an unknown number of bugs in it and will be deleted soon :)

petex

  • Jr. Member
  • **
  • Posts: 93
Re: Getting a USB stack to work on STM32
« Reply #16 on: February 10, 2021, 03:30:54 pm »
that's exactly it. Which module has the bug ? - not wishing to abandon work so far......
I copied your latest usbhal module.

petex

  • Jr. Member
  • **
  • Posts: 93
Re: Getting a USB stack to work on STM32
« Reply #17 on: February 10, 2021, 06:47:26 pm »
I am getting a problem getting your code to compile

in simpleusb_cdc
Code: Pascal  [Select][+][-]
  1.   fConfigCallback:=fDevice^.AddConfigCallback(ueConfigured, @ DoConfigure);  
  2.  

Quote
simpleusb.pas(751,27) Hint: Found declaration: AddConfigCallback(TUSBConfigEvent;const TSimpleUSBConfigCallback):<procedure variable type of procedure(PSimpleUSBDevice;Byte);StdCall>;
simpleusb_cdc.pas(198,80) Error: Incompatible type for arg no. 2: Got "<procedure variable type of function(PSimpleUSBDevice;Byte;var TUsbControlRequest):<enumeration type>;StdCall>", expected "<procedure variable type of function(PSimpleUSBDevice;Byte;var TUsbControlRequest):<enumeration type> of object;StdCall>"

Laksen

  • Hero Member
  • *****
  • Posts: 794
    • J-Software
Re: Getting a USB stack to work on STM32
« Reply #18 on: February 11, 2021, 12:51:15 am »
I remember having that issue but I can't remember how I fixed it.. How old a compiler are you using?

petex

  • Jr. Member
  • **
  • Posts: 93
Re: Getting a USB stack to work on STM32
« Reply #19 on: February 11, 2021, 10:25:04 am »
its quite recent, the one from the MBF repository. Is it a compiler switch/option needed ?

Laksen

  • Hero Member
  • *****
  • Posts: 794
    • J-Software
Re: Getting a USB stack to work on STM32
« Reply #20 on: February 11, 2021, 11:42:48 am »
It should be fine as is with the directives in the top. Did you modify the source? The line numbers don't seem to match exactly

Also, can you try with newest trunk?

petex

  • Jr. Member
  • **
  • Posts: 93
Re: Getting a USB stack to work on STM32
« Reply #21 on: February 11, 2021, 01:04:32 pm »
Quote
simpleusb_cdc.pas(195,73) Error: Incompatible type for arg no. 2: Got "<procedure variable type of procedure(PSimpleUSBDevice;Byte);StdCall>", expected "<procedure variable type of procedure(PSimpleUSBDevice;Byte) of object;StdCall>"

Code: Pascal  [Select][+][-]
  1.   fConfigCallback:=fDevice^.AddConfigCallback(ueConfigured, @DoConfigure);  
  2.  

Same problem with updated files.
The basic fp examples for delegation work ok with this compiler. You seem to be using some esoteric features here and the compiler is not understanding it. How am i going to use more basic functionality to achieve the same goal ? I don't really care about super encapsulation here.

I just want to get something working here so I can see if it is worth sticking with, otherwise I need to look around for another solution. I have spent a lot of time with the original code.

Modifying the source is a red herring as I played around with some bits of code to investigate the problem.



« Last Edit: February 11, 2021, 01:09:08 pm by petex »

PascalDragon

  • Hero Member
  • *****
  • Posts: 5909
  • Compiler Developer
Re: Getting a USB stack to work on STM32
« Reply #22 on: February 11, 2021, 02:31:50 pm »
Quote
simpleusb_cdc.pas(195,73) Error: Incompatible type for arg no. 2: Got "<procedure variable type of procedure(PSimpleUSBDevice;Byte);StdCall>", expected "<procedure variable type of procedure(PSimpleUSBDevice;Byte) of object;StdCall>"

Code: Pascal  [Select][+][-]
  1.   fConfigCallback:=fDevice^.AddConfigCallback(ueConfigured, @DoConfigure);  
  2.  

Same problem with updated files.
The basic fp examples for delegation work ok with this compiler. You seem to be using some esoteric features here and the compiler is not understanding it. How am i going to use more basic functionality to achieve the same goal ? I don't really care about super encapsulation here.

Do you use a FPC trunk (aka 3.3.1) from at most 7 weeks ago? If not, then there is your problem, cause that's only supported since then.

Laksen

  • Hero Member
  • *****
  • Posts: 794
    • J-Software
Re: Getting a USB stack to work on STM32
« Reply #23 on: February 11, 2021, 02:41:51 pm »
Quote
simpleusb_cdc.pas(195,73) Error: Incompatible type for arg no. 2: Got "<procedure variable type of procedure(PSimpleUSBDevice;Byte);StdCall>", expected "<procedure variable type of procedure(PSimpleUSBDevice;Byte) of object;StdCall>"

Code: Pascal  [Select][+][-]
  1.   fConfigCallback:=fDevice^.AddConfigCallback(ueConfigured, @DoConfigure);  
  2.  

Same problem with updated files.
The basic fp examples for delegation work ok with this compiler. You seem to be using some esoteric features here and the compiler is not understanding it. How am i going to use more basic functionality to achieve the same goal ? I don't really care about super encapsulation here.

Do you use a FPC trunk (aka 3.3.1) from at most 7 weeks ago? If not, then there is your problem, cause that's only supported since then.

Thanks for confirming Sven :) I was frantically looking through my local changes to see if I had forgotten to commit a fix for something

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Getting a USB stack to work on STM32
« Reply #24 on: February 11, 2021, 02:59:43 pm »
Trunk version that I used for building mbf binaries could very well be a little older.

I will see if I can update it to a fresher version of trunk, only problem is that currently building trunk inside of fpcupdeluxe is broken on Mac (which is currently a big issue for me), so I will have to see if I can catch a version that is young enough and still keeps fpcupdeluxe happy.. (Or find a fix for fpcupdeluxe)...

Error when building trunk is:

error: /Library/Developer/CommandLineTools/usr/bin/codesign_allocate: can't create output file: /usr/bin/codesign.cstemp (Operation not permitted)

perhaps that rings a bell for anybody, when I compile trunk in a unix shell things work just fine.

MiR

  • Sr. Member
  • ****
  • Posts: 275
Re: Getting a USB stack to work on STM32
« Reply #25 on: February 11, 2021, 03:30:19 pm »
@Petex:

Can you please try this version:

http://temp.michael-ring.org/fpc-arm-embedded-3.3.1-win64-20210207.zip

simply extract it where your current binaries are, this is trunk from a week or so....

@Laksen:

Do you by chance happen to own a Segger J-Link?

Laksen

  • Hero Member
  • *****
  • Posts: 794
    • J-Software
Re: Getting a USB stack to work on STM32
« Reply #26 on: February 11, 2021, 03:59:42 pm »
@Laksen:

Do you by chance happen to own a Segger J-Link?
Not to my knowledge. Never been a huge segger fan :)
I use a Busblaster v3 for all my jtag needs. Luckily haven't had a need for SWD yet

petex

  • Jr. Member
  • **
  • Posts: 93
Re: Getting a USB stack to work on STM32
« Reply #27 on: February 11, 2021, 05:43:50 pm »
Quote
@Petex:

Can you please try this version:

Ok thanks MiR. That compile error has gone and its all built ok.
So now its a hard slog getting the USB to work!!. I'll keep you posted.

Laksen

  • Hero Member
  • *****
  • Posts: 794
    • J-Software
Re: Getting a USB stack to work on STM32
« Reply #28 on: February 11, 2021, 05:49:15 pm »
Good to hear it compiled at last :)

Just to avoid wasting time, the MSD class driver is pretty broken so you should remove that from the code for now. I accidentally left it in the cdc design. But I've had the CDC running for hours without it breaking (on linux)

petex

  • Jr. Member
  • **
  • Posts: 93
Re: Getting a USB stack to work on STM32
« Reply #29 on: February 11, 2021, 05:55:29 pm »
hello,
I already left that out. I can report that windows has installed it using the generic usbser.sys device driver and the basic loop back test to terminal works.

I now have to adapt smpleusb to my acid test program and see if it performs any better than the original.

 

TinyPortal © 2005-2018