Serasidis / STM32_HID_Bootloader

Driverless USB HID bootloader and flashing tool for STM32F10X devices
396 stars 148 forks source link

Blue pills code looping on procedure return #40

Open rromano001 opened 3 years ago

rromano001 commented 3 years ago

Hello, I am not an Arduino user and lack of debugger is a terrific issue. I loaded a test program from web, https://maker.pro/arduino/projects/simple-fm-radio-receiver-with-arduino-uno-and-rda5807m loaded doesn't work as is. Adapting got some time to isolate where is stuck. Code is quite noobs and seems modified from other sources but issue come from library or bootloader. Need spread a lot of wait time on setup around serial communication directive before use them. At final code stuck at wire communication, procedure never return and loop as stack got corrupted, reenter procedure? No debugger no idea what happen... Arduino IDE is just a time wasting. changed key selector from analog to digital, added timeout on exit. stuck on status read where never return back to main loop. Code run enter exit setup, enter loop but stuck here: if(( millis()-time2)>50) { Serial.print("Pre StatRD"); <<-- execute this ReadEstado(); <<-- stuck here (stack fault?) Serial.println("Post StatRD"); <<--- Never execute this line after enter previous line procedure. Procedure continue loop itself

init ok sensor = 98 Post butt Millis=2963 Time=2912 Time1=2912 Time2=2912 Time3=2912 Pre StatRDReqfrom for Loop after for End proc readST Reqfrom for Loop after for End proc readST Reqfrom for Loop after for End proc readST Reqfrom for Loop after for End proc readST Reqfrom for Loop after for End proc readST Reqfrom for Loop after for End proc readST Reqfrom for Loop after for End proc readST Reqfrom for Loop after for End proc readST

2 3 second hang, stack overlow? Reqfrom for Loop after for End proc readST Reqfrom for Loop after for End proc readST Reqfrom

rdatest.ino.zip

got similar issue from rf generator test file, this is SPI out only no hardware required for test. Abandoned migrating to native code with minor issue.

ADF4351.zip

rromano001 commented 3 years ago

Found the possible source of original radio library from maker.pro: http://www.mathertel.de/Arduino/RadioLibrary.aspx or from groove library: https://wiki.seeedstudio.com/Grove-I2C_FM_Receiver/

Examples require again add delay on setup serial library. Matthias: serial radio work, Lcdradio not but require adaptation. Serialscan loop on scan but never stop as if wire was broken. Grove too doesn't work, loop on seek without stopping. Radio hardware is Ok tested with serialradio example.

Next step is to migrate to mxCubeIDE code, this platform is unreliable in my point of view. Matthias code look professional grade but other are just looking beginner level hash of Matthias lib or grabbed somewhere else.

Screenshot from 2020-09-28 11-31-55

rromano001 commented 3 years ago

Here file adapted from examples to just not crash on BluePills. fmradio.zip

After some interaction seems the cause of blocking USB subsystem on Linux mint 20. Bluetooth still work, external wired stop. no external device listed and reboot required to restore USB port functionality.

~$ lsusb Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 003 Device 002: ID 0bda:c024 Realtek Semiconductor Corp. Bluetooth Radio Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub ~$

KenjutsuGH commented 3 years ago

Just to understand better, are there any problems with the STM32_HID_Bootloader then?

rromano001 commented 3 years ago

Hi Kenjutsu, yes I am experiencing trouble with serial communication, STM32 code hang. I found workaround of inserting delay but doesn't solve issue. Attached Salea LogicPro8 to see what happen USB subsystem freezed up. Removed Salea and all other peripheral, on Linux mint 20 HID serial communication hang and reboot is required to restore USB functionality. As I wrote not an Arduino fan so no idea how to debug code. Thank you. Roberto

On Tue, 29 Sep 2020 23:45:12 -0700 KenjutsuGH notifications@github.com wrote:

Just to understand better, are there any problems with the STM32_HID_Bootloader then?

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/Serasidis/STM32_HID_Bootloader/issues/40#issuecomment-701193007

rromano, romebay both are alias of same email

KenjutsuGH commented 3 years ago

What options do you have under Tools?

rromano001 commented 3 years ago

Hi, s screenshot of tools, Board generic stm32f103 Blue pill f103c8 usart generic serial usb cdc generic supersedes usb low/full speed optimize smallest -os (default) runtime newlib nano (default) HID Bootloader 2.2 Regards Roberto

