USB as Serial with bootloader 2.0

konczakp
Tue Aug 16, 2016 11:11 am
I’ve read many topics about problems with usb/serial but I’m still having difficulties to get it run. Maybe I’ve missed some important information or I’m doing something wrong so please help me with it. First of all I’m using Ubuntu 14.04 with gcc 4.8.4 and maple mini as a board

gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)


Pito
Tue Aug 16, 2016 11:52 am
Your bootloader upload finishes at 1b8c, while I saw others at 1b7c..
1b7c is the size of maple_mini_boot20.bin here..

Btw – why this switch while flashing the bootloader in: -g 0x0 ?

Crazy idea: when setting the start of execution at main flash start (the above g 0x0 switch), after flashing the bootloader in the main flash is erased as well – and here in the empty flash the execution starts then..
First run after flashing the bootloader – it jumps to empty main flash, runs through it (nops) and wraps around till it finds bootloader somewhere and starts the upload normally. After the first sketch upload – it jumps to the newly uploaded sketch start (uploaded into main flash), and will not find the bootloader..
When you get bootloader flashed in again, the main flash will be also erased again, and, while running over the entire empty flash, it finds the bootloader somehow.. This reminds me on similar issues I cope with many decades back :)
Weird idea, indeed.. :twisted:


konczakp
Tue Aug 16, 2016 6:30 pm
I did some more tests. I’ve moved to Windows :( and uploaded an original bootloader from leaflabs. It started to work perfectly so I did global erase and upload bootloader 2.0 and It stopped working unfortunately. On the original bootloader dfu and serial was working perfectly so I was able to upload new sketches and also see data on serial. This time I have used Flash Loader Demonstrator from ST to eliminate stm32flash problem. Is it possible that there is a problem with bootloader 2.0? Can someone download it from https://github.com/rogerclarkmelbourne/ … boot20.bin and try to upload to maple mini?

RogerClark
Tue Aug 16, 2016 11:58 pm
Some people have been reporting problems with the bootloader 2.0 but not everyone has problems

Try using the commits menu in github to download an old version of the binary e.g. perhaps 6 months ago and see if that is any better

PS. It would be good to know what the problem is, because I have not been able to reproduce the problem, hence i can’t investigate and fix it.


konczakp
Thu Aug 18, 2016 7:28 pm
I have uploaded older bootloader (17 Jul 2015) and it is working. Sometimes it needs an extra reset for upload but not every time. I have used this version https://github.com/rogerclarkmelbourne/ … boot20.bin I hope this will help somehow because still the original maple mini bootloader seems to work more reliable.

konczakp
Fri Aug 19, 2016 9:53 pm
BTW, is there any chance to change how the maple mini is introducing to the system? I mean the name which now is maple mini and I would like to change to new_name.

RogerClark
Fri Aug 19, 2016 10:07 pm
There is another ongoing thread about this.

The problem seems to be the mini maple bin file on the server is corrupt as the make file did not clean out object files from a different type of board.

I will recompile all binaries again today


RogerClark
Sat Aug 20, 2016 2:52 am
I have recompiled the maple mini binary, and hopefully it has fixed this problem

konczakp
Sun Aug 21, 2016 8:51 pm
It’s working now perfectly! Thanks a lot!. But still the question persist:

is there any chance to change how the maple mini is introducing to the system? I mean the name which now is maple mini the vendor LeafLabs and I would like to change to some new name and new vendor. Can You tell me how to do this?


RogerClark
Sun Aug 21, 2016 8:59 pm
The name reported by Windows is set by the driver installer.

In the core and the bootloader were are also description strings you can change, but in Windows you only see those names if you go right into the device properties dialog and go down though the various data items in that dialog

You can also change the VID and PID identifiers in the core and bootloader as well, but if yiu do that, you will defiitely need to change the installer to match those new values


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.

#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:

}


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
Fri Aug 26, 2016 9:18 pm
When I do like this

#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);

}


konczakp
Tue Aug 30, 2016 7:24 am
Any idea ?

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
Wed Aug 31, 2016 8:29 pm
I have solved it! If anyone will have the same problem just put

setDataTerminalReady(true)


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
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.

Pito
Thu Sep 01, 2016 10:02 am
Try to unplug the TFT module and run the sketch again. What happens?

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.

stevestrong
Fri Sep 02, 2016 8:00 am
@konczakp
I see in the sketch the SPI initialization and I thought that it is for the display, but it makes sense that it is a preparation for SD access.
OK, so I would suggest you, just like in the other thread, to remove the latest tft functions one by one, from the last one up to setTextSize(1), and check which function causes the trouble. Because setTextSize(1) cannot be the root cause.

stevestrong
Sat Sep 03, 2016 10:15 am
@konczakp
I have tried your code, and it works on my board, with small changes, detailed description in the other thread.

Leave a Reply

Your email address will not be published. Required fields are marked *