Entwicklung SIGNALDuino Empfänger Firm- und Hardware V4 für Maple Mini und ESP32

Begonnen von Ralf9, 13 Dezember 2019, 12:48:26

Vorheriges Thema - Nächstes Thema

Ralf9

ZitatIst bei mir mit dem MSC-BL von Telekatz nicht der Fall.
Läuft.

Ich habe nun auch mal den MSC-BL geflasht, damit läuft es bei mir auch

Zitat
[  +9,037119] usb 1-9: USB disconnect, device number 34
[  +0,000067] cdc_acm 1-9:1.0: failed to set dtr/rts
[  +1,944667] usb 1-9: new full-speed USB device number 35 using xhci_hcd
[  +0,149355] usb 1-9: New USB device found, idVendor=0483, idProduct=5740
[  +0,000002] usb 1-9: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  +0,000001] usb 1-9: Product: MAPLEMINI_F103CB CDC in FS Mode
[  +0,000001] usb 1-9: Manufacturer: STMicroelectronics
[  +0,000000] usb 1-9: SerialNumber: 8D7452895051
[  +0,000410] cdc_acm 1-9:1.0: ttyACM0: USB ACM device
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs

MAPLEMINI_F103CB CDC in FS Mode


War bei mir auch die Meldung !

Schön, dass es geht.

Das 2mal Reset-Pressen zum Neu-Flashen muss man noch das "Gefühl" dafür entwickeln ...  ;D

PS: Schau mal in Dein Postfach...

Telekatz

Der Fehler am Bootloader2.0 ist der, dass beim verlassen des Bootloaders USB nicht getrennt wird. Dadurch findet keine erneute enumeration des CDC Devices statt.

Man kann entweder den Bootloader patchen:
void jumpToUser(u32 usrAddr) {

    /* tear down all the dfu related setup */
    // disable usb interrupts, clear them, turn off usb, set the disc pin
    // todo pick exactly what we want to do here, now its just a conservative
    flashLock();
    usbDsbISR();
    nvicDisableInterrupts();

#ifndef HAS_MAPLE_HARDWARE
    usbDsbBus();
#else
    gpio_write_bit(USB_DISC_BANK,USB_DISC_PIN,1);
#endif

// Does nothing, as PC12 is not connected on teh Maple mini according to the schemmatic     setPin(GPIOC, 12); // disconnect usb from host. todo, macroize pin
    systemReset(); // resets clocks and periphs, not core regs

    setMspAndJump(usrAddr);
}



Oder man trennt die Verbindung kurz im setup Teil vom Sketch:
uint8_t led = 0;
//#define USBD_ENUM_DELAY 200

void setup() {

   pinMode(D34, OUTPUT);
   digitalWrite(D34,1);
   delay(100);
   digitalWrite(D34, 0);
 
   pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  led = ~ led & 1;
  digitalWrite(LED_BUILTIN, led);
  delay(2000);
}




Ralf9

ZitatDer Fehler am Bootloader2.0 ist der, dass beim verlassen des Bootloaders USB nicht getrennt wird. Dadurch findet keine erneute enumeration des CDC Devices statt.
Der Fehler wirkt sich aber nur beim STM32 Core 1.8.0 aus, mit Rogers Core funktioniert das USB nach einem Reset auch mit dem Bootloader 2.0.

ZitatMan kann entweder den Bootloader patchen
Dies wäre die bessere Variante.

Kannst Du einen gepatchten Bootloader2.0 erstellen?

Gruß Ralf


FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

Ralf9

   pinMode(D34, OUTPUT);
   digitalWrite(D34,1);
   delay(100);
   digitalWrite(D34, 0);


Was ist D34, ich kann nichts darüber finden.

FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs

Bei mir hat gerade der Kompile mit Arduino geklappt:
? Use one of ?S ? b CE CD CG CR CS CW C eC e P r R S t T V W x XE XQ
V 4.1.0-dev200322 SIGNALduino cc1101 (R: B-*) - compiled at Apr 17 2020 22:31:14


Wow, ein Act!  ::)

Mit einigen Anpassungen und Vereinfachungen!

Ralf9

Ich habs getestet, bei der sduino V 4.1.0 firmware funktioniert das USB mit dem Bootloader 2.0 auch nach einem Reset, wenn ich dies nach setup einfüge.

void setup() {
   pinMode(D34, OUTPUT);
   digitalWrite(D34,1);
   delay(100);
   digitalWrite(D34,0);


Wird es auch noch problemlos funktionieren, wenn die Verbindung kurz im setup Teil vom Sketch getrennt wird und ein gepatchter Bootloader 2.0 verwendet wird?
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

Telekatz

Zitat von: Ralf9 am 17 April 2020, 22:31:35
   pinMode(D34, OUTPUT);
   digitalWrite(D34,1);
   delay(100);
   digitalWrite(D34, 0);


Was ist D34, ich kann nichts darüber finden.


D34 ist PB_9 (USB DISC). Findet man in der variant.cpp.

Anbei der gepatchte Bootloader2.0.

Zitat von: Ralf9 am 17 April 2020, 22:49:50
Wird es auch noch problemlos funktionieren, wenn die Verbindung kurz im setup Teil vom Sketch getrennt wird und ein gepatchter Bootloader 2.0 verwendet wird?
Ich denke ja.

Ralf9

ZitatAnbei der gepatchte Bootloader2.0.
Danke, für Deine Hilfe, damit funktioniert es wie gewünscht auch mit dem Bootloader2.0


Wie soll ich nun weiter vorgehen.

Das sauberste wäre ein Issue bei Roger zu machen, damit der Fehler im Bootloader2.0 gepatcht wird.
Ich würde dann neue sduino V.4.1.x bin Files für den Bootloader2.0 machen, wer diese bin verwenden will muss vorher den neuen gepatchten Bootloader2.0 flashen



FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs

Da Roger meist schnell antwortet, habe ich mir erlaubt, diese Issue bei ihm einzustellen:

https://github.com/rogerclarkmelbourne/STM32duino-bootloader/issues/91

Ralf9

Ich habe von einem STM32 Core Entwickler eine Antwort bekommen:

ZitatIt seems stange as the core already handle the reenum:
https://github.com/stm32duino/Arduino_Core_STM32/blob/16f3644e7b9f8225dcb01f48bd857bdc3a978580/cores/arduino/stm32/usb/usbd_if.c#L19

This will change in the 1.9.0 to be more compliant with USB specs
https://github.com/stm32duino/Arduino_Core_STM32/commit/e1d409f1203d5820e563e7be4bb084b57dc5b4b6

anyway still one issue to fix for hardware which does not follow the spec:
https://github.com/stm32duino/Arduino_Core_STM32/issues/1029

Nachtrag:
https://www.stm32duino.com/viewtopic.php?p=2168#p2168
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

juergs


Ralf9

Ohne die Hilfe von Telekatz wäre ich da aber wahrscheinlich nicht weitergekommen.

Anscheinend hält sich der Maple Mini nicht ganz an die USB Spec

Mir ist noch nicht klar was ich an der 
https://github.com/stm32duino/Arduino_Core_STM32/blob/16f3644e7b9f8225dcb01f48bd857bdc3a978580/cores/arduino/stm32/usb/usbd_if.c#L19
ändern muss

Gruß Ralf
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7

Ralf9

https://www.stm32duino.com/viewtopic.php?p=2172#p2172
ZitatRafl9
Main issue is why you get issue, sveral other user (including me) does not have this issue.
So, it seems in your case the reenum does not have the expected effect, call too earlier? Delay should be increased?

You can override the core reenum function as it is a weak one or increase the delay as th delay is a definition wchich can be rederfined
FHEM auf Cubietruck mit Igor-Image, SSD und  hmland + HM-CFG-USB-2,  HMUARTLGW Lan,   HM-LC-Bl1PBU-FM, HM-CC-RT-DN, HM-SEC-SC-2, HM-MOD-Re-8, HM-MOD-Em-8
HM-Wired:  HMW_IO_12_FM, HMW_Sen_SC_12_DR, Selbstbau IO-Module HBW_IO_SW
Maple-SIGNALduino, WH3080,  Hideki, Id 7