On Wed, 30 Sep 2020 02:40:25 -0700 KenjutsuGH notifications@github.com wrote:

What options do you have under Tools?

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/Serasidis/STM32_HID_Bootloader/issues/40#issuecomment-701281755

rromano, romebay both are alias of same email

KenjutsuGH commented 3 years ago

Hi,

I am using macOS 10.13.6 so I can not help you with the Linux stuff. I have the same settings under Tools. I also noticed that as soon as Serial.begin(115200) is executed, it takes about 1.5s before I would see output in the serial monitor.

As an example, I modified the classic Blink sketch to output some info to the serial port:

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);  
  Serial.println("Serial setup done");
}

// the loop function runs over and over again forever
void loop() {
  Serial.println("LED_BUILTIN, HIGH");
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  Serial.println("LED_BUILTIN, LOW");
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

After the upload, I never see the "Serial setup done" message being displayed. Instead of using a delay() statement after Serial.begin() , I use

while (!Serial);

With the above code, all the info is displayed in the Serial Monitor and the program keeps on running. I can close the Serial Monitor and use a program such as CoolTerm (also available for Linux) to connect to the serial port of the BP and the output continues to be displayed.

Unfortunately, I do not have a RDA5807M module to test your program. I do have the same I2C OLED display, and when I upload your program, I see info on the OLED, and the following in the Serial Monitor:

init ok
sensor = 0
Post butt
Millis=2975 Time=2925 Time1=2925 Time2=2925 Time3=2925
Post millisFrecuencia = 210
Post FreqPost Volume>BLOCK_E found.
End Loop
sensor = 0
Post butt
Millis=3147 Time=2925 Time1=2925 Time2=2925 Time3=2925
Pre StatRDReqfrom for Loop after for 
fpistm commented 3 years ago

https://www.arduino.cc/reference/en/language/functions/communication/serial/ifserial/

rromano001 commented 3 years ago

Hello, thank for prompt answer, I suppose on MAC it work hassle free. On Linux too many time it lock out but this is strange, so inspect code is more difficult. I suspect also some Linux incoerence, as if some wrong code injected. Maybe M$ is poisoning code? About RDA module can send you one for free but from your writing sketch has no issue on mac. Regards Roberto

On Wed, 30 Sep 2020 23:07:00 -0700 KenjutsuGH notifications@github.com wrote:

Hi,

I am using macOS 10.13.6 so I can not help you with the Linux stuff. I have the same settings under Tools. I also noticed that as soon as Serial.begin(115200) is executed, it takes about 1.5s before I would see output in the serial monitor.

As an example, I modified the classic Blink sketch to output some info to the serial port:

void setup() {
 // initialize digital pin LED_BUILTIN as an output.
 pinMode(LED_BUILTIN, OUTPUT);
 Serial.begin(115200);  
 Serial.println("Serial setup done");
}

// the loop function runs over and over again forever
void loop() {
 Serial.println("LED_BUILTIN, HIGH");
 digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the 
voltage level)
 delay(1000);                       // wait for a second
 Serial.println("LED_BUILTIN, LOW");
 digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making 
the voltage LOW
 delay(1000);                       // wait for a second
}

After the upload, I never see the "Serial setup done" message being displayed. Instead of using a delay() statement after Serial.begin() , I use

while (!Serial);

With the above code, all the info is displayed in the Serial Monitor and the program keeps on running. I can close the Serial Monitor and use a program such as CoolTerm (also available for Linux) to connect to the serial port of the BP and the output continues to be displayed.

Unfortunately, I do not have a RDA5807M module to test your program. I do have the same I2C OLED display, and when I upload your program, I see info on the OLED, and the following in the Serial Monitor:

init ok
sensor = 0
Post butt
Millis=2975 Time=2925 Time1=2925 Time2=2925 Time3=2925
Post millisFrecuencia = 210
Post FreqPost Volume>BLOCK_E found.
End Loop
sensor = 0
Post butt
Millis=3147 Time=2925 Time1=2925 Time2=2925 Time3=2925
Pre StatRDReqfrom for Loop after for 

-- You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/Serasidis/STM32_HID_Bootloader/issues/40#issuecomment-701908685

rromano, romebay both are alias of same email

KenjutsuGH commented 3 years ago

Have you tried another upload method such as SWD or Serial?