USB as Serial with bootloader 2.0

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

USB as Serial with bootloader 2.0

Post by 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

Code: Select all

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) 
I'm uploading a new bootloader via usb-to-rs without any problem:

stm32flash -w maple_mini_boot20.bin -g 0x0 /dev/ttyUSB0

Code: Select all

stm32flash 0.5

http://stm32flash.sourceforge.net/

Using Parser : Raw BINARY
Interface serial_posix: 57600 8E1
Version      : 0x22
Option 1     : 0x00
Option 2     : 0x00
Device ID    : 0x0410 (STM32F10xxx Medium-density)
- RAM        : 20KiB  (512b reserved by bootloader)
- Flash      : 128KiB (size first sector: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
Write to memory
Erasing memory
Wrote address 0x08001b8c (100.00%) Done.

Starting execution at address 0x08000000... done.
Under linux command line dmesg shows:

Code: Select all

[13112.533027] usb 1-1.1.4: new full-speed USB device number 32 using ehci-pci
[13112.627038] usb 1-1.1.4: New USB device found, idVendor=1eaf, idProduct=0003
[13112.627047] usb 1-1.1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[13112.627053] usb 1-1.1.4: Product: Maple 003
[13112.627057] usb 1-1.1.4: Manufacturer: LeafLabs
[13112.627061] usb 1-1.1.4: SerialNumber: LLM 003
Under Arduino IDE 1.6.9 I'm choosing:
board -> maple mini
Bootloader version -> bootloader 2.0
Port -> empty

Then I'm uploading simple sketch to initiate Serial

Code: Select all

void setup()                    // run once, when the sketch starts
{
  Serial.begin(9600);           // set up Serial library at 9600 bps

}

void loop()                       // run over and over again
{
   Serial.println("Hello world!");  // prints hello with ending line break 
   delay(1000);
}

Upload is working fine

Code: Select all

dfu-util 0.8
dfu-util: Invalid DFU suffix signature

dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Opening DFU capable USB device...
ID 1eaf:0003
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #2 ...
Determining device status: state = dfuIDLE, status = 0
dfuIDLE, continuing
DFU mode device DFU version 0110
Device returned transfer size 1024
Copying data from PC to DFU device

Download	[                         ]   0%            0 bytes
Download	[==                       ]   8%         1024 bytes
Download	[====                     ]  16%         2048 bytes
Download	[======                   ]  24%         3072 bytes
Download	[========                 ]  32%         4096 bytes
Download	[==========               ]  41%         5120 bytes
Download	[============             ]  49%         6144 bytes
Download	[==============           ]  57%         7168 bytes
Download	[================         ]  65%         8192 bytes
Download	[==================       ]  74%         9216 bytes
Download	[====================     ]  82%        10240 bytes
Download	[======================   ]  90%        11264 bytes
Download	[======================== ]  98%        11420 bytes
Download	[=========================] 100%        11420 bytes
Download done.
state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present
Done!
Resetting USB to switch back to runtime mode
After this nothing is changing. There is no ttyACMx or whatever. Nothing is changing in dmesg. After first sketch upload I'm also unable to upload anything else. I'm getting.

Code: Select all

Failed to open serial device.
dfu-util: Invalid DFU suffix signature
dfu-util: A valid DFU suffix will be required in a future dfu-util release!!!
dfu-util: Cannot set alternate interface

dfu-util 0.8

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2014 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to dfu-util@lists.gnumonks.org

Opening DFU capable USB device...
ID 1eaf:0003
Run-time device DFU version 0110
Claiming USB DFU Interface...
Setting Alternate Setting #2 ...
It seems that sketch upload is messing up with bootloader or something like that because after uploading bootloader again I'm able to upload new sketch but then the problem persist. Some one on this forum had the same problem but after using lower version of gcc it started to work. I'm not using 4.9 and higher so this should work out of the box. Can some one tell me what is wrong or what I'm doing wrong?

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

Re: USB as Serial with bootloader 2.0

Post by 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:
Pukao Hats Cleaning Services Ltd.

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

Re: USB as Serial with bootloader 2.0

Post by 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?

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

Re: USB as Serial with bootloader 2.0

Post by 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
Posts: 191
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

Post by 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
Posts: 191
Joined: Thu Jul 14, 2016 4:17 pm

Re: USB as Serial with bootloader 2.0

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

User avatar
RogerClark
Posts: 7185
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 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

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

Re: USB as Serial with bootloader 2.0

Post by RogerClark » Sat Aug 20, 2016 2:52 am

I have recompiled the maple mini binary, and hopefully it has fixed this problem

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

Re: USB as Serial with bootloader 2.0

Post by 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?

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

Re: USB as Serial with bootloader 2.0

Post by 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

Post Reply