USB as Serial with bootloader 2.0

Maple Mini, Maple Rev3, Maple Rev 5 and Maple Ret 6, iTead Maple etc
konczakp
Posts: 187
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

Post by konczakp » Fri Aug 26, 2016 9:02 pm

Unfortunately I'm encountering some new problems. When using usb on maple mini as serial port with the code below then the serial is stopping to work. It's disappearing from device manager and I'm unable to do anything. I have to reboot the device and upload something else under bootloader mode before serial is being loaded.

Code: Select all

#include <Adafruit_GFX.h>
#include <gfxfont.h>
#include <SPI.h>
#include "Adafruit_ILI9341_8bit_STM.h"

Adafruit_ILI9341_8bit_STM tft = Adafruit_ILI9341_8bit_STM();

void setup() {
  Serial.begin(115200);
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);                                           // CPHA = 0
  SPI.setBitOrder(MSBFIRST);

  tft.begin();
  
  tft.setRotation(2);
  tft.fillScreen(ILI9341_BLACK);
  tft.setCursor(30 , 30);
  tft.setTextColor(ILI9341_WHITE);
  tft.setTextSize(3);
  tft.println("test");
  tft.setTextSize(1);
  tft.setCursor(55 , 20);
  tft.println("test");

  Serial.println("test");
}

void loop() {
  // put your main code here, to run repeatedly:

}
strange thing is that when I get rid of those lines from the code

Code: Select all

tft.setTextSize(1);
tft.setCursor(55 , 20);
tft.println("test");
It is starting to work. I have no Idea what is going on. When connected through usb to rs everything is working fine so there is something wrong with the bootloader. I've checked also original one but the same problem. I really need help with this.

User avatar
RogerClark
Posts: 6907
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: USB as Serial with bootloader 2.0

Post by RogerClark » Fri Aug 26, 2016 9:07 pm

Serial is Not in the bootloader, it is compiled into the sketch

If Serial USB stops working it is because your sketch has crashed or somehow corrupted the USB subsystem.

I see nothing in you code which would tell you it is still running at all.

Try putting some Blink code into loop and see if it continues to flash, I suspect it wont as the code in setup has probably crashed.

konczakp
Posts: 187
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

Post by konczakp » Fri Aug 26, 2016 9:18 pm

When I do like this

Code: Select all

#include <Adafruit_GFX.h>
#include <gfxfont.h>
#include <SPI.h>
#include "Adafruit_ILI9341_8bit_STM.h"

Adafruit_ILI9341_8bit_STM tft = Adafruit_ILI9341_8bit_STM();

void setup() {
  pinMode(PC13, OUTPUT);

  Serial.begin(115200);
  SPI.begin();
  SPI.setDataMode(SPI_MODE0);                                           
  SPI.setBitOrder(MSBFIRST);

  tft.begin();
  
  tft.setRotation(2);
  tft.fillScreen(ILI9341_BLACK);
  tft.setCursor(30 , 30);
  tft.setTextColor(ILI9341_WHITE);
  tft.setTextSize(3);
  tft.println("test");
  tft.setTextSize(1);
  tft.setCursor(55 , 20);
  tft.println("test");

 
}

void loop() {

  
digitalWrite(PC13, HIGH);   
delay(1000);              
digitalWrite(PC13, LOW);    
delay(1000);    
  

}
blink example is working fine but not the serial so it seems that maple is working correctly even the serial crashes

EDIT:
I have found out that this problem is generated by

Code: Select all

tft.setTextSize(1);
When I change to (2) then it is working. Why ? what can be wrong with textsize=1?

konczakp
Posts: 187
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

Post by konczakp » Tue Aug 30, 2016 7:24 am

Any idea ?

konczakp
Posts: 187
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

Post by konczakp » Wed Aug 31, 2016 6:56 pm

There is another problem. This time even more important for me. I hope someone here also do some programming in Qt. I have ready program working under Linux written in C++ under Qt but under Windows I have a problem with serial - again :/ I'm using QSerialPort from terminal example and under Linux I'm able to send and receive the data (from/to maple mini) but under windows I'm only able to send data. And now the funny part: if I open a serial connection under Arduino IDE and close it without doing anything else from now on I'm able to read/write data over QSerialPort in my program until I'll disconnect and connect again maple mini to usb port. I also did some more tests and while I'm using Arduino UNO and not the maple mini I'm able do read/write via QSerialPort without using Arduino IDE - everything works as it should. I assume that there is some problem with CDC driver ? Way of opening port etc. Anyone have an idea how to make this working. I need my program to run multi-platform and not only linux :/

konczakp
Posts: 187
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

Post by konczakp » Wed Aug 31, 2016 8:29 pm

I have solved it! If anyone will have the same problem just put

Code: Select all

setDataTerminalReady(true)
after opening the serial. This will set DTR on. Arduino IDE is doing the same that is why it was working :)

But still I have a problem with screen as described above.

stevestrong
Posts: 1605
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: USB as Serial with bootloader 2.0

Post by stevestrong » Thu Sep 01, 2016 8:37 am

@konczakp
I don't think there is a serial problem.
According to your sketch, the main loop only toggles the LED, but nothing will be sent to serial.
What do you expect?

EDIT
In addition, you are trying to use the TFT 8 bit parallel lib over SPI? It will not work.

konczakp
Posts: 187
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

Post by konczakp » Thu Sep 01, 2016 9:20 am

@stevestrong
Why do You think so ? After calling tft function mentioned above Serial crashes but everything else is working fine (this is why I put blink example in the loop) so where your conclusion is from? Now when I connect maple mini to usb I have serial (via cdc) available and after calling tft it disappears. Same problem as here: http://www.stm32duino.com/viewtopic.php?p=17432#p17410 So I expect that when I start a serial in setup it will be available anytime in sketch. Loop with led was only a test to check if maple is still working. And no I'm not trying to use TFT 8 bit parallel lib over SPI. Only SD I'm using over SPI but this is off topic.

User avatar
Pito
Posts: 1522
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: USB as Serial with bootloader 2.0

Post by Pito » Thu Sep 01, 2016 10:02 am

Try to unplug the TFT module and run the sketch again. What happens?
Pukao Hats Cleaning Services Ltd.

konczakp
Posts: 187
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

Post by konczakp » Thu Sep 01, 2016 3:06 pm

No change. I have tried that earlier because i thought that there is some hardware problem but no. This doesn't change anything at all.I have also used external font specially made for size 1 but also no change.

Post Reply