Yet another OSX Rant – Peculiar issue

Krish2487
Mon Jan 09, 2017 6:00 pm
Hello,
I am a long time lurker who has enjoyed the benifits of the STM32 (mbed platform) but have recently moved to arduino for STM32.

I have gone through the forums and tried to search for my issue but havent found any. I would not cause any unnecessary trouble if I could address this issue on my own.

I have successfully flashed the bluepill boards with the modified generic-PC13.bin using the stm32flash utility.
( I have added BOOTLOADER_WAIT 30 in the config.h file for PC13 target as seen on another thread).

I have also changed the upload_reset in the maple_upload script from 750 to 1500.

Running dfu-util -l gives me this

dfu-util -l
dfu-util 0.9

Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.
Copyright 2010-2016 Tormod Volden and Stefan Schmidt
This program is Free Software and has ABSOLUTELY NO WARRANTY
Please report bugs to http://sourceforge.net/p/dfu-util/tickets/

Deducing device DFU version from functional descriptor length
Found Runtime: [13d3:3295] ver=0531, devnum=4, cfg=1, intf=3, path="29-1.6", alt=0, name="UNKNOWN", serial="74F06DF56885"
Found DFU: [1eaf:0003] ver=0201, devnum=2, cfg=1, intf=0, path="20-1", alt=2, name="STM32duino bootloader v1.0 Upload to Flash 0x8002000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=2, cfg=1, intf=0, path="20-1", alt=1, name="STM32duino bootloader v1.0 Upload to Flash 0x8005000", serial="LLM 003"
Found DFU: [1eaf:0003] ver=0201, devnum=2, cfg=1, intf=0, path="20-1", alt=0, name="STM32duino bootloader v1.0 ERROR. Upload to RAM not supported.", serial="LLM 003"


RogerClark
Mon Jan 09, 2017 8:07 pm
I am not sure if this is the same problem, but..

Did you see the post about Sierra requiring a modified version of the bootloader?
( and possibly a change to the core)

The post was in the last 2 or 3 weeks, so should not be too hard to find.

Note. I have not implemented the change to the bootloader etc into the master copy, as it could break things for all Windows and Linux users, which account for 95% of all users.


Krish2487
Mon Jan 09, 2017 8:15 pm
After posting my request, I saw a pending pull request on the github repo by “jaredburkett” specifically for mac timing issues.
I downloaded the appropriate binary and ran the tests again. The same issue persists.

I have not specifically looked for any threads wrt sierra recompilation. I will go through the board again to see if I missed anything.

Thank you for the help roger! :-)


RogerClark
Mon Jan 09, 2017 8:45 pm
OK.

Looking at the output from DFU Util, it looks like it is uploading.

You could try removing the Serial.begin and Serial.print and see if GPIO works on its own, as its possible that something else in Sierra is screwing up the USB Serial.

You could also try STM’s F1 core rather than the LibMaple core as its USB implementation is completely different.

https://github.com/stm32duino

(There is a posting about how you install the STM core, as you can’t do it via the boards manager at the moment as the BM install only works for the Nucleo)

BTW.
I do have a old Macbook Pro, but its slightly too old to allow me to install Sierra. I also have a Hackintosh, but its the same situation, too old for Sierra, and as both work fine on Yosemite, and El Capitan respectively, I’m in no rush to buy new hardware just for the latest version of MacOs (as every new version of MacOS seems to bring a more issues and incompatibilities with external hardware – e.g. my USB mixing desk no longer works with El Capitan)


Krish2487
Mon Jan 09, 2017 8:52 pm
Thanks!! :-)
I assume you are referring to this thread roger??

http://www.stm32duino.com/viewtopic.php?f=3&t=1656

(Oh and tried by removing the Serial.begin() section too..)
Tried and same result. I ll try with the F1 core and post my findings. Maybe it might save someone else some frustration later.
:-D

PS: I am using platformio for my development and not the arduino IDE. Still, it should not really matter much.


RogerClark
Tue Jan 10, 2017 2:48 am
Krish2487 wrote:Thanks!! :-)

PS: I am using platformio for my development and not the arduino IDE. Still, it should not really matter much.


Krish2487
Tue Jan 10, 2017 3:23 am
That did the trick roger!!
:-D

Auto reset works, upload works, it just works..

The serial port shows up.. serial comms are functional..
Any specific insight in what can be done to repeat the process on platformio IDE??


RogerClark
Tue Jan 10, 2017 4:12 am
I think there is a thread somewhere on the forum about platformio, but I don’t use it myself

About 90% of the forum members use the normal Arduino IDE. I few people use Eclipse, and some other IDE’s (like visual studio), but its hard enough supporting the Arduino IDE (which seems to have a new version about one a month, which needs to be tested to confirm it still works OK)


Krish2487
Tue Jan 10, 2017 4:40 am
Now, things are getting interesting.
I have the arduino and platformio IDE installed.

I have used a variety of permutations and combinations ( maple_upload (platformio IDE) and binary (arduino), maple_upload (platformio IDE) and binary (platformio IDE), maple_upload (arduino) and binary (arduino), maple_upload (arduino) and binary (platformio IDE) )
to understand what might be thee issue.

I was able to upload the binary with either of the maple_upload scripts. However the serial port enumerated only when I compiled from the arduino IDE.
The serial port did not enumrerate when I compiled the same code with platformio IDE. Further investigation into the size of the compiled binaries revealed a difference in size of almost 50%!!!

This is the code I compiled

#include <Arduino.h>

void setup(){
Serial.begin(115200);
pinMode(PC13, OUTPUT);
digitalWrite(PC13, HIGH);
}

void loop(){
Serial.println("Hello World");
digitalWrite(PC13, !digitalRead(PC13));
delay(1000);
}


RogerClark
Tue Jan 10, 2017 6:23 am
I suspect the platformio is not compiling the USB serial into the binary.

The bootloader only provides the DFU for upload. After the upload is complete, it simply jumps to the start of the sketch code, and if the skech has USB serial compiled in, you get USB Serial.

There are a whole bunch of “defines” (in boards.txt) which switch a variety of things (based on the menu settings in the IDE), but the main one if whether there is USB serial (as some boards have built in USB to serial devices, so don’t need or want USB Serial)


Krish2487
Tue Jan 10, 2017 6:40 pm
It seems more and more likely that your post about the USB Serial not being compiled along with the main code is spot on.

I uploaded the binary of the above sketch (compiled using arduino IDE) using maple_upload and was able to observe the serial output in terminal monitor.

Even platformIO was able to see the serial port!!.
Next I compiled the binary using the platformio and uploaded from within the platformio IDE (using the same maple_upload and dfu upload).
But this time the board was stuck and the serial port was lost. The board as reported earlier, reverted to the six quick flashes and slow flashing and then stopped altogether.

Unfortunately platformio uses Scons for the build engine, which is beyond my immediate understanding to manipulate.
Hence I requested a complete command of compiling the binary. I wanted to compile the same binary manually using the toolchain packaged along with platformio and check the results.. then see what is the difference in the Scons script and the STM32duino compilation process.

Thank you for the help so far roger!! :-)


Krish2487
Wed Jan 11, 2017 4:25 am
Update:

Changing the board definition from a generic_STM32F103C8 board to “maple_mini” solved the issue.
I am guessing the generic_STM32F103C8 boards do not, by definition, compile the USB Serial libraries.

I am now able to upload and compile the code from within platformio using the maple_upload script.

:-)

Thank you for all the help extended roger!! :-)


RogerClark
Wed Jan 11, 2017 5:05 am
I’m glad its working, but you will still have some issues if you set the board as Maple mini, because it probably wont reset the USB correctly then you press upload from the IDE.

Take a look in boards.txt generic stm32f103c in the upload menu it what defines are setup.


Krish2487
Wed Jan 11, 2017 6:21 am
I did.
The differences between maple_mini and genericstm32f103c8 seem to be pretty much in the compilation and linking of the USB Serial and the reset vector address.
Oh and the available flash and RAM.

I can live with the manual reset of the board post upload.
So far, though, I have tried about 50-70 times since yesterday night. It has always uploaded reliably.

I always have to reset the board after upload to get it to start the sketch. It is a very acceptable compromise. :-)


Leave a Reply

